43
50
TODO: separate three contexts above, move them to separate bitfields.
46
#define SELECT_DISTINCT (1ULL << 0) // SELECT, user
47
#define SELECT_STRAIGHT_JOIN (1ULL << 1) // SELECT, user
48
#define SELECT_DESCRIBE (1ULL << 2) // SELECT, user
49
#define SELECT_SMALL_RESULT (1ULL << 3) // SELECT, user
50
#define SELECT_BIG_RESULT (1ULL << 4) // SELECT, user
51
#define OPTION_FOUND_ROWS (1ULL << 5) // SELECT, user
52
#define SELECT_NO_JOIN_CACHE (1ULL << 7) // intern
53
#define OPTION_BIG_TABLES (1ULL << 8) // THD, user
54
#define OPTION_BIG_SELECTS (1ULL << 9) // THD, user
55
#define OPTION_LOG_OFF (1ULL << 10) // THD, user
56
#define OPTION_QUOTE_SHOW_CREATE (1ULL << 11) // THD, user, unused
57
#define TMP_TABLE_ALL_COLUMNS (1ULL << 12) // SELECT, intern
58
#define OPTION_WARNINGS (1ULL << 13) // THD, user
59
#define OPTION_AUTO_IS_NULL (1ULL << 14) // THD, user, binlog
60
#define OPTION_FOUND_COMMENT (1ULL << 15) // SELECT, intern, parser
61
#define OPTION_SAFE_UPDATES (1ULL << 16) // THD, user
62
#define OPTION_BUFFER_RESULT (1ULL << 17) // SELECT, user
63
#define OPTION_BIN_LOG (1ULL << 18) // THD, user
64
#define OPTION_NOT_AUTOCOMMIT (1ULL << 19) // THD, user
65
#define OPTION_BEGIN (1ULL << 20) // THD, intern
66
#define OPTION_TABLE_LOCK (1ULL << 21) // THD, intern
67
#define OPTION_QUICK (1ULL << 22) // SELECT (for DELETE)
68
#define OPTION_KEEP_LOG (1ULL << 23) // THD, user
53
#define SELECT_DISTINCT (UINT64_C(1) << 0) // SELECT, user
54
#define SELECT_STRAIGHT_JOIN (UINT64_C(1) << 1) // SELECT, user
55
#define SELECT_DESCRIBE (UINT64_C(1) << 2) // SELECT, user
56
#define SELECT_SMALL_RESULT (UINT64_C(1) << 3) // SELECT, user
57
#define SELECT_BIG_RESULT (UINT64_C(1) << 4) // SELECT, user
58
#define OPTION_FOUND_ROWS (UINT64_C(1) << 5) // SELECT, user
59
#define SELECT_NO_JOIN_CACHE (UINT64_C(1) << 7) // intern
60
#define OPTION_BIG_TABLES (UINT64_C(1) << 8) // THD, user
61
#define OPTION_BIG_SELECTS (UINT64_C(1) << 9) // THD, user
62
#define OPTION_LOG_OFF (UINT64_C(1) << 10) // THD, user
63
#define TMP_TABLE_ALL_COLUMNS (UINT64_C(1) << 12) // SELECT, intern
64
#define OPTION_WARNINGS (UINT64_C(1) << 13) // THD, user
65
#define OPTION_AUTO_IS_NULL (UINT64_C(1) << 14) // THD, user, binlog
66
#define OPTION_FOUND_COMMENT (UINT64_C(1) << 15) // SELECT, intern, parser
67
#define OPTION_SAFE_UPDATES (UINT64_C(1) << 16) // THD, user
68
#define OPTION_BUFFER_RESULT (UINT64_C(1) << 17) // SELECT, user
69
#define OPTION_NOT_AUTOCOMMIT (UINT64_C(1) << 19) // THD, user
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
70
75
/* The following is used to detect a conflict with DISTINCT */
71
#define SELECT_ALL (1ULL << 24) // SELECT, user, parser
76
#define SELECT_ALL (UINT64_C(1) << 24) // SELECT, user, parser
73
78
/** The following can be set when importing tables in a 'wrong order'
74
79
to suppress foreign key checks */
75
#define OPTION_NO_FOREIGN_KEY_CHECKS (1ULL << 26) // THD, user, binlog
80
#define OPTION_NO_FOREIGN_KEY_CHECKS (UINT64_C(1) << 26) // THD, user, binlog
76
81
/** The following speeds up inserts to InnoDB tables by suppressing unique
77
82
key checks in some cases */
78
#define OPTION_RELAXED_UNIQUE_CHECKS (1ULL << 27) // THD, user, binlog
79
#define SELECT_NO_UNLOCK (1ULL << 28) // SELECT, intern
80
#define OPTION_SCHEMA_TABLE (1ULL << 29) // SELECT, intern
83
#define OPTION_RELAXED_UNIQUE_CHECKS (UINT64_C(1) << 27) // THD, user, binlog
84
#define SELECT_NO_UNLOCK (UINT64_C(1) << 28) // SELECT, intern
85
#define OPTION_SCHEMA_TABLE (UINT64_C(1) << 29) // SELECT, intern
81
86
/** Flag set if setup_tables already done */
82
#define OPTION_SETUP_TABLES_DONE (1ULL << 30) // intern
87
#define OPTION_SETUP_TABLES_DONE (UINT64_C(1) << 30) // intern
83
88
/** If not set then the thread will ignore all warnings with level notes. */
84
#define OPTION_SQL_NOTES (1ULL << 31) // THD, user
89
#define OPTION_SQL_NOTES (UINT64_C(1) << 31) // THD, user
86
91
Force the used temporary table to be a MyISAM table (because we will use
87
92
fulltext functions when reading from it.
89
#define TMP_TABLE_FORCE_MYISAM (1ULL << 32)
90
#define OPTION_PROFILING (1ULL << 33)
94
#define TMP_TABLE_FORCE_MYISAM (UINT64_C(1) << 32)
95
#define OPTION_PROFILING (UINT64_C(1) << 33)
93
98
Dont report errors for individual rows,
94
99
But just report error on commit (or read ofcourse)
96
#define OPTION_ALLOW_BATCH (1ULL << 33) // THD, intern (slave)
101
#define OPTION_ALLOW_BATCH (UINT64_C(1) << 33) // THD, intern (slave)
99
104
Maximum length of time zone name that we support
194
205
#define REFRESH_TABLES 4 /* close all tables */
195
206
#define REFRESH_HOSTS 8 /* Flush host cache */
196
207
#define REFRESH_STATUS 16 /* Flush status variables */
197
#define REFRESH_THREADS 32 /* Flush thread cache */
198
#define REFRESH_SLAVE 64 /* Reset master info and restart slave
200
#define REFRESH_MASTER 128 /* Remove all bin logs in the index
201
and truncate the index */
203
209
/* The following can't be set with mysql_refresh() */
204
210
#define REFRESH_READ_LOCK 16384 /* Lock tables for read */
205
211
#define REFRESH_FAST 32768 /* Intern flag */
207
/* RESET (remove all queries) from query cache */
208
#define REFRESH_QUERY_CACHE 65536
209
#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
210
#define REFRESH_DES_KEY_FILE 0x40000L
211
#define REFRESH_USER_RESOURCES 0x80000L
213
213
#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
214
214
#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
215
215
#define CLIENT_LONG_FLAG 4 /* Get all column flags */
308
305
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
311
typedef struct st_net {
313
unsigned char *buff,*buff_end,*write_pos,*read_pos;
314
int fd; /* For Perl DBI/dbd */
316
The following variable is set if we are doing several queries in one
317
command ( as in LOAD TABLE ... FROM MASTER ),
318
and do not want to confuse the client with OK at the wrong time
320
unsigned long remain_in_buf,length, buf_length, where_b;
321
unsigned long max_packet,max_packet_size;
322
unsigned int pkt_nr,compress_pkt_nr;
323
unsigned int write_timeout;
324
unsigned int read_timeout;
325
unsigned int retry_count;
327
unsigned int *return_status;
328
unsigned char reading_or_writing;
332
Pointer to query object in query cache, do not equal NULL (0) for
333
queries in cache that have not stored its results yet
336
Unused, please remove with the next incompatible ABI change.
338
unsigned char *unused;
339
unsigned int last_errno;
341
/** Client library error message buffer. Actually belongs to struct MYSQL. */
342
char last_error[DRIZZLE_ERRMSG_SIZE];
343
/** Client library sqlstate buffer. Set along with the error message. */
344
char sqlstate[SQLSTATE_LENGTH+1];
349
310
#define packet_error (~(uint32_t) 0)
351
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
352
enum enum_field_types { DRIZZLE_TYPE_TINY=1,
353
DRIZZLE_TYPE_SHORT, DRIZZLE_TYPE_LONG,
355
DRIZZLE_TYPE_NULL, DRIZZLE_TYPE_TIMESTAMP,
356
DRIZZLE_TYPE_LONGLONG,
357
DRIZZLE_TYPE_DATE, DRIZZLE_TYPE_TIME,
358
DRIZZLE_TYPE_DATETIME,
359
DRIZZLE_TYPE_NEWDATE, DRIZZLE_TYPE_VARCHAR,
360
DRIZZLE_TYPE_NEWDECIMAL=253,
361
DRIZZLE_TYPE_ENUM=254,
362
DRIZZLE_TYPE_BLOB=255
366
/* Shutdown/kill enums and constants */
313
/* Shutdown/kill enums and constants */
368
315
/* Bits for THD::killable. */
369
316
#define DRIZZLE_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
371
318
#define DRIZZLE_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
372
319
#define DRIZZLE_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
374
enum drizzle_enum_shutdown_level {
376
We want levels to be in growing order of hardness (because we use number
377
comparisons). Note that DEFAULT does not respect the growing property, but
380
SHUTDOWN_DEFAULT = 0,
381
/* wait for existing connections to finish */
382
SHUTDOWN_WAIT_CONNECTIONS= DRIZZLE_SHUTDOWN_KILLABLE_CONNECT,
383
/* wait for existing trans to finish */
384
SHUTDOWN_WAIT_TRANSACTIONS= DRIZZLE_SHUTDOWN_KILLABLE_TRANS,
385
/* wait for existing updates to finish (=> no partial MyISAM update) */
386
SHUTDOWN_WAIT_UPDATES= DRIZZLE_SHUTDOWN_KILLABLE_UPDATE,
387
/* flush InnoDB buffers and other storage engines' buffers*/
388
SHUTDOWN_WAIT_ALL_BUFFERS= (DRIZZLE_SHUTDOWN_KILLABLE_UPDATE << 1),
389
/* don't flush InnoDB buffers, flush other storage engines' buffers*/
390
SHUTDOWN_WAIT_CRITICAL_BUFFERS= (DRIZZLE_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
391
/* Now the 2 levels of the KILL command */
321
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
322
enum enum_field_types { DRIZZLE_TYPE_TINY,
326
DRIZZLE_TYPE_TIMESTAMP,
327
DRIZZLE_TYPE_LONGLONG,
329
DRIZZLE_TYPE_DATETIME,
331
DRIZZLE_TYPE_VARCHAR,
332
DRIZZLE_TYPE_VIRTUAL,
333
DRIZZLE_TYPE_NEWDECIMAL,
336
DRIZZLE_TYPE_MAX=DRIZZLE_TYPE_BLOB
413
356
#define net_new_transaction(net) ((net)->pkt_nr=0)
419
bool my_net_init(NET *net, Vio* vio);
420
void my_net_local_init(NET *net);
421
void net_end(NET *net);
422
void net_clear(NET *net, bool clear_buffer);
423
bool net_realloc(NET *net, size_t length);
424
bool net_flush(NET *net);
425
bool my_net_write(NET *net,const unsigned char *packet, size_t len);
426
bool net_write_command(NET *net,unsigned char command,
427
const unsigned char *header, size_t head_len,
428
const unsigned char *packet, size_t len);
429
int32_t net_real_write(NET *net,const unsigned char *packet, size_t len);
430
uint32_t my_net_read(NET *net);
433
/** @TODO global.h is actually not needed here... only stdint and protocol.h */
434
#ifdef DRIZZLE_SERVER_GLOBAL_H
435
void my_net_set_write_timeout(NET *net, uint timeout);
436
void my_net_set_read_timeout(NET *net, uint timeout);
440
unsigned long seed1,seed2,max_value;
441
double max_value_dbl;
448
359
/* The following is for user defined functions */
482
393
#define NET_HEADER_SIZE 4 /* standard header size */
483
394
#define COMP_HEADER_SIZE 3 /* compression header extra size */
485
/* Prototypes to password functions */
492
These functions are used for authentication by client and server and
493
implemented in sql/password.c
496
void randominit(struct rand_struct *, uint32_t seed1, uint32_t seed2);
497
double my_rnd(struct rand_struct *);
498
void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
500
void hash_password(uint32_t *to, const char *password, uint32_t password_len);
502
void make_scrambled_password(char *to, const char *password);
503
void scramble(char *to, const char *message, const char *password);
504
bool check_scramble(const char *reply, const char *message,
505
const unsigned char *hash_stage2);
506
void get_salt_from_password(unsigned char *res, const char *password);
507
void make_password_from_salt(char *to, const unsigned char *hash_stage2);
508
char *octet2hex(char *to, const char *str, unsigned int len);
510
/* end of password.c */
512
char *get_tty_password(const char *opt_message);
513
const char *drizzle_errno_to_sqlstate(unsigned int drizzle_errno);
515
/** @TODO Is it necessary to include all of drizzled/global.h here? */
516
#ifdef DRIZZLE_SERVER_GLOBAL_H
517
uint32_t net_field_length(uchar **packet);
518
uint64_t net_field_length_ll(uchar **packet);
519
uchar *net_store_length(uchar *pkg, uint64_t length);
526
397
#define NULL_LENGTH UINT32_MAX /* For net_store_length */
527
#define DRIZZLE_STMT_HEADER 4
528
#define DRIZZLE_LONG_DATA_HEADER 6