55
59
#define SELECT_NO_JOIN_CACHE (UINT64_C(1) << 7) // intern
56
60
#define OPTION_BIG_TABLES (UINT64_C(1) << 8) // THD, user
57
61
#define OPTION_BIG_SELECTS (UINT64_C(1) << 9) // THD, user
62
#define OPTION_LOG_OFF (UINT64_C(1) << 10) // THD, user
58
63
#define TMP_TABLE_ALL_COLUMNS (UINT64_C(1) << 12) // SELECT, intern
59
64
#define OPTION_WARNINGS (UINT64_C(1) << 13) // THD, user
60
65
#define OPTION_AUTO_IS_NULL (UINT64_C(1) << 14) // THD, user, binlog
61
66
#define OPTION_FOUND_COMMENT (UINT64_C(1) << 15) // SELECT, intern, parser
67
#define OPTION_SAFE_UPDATES (UINT64_C(1) << 16) // THD, user
62
68
#define OPTION_BUFFER_RESULT (UINT64_C(1) << 17) // SELECT, user
63
69
#define OPTION_NOT_AUTOCOMMIT (UINT64_C(1) << 19) // THD, user
64
70
#define OPTION_BEGIN (UINT64_C(1) << 20) // THD, intern
71
#define OPTION_TABLE_LOCK (UINT64_C(1) << 21) // THD, intern
72
#define OPTION_QUICK (UINT64_C(1) << 22) // SELECT (for DELETE)
73
#define OPTION_KEEP_LOG (UINT64_C(1) << 23) // THD, user
66
75
/* The following is used to detect a conflict with DISTINCT */
67
76
#define SELECT_ALL (UINT64_C(1) << 24) // SELECT, user, parser
104
139
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
141
#define LOCAL_HOST "localhost"
142
#define LOCAL_HOST_NAMEDPIPE "."
107
145
You should add new commands to the end of this list, otherwise old
108
146
servers won't be able to handle them as 'unsupported'.
149
enum enum_server_command
151
COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
152
COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN,
153
COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_PING,
154
COM_TIME, COM_CHANGE_USER,
156
COM_SET_OPTION, COM_DAEMON,
157
/* don't forget to update const char *command_name[] in sql_parse.cc */
112
165
Length of random string sent by server on handshake; this is also length of
113
166
obfuscated password, recieved from client
115
168
#define SCRAMBLE_LENGTH 20
116
169
#define SCRAMBLE_LENGTH_323 8
170
/* length of password stored in the db: new passwords are preceeded with '*' */
171
#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
172
#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
118
175
#define NOT_NULL_FLAG 1 /* Field can't be NULL */
119
176
#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
121
178
#define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
122
179
#define BLOB_FLAG 16 /* Field is a blob */
123
180
#define UNSIGNED_FLAG 32 /* Field is unsigned */
181
#define DECIMAL_FLAG 64 /* Field is zerofill */
124
182
#define BINARY_FLAG 128 /* Field is binary */
126
184
/* The following are only sent to new clients */
127
185
#define ENUM_FLAG 256 /* field is an enum */
128
186
#define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
129
#define FUNCTION_DEFAULT_FLAG 1024 /* Field is a timestamp, uses a function to generate the value. */
187
#define TIMESTAMP_FLAG 1024 /* Field is a timestamp */
188
#define SET_FLAG 2048 /* field is a set */
130
189
#define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */
131
190
#define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */
191
#define NUM_FLAG 32768 /* Field is num (for clients) */
132
192
#define PART_KEY_FLAG 16384 /* Intern; Part of some key */
133
193
#define GROUP_FLAG 32768 /* Intern: Group field */
134
194
#define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
135
195
#define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */
196
#define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
197
#define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
198
#define FIELD_IN_ADD_INDEX (1<< 20) /* Intern: Field used in ADD INDEX */
199
#define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */
200
#define FIELD_STORAGE_FLAGS 22 /* Storage type: bit 22, 23 and 24 */
136
201
#define COLUMN_FORMAT_FLAGS 25 /* Column format: bit 25, 26 and 27 */
137
#define COLUMN_FORMAT_MASK 7
203
#define REFRESH_GRANT 1 /* Refresh grant tables */
204
#define REFRESH_LOG 2 /* Start on new log file */
205
#define REFRESH_TABLES 4 /* close all tables */
206
#define REFRESH_HOSTS 8 /* Flush host cache */
207
#define REFRESH_STATUS 16 /* Flush status variables */
209
/* The following can't be set with mysql_refresh() */
210
#define REFRESH_READ_LOCK 16384 /* Lock tables for read */
211
#define REFRESH_FAST 32768 /* Intern flag */
213
#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
214
#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
215
#define CLIENT_LONG_FLAG 4 /* Get all column flags */
216
#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
217
#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
218
#define CLIENT_COMPRESS 32 /* Can use compression protocol */
219
#define CLIENT_ODBC 64 /* Odbc client */
220
#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
221
#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
222
#define UNUSED_CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */
223
#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
224
#define CLIENT_SSL 2048 /* Switch to SSL after handshake */
225
#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
226
#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */
227
#define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */
228
#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
229
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
230
#define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
232
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
233
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
235
/* Gather all possible capabilites (flags) supported by the server */
236
#define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD | \
237
CLIENT_FOUND_ROWS | \
239
CLIENT_CONNECT_WITH_DB | \
243
CLIENT_LOCAL_FILES | \
244
CLIENT_IGNORE_SPACE | \
245
CLIENT_INTERACTIVE | \
247
CLIENT_IGNORE_SIGPIPE | \
248
CLIENT_TRANSACTIONS | \
250
CLIENT_SECURE_CONNECTION | \
251
CLIENT_MULTI_STATEMENTS | \
252
CLIENT_MULTI_RESULTS | \
253
CLIENT_SSL_VERIFY_SERVER_CERT | \
254
CLIENT_REMEMBER_OPTIONS)
257
Switch off the flags that are optional and depending on build flags
258
If any of the optional flags is supported by the build it will be switched
259
on before sending to the client during the connection handshake.
261
#define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
262
& ~CLIENT_COMPRESS) \
263
& ~CLIENT_SSL_VERIFY_SERVER_CERT)
139
265
#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
140
266
#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
141
267
#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
142
268
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
143
269
#define SERVER_QUERY_NO_INDEX_USED 32
271
The server was able to fulfill the clients request and opened a
272
read-only non-scrollable cursor for a query. This flag comes
273
in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
275
#define SERVER_STATUS_CURSOR_EXISTS 64
277
This flag is sent when a read-only cursor is exhausted, in reply to
278
COM_STMT_FETCH command.
280
#define SERVER_STATUS_LAST_ROW_SENT 128
144
281
#define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */
282
#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
284
Tell clients that this query was logged to the slow query log.
285
Not yet set in the server, but interface is defined for applications
286
to use. See WorkLog 4098.
288
#define SERVER_QUERY_WAS_SLOW 1024
146
290
#define DRIZZLE_ERRMSG_SIZE 512
291
#define NET_READ_TIMEOUT 30 /* Timeout on read */
292
#define NET_WRITE_TIMEOUT 60 /* Timeout on write */
293
#define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
148
295
#define ONLY_KILL_QUERY 1
297
#define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */
298
#define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */
299
#define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */
150
300
#define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */
151
301
#define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */
152
#define MAX_BLOB_WIDTH (uint32_t)16777216 /* Default width for blob */
302
#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
303
#define MAX_BLOB_WIDTH 16777216 /* Default width for blob */
154
305
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
159
#define packet_error UINT32_MAX
161
#if defined(__cplusplus)
166
enum enum_server_command
175
/* don't forget to update const char *command_name[] in sql_parse.cc */
181
enum enum_field_types {
310
#define packet_error (~(uint32_t) 0)
313
/* Shutdown/kill enums and constants */
315
/* Bits for THD::killable. */
316
#define DRIZZLE_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
317
#define DRIZZLE_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
318
#define DRIZZLE_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
319
#define DRIZZLE_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
321
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
322
enum enum_field_types { DRIZZLE_TYPE_TINY,
182
323
DRIZZLE_TYPE_LONG,
183
324
DRIZZLE_TYPE_DOUBLE,
184
325
DRIZZLE_TYPE_NULL,
187
328
DRIZZLE_TYPE_DATETIME,
188
329
DRIZZLE_TYPE_DATE,
189
330
DRIZZLE_TYPE_VARCHAR,
190
DRIZZLE_TYPE_DECIMAL,
331
DRIZZLE_TYPE_VIRTUAL,
332
DRIZZLE_TYPE_NEWDECIMAL,
191
333
DRIZZLE_TYPE_ENUM,
192
334
DRIZZLE_TYPE_BLOB,
194
DRIZZLE_TYPE_BOOLEAN,
196
DRIZZLE_TYPE_MICROTIME
198
const int enum_field_types_size= DRIZZLE_TYPE_MICROTIME + 1;
200
} /* namespace drizzled */
202
#endif /* defined(__cplusplus) */
204
#endif /* DRIZZLED_COMMON_H */
335
DRIZZLE_TYPE_MAX=DRIZZLE_TYPE_BLOB
339
enum enum_cursor_type
341
CURSOR_TYPE_NO_CURSOR= 0,
342
CURSOR_TYPE_READ_ONLY= 1,
343
CURSOR_TYPE_FOR_UPDATE= 2,
344
CURSOR_TYPE_SCROLLABLE= 4
348
/* options for mysql_set_option */
349
enum enum_drizzle_set_option
351
DRIZZLE_OPTION_MULTI_STATEMENTS_ON,
352
DRIZZLE_OPTION_MULTI_STATEMENTS_OFF
355
#define net_new_transaction(net) ((net)->pkt_nr=0)
358
/* The following is for user defined functions */
360
enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
363
typedef struct st_udf_args
365
unsigned int arg_count; /* Number of arguments */
366
enum Item_result *arg_type; /* Pointer to item_results */
367
char **args; /* Pointer to argument */
368
unsigned long *lengths; /* Length of string arguments */
369
char *maybe_null; /* Set to 1 for all maybe_null args */
370
char **attributes; /* Pointer to attribute name */
371
unsigned long *attribute_lengths; /* Length of attribute arguments */
375
/* This holds information about the result */
377
typedef struct st_udf_init
379
bool maybe_null; /* 1 if function can return NULL */
380
unsigned int decimals; /* for real functions */
381
unsigned long max_length; /* For string functions */
382
char *ptr; /* free pointer for function data */
383
bool const_item; /* 1 if function always returns the same value */
387
TODO: add a notion for determinism of the UDF.
388
See Item_udf_func::update_used_tables ()
391
/* Constants when using compression */
392
#define NET_HEADER_SIZE 4 /* standard header size */
393
#define COMP_HEADER_SIZE 3 /* compression header extra size */
396
#define NULL_LENGTH UINT32_MAX /* For drizzleclient_net_store_length */