23 #define HOSTNAME_LENGTH 60
24 #define SYSTEM_CHARSET_MBMAXLEN 3
25 #define NAME_CHAR_LEN 64
26 #define USERNAME_CHAR_LENGTH 16
27 #define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
28 #define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
30 #define MYSQL_AUTODETECT_CHARSET_NAME "auto"
32 #define SERVER_VERSION_LENGTH 60
33 #define SQLSTATE_LENGTH 5
38 #define TABLE_COMMENT_INLINE_MAXLEN 180
39 #define TABLE_COMMENT_MAXLEN 2048
40 #define COLUMN_COMMENT_MAXLEN 1024
41 #define INDEX_COMMENT_MAXLEN 1024
42 #define TABLE_PARTITION_COMMENT_MAXLEN 1024
50 #define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
52 #define LOCAL_HOST "localhost"
53 #define LOCAL_HOST_NAMEDPIPE "."
56 #if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
57 #define MYSQL_NAMEDPIPE "MySQL"
58 #define MYSQL_SERVICENAME "MySQL"
66 enum enum_server_command
68 COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
69 COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
70 COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING,
71 COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
72 COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
73 COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE,
74 COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_DAEMON,
87 #define SCRAMBLE_LENGTH 20
88 #define SCRAMBLE_LENGTH_323 8
90 #define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
91 #define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
94 #define NOT_NULL_FLAG 1
95 #define PRI_KEY_FLAG 2
96 #define UNIQUE_KEY_FLAG 4
97 #define MULTIPLE_KEY_FLAG 8
99 #define UNSIGNED_FLAG 32
100 #define ZEROFILL_FLAG 64
101 #define BINARY_FLAG 128
104 #define ENUM_FLAG 256
105 #define AUTO_INCREMENT_FLAG 512
106 #define TIMESTAMP_FLAG 1024
107 #define SET_FLAG 2048
108 #define NO_DEFAULT_VALUE_FLAG 4096
109 #define ON_UPDATE_NOW_FLAG 8192
110 #define NUM_FLAG 32768
111 #define PART_KEY_FLAG 16384
112 #define GROUP_FLAG 32768
113 #define UNIQUE_FLAG 65536
114 #define BINCMP_FLAG 131072
115 #define GET_FIXED_FIELDS_FLAG (1 << 18)
116 #define FIELD_IN_PART_FUNC_FLAG (1 << 19)
121 #define FIELD_IN_ADD_INDEX (1 << 20)
122 #define FIELD_IS_RENAMED (1<< 21)
123 #define FIELD_FLAGS_STORAGE_MEDIA 22
124 #define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA)
125 #define FIELD_FLAGS_COLUMN_FORMAT 24
126 #define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
127 #define FIELD_IS_DROPPED (1<< 26)
129 #define REFRESH_GRANT 1
130 #define REFRESH_LOG 2
131 #define REFRESH_TABLES 4
132 #define REFRESH_HOSTS 8
133 #define REFRESH_STATUS 16
134 #define REFRESH_THREADS 32
135 #define REFRESH_SLAVE 64
137 #define REFRESH_MASTER 128
139 #define REFRESH_ERROR_LOG 256
140 #define REFRESH_ENGINE_LOG 512
141 #define REFRESH_BINARY_LOG 1024
142 #define REFRESH_RELAY_LOG 2048
143 #define REFRESH_GENERAL_LOG 4096
144 #define REFRESH_SLOW_LOG 8192
147 #define REFRESH_READ_LOCK 16384
148 #define REFRESH_FAST 32768
151 #define REFRESH_QUERY_CACHE 65536
152 #define REFRESH_QUERY_CACHE_FREE 0x20000L
153 #define REFRESH_DES_KEY_FILE 0x40000L
154 #define REFRESH_USER_RESOURCES 0x80000L
155 #define REFRESH_FOR_EXPORT 0x100000L
157 #define CLIENT_LONG_PASSWORD 1
158 #define CLIENT_FOUND_ROWS 2
159 #define CLIENT_LONG_FLAG 4
160 #define CLIENT_CONNECT_WITH_DB 8
161 #define CLIENT_NO_SCHEMA 16
162 #define CLIENT_COMPRESS 32
163 #define CLIENT_ODBC 64
164 #define CLIENT_LOCAL_FILES 128
165 #define CLIENT_IGNORE_SPACE 256
166 #define CLIENT_PROTOCOL_41 512
167 #define CLIENT_INTERACTIVE 1024
168 #define CLIENT_SSL 2048
169 #define CLIENT_IGNORE_SIGPIPE 4096
170 #define CLIENT_TRANSACTIONS 8192
171 #define CLIENT_RESERVED 16384
172 #define CLIENT_SECURE_CONNECTION 32768
173 #define CLIENT_MULTI_STATEMENTS (1UL << 16)
174 #define CLIENT_MULTI_RESULTS (1UL << 17)
175 #define CLIENT_PS_MULTI_RESULTS (1UL << 18)
177 #define CLIENT_PLUGIN_AUTH (1UL << 19)
178 #define CLIENT_CONNECT_ATTRS (1UL << 20)
181 #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21)
184 #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22)
186 #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
187 #define CLIENT_REMEMBER_OPTIONS (1UL << 31)
190 #define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
192 #define CAN_CLIENT_COMPRESS 0
196 #define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD \
197 | CLIENT_FOUND_ROWS \
199 | CLIENT_CONNECT_WITH_DB \
203 | CLIENT_LOCAL_FILES \
204 | CLIENT_IGNORE_SPACE \
205 | CLIENT_PROTOCOL_41 \
206 | CLIENT_INTERACTIVE \
208 | CLIENT_IGNORE_SIGPIPE \
209 | CLIENT_TRANSACTIONS \
211 | CLIENT_SECURE_CONNECTION \
212 | CLIENT_MULTI_STATEMENTS \
213 | CLIENT_MULTI_RESULTS \
214 | CLIENT_PS_MULTI_RESULTS \
215 | CLIENT_SSL_VERIFY_SERVER_CERT \
216 | CLIENT_REMEMBER_OPTIONS \
217 | CLIENT_PLUGIN_AUTH \
218 | CLIENT_CONNECT_ATTRS \
219 | CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA \
220 | CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS \
228 #define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
229 & ~CLIENT_COMPRESS) \
230 & ~CLIENT_SSL_VERIFY_SERVER_CERT)
239 #define SERVER_STATUS_IN_TRANS 1
240 #define SERVER_STATUS_AUTOCOMMIT 2
241 #define SERVER_MORE_RESULTS_EXISTS 8
242 #define SERVER_QUERY_NO_GOOD_INDEX_USED 16
243 #define SERVER_QUERY_NO_INDEX_USED 32
249 #define SERVER_STATUS_CURSOR_EXISTS 64
254 #define SERVER_STATUS_LAST_ROW_SENT 128
255 #define SERVER_STATUS_DB_DROPPED 256
256 #define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
262 #define SERVER_STATUS_METADATA_CHANGED 1024
263 #define SERVER_QUERY_WAS_SLOW 2048
268 #define SERVER_PS_OUT_PARAMS 4096
277 #define SERVER_STATUS_IN_TRANS_READONLY 8192
288 #define SERVER_STATUS_CLEAR_SET (SERVER_QUERY_NO_GOOD_INDEX_USED| \
289 SERVER_QUERY_NO_INDEX_USED|\
290 SERVER_MORE_RESULTS_EXISTS|\
291 SERVER_STATUS_METADATA_CHANGED |\
292 SERVER_QUERY_WAS_SLOW |\
293 SERVER_STATUS_DB_DROPPED |\
294 SERVER_STATUS_CURSOR_EXISTS|\
295 SERVER_STATUS_LAST_ROW_SENT)
297 #define MYSQL_ERRMSG_SIZE 512
298 #define NET_READ_TIMEOUT 30
299 #define NET_WRITE_TIMEOUT 60
300 #define NET_WAIT_TIMEOUT 8*60*60
302 #define ONLY_KILL_QUERY 1
308 #define MAX_TINYINT_WIDTH 3
309 #define MAX_SMALLINT_WIDTH 5
310 #define MAX_MEDIUMINT_WIDTH 8
311 #define MAX_INT_WIDTH 10
312 #define MAX_BIGINT_WIDTH 20
313 #define MAX_CHAR_WIDTH 255
314 #define MAX_BLOB_WIDTH 16777216
317 #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
319 unsigned char *buff,*buff_end,*write_pos,*read_pos;
326 unsigned long remain_in_buf,length, buf_length, where_b;
327 unsigned long max_packet,max_packet_size;
328 unsigned int pkt_nr,compress_pkt_nr;
329 unsigned int write_timeout, read_timeout, retry_count;
331 unsigned int *return_status;
332 unsigned char reading_or_writing;
346 unsigned char *unused;
347 unsigned int last_errno;
367 #define packet_error (~(unsigned long) 0)
369 enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
370 MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
371 MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
372 MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
373 MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
374 MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
375 MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
376 MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
378 MYSQL_TYPE_TIMESTAMP2,
379 MYSQL_TYPE_DATETIME2,
381 MYSQL_TYPE_NEWDECIMAL=246,
384 MYSQL_TYPE_TINY_BLOB=249,
385 MYSQL_TYPE_MEDIUM_BLOB=250,
386 MYSQL_TYPE_LONG_BLOB=251,
388 MYSQL_TYPE_VAR_STRING=253,
389 MYSQL_TYPE_STRING=254,
390 MYSQL_TYPE_GEOMETRY=255
395 #define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
396 #define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
397 #define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
398 #define FIELD_TYPE_TINY MYSQL_TYPE_TINY
399 #define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
400 #define FIELD_TYPE_LONG MYSQL_TYPE_LONG
401 #define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
402 #define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
403 #define FIELD_TYPE_NULL MYSQL_TYPE_NULL
404 #define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
405 #define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
406 #define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
407 #define FIELD_TYPE_DATE MYSQL_TYPE_DATE
408 #define FIELD_TYPE_TIME MYSQL_TYPE_TIME
409 #define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
410 #define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
411 #define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
412 #define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
413 #define FIELD_TYPE_SET MYSQL_TYPE_SET
414 #define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
415 #define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
416 #define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
417 #define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
418 #define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
419 #define FIELD_TYPE_STRING MYSQL_TYPE_STRING
420 #define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
421 #define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
422 #define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
423 #define FIELD_TYPE_BIT MYSQL_TYPE_BIT
429 #define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
430 #define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
431 #define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
432 #define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
434 enum mysql_enum_shutdown_level {
440 SHUTDOWN_DEFAULT = 0,
442 SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
444 SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
446 SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
448 SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
450 SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
452 #if MYSQL_VERSION_ID >= 50000
459 enum enum_cursor_type
461 CURSOR_TYPE_NO_CURSOR= 0,
462 CURSOR_TYPE_READ_ONLY= 1,
463 CURSOR_TYPE_FOR_UPDATE= 2,
464 CURSOR_TYPE_SCROLLABLE= 4
469 enum enum_mysql_set_option
471 MYSQL_OPTION_MULTI_STATEMENTS_ON,
472 MYSQL_OPTION_MULTI_STATEMENTS_OFF
475 #define net_new_transaction(net) ((net)->pkt_nr=0)
482 void my_net_local_init(
NET *net);
483 void net_end(
NET *net);
487 my_bool
my_net_write(
NET *net,
const unsigned char *packet,
size_t len);
489 const unsigned char *header,
size_t head_len,
490 const unsigned char *packet,
size_t len);
494 #ifdef MY_GLOBAL_INCLUDED
495 void my_net_set_write_timeout(
NET *net, uint timeout);
496 void my_net_set_read_timeout(
NET *net, uint timeout);
500 unsigned long seed1,seed2,max_value;
501 double max_value_dbl;
510 enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
515 unsigned int arg_count;
516 enum Item_result *arg_type;
518 unsigned long *lengths;
521 unsigned long *attribute_lengths;
530 unsigned int decimals;
531 unsigned long max_length;
542 #define NET_HEADER_SIZE 4
543 #define COMP_HEADER_SIZE 3
556 void randominit(
struct rand_struct *,
unsigned long seed1,
557 unsigned long seed2);
559 void create_random_string(
char *
to,
unsigned int length,
struct rand_struct *rand_st);
561 void hash_password(
unsigned long *
to,
const char *password,
unsigned int password_len);
562 void make_scrambled_password_323(
char *
to,
const char *password);
563 void scramble_323(
char *
to,
const char *
message,
const char *password);
564 my_bool check_scramble_323(
const unsigned char *
reply,
const char *
message,
565 unsigned long *salt);
566 void get_salt_from_password_323(
unsigned long *res,
const char *password);
567 void make_password_from_salt_323(
char *
to,
const unsigned long *salt);
569 void make_scrambled_password(
char *
to,
const char *password);
570 void scramble(
char *
to,
const char *
message,
const char *password);
571 my_bool check_scramble(
const unsigned char *
reply,
const char *
message,
572 const unsigned char *hash_stage2);
573 void get_salt_from_password(
unsigned char *res,
const char *password);
574 void make_password_from_salt(
char *
to,
const unsigned char *hash_stage2);
575 char *octet2hex(
char *
to,
const char *str,
unsigned int len);
579 char *get_tty_password(
const char *opt_message);
580 const char *mysql_errno_to_sqlstate(
unsigned int mysql_errno);
584 my_bool my_thread_init(
void);
585 void my_thread_end(
void);
587 #ifdef MY_GLOBAL_INCLUDED
588 ulong STDCALL net_field_length(uchar **packet);
589 my_ulonglong net_field_length_ll(uchar **packet);
590 uchar *net_store_length(uchar *pkg, ulonglong length);
597 #define NULL_LENGTH ((unsigned long) ~0)
598 #define MYSQL_STMT_HEADER 4
599 #define MYSQL_LONG_DATA_HEADER 6
601 #define NOT_FIXED_DEC 31