Clone of PhatAC @ https://github.com/floaterxk/PhatAC

mysql_com.h 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  12. /*
  13. ** Common definition between mysql server & client
  14. */
  15. #ifndef _mysql_com_h
  16. #define _mysql_com_h
  17. #include "binary_log_types.h"
  18. #include "my_command.h"
  19. #define HOSTNAME_LENGTH 60
  20. #define SYSTEM_CHARSET_MBMAXLEN 3
  21. #define FILENAME_CHARSET_MBMAXLEN 5
  22. #define NAME_CHAR_LEN 64 /* Field/table name length */
  23. #define USERNAME_CHAR_LENGTH 32
  24. #define USERNAME_CHAR_LENGTH_STR "32"
  25. #ifndef NAME_LEN
  26. #define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
  27. #endif
  28. #define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
  29. #define MYSQL_AUTODETECT_CHARSET_NAME "auto"
  30. #define SERVER_VERSION_LENGTH 60
  31. #define SQLSTATE_LENGTH 5
  32. /*
  33. Maximum length of comments
  34. */
  35. #define TABLE_COMMENT_INLINE_MAXLEN 180 /* pre 6.0: 60 characters */
  36. #define TABLE_COMMENT_MAXLEN 2048
  37. #define COLUMN_COMMENT_MAXLEN 1024
  38. #define INDEX_COMMENT_MAXLEN 1024
  39. #define TABLE_PARTITION_COMMENT_MAXLEN 1024
  40. /*
  41. Maximum length of protocol packet.
  42. OK packet length limit also restricted to this value as any length greater
  43. than this value will have first byte of OK packet to be 254 thus does not
  44. provide a means to identify if this is OK or EOF packet.
  45. */
  46. #define MAX_PACKET_LENGTH (256L*256L*256L-1)
  47. /*
  48. USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
  49. username and hostname parts of the user identifier with trailing zero in
  50. MySQL standard format:
  51. user_name_part@host_name_part\0
  52. */
  53. #define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
  54. #define LOCAL_HOST "localhost"
  55. #define LOCAL_HOST_NAMEDPIPE "."
  56. #if defined(_WIN32)
  57. #define MYSQL_NAMEDPIPE "MySQL"
  58. #define MYSQL_SERVICENAME "MySQL"
  59. #endif /* _WIN32 */
  60. /* The length of the header part for each generated column in the .frm file. */
  61. #define FRM_GCOL_HEADER_SIZE 4
  62. /*
  63. Maximum length of the expression statement defined for generated columns.
  64. */
  65. #define GENERATED_COLUMN_EXPRESSION_MAXLEN 65535 - FRM_GCOL_HEADER_SIZE
  66. /*
  67. Length of random string sent by server on handshake; this is also length of
  68. obfuscated password, received from client
  69. */
  70. #define SCRAMBLE_LENGTH 20
  71. #define AUTH_PLUGIN_DATA_PART_1_LENGTH 8
  72. /* length of password stored in the db: new passwords are preceeded with '*' */
  73. #define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
  74. #define NOT_NULL_FLAG 1 /* Field can't be NULL */
  75. #define PRI_KEY_FLAG 2 /* Field is part of a primary key */
  76. #define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
  77. #define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */
  78. #define BLOB_FLAG 16 /* Field is a blob */
  79. #define UNSIGNED_FLAG 32 /* Field is unsigned */
  80. #define ZEROFILL_FLAG 64 /* Field is zerofill */
  81. #define BINARY_FLAG 128 /* Field is binary */
  82. /* The following are only sent to new clients */
  83. #define ENUM_FLAG 256 /* field is an enum */
  84. #define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */
  85. #define TIMESTAMP_FLAG 1024 /* Field is a timestamp */
  86. #define SET_FLAG 2048 /* field is a set */
  87. #define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */
  88. #define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */
  89. #define NUM_FLAG 32768 /* Field is num (for clients) */
  90. #define PART_KEY_FLAG 16384 /* Intern; Part of some key */
  91. #define GROUP_FLAG 32768 /* Intern: Group field */
  92. #define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */
  93. #define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */
  94. #define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
  95. #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
  96. /**
  97. Intern: Field in TABLE object for new version of altered table,
  98. which participates in a newly added index.
  99. */
  100. #define FIELD_IN_ADD_INDEX (1 << 20)
  101. #define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */
  102. #define FIELD_FLAGS_STORAGE_MEDIA 22 /* Field storage media, bit 22-23 */
  103. #define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA)
  104. #define FIELD_FLAGS_COLUMN_FORMAT 24 /* Field column format, bit 24-25 */
  105. #define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
  106. #define FIELD_IS_DROPPED (1<< 26) /* Intern: Field is being dropped */
  107. #define EXPLICIT_NULL_FLAG (1<< 27) /* Field is explicitly specified as
  108. NULL by the user */
  109. #define REFRESH_GRANT 1 /* Refresh grant tables */
  110. #define REFRESH_LOG 2 /* Start on new log file */
  111. #define REFRESH_TABLES 4 /* close all tables */
  112. #define REFRESH_HOSTS 8 /* Flush host cache */
  113. #define REFRESH_STATUS 16 /* Flush status variables */
  114. #define REFRESH_THREADS 32 /* Flush thread cache */
  115. #define REFRESH_SLAVE 64 /* Reset master info and restart slave
  116. thread */
  117. #define REFRESH_MASTER 128 /* Remove all bin logs in the index
  118. and truncate the index */
  119. #define REFRESH_ERROR_LOG 256 /* Rotate only the erorr log */
  120. #define REFRESH_ENGINE_LOG 512 /* Flush all storage engine logs */
  121. #define REFRESH_BINARY_LOG 1024 /* Flush the binary log */
  122. #define REFRESH_RELAY_LOG 2048 /* Flush the relay log */
  123. #define REFRESH_GENERAL_LOG 4096 /* Flush the general log */
  124. #define REFRESH_SLOW_LOG 8192 /* Flush the slow query log */
  125. /* The following can't be set with mysql_refresh() */
  126. #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
  127. #define REFRESH_FAST 32768 /* Intern flag */
  128. /* RESET (remove all queries) from query cache */
  129. #define REFRESH_QUERY_CACHE 65536
  130. #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
  131. #define REFRESH_DES_KEY_FILE 0x40000L
  132. #define REFRESH_USER_RESOURCES 0x80000L
  133. #define REFRESH_FOR_EXPORT 0x100000L /* FLUSH TABLES ... FOR EXPORT */
  134. #define REFRESH_OPTIMIZER_COSTS 0x200000L /* FLUSH OPTIMIZER_COSTS */
  135. #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
  136. #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
  137. #define CLIENT_LONG_FLAG 4 /* Get all column flags */
  138. #define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
  139. #define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
  140. #define CLIENT_COMPRESS 32 /* Can use compression protocol */
  141. #define CLIENT_ODBC 64 /* Odbc client */
  142. #define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
  143. #define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
  144. #define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */
  145. #define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
  146. #define CLIENT_SSL 2048 /* Switch to SSL after handshake */
  147. #define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
  148. #define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */
  149. #define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */
  150. #define CLIENT_RESERVED2 32768 /* Old flag for 4.1 authentication */
  151. #define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
  152. #define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */
  153. #define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */
  154. #define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */
  155. #define CLIENT_CONNECT_ATTRS (1UL << 20) /* Client supports connection attributes */
  156. /* Enable authentication response packet to be larger than 255 bytes. */
  157. #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21)
  158. /* Don't close the connection for a connection with expired password. */
  159. #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22)
  160. /**
  161. Capable of handling server state change information. Its a hint to the
  162. server to include the state change information in Ok packet.
  163. */
  164. #define CLIENT_SESSION_TRACK (1UL << 23)
  165. /* Client no longer needs EOF packet */
  166. #define CLIENT_DEPRECATE_EOF (1UL << 24)
  167. #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
  168. #define CLIENT_REMEMBER_OPTIONS (1UL << 31)
  169. #ifdef HAVE_COMPRESS
  170. #define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
  171. #else
  172. #define CAN_CLIENT_COMPRESS 0
  173. #endif
  174. /* Gather all possible capabilites (flags) supported by the server */
  175. #define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD \
  176. | CLIENT_FOUND_ROWS \
  177. | CLIENT_LONG_FLAG \
  178. | CLIENT_CONNECT_WITH_DB \
  179. | CLIENT_NO_SCHEMA \
  180. | CLIENT_COMPRESS \
  181. | CLIENT_ODBC \
  182. | CLIENT_LOCAL_FILES \
  183. | CLIENT_IGNORE_SPACE \
  184. | CLIENT_PROTOCOL_41 \
  185. | CLIENT_INTERACTIVE \
  186. | CLIENT_SSL \
  187. | CLIENT_IGNORE_SIGPIPE \
  188. | CLIENT_TRANSACTIONS \
  189. | CLIENT_RESERVED \
  190. | CLIENT_RESERVED2 \
  191. | CLIENT_MULTI_STATEMENTS \
  192. | CLIENT_MULTI_RESULTS \
  193. | CLIENT_PS_MULTI_RESULTS \
  194. | CLIENT_SSL_VERIFY_SERVER_CERT \
  195. | CLIENT_REMEMBER_OPTIONS \
  196. | CLIENT_PLUGIN_AUTH \
  197. | CLIENT_CONNECT_ATTRS \
  198. | CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA \
  199. | CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS \
  200. | CLIENT_SESSION_TRACK \
  201. | CLIENT_DEPRECATE_EOF \
  202. )
  203. /*
  204. Switch off the flags that are optional and depending on build flags
  205. If any of the optional flags is supported by the build it will be switched
  206. on before sending to the client during the connection handshake.
  207. */
  208. #define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
  209. & ~CLIENT_COMPRESS) \
  210. & ~CLIENT_SSL_VERIFY_SERVER_CERT)
  211. /**
  212. Is raised when a multi-statement transaction
  213. has been started, either explicitly, by means
  214. of BEGIN or COMMIT AND CHAIN, or
  215. implicitly, by the first transactional
  216. statement, when autocommit=off.
  217. */
  218. #define SERVER_STATUS_IN_TRANS 1
  219. #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
  220. #define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
  221. #define SERVER_QUERY_NO_GOOD_INDEX_USED 16
  222. #define SERVER_QUERY_NO_INDEX_USED 32
  223. /**
  224. The server was able to fulfill the clients request and opened a
  225. read-only non-scrollable cursor for a query. This flag comes
  226. in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
  227. */
  228. #define SERVER_STATUS_CURSOR_EXISTS 64
  229. /**
  230. This flag is sent when a read-only cursor is exhausted, in reply to
  231. COM_STMT_FETCH command.
  232. */
  233. #define SERVER_STATUS_LAST_ROW_SENT 128
  234. #define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */
  235. #define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
  236. /**
  237. Sent to the client if after a prepared statement reprepare
  238. we discovered that the new statement returns a different
  239. number of result set columns.
  240. */
  241. #define SERVER_STATUS_METADATA_CHANGED 1024
  242. #define SERVER_QUERY_WAS_SLOW 2048
  243. /**
  244. To mark ResultSet containing output parameter values.
  245. */
  246. #define SERVER_PS_OUT_PARAMS 4096
  247. /**
  248. Set at the same time as SERVER_STATUS_IN_TRANS if the started
  249. multi-statement transaction is a read-only transaction. Cleared
  250. when the transaction commits or aborts. Since this flag is sent
  251. to clients in OK and EOF packets, the flag indicates the
  252. transaction status at the end of command execution.
  253. */
  254. #define SERVER_STATUS_IN_TRANS_READONLY 8192
  255. /**
  256. This status flag, when on, implies that one of the state information has
  257. changed on the server because of the execution of the last statement.
  258. */
  259. #define SERVER_SESSION_STATE_CHANGED (1UL << 14)
  260. /**
  261. Server status flags that must be cleared when starting
  262. execution of a new SQL statement.
  263. Flags from this set are only added to the
  264. current server status by the execution engine, but
  265. never removed -- the execution engine expects them
  266. to disappear automagically by the next command.
  267. */
  268. #define SERVER_STATUS_CLEAR_SET (SERVER_QUERY_NO_GOOD_INDEX_USED| \
  269. SERVER_QUERY_NO_INDEX_USED|\
  270. SERVER_MORE_RESULTS_EXISTS|\
  271. SERVER_STATUS_METADATA_CHANGED |\
  272. SERVER_QUERY_WAS_SLOW |\
  273. SERVER_STATUS_DB_DROPPED |\
  274. SERVER_STATUS_CURSOR_EXISTS|\
  275. SERVER_STATUS_LAST_ROW_SENT|\
  276. SERVER_SESSION_STATE_CHANGED)
  277. #define MYSQL_ERRMSG_SIZE 512
  278. #define NET_READ_TIMEOUT 30 /* Timeout on read */
  279. #define NET_WRITE_TIMEOUT 60 /* Timeout on write */
  280. #define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */
  281. #define ONLY_KILL_QUERY 1
  282. struct st_vio; /* Only C */
  283. typedef struct st_vio Vio;
  284. #define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */
  285. #define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */
  286. #define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */
  287. #define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */
  288. #define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */
  289. #define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
  290. #define MAX_BLOB_WIDTH 16777216 /* Default width for blob */
  291. typedef struct st_net {
  292. Vio *vio;
  293. unsigned char *buff,*buff_end,*write_pos,*read_pos;
  294. my_socket fd; /* For Perl DBI/dbd */
  295. /*
  296. The following variable is set if we are doing several queries in one
  297. command ( as in LOAD TABLE ... FROM MASTER ),
  298. and do not want to confuse the client with OK at the wrong time
  299. */
  300. unsigned long remain_in_buf,length, buf_length, where_b;
  301. unsigned long max_packet,max_packet_size;
  302. unsigned int pkt_nr,compress_pkt_nr;
  303. unsigned int write_timeout, read_timeout, retry_count;
  304. int fcntl;
  305. unsigned int *return_status;
  306. unsigned char reading_or_writing;
  307. char save_char;
  308. my_bool unused1; /* Please remove with the next incompatible ABI change */
  309. my_bool unused2; /* Please remove with the next incompatible ABI change */
  310. my_bool compress;
  311. my_bool unused3; /* Please remove with the next incompatible ABI change. */
  312. /*
  313. Pointer to query object in query cache, do not equal NULL (0) for
  314. queries in cache that have not stored its results yet
  315. */
  316. /*
  317. Unused, please remove with the next incompatible ABI change.
  318. */
  319. unsigned char *unused;
  320. unsigned int last_errno;
  321. unsigned char error;
  322. my_bool unused4; /* Please remove with the next incompatible ABI change. */
  323. my_bool unused5; /* Please remove with the next incompatible ABI change. */
  324. /** Client library error message buffer. Actually belongs to struct MYSQL. */
  325. char last_error[MYSQL_ERRMSG_SIZE];
  326. /** Client library sqlstate buffer. Set along with the error message. */
  327. char sqlstate[SQLSTATE_LENGTH+1];
  328. /**
  329. Extension pointer, for the caller private use.
  330. Any program linking with the networking library can use this pointer,
  331. which is handy when private connection specific data needs to be
  332. maintained.
  333. The mysqld server process uses this pointer internally,
  334. to maintain the server internal instrumentation for the connection.
  335. */
  336. void *extension;
  337. } NET;
  338. #define packet_error (~(unsigned long) 0)
  339. /* For backward compatibility */
  340. #define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
  341. #define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
  342. #define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
  343. #define FIELD_TYPE_TINY MYSQL_TYPE_TINY
  344. #define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
  345. #define FIELD_TYPE_LONG MYSQL_TYPE_LONG
  346. #define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
  347. #define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
  348. #define FIELD_TYPE_NULL MYSQL_TYPE_NULL
  349. #define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
  350. #define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
  351. #define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
  352. #define FIELD_TYPE_DATE MYSQL_TYPE_DATE
  353. #define FIELD_TYPE_TIME MYSQL_TYPE_TIME
  354. #define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
  355. #define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
  356. #define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
  357. #define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
  358. #define FIELD_TYPE_SET MYSQL_TYPE_SET
  359. #define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
  360. #define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
  361. #define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
  362. #define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
  363. #define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
  364. #define FIELD_TYPE_STRING MYSQL_TYPE_STRING
  365. #define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
  366. #define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
  367. #define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
  368. #define FIELD_TYPE_BIT MYSQL_TYPE_BIT
  369. /* Shutdown/kill enums and constants */
  370. /* Bits for THD::killable. */
  371. #define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
  372. #define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
  373. #define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
  374. #define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
  375. enum mysql_enum_shutdown_level {
  376. /*
  377. We want levels to be in growing order of hardness (because we use number
  378. comparisons). Note that DEFAULT does not respect the growing property, but
  379. it's ok.
  380. */
  381. SHUTDOWN_DEFAULT = 0,
  382. /* wait for existing connections to finish */
  383. SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
  384. /* wait for existing trans to finish */
  385. SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
  386. /* wait for existing updates to finish (=> no partial MyISAM update) */
  387. SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
  388. /* flush InnoDB buffers and other storage engines' buffers*/
  389. SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
  390. /* don't flush InnoDB buffers, flush other storage engines' buffers*/
  391. SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
  392. /* Now the 2 levels of the KILL command */
  393. KILL_QUERY= 254,
  394. KILL_CONNECTION= 255
  395. };
  396. enum enum_cursor_type
  397. {
  398. CURSOR_TYPE_NO_CURSOR= 0,
  399. CURSOR_TYPE_READ_ONLY= 1,
  400. CURSOR_TYPE_FOR_UPDATE= 2,
  401. CURSOR_TYPE_SCROLLABLE= 4
  402. };
  403. /* options for mysql_set_option */
  404. enum enum_mysql_set_option
  405. {
  406. MYSQL_OPTION_MULTI_STATEMENTS_ON,
  407. MYSQL_OPTION_MULTI_STATEMENTS_OFF
  408. };
  409. /*
  410. Type of state change information that the server can include in the Ok
  411. packet.
  412. Note : 1) session_state_type shouldn't go past 255 (i.e. 1-byte boundary).
  413. 2) Modify the definition of SESSION_TRACK_END when a new member is
  414. added.
  415. */
  416. enum enum_session_state_type
  417. {
  418. SESSION_TRACK_SYSTEM_VARIABLES, /* Session system variables */
  419. SESSION_TRACK_SCHEMA, /* Current schema */
  420. SESSION_TRACK_STATE_CHANGE, /* track session state changes */
  421. SESSION_TRACK_GTIDS,
  422. SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /* Transaction chistics */
  423. SESSION_TRACK_TRANSACTION_STATE /* Transaction state */
  424. };
  425. #define SESSION_TRACK_BEGIN SESSION_TRACK_SYSTEM_VARIABLES
  426. #define SESSION_TRACK_END SESSION_TRACK_TRANSACTION_STATE
  427. #define IS_SESSION_STATE_TYPE(T) \
  428. (((int)(T) >= SESSION_TRACK_BEGIN) && ((T) <= SESSION_TRACK_END))
  429. #define net_new_transaction(net) ((net)->pkt_nr=0)
  430. #ifdef __cplusplus
  431. extern "C" {
  432. #endif
  433. my_bool my_net_init(NET *net, Vio* vio);
  434. void my_net_local_init(NET *net);
  435. void net_end(NET *net);
  436. void net_clear(NET *net, my_bool check_buffer);
  437. void net_claim_memory_ownership(NET *net);
  438. my_bool net_realloc(NET *net, size_t length);
  439. my_bool net_flush(NET *net);
  440. my_bool my_net_write(NET *net,const unsigned char *packet, size_t len);
  441. my_bool net_write_command(NET *net,unsigned char command,
  442. const unsigned char *header, size_t head_len,
  443. const unsigned char *packet, size_t len);
  444. my_bool net_write_packet(NET *net, const unsigned char *packet, size_t length);
  445. unsigned long my_net_read(NET *net);
  446. #ifdef MY_GLOBAL_INCLUDED
  447. void my_net_set_write_timeout(NET *net, uint timeout);
  448. void my_net_set_read_timeout(NET *net, uint timeout);
  449. #endif
  450. struct rand_struct {
  451. unsigned long seed1,seed2,max_value;
  452. double max_value_dbl;
  453. };
  454. #ifdef __cplusplus
  455. }
  456. #endif
  457. /* The following is for user defined functions */
  458. enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
  459. DECIMAL_RESULT};
  460. typedef struct st_udf_args
  461. {
  462. unsigned int arg_count; /* Number of arguments */
  463. enum Item_result *arg_type; /* Pointer to item_results */
  464. char **args; /* Pointer to argument */
  465. unsigned long *lengths; /* Length of string arguments */
  466. char *maybe_null; /* Set to 1 for all maybe_null args */
  467. char **attributes; /* Pointer to attribute name */
  468. unsigned long *attribute_lengths; /* Length of attribute arguments */
  469. void *extension;
  470. } UDF_ARGS;
  471. /* This holds information about the result */
  472. typedef struct st_udf_init
  473. {
  474. my_bool maybe_null; /* 1 if function can return NULL */
  475. unsigned int decimals; /* for real functions */
  476. unsigned long max_length; /* For string functions */
  477. char *ptr; /* free pointer for function data */
  478. my_bool const_item; /* 1 if function always returns the same value */
  479. void *extension;
  480. } UDF_INIT;
  481. /*
  482. TODO: add a notion for determinism of the UDF.
  483. See Item_udf_func::update_used_tables ()
  484. */
  485. /* Constants when using compression */
  486. #define NET_HEADER_SIZE 4 /* standard header size */
  487. #define COMP_HEADER_SIZE 3 /* compression header extra size */
  488. /* Prototypes to password functions */
  489. #ifdef __cplusplus
  490. extern "C" {
  491. #endif
  492. /*
  493. These functions are used for authentication by client and server and
  494. implemented in sql/password.c
  495. */
  496. void randominit(struct rand_struct *, unsigned long seed1,
  497. unsigned long seed2);
  498. double my_rnd(struct rand_struct *);
  499. void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
  500. void hash_password(unsigned long *to, const char *password, unsigned int password_len);
  501. void make_scrambled_password_323(char *to, const char *password);
  502. void scramble_323(char *to, const char *message, const char *password);
  503. my_bool check_scramble_323(const unsigned char *reply, const char *message,
  504. unsigned long *salt);
  505. void get_salt_from_password_323(unsigned long *res, const char *password);
  506. void make_password_from_salt_323(char *to, const unsigned long *salt);
  507. void make_scrambled_password(char *to, const char *password);
  508. void scramble(char *to, const char *message, const char *password);
  509. my_bool check_scramble(const unsigned char *reply, const char *message,
  510. const unsigned char *hash_stage2);
  511. void get_salt_from_password(unsigned char *res, const char *password);
  512. void make_password_from_salt(char *to, const unsigned char *hash_stage2);
  513. char *octet2hex(char *to, const char *str, unsigned int len);
  514. /* end of password.c */
  515. char *get_tty_password(const char *opt_message);
  516. const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
  517. /* Some other useful functions */
  518. my_bool my_thread_init(void);
  519. void my_thread_end(void);
  520. #ifdef MY_GLOBAL_INCLUDED
  521. ulong STDCALL net_field_length(uchar **packet);
  522. my_ulonglong net_field_length_ll(uchar **packet);
  523. uchar *net_store_length(uchar *pkg, ulonglong length);
  524. unsigned int net_length_size(ulonglong num);
  525. #endif
  526. #ifdef __cplusplus
  527. }
  528. #endif
  529. #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
  530. #define MYSQL_STMT_HEADER 4
  531. #define MYSQL_LONG_DATA_HEADER 6
  532. #define NOT_FIXED_DEC 31
  533. #endif