MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mysql_com.h
1 /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 /*
17 ** Common definition between mysql server & client
18 */
19 
20 #ifndef _mysql_com_h
21 #define _mysql_com_h
22 
23 #define HOSTNAME_LENGTH 60
24 #define SYSTEM_CHARSET_MBMAXLEN 3
25 #define NAME_CHAR_LEN 64 /* Field/table name length */
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)
29 
30 #define MYSQL_AUTODETECT_CHARSET_NAME "auto"
31 
32 #define SERVER_VERSION_LENGTH 60
33 #define SQLSTATE_LENGTH 5
34 
35 /*
36  Maximum length of comments
37 */
38 #define TABLE_COMMENT_INLINE_MAXLEN 180 /* pre 6.0: 60 characters */
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
43 
44 /*
45  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
46  username and hostname parts of the user identifier with trailing zero in
47  MySQL standard format:
48  user_name_part@host_name_part\0
49 */
50 #define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
51 
52 #define LOCAL_HOST "localhost"
53 #define LOCAL_HOST_NAMEDPIPE "."
54 
55 
56 #if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
57 #define MYSQL_NAMEDPIPE "MySQL"
58 #define MYSQL_SERVICENAME "MySQL"
59 #endif /* __WIN__ */
60 
61 /*
62  You should add new commands to the end of this list, otherwise old
63  servers won't be able to handle them as 'unsupported'.
64 */
65 
66 enum enum_server_command
67 {
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,
75  COM_BINLOG_DUMP_GTID,
76  /* don't forget to update const char *command_name[] in sql_parse.cc */
77 
78  /* Must be last */
79  COM_END
80 };
81 
82 
83 /*
84  Length of random string sent by server on handshake; this is also length of
85  obfuscated password, recieved from client
86 */
87 #define SCRAMBLE_LENGTH 20
88 #define SCRAMBLE_LENGTH_323 8
89 /* length of password stored in the db: new passwords are preceeded with '*' */
90 #define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
91 #define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
92 
93 
94 #define NOT_NULL_FLAG 1 /* Field can't be NULL */
95 #define PRI_KEY_FLAG 2 /* Field is part of a primary key */
96 #define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
97 #define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
98 #define BLOB_FLAG 16 /* Field is a blob */
99 #define UNSIGNED_FLAG 32 /* Field is unsigned */
100 #define ZEROFILL_FLAG 64 /* Field is zerofill */
101 #define BINARY_FLAG 128 /* Field is binary */
102 
103 /* The following are only sent to new clients */
104 #define ENUM_FLAG 256 /* field is an enum */
105 #define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
106 #define TIMESTAMP_FLAG 1024 /* Field is a timestamp */
107 #define SET_FLAG 2048 /* field is a set */
108 #define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */
109 #define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */
110 #define NUM_FLAG 32768 /* Field is num (for clients) */
111 #define PART_KEY_FLAG 16384 /* Intern; Part of some key */
112 #define GROUP_FLAG 32768 /* Intern: Group field */
113 #define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
114 #define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */
115 #define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
116 #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
117 
121 #define FIELD_IN_ADD_INDEX (1 << 20)
122 #define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */
123 #define FIELD_FLAGS_STORAGE_MEDIA 22 /* Field storage media, bit 22-23 */
124 #define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA)
125 #define FIELD_FLAGS_COLUMN_FORMAT 24 /* Field column format, bit 24-25 */
126 #define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
127 #define FIELD_IS_DROPPED (1<< 26) /* Intern: Field is being dropped */
128 
129 #define REFRESH_GRANT 1 /* Refresh grant tables */
130 #define REFRESH_LOG 2 /* Start on new log file */
131 #define REFRESH_TABLES 4 /* close all tables */
132 #define REFRESH_HOSTS 8 /* Flush host cache */
133 #define REFRESH_STATUS 16 /* Flush status variables */
134 #define REFRESH_THREADS 32 /* Flush thread cache */
135 #define REFRESH_SLAVE 64 /* Reset master info and restart slave
136  thread */
137 #define REFRESH_MASTER 128 /* Remove all bin logs in the index
138  and truncate the index */
139 #define REFRESH_ERROR_LOG 256 /* Rotate only the erorr log */
140 #define REFRESH_ENGINE_LOG 512 /* Flush all storage engine logs */
141 #define REFRESH_BINARY_LOG 1024 /* Flush the binary log */
142 #define REFRESH_RELAY_LOG 2048 /* Flush the relay log */
143 #define REFRESH_GENERAL_LOG 4096 /* Flush the general log */
144 #define REFRESH_SLOW_LOG 8192 /* Flush the slow query log */
145 
146 /* The following can't be set with mysql_refresh() */
147 #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
148 #define REFRESH_FAST 32768 /* Intern flag */
149 
150 /* RESET (remove all queries) from query cache */
151 #define REFRESH_QUERY_CACHE 65536
152 #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
153 #define REFRESH_DES_KEY_FILE 0x40000L
154 #define REFRESH_USER_RESOURCES 0x80000L
155 #define REFRESH_FOR_EXPORT 0x100000L /* FLUSH TABLES ... FOR EXPORT */
156 
157 #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
158 #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
159 #define CLIENT_LONG_FLAG 4 /* Get all column flags */
160 #define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
161 #define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
162 #define CLIENT_COMPRESS 32 /* Can use compression protocol */
163 #define CLIENT_ODBC 64 /* Odbc client */
164 #define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
165 #define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
166 #define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */
167 #define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
168 #define CLIENT_SSL 2048 /* Switch to SSL after handshake */
169 #define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
170 #define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */
171 #define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */
172 #define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
173 #define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
174 #define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
175 #define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */
176 
177 #define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */
178 #define CLIENT_CONNECT_ATTRS (1UL << 20) /* Client supports connection attributes */
179 
180 /* Enable authentication response packet to be larger than 255 bytes. */
181 #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21)
182 
183 /* Don't close the connection for a connection with expired password. */
184 #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22)
185 
186 #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
187 #define CLIENT_REMEMBER_OPTIONS (1UL << 31)
188 
189 #ifdef HAVE_COMPRESS
190 #define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
191 #else
192 #define CAN_CLIENT_COMPRESS 0
193 #endif
194 
195 /* Gather all possible capabilites (flags) supported by the server */
196 #define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD \
197  | CLIENT_FOUND_ROWS \
198  | CLIENT_LONG_FLAG \
199  | CLIENT_CONNECT_WITH_DB \
200  | CLIENT_NO_SCHEMA \
201  | CLIENT_COMPRESS \
202  | CLIENT_ODBC \
203  | CLIENT_LOCAL_FILES \
204  | CLIENT_IGNORE_SPACE \
205  | CLIENT_PROTOCOL_41 \
206  | CLIENT_INTERACTIVE \
207  | CLIENT_SSL \
208  | CLIENT_IGNORE_SIGPIPE \
209  | CLIENT_TRANSACTIONS \
210  | CLIENT_RESERVED \
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 \
221 )
222 
223 /*
224  Switch off the flags that are optional and depending on build flags
225  If any of the optional flags is supported by the build it will be switched
226  on before sending to the client during the connection handshake.
227 */
228 #define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
229  & ~CLIENT_COMPRESS) \
230  & ~CLIENT_SSL_VERIFY_SERVER_CERT)
231 
239 #define SERVER_STATUS_IN_TRANS 1
240 #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
241 #define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
242 #define SERVER_QUERY_NO_GOOD_INDEX_USED 16
243 #define SERVER_QUERY_NO_INDEX_USED 32
244 
249 #define SERVER_STATUS_CURSOR_EXISTS 64
250 
254 #define SERVER_STATUS_LAST_ROW_SENT 128
255 #define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */
256 #define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
257 
262 #define SERVER_STATUS_METADATA_CHANGED 1024
263 #define SERVER_QUERY_WAS_SLOW 2048
264 
268 #define SERVER_PS_OUT_PARAMS 4096
269 
277 #define SERVER_STATUS_IN_TRANS_READONLY 8192
278 
279 
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)
296 
297 #define MYSQL_ERRMSG_SIZE 512
298 #define NET_READ_TIMEOUT 30 /* Timeout on read */
299 #define NET_WRITE_TIMEOUT 60 /* Timeout on write */
300 #define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
301 
302 #define ONLY_KILL_QUERY 1
303 
304 
305 struct st_vio; /* Only C */
306 typedef struct st_vio Vio;
307 
308 #define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */
309 #define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */
310 #define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */
311 #define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */
312 #define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */
313 #define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
314 #define MAX_BLOB_WIDTH 16777216 /* Default width for blob */
315 
316 typedef struct st_net {
317 #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY)
318  Vio *vio;
319  unsigned char *buff,*buff_end,*write_pos,*read_pos;
320  my_socket fd; /* For Perl DBI/dbd */
321  /*
322  The following variable is set if we are doing several queries in one
323  command ( as in LOAD TABLE ... FROM MASTER ),
324  and do not want to confuse the client with OK at the wrong time
325  */
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;
330  int fcntl;
331  unsigned int *return_status;
332  unsigned char reading_or_writing;
333  char save_char;
334  my_bool unused1; /* Please remove with the next incompatible ABI change */
335  my_bool unused2; /* Please remove with the next incompatible ABI change */
336  my_bool compress;
337  my_bool unused3; /* Please remove with the next incompatible ABI change. */
338  /*
339  Pointer to query object in query cache, do not equal NULL (0) for
340  queries in cache that have not stored its results yet
341  */
342 #endif
343  /*
344  Unused, please remove with the next incompatible ABI change.
345  */
346  unsigned char *unused;
347  unsigned int last_errno;
348  unsigned char error;
349  my_bool unused4; /* Please remove with the next incompatible ABI change. */
350  my_bool unused5; /* Please remove with the next incompatible ABI change. */
352  char last_error[MYSQL_ERRMSG_SIZE];
354  char sqlstate[SQLSTATE_LENGTH+1];
363  void *extension;
364 } NET;
365 
366 
367 #define packet_error (~(unsigned long) 0)
368 
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,
377  MYSQL_TYPE_BIT,
378  MYSQL_TYPE_TIMESTAMP2,
379  MYSQL_TYPE_DATETIME2,
380  MYSQL_TYPE_TIME2,
381  MYSQL_TYPE_NEWDECIMAL=246,
382  MYSQL_TYPE_ENUM=247,
383  MYSQL_TYPE_SET=248,
384  MYSQL_TYPE_TINY_BLOB=249,
385  MYSQL_TYPE_MEDIUM_BLOB=250,
386  MYSQL_TYPE_LONG_BLOB=251,
387  MYSQL_TYPE_BLOB=252,
388  MYSQL_TYPE_VAR_STRING=253,
389  MYSQL_TYPE_STRING=254,
390  MYSQL_TYPE_GEOMETRY=255
391 
392 };
393 
394 /* For backward compatibility */
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
424 
425 
426 /* Shutdown/kill enums and constants */
427 
428 /* Bits for THD::killable. */
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)
433 
434 enum mysql_enum_shutdown_level {
435  /*
436  We want levels to be in growing order of hardness (because we use number
437  comparisons). Note that DEFAULT does not respect the growing property, but
438  it's ok.
439  */
440  SHUTDOWN_DEFAULT = 0,
441  /* wait for existing connections to finish */
442  SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
443  /* wait for existing trans to finish */
444  SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
445  /* wait for existing updates to finish (=> no partial MyISAM update) */
446  SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
447  /* flush InnoDB buffers and other storage engines' buffers*/
448  SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
449  /* don't flush InnoDB buffers, flush other storage engines' buffers*/
450  SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
451  /* Now the 2 levels of the KILL command */
452 #if MYSQL_VERSION_ID >= 50000
453  KILL_QUERY= 254,
454 #endif
455  KILL_CONNECTION= 255
456 };
457 
458 
459 enum enum_cursor_type
460 {
461  CURSOR_TYPE_NO_CURSOR= 0,
462  CURSOR_TYPE_READ_ONLY= 1,
463  CURSOR_TYPE_FOR_UPDATE= 2,
464  CURSOR_TYPE_SCROLLABLE= 4
465 };
466 
467 
468 /* options for mysql_set_option */
469 enum enum_mysql_set_option
470 {
471  MYSQL_OPTION_MULTI_STATEMENTS_ON,
472  MYSQL_OPTION_MULTI_STATEMENTS_OFF
473 };
474 
475 #define net_new_transaction(net) ((net)->pkt_nr=0)
476 
477 #ifdef __cplusplus
478 extern "C" {
479 #endif
480 
481 my_bool my_net_init(NET *net, Vio* vio);
482 void my_net_local_init(NET *net);
483 void net_end(NET *net);
484 void net_clear(NET *net, my_bool check_buffer);
485 my_bool net_realloc(NET *net, size_t length);
486 my_bool net_flush(NET *net);
487 my_bool my_net_write(NET *net,const unsigned char *packet, size_t len);
488 my_bool net_write_command(NET *net,unsigned char command,
489  const unsigned char *header, size_t head_len,
490  const unsigned char *packet, size_t len);
491 my_bool net_write_packet(NET *net, const unsigned char *packet, size_t length);
492 unsigned long my_net_read(NET *net);
493 
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);
497 #endif
498 
499 struct rand_struct {
500  unsigned long seed1,seed2,max_value;
501  double max_value_dbl;
502 };
503 
504 #ifdef __cplusplus
505 }
506 #endif
507 
508  /* The following is for user defined functions */
509 
510 enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
511  DECIMAL_RESULT};
512 
513 typedef struct st_udf_args
514 {
515  unsigned int arg_count; /* Number of arguments */
516  enum Item_result *arg_type; /* Pointer to item_results */
517  char **args; /* Pointer to argument */
518  unsigned long *lengths; /* Length of string arguments */
519  char *maybe_null; /* Set to 1 for all maybe_null args */
520  char **attributes; /* Pointer to attribute name */
521  unsigned long *attribute_lengths; /* Length of attribute arguments */
522  void *extension;
523 } UDF_ARGS;
524 
525  /* This holds information about the result */
526 
527 typedef struct st_udf_init
528 {
529  my_bool maybe_null; /* 1 if function can return NULL */
530  unsigned int decimals; /* for real functions */
531  unsigned long max_length; /* For string functions */
532  char *ptr; /* free pointer for function data */
533  my_bool const_item; /* 1 if function always returns the same value */
534  void *extension;
535 } UDF_INIT;
536 /*
537  TODO: add a notion for determinism of the UDF.
538  See Item_udf_func::update_used_tables ()
539 */
540 
541  /* Constants when using compression */
542 #define NET_HEADER_SIZE 4 /* standard header size */
543 #define COMP_HEADER_SIZE 3 /* compression header extra size */
544 
545  /* Prototypes to password functions */
546 
547 #ifdef __cplusplus
548 extern "C" {
549 #endif
550 
551 /*
552  These functions are used for authentication by client and server and
553  implemented in sql/password.c
554 */
555 
556 void randominit(struct rand_struct *, unsigned long seed1,
557  unsigned long seed2);
558 double my_rnd(struct rand_struct *);
559 void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
560 
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);
568 
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);
576 
577 /* end of password.c */
578 
579 char *get_tty_password(const char *opt_message);
580 const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
581 
582 /* Some other useful functions */
583 
584 my_bool my_thread_init(void);
585 void my_thread_end(void);
586 
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);
591 #endif
592 
593 #ifdef __cplusplus
594 }
595 #endif
596 
597 #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
598 #define MYSQL_STMT_HEADER 4
599 #define MYSQL_LONG_DATA_HEADER 6
600 
601 #define NOT_FIXED_DEC 31
602 #endif