mysql_com.h 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. /* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. Without limiting anything contained in the foregoing, this file,
  12. which is part of C Driver for MySQL (Connector/C), is also subject to the
  13. Universal FOSS Exception, version 1.0, a copy of which can be found at
  14. http://oss.oracle.com/licenses/universal-foss-exception.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License, version 2.0, for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  22. /**
  23. @file include/mysql_com.h
  24. Common definition between mysql server & client.
  25. */
  26. #ifndef _mysql_com_h
  27. #define _mysql_com_h
  28. #ifndef MYSQL_ABI_CHECK
  29. #include <stdbool.h>
  30. #include <stdint.h>
  31. #endif
  32. #include "my_command.h"
  33. #include "my_compress.h"
  34. /*
  35. We need a definition for my_socket. On the client, <mysql.h> already provides
  36. it, but on the server side, we need to get it from a header.
  37. */
  38. #ifndef my_socket_defined
  39. #include "my_io.h"
  40. #include "mysql/components/services/bits/my_io_bits.h"
  41. #endif
  42. #ifndef MYSQL_ABI_CHECK
  43. #include <stdbool.h>
  44. #endif
  45. #define SYSTEM_CHARSET_MBMAXLEN 3
  46. #define FILENAME_CHARSET_MBMAXLEN 5
  47. #define NAME_CHAR_LEN 64 /**< Field/table name length */
  48. #define PARTITION_EXPR_CHAR_LEN \
  49. 2048 /**< Maximum expression length in chars \
  50. */
  51. #define USERNAME_CHAR_LENGTH 32
  52. #define USERNAME_CHAR_LENGTH_STR "32"
  53. #ifndef NAME_LEN
  54. #define NAME_LEN (NAME_CHAR_LEN * SYSTEM_CHARSET_MBMAXLEN)
  55. #endif
  56. #define USERNAME_LENGTH (USERNAME_CHAR_LENGTH * SYSTEM_CHARSET_MBMAXLEN)
  57. #define CONNECT_STRING_MAXLEN 1024
  58. #define MYSQL_AUTODETECT_CHARSET_NAME "auto"
  59. #define SERVER_VERSION_LENGTH 60
  60. #define SQLSTATE_LENGTH 5
  61. /*
  62. In FIDO terminology, relying party is the server where required services are
  63. running. Relying party ID is unique name given to server.
  64. */
  65. #define RELYING_PARTY_ID_LENGTH 255
  66. /* Length of random salt sent during fido registration */
  67. #define CHALLENGE_LENGTH 32
  68. /* Maximum authentication factors server supports */
  69. #define MAX_AUTH_FACTORS 3
  70. /**
  71. Maximum length of comments
  72. pre 5.6: 60 characters
  73. */
  74. #define TABLE_COMMENT_INLINE_MAXLEN 180
  75. #define TABLE_COMMENT_MAXLEN 2048
  76. #define COLUMN_COMMENT_MAXLEN 1024
  77. #define INDEX_COMMENT_MAXLEN 1024
  78. #define TABLE_PARTITION_COMMENT_MAXLEN 1024
  79. #define TABLESPACE_COMMENT_MAXLEN 2048
  80. /**
  81. Maximum length of protocol packet.
  82. @ref page_protocol_basic_ok_packet length limit also restricted to this value
  83. as any length greater than this value will have first byte of
  84. @ref page_protocol_basic_ok_packet to be 254 thus does not
  85. provide a means to identify if this is @ref page_protocol_basic_ok_packet or
  86. @ref page_protocol_basic_eof_packet.
  87. */
  88. #define MAX_PACKET_LENGTH (256L * 256L * 256L - 1)
  89. #define LOCAL_HOST "localhost"
  90. #define LOCAL_HOST_NAMEDPIPE "."
  91. #if defined(_WIN32)
  92. #define MYSQL_NAMEDPIPE "MySQL"
  93. #define MYSQL_SERVICENAME "MySQL"
  94. #endif /* _WIN32 */
  95. /** The length of the header part for each generated column in the .frm file.*/
  96. #define FRM_GCOL_HEADER_SIZE 4
  97. /**
  98. Maximum length of the expression statement defined for generated columns.
  99. */
  100. #define GENERATED_COLUMN_EXPRESSION_MAXLEN 65535 - FRM_GCOL_HEADER_SIZE
  101. /**
  102. Length of random string sent by server on handshake; this is also length of
  103. obfuscated password, received from client
  104. */
  105. #define SCRAMBLE_LENGTH 20
  106. #define AUTH_PLUGIN_DATA_PART_1_LENGTH 8
  107. /** length of password stored in the db: new passwords are preceeded with '*'*/
  108. #define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH * 2 + 1)
  109. /**
  110. @defgroup group_cs_column_definition_flags Column Definition Flags
  111. @ingroup group_cs
  112. @brief Values for the flags bitmask used by ::Send_field:flags
  113. Currently need to fit into 32 bits.
  114. Each bit represents an optional feature of the protocol.
  115. Both the client and the server are sending these.
  116. The intersection of the two determines what optional parts of the
  117. protocol will be used.
  118. */
  119. /**
  120. @addtogroup group_cs_column_definition_flags
  121. @{
  122. */
  123. #define NOT_NULL_FLAG 1 /**< Field can't be NULL */
  124. #define PRI_KEY_FLAG 2 /**< Field is part of a primary key */
  125. #define UNIQUE_KEY_FLAG 4 /**< Field is part of a unique key */
  126. #define MULTIPLE_KEY_FLAG 8 /**< Field is part of a key */
  127. #define BLOB_FLAG 16 /**< Field is a blob */
  128. #define UNSIGNED_FLAG 32 /**< Field is unsigned */
  129. #define ZEROFILL_FLAG 64 /**< Field is zerofill */
  130. #define BINARY_FLAG 128 /**< Field is binary */
  131. /* The following are only sent to new clients */
  132. #define ENUM_FLAG 256 /**< field is an enum */
  133. #define AUTO_INCREMENT_FLAG 512 /**< field is a autoincrement field */
  134. #define TIMESTAMP_FLAG 1024 /**< Field is a timestamp */
  135. #define SET_FLAG 2048 /**< field is a set */
  136. #define NO_DEFAULT_VALUE_FLAG 4096 /**< Field doesn't have default value */
  137. #define ON_UPDATE_NOW_FLAG 8192 /**< Field is set to NOW on UPDATE */
  138. #define NUM_FLAG 32768 /**< Field is num (for clients) */
  139. #define PART_KEY_FLAG 16384 /**< Intern; Part of some key */
  140. #define GROUP_FLAG 32768 /**< Intern: Group field */
  141. #define UNIQUE_FLAG 65536 /**< Intern: Used by sql_yacc */
  142. #define BINCMP_FLAG 131072 /**< Intern: Used by sql_yacc */
  143. #define GET_FIXED_FIELDS_FLAG \
  144. (1 << 18) /**< Used to get fields in item tree \
  145. */
  146. #define FIELD_IN_PART_FUNC_FLAG (1 << 19) /**< Field part of partition func */
  147. /**
  148. Intern: Field in TABLE object for new version of altered table,
  149. which participates in a newly added index.
  150. */
  151. #define FIELD_IN_ADD_INDEX (1 << 20)
  152. #define FIELD_IS_RENAMED (1 << 21) /**< Intern: Field is being renamed */
  153. #define FIELD_FLAGS_STORAGE_MEDIA 22 /**< Field storage media, bit 22-23 */
  154. #define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA)
  155. #define FIELD_FLAGS_COLUMN_FORMAT 24 /**< Field column format, bit 24-25 */
  156. #define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT)
  157. #define FIELD_IS_DROPPED (1 << 26) /**< Intern: Field is being dropped */
  158. #define EXPLICIT_NULL_FLAG \
  159. (1 << 27) /**< Field is explicitly specified as \
  160. NULL by the user */
  161. /* 1 << 28 is unused. */
  162. /** Field will not be loaded in secondary engine. */
  163. #define NOT_SECONDARY_FLAG (1 << 29)
  164. /** Field is explicitly marked as invisible by the user. */
  165. #define FIELD_IS_INVISIBLE (1 << 30)
  166. /** @}*/
  167. /**
  168. @defgroup group_cs_com_refresh_flags COM_REFRESH Flags
  169. @ingroup group_cs
  170. @brief Values for the `sub_command` in ::COM_REFRESH
  171. Currently the protocol carries only 8 bits of these flags.
  172. The rest (8-end) are used only internally in the server.
  173. */
  174. /**
  175. @addtogroup group_cs_com_refresh_flags
  176. @{
  177. */
  178. #define REFRESH_GRANT 1 /**< Refresh grant tables, FLUSH PRIVILEGES */
  179. #define REFRESH_LOG 2 /**< Start on new log file, FLUSH LOGS */
  180. #define REFRESH_TABLES 4 /**< close all tables, FLUSH TABLES */
  181. #define REFRESH_HOSTS 8 /**< Flush host cache, FLUSH HOSTS */
  182. #define REFRESH_STATUS 16 /**< Flush status variables, FLUSH STATUS */
  183. #define REFRESH_THREADS 32 /**< Flush thread cache */
  184. #define REFRESH_REPLICA \
  185. 64 /**< Reset master info and restart replica \
  186. thread, RESET REPLICA */
  187. #define REFRESH_SLAVE \
  188. REFRESH_REPLICA /**< Reset master info and restart replica \
  189. thread, RESET REPLICA. This is deprecated, \
  190. use REFRESH_REPLICA instead. */
  191. #define REFRESH_MASTER \
  192. 128 /**< Remove all bin logs in the index \
  193. and truncate the index, RESET MASTER */
  194. #define REFRESH_ERROR_LOG 256 /**< Rotate only the erorr log */
  195. #define REFRESH_ENGINE_LOG 512 /**< Flush all storage engine logs */
  196. #define REFRESH_BINARY_LOG 1024 /**< Flush the binary log */
  197. #define REFRESH_RELAY_LOG 2048 /**< Flush the relay log */
  198. #define REFRESH_GENERAL_LOG 4096 /**< Flush the general log */
  199. #define REFRESH_SLOW_LOG 8192 /**< Flush the slow query log */
  200. #define REFRESH_READ_LOCK 16384 /**< Lock tables for read. */
  201. /**
  202. Wait for an impending flush before closing the tables.
  203. @sa REFRESH_READ_LOCK, handle_reload_request, close_cached_tables
  204. */
  205. #define REFRESH_FAST 32768
  206. #define REFRESH_USER_RESOURCES 0x80000L /** FLISH RESOUCES. @sa ::reset_mqh */
  207. #define REFRESH_FOR_EXPORT 0x100000L /** FLUSH TABLES ... FOR EXPORT */
  208. #define REFRESH_OPTIMIZER_COSTS 0x200000L /** FLUSH OPTIMIZER_COSTS */
  209. #define REFRESH_PERSIST 0x400000L /** RESET PERSIST */
  210. /** @}*/
  211. /**
  212. @defgroup group_cs_capabilities_flags Capabilities Flags
  213. @ingroup group_cs
  214. @brief Values for the capabilities flag bitmask used by the MySQL protocol
  215. Currently need to fit into 32 bits.
  216. Each bit represents an optional feature of the protocol.
  217. Both the client and the server are sending these.
  218. The intersection of the two determines whast optional parts of the
  219. protocol will be used.
  220. */
  221. /**
  222. @addtogroup group_cs_capabilities_flags
  223. @{
  224. */
  225. /**
  226. Use the improved version of Old Password Authentication.
  227. Not used.
  228. @note Assumed to be set since 4.1.1.
  229. */
  230. #define CLIENT_LONG_PASSWORD 1
  231. /**
  232. Send found rows instead of affected rows in @ref
  233. page_protocol_basic_eof_packet
  234. */
  235. #define CLIENT_FOUND_ROWS 2
  236. /**
  237. @brief Get all column flags
  238. Longer flags in Protocol::ColumnDefinition320.
  239. @todo Reference Protocol::ColumnDefinition320
  240. Server
  241. ------
  242. Supports longer flags.
  243. Client
  244. ------
  245. Expects longer flags.
  246. */
  247. #define CLIENT_LONG_FLAG 4
  248. /**
  249. Database (schema) name can be specified on connect in Handshake Response
  250. Packet.
  251. @todo Reference Handshake Response Packet.
  252. Server
  253. ------
  254. Supports schema-name in Handshake Response Packet.
  255. Client
  256. ------
  257. Handshake Response Packet contains a schema-name.
  258. @sa send_client_reply_packet()
  259. */
  260. #define CLIENT_CONNECT_WITH_DB 8
  261. #define CLIENT_NO_SCHEMA 16 /**< Don't allow database.table.column */
  262. /**
  263. Compression protocol supported.
  264. @todo Reference Compression
  265. Server
  266. ------
  267. Supports compression.
  268. Client
  269. ------
  270. Switches to Compression compressed protocol after successful authentication.
  271. */
  272. #define CLIENT_COMPRESS 32
  273. /**
  274. Special handling of ODBC behavior.
  275. @note No special behavior since 3.22.
  276. */
  277. #define CLIENT_ODBC 64
  278. /**
  279. Can use LOAD DATA LOCAL.
  280. Server
  281. ------
  282. Enables the LOCAL INFILE request of LOAD DATA|XML.
  283. Client
  284. ------
  285. Will handle LOCAL INFILE request.
  286. */
  287. #define CLIENT_LOCAL_FILES 128
  288. /**
  289. Ignore spaces before '('
  290. Server
  291. ------
  292. Parser can ignore spaces before '('.
  293. Client
  294. ------
  295. Let the parser ignore spaces before '('.
  296. */
  297. #define CLIENT_IGNORE_SPACE 256
  298. /**
  299. New 4.1 protocol
  300. @todo Reference the new 4.1 protocol
  301. Server
  302. ------
  303. Supports the 4.1 protocol.
  304. Client
  305. ------
  306. Uses the 4.1 protocol.
  307. @note this value was CLIENT_CHANGE_USER in 3.22, unused in 4.0
  308. */
  309. #define CLIENT_PROTOCOL_41 512
  310. /**
  311. This is an interactive client
  312. Use @ref System_variables::net_wait_timeout
  313. versus @ref System_variables::net_interactive_timeout.
  314. Server
  315. ------
  316. Supports interactive and noninteractive clients.
  317. Client
  318. ------
  319. Client is interactive.
  320. @sa mysql_real_connect()
  321. */
  322. #define CLIENT_INTERACTIVE 1024
  323. /**
  324. Use SSL encryption for the session
  325. @todo Reference SSL
  326. Server
  327. ------
  328. Supports SSL
  329. Client
  330. ------
  331. Switch to SSL after sending the capability-flags.
  332. */
  333. #define CLIENT_SSL 2048
  334. /**
  335. Client only flag. Not used.
  336. Client
  337. ------
  338. Do not issue SIGPIPE if network failures occur (libmysqlclient only).
  339. @sa mysql_real_connect()
  340. */
  341. #define CLIENT_IGNORE_SIGPIPE 4096
  342. /**
  343. Client knows about transactions
  344. Server
  345. ------
  346. Can send status flags in @ref page_protocol_basic_ok_packet /
  347. @ref page_protocol_basic_eof_packet.
  348. Client
  349. ------
  350. Expects status flags in @ref page_protocol_basic_ok_packet /
  351. @ref page_protocol_basic_eof_packet.
  352. @note This flag is optional in 3.23, but always set by the server since 4.0.
  353. @sa send_server_handshake_packet(), parse_client_handshake_packet(),
  354. net_send_ok(), net_send_eof()
  355. */
  356. #define CLIENT_TRANSACTIONS 8192
  357. #define CLIENT_RESERVED 16384 /**< DEPRECATED: Old flag for 4.1 protocol */
  358. #define CLIENT_RESERVED2 \
  359. 32768 /**< DEPRECATED: Old flag for 4.1 authentication \
  360. CLIENT_SECURE_CONNECTION */
  361. /**
  362. Enable/disable multi-stmt support
  363. Also sets @ref CLIENT_MULTI_RESULTS. Currently not checked anywhere.
  364. Server
  365. ------
  366. Can handle multiple statements per COM_QUERY and COM_STMT_PREPARE.
  367. Client
  368. -------
  369. May send multiple statements per COM_QUERY and COM_STMT_PREPARE.
  370. @note Was named ::CLIENT_MULTI_QUERIES in 4.1.0, renamed later.
  371. Requires
  372. --------
  373. ::CLIENT_PROTOCOL_41
  374. @todo Reference COM_QUERY and COM_STMT_PREPARE
  375. */
  376. #define CLIENT_MULTI_STATEMENTS (1UL << 16)
  377. /**
  378. Enable/disable multi-results
  379. Server
  380. ------
  381. Can send multiple resultsets for COM_QUERY.
  382. Error if the server needs to send them and client
  383. does not support them.
  384. Client
  385. -------
  386. Can handle multiple resultsets for COM_QUERY.
  387. Requires
  388. --------
  389. ::CLIENT_PROTOCOL_41
  390. @sa mysql_execute_command(), sp_head::MULTI_RESULTS
  391. */
  392. #define CLIENT_MULTI_RESULTS (1UL << 17)
  393. /**
  394. Multi-results and OUT parameters in PS-protocol.
  395. Server
  396. ------
  397. Can send multiple resultsets for COM_STMT_EXECUTE.
  398. Client
  399. ------
  400. Can handle multiple resultsets for COM_STMT_EXECUTE.
  401. Requires
  402. --------
  403. ::CLIENT_PROTOCOL_41
  404. @todo Reference COM_STMT_EXECUTE and PS-protocol
  405. @sa Protocol_binary::send_out_parameters
  406. */
  407. #define CLIENT_PS_MULTI_RESULTS (1UL << 18)
  408. /**
  409. Client supports plugin authentication
  410. Server
  411. ------
  412. Sends extra data in Initial Handshake Packet and supports the pluggable
  413. authentication protocol.
  414. Client
  415. ------
  416. Supports authentication plugins.
  417. Requires
  418. --------
  419. ::CLIENT_PROTOCOL_41
  420. @todo Reference plugin authentication, Initial Handshake Packet,
  421. Authentication plugins
  422. @sa send_change_user_packet(), send_client_reply_packet(), run_plugin_auth(),
  423. parse_com_change_user_packet(), parse_client_handshake_packet()
  424. */
  425. #define CLIENT_PLUGIN_AUTH (1UL << 19)
  426. /**
  427. Client supports connection attributes
  428. Server
  429. ------
  430. Permits connection attributes in Protocol::HandshakeResponse41.
  431. Client
  432. ------
  433. Sends connection attributes in Protocol::HandshakeResponse41.
  434. @todo Reference Protocol::HandshakeResponse41
  435. @sa send_client_connect_attrs(), read_client_connect_attrs()
  436. */
  437. #define CLIENT_CONNECT_ATTRS (1UL << 20)
  438. /**
  439. Enable authentication response packet to be larger than 255 bytes.
  440. When the ability to change default plugin require that the initial password
  441. field in the Protocol::HandshakeResponse41 paclet can be of arbitrary size.
  442. However, the 4.1 client-server protocol limits the length of the
  443. auth-data-field sent from client to server to 255 bytes.
  444. The solution is to change the type of the field to a true length encoded
  445. string and indicate the protocol change
  446. with this client capability flag.
  447. Server
  448. ------
  449. Understands length-encoded integer for auth response data in
  450. Protocol::HandshakeResponse41.
  451. Client
  452. ------
  453. Length of auth response data in Protocol::HandshakeResponse41
  454. is a length-encoded integer.
  455. @todo Reference Protocol::HandshakeResponse41
  456. @note The flag was introduced in 5.6.6, but had the wrong value.
  457. @sa send_client_reply_packet(), parse_client_handshake_packet(),
  458. get_56_lenc_string(), get_41_lenc_string()
  459. */
  460. #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21)
  461. /**
  462. Don't close the connection for a user account with expired password.
  463. Server
  464. ------
  465. Announces support for expired password extension.
  466. Client
  467. ------
  468. Can handle expired passwords.
  469. @todo Reference expired password
  470. @sa MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, disconnect_on_expired_password
  471. ACL_USER::password_expired, check_password_lifetime(), acl_authenticate()
  472. */
  473. #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22)
  474. /**
  475. Capable of handling server state change information. Its a hint to the
  476. server to include the state change information in
  477. @ref page_protocol_basic_ok_packet.
  478. Server
  479. ------
  480. Can set ::SERVER_SESSION_STATE_CHANGED in the ::SERVER_STATUS_flags_enum
  481. and send @ref sect_protocol_basic_ok_packet_sessinfo in a
  482. @ref page_protocol_basic_ok_packet.
  483. Client
  484. ------
  485. Expects the server to send @ref sect_protocol_basic_ok_packet_sessinfo in
  486. a @ref page_protocol_basic_ok_packet.
  487. @sa enum_session_state_type, read_ok_ex(), net_send_ok(), Session_tracker,
  488. State_tracker
  489. */
  490. #define CLIENT_SESSION_TRACK (1UL << 23)
  491. /**
  492. Client no longer needs @ref page_protocol_basic_eof_packet and will
  493. use @ref page_protocol_basic_ok_packet instead.
  494. @sa net_send_ok()
  495. Server
  496. ------
  497. Can send OK after a Text Resultset.
  498. Client
  499. ------
  500. Expects an @ref page_protocol_basic_ok_packet (instead of
  501. @ref page_protocol_basic_eof_packet) after the resultset rows of a
  502. Text Resultset.
  503. Background
  504. ----------
  505. To support ::CLIENT_SESSION_TRACK, additional information must be sent after
  506. all successful commands. Although the @ref page_protocol_basic_ok_packet is
  507. extensible, the @ref page_protocol_basic_eof_packet is not due to the overlap
  508. of its bytes with the content of the Text Resultset Row.
  509. Therefore, the @ref page_protocol_basic_eof_packet in the
  510. Text Resultset is replaced with an @ref page_protocol_basic_ok_packet.
  511. @ref page_protocol_basic_eof_packet is deprecated as of MySQL 5.7.5.
  512. @todo Reference Text Resultset
  513. @sa cli_safe_read_with_ok(), read_ok_ex(), net_send_ok(), net_send_eof()
  514. */
  515. #define CLIENT_DEPRECATE_EOF (1UL << 24)
  516. /**
  517. The client can handle optional metadata information in the resultset.
  518. */
  519. #define CLIENT_OPTIONAL_RESULTSET_METADATA (1UL << 25)
  520. /**
  521. Compression protocol extended to support zstd compression method
  522. This capability flag is used to send zstd compression level between
  523. client and server provided both client and server are enabled with
  524. this flag.
  525. Server
  526. ------
  527. Server sets this flag when global variable protocol-compression-algorithms
  528. has zstd in its list of supported values.
  529. Client
  530. ------
  531. Client sets this flag when it is configured to use zstd compression method.
  532. */
  533. #define CLIENT_ZSTD_COMPRESSION_ALGORITHM (1UL << 26)
  534. /**
  535. Support optional extension for query parameters into the @ref
  536. page_protocol_com_query and @ref page_protocol_com_stmt_execute packets.
  537. Server
  538. ------
  539. Expects an optional part containing the query parameter set(s). Executes the
  540. query for each set of parameters or returns an error if more than 1 set of
  541. parameters is sent and the server can't execute it.
  542. Client
  543. ------
  544. Can send the optional part containing the query parameter set(s).
  545. */
  546. #define CLIENT_QUERY_ATTRIBUTES (1UL << 27)
  547. /**
  548. Support Multi factor authentication.
  549. Server
  550. ------
  551. Server sends AuthNextFactor packet after every nth factor authentication
  552. method succeeds, except the last factor authentication.
  553. Client
  554. ------
  555. Client reads AuthNextFactor packet sent by server and initiates next factor
  556. authentication method.
  557. */
  558. #define MULTI_FACTOR_AUTHENTICATION (1UL << 28)
  559. /**
  560. This flag will be reserved to extend the 32bit capabilities structure to
  561. 64bits.
  562. */
  563. #define CLIENT_CAPABILITY_EXTENSION (1UL << 29)
  564. /**
  565. Verify server certificate.
  566. Client only flag.
  567. @deprecated in favor of --ssl-mode.
  568. */
  569. #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
  570. /**
  571. Don't reset the options after an unsuccessful connect
  572. Client only flag.
  573. Typically passed via ::mysql_real_connect() 's client_flag parameter.
  574. @sa mysql_real_connect()
  575. */
  576. #define CLIENT_REMEMBER_OPTIONS (1UL << 31)
  577. /** @}*/
  578. /** a compatibility alias for CLIENT_COMPRESS */
  579. #define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
  580. /** Gather all possible capabilites (flags) supported by the server */
  581. #define CLIENT_ALL_FLAGS \
  582. (CLIENT_LONG_PASSWORD | CLIENT_FOUND_ROWS | CLIENT_LONG_FLAG | \
  583. CLIENT_CONNECT_WITH_DB | CLIENT_NO_SCHEMA | CLIENT_COMPRESS | CLIENT_ODBC | \
  584. CLIENT_LOCAL_FILES | CLIENT_IGNORE_SPACE | CLIENT_PROTOCOL_41 | \
  585. CLIENT_INTERACTIVE | CLIENT_SSL | CLIENT_IGNORE_SIGPIPE | \
  586. CLIENT_TRANSACTIONS | CLIENT_RESERVED | CLIENT_RESERVED2 | \
  587. CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS | CLIENT_PS_MULTI_RESULTS | \
  588. CLIENT_SSL_VERIFY_SERVER_CERT | CLIENT_REMEMBER_OPTIONS | \
  589. CLIENT_PLUGIN_AUTH | CLIENT_CONNECT_ATTRS | \
  590. CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \
  591. CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS | CLIENT_SESSION_TRACK | \
  592. CLIENT_DEPRECATE_EOF | CLIENT_OPTIONAL_RESULTSET_METADATA | \
  593. CLIENT_ZSTD_COMPRESSION_ALGORITHM | CLIENT_QUERY_ATTRIBUTES | \
  594. MULTI_FACTOR_AUTHENTICATION)
  595. /**
  596. Switch off from ::CLIENT_ALL_FLAGS the flags that are optional and
  597. depending on build flags.
  598. If any of the optional flags is supported by the build it will be switched
  599. on before sending to the client during the connection handshake.
  600. */
  601. #define CLIENT_BASIC_FLAGS \
  602. (CLIENT_ALL_FLAGS & \
  603. ~(CLIENT_SSL | CLIENT_COMPRESS | CLIENT_SSL_VERIFY_SERVER_CERT | \
  604. CLIENT_ZSTD_COMPRESSION_ALGORITHM))
  605. /** The status flags are a bit-field */
  606. enum SERVER_STATUS_flags_enum {
  607. /**
  608. Is raised when a multi-statement transaction
  609. has been started, either explicitly, by means
  610. of BEGIN or COMMIT AND CHAIN, or
  611. implicitly, by the first transactional
  612. statement, when autocommit=off.
  613. */
  614. SERVER_STATUS_IN_TRANS = 1,
  615. SERVER_STATUS_AUTOCOMMIT = 2, /**< Server in auto_commit mode */
  616. SERVER_MORE_RESULTS_EXISTS = 8, /**< Multi query - next query exists */
  617. SERVER_QUERY_NO_GOOD_INDEX_USED = 16,
  618. SERVER_QUERY_NO_INDEX_USED = 32,
  619. /**
  620. The server was able to fulfill the clients request and opened a
  621. read-only non-scrollable cursor for a query. This flag comes
  622. in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
  623. Used by Binary Protocol Resultset to signal that COM_STMT_FETCH
  624. must be used to fetch the row-data.
  625. @todo Refify "Binary Protocol Resultset" and "COM_STMT_FETCH".
  626. */
  627. SERVER_STATUS_CURSOR_EXISTS = 64,
  628. /**
  629. This flag is sent when a read-only cursor is exhausted, in reply to
  630. COM_STMT_FETCH command.
  631. */
  632. SERVER_STATUS_LAST_ROW_SENT = 128,
  633. SERVER_STATUS_DB_DROPPED = 256, /**< A database was dropped */
  634. SERVER_STATUS_NO_BACKSLASH_ESCAPES = 512,
  635. /**
  636. Sent to the client if after a prepared statement reprepare
  637. we discovered that the new statement returns a different
  638. number of result set columns.
  639. */
  640. SERVER_STATUS_METADATA_CHANGED = 1024,
  641. SERVER_QUERY_WAS_SLOW = 2048,
  642. /**
  643. To mark ResultSet containing output parameter values.
  644. */
  645. SERVER_PS_OUT_PARAMS = 4096,
  646. /**
  647. Set at the same time as SERVER_STATUS_IN_TRANS if the started
  648. multi-statement transaction is a read-only transaction. Cleared
  649. when the transaction commits or aborts. Since this flag is sent
  650. to clients in OK and EOF packets, the flag indicates the
  651. transaction status at the end of command execution.
  652. */
  653. SERVER_STATUS_IN_TRANS_READONLY = 8192,
  654. /**
  655. This status flag, when on, implies that one of the state information has
  656. changed on the server because of the execution of the last statement.
  657. */
  658. SERVER_SESSION_STATE_CHANGED = (1UL << 14)
  659. };
  660. /**
  661. Server status flags that must be cleared when starting
  662. execution of a new SQL statement.
  663. Flags from this set are only added to the
  664. current server status by the execution engine, but
  665. never removed -- the execution engine expects them
  666. to disappear automagically by the next command.
  667. */
  668. #define SERVER_STATUS_CLEAR_SET \
  669. (SERVER_QUERY_NO_GOOD_INDEX_USED | SERVER_QUERY_NO_INDEX_USED | \
  670. SERVER_MORE_RESULTS_EXISTS | SERVER_STATUS_METADATA_CHANGED | \
  671. SERVER_QUERY_WAS_SLOW | SERVER_STATUS_DB_DROPPED | \
  672. SERVER_STATUS_CURSOR_EXISTS | SERVER_STATUS_LAST_ROW_SENT | \
  673. SERVER_SESSION_STATE_CHANGED)
  674. /** Max length of a error message. Should be kept in sync with ::ERRMSGSIZE. */
  675. #define MYSQL_ERRMSG_SIZE 512
  676. #define NET_READ_TIMEOUT 30 /**< Timeout on read */
  677. #define NET_WRITE_TIMEOUT 60 /**< Timeout on write */
  678. #define NET_WAIT_TIMEOUT 8 * 60 * 60 /**< Wait for new query */
  679. /**
  680. Flag used by the parser. Kill only the query and not the connection.
  681. @sa SQLCOM_KILL, sql_kill(), LEX::type
  682. */
  683. #define ONLY_KILL_QUERY 1
  684. #ifndef MYSQL_VIO
  685. struct Vio;
  686. #define MYSQL_VIO struct Vio *
  687. #endif
  688. #define MAX_TINYINT_WIDTH 3 /**< Max width for a TINY w.o. sign */
  689. #define MAX_SMALLINT_WIDTH 5 /**< Max width for a SHORT w.o. sign */
  690. #define MAX_MEDIUMINT_WIDTH 8 /**< Max width for a INT24 w.o. sign */
  691. #define MAX_INT_WIDTH 10 /**< Max width for a LONG w.o. sign */
  692. #define MAX_BIGINT_WIDTH 20 /**< Max width for a LONGLONG */
  693. /// Max width for a CHAR column, in number of characters
  694. #define MAX_CHAR_WIDTH 255
  695. /// Default width for blob in bytes @todo - align this with sizes from field.h
  696. #define MAX_BLOB_WIDTH 16777216
  697. #define NET_ERROR_UNSET 0 /**< No error has occurred yet */
  698. #define NET_ERROR_SOCKET_RECOVERABLE 1 /**< Socket still usable */
  699. #define NET_ERROR_SOCKET_UNUSABLE 2 /**< Do not use the socket */
  700. #define NET_ERROR_SOCKET_NOT_READABLE 3 /**< Try write and close socket */
  701. #define NET_ERROR_SOCKET_NOT_WRITABLE 4 /**< Try read and close socket */
  702. typedef struct NET {
  703. MYSQL_VIO vio;
  704. unsigned char *buff, *buff_end, *write_pos, *read_pos;
  705. my_socket fd; /* For Perl DBI/dbd */
  706. /**
  707. Set if we are doing several queries in one
  708. command ( as in LOAD TABLE ... FROM MASTER ),
  709. and do not want to confuse the client with OK at the wrong time
  710. */
  711. unsigned long remain_in_buf, length, buf_length, where_b;
  712. unsigned long max_packet, max_packet_size;
  713. unsigned int pkt_nr, compress_pkt_nr;
  714. unsigned int write_timeout, read_timeout, retry_count;
  715. int fcntl;
  716. unsigned int *return_status;
  717. unsigned char reading_or_writing;
  718. unsigned char save_char;
  719. bool compress;
  720. unsigned int last_errno;
  721. unsigned char error;
  722. /** Client library error message buffer. Actually belongs to struct MYSQL. */
  723. char last_error[MYSQL_ERRMSG_SIZE];
  724. /** Client library sqlstate buffer. Set along with the error message. */
  725. char sqlstate[SQLSTATE_LENGTH + 1];
  726. /**
  727. Extension pointer, for the caller private use.
  728. Any program linking with the networking library can use this pointer,
  729. which is handy when private connection specific data needs to be
  730. maintained.
  731. The mysqld server process uses this pointer internally,
  732. to maintain the server internal instrumentation for the connection.
  733. */
  734. void *extension;
  735. } NET;
  736. #define packet_error (~(unsigned long)0)
  737. /**
  738. @addtogroup group_cs_backward_compatibility Backward compatibility
  739. @ingroup group_cs
  740. @{
  741. */
  742. #define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
  743. #define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL
  744. #define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
  745. #define FIELD_TYPE_TINY MYSQL_TYPE_TINY
  746. #define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
  747. #define FIELD_TYPE_LONG MYSQL_TYPE_LONG
  748. #define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT
  749. #define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
  750. #define FIELD_TYPE_NULL MYSQL_TYPE_NULL
  751. #define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
  752. #define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
  753. #define FIELD_TYPE_INT24 MYSQL_TYPE_INT24
  754. #define FIELD_TYPE_DATE MYSQL_TYPE_DATE
  755. #define FIELD_TYPE_TIME MYSQL_TYPE_TIME
  756. #define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
  757. #define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
  758. #define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
  759. #define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
  760. #define FIELD_TYPE_SET MYSQL_TYPE_SET
  761. #define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
  762. #define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
  763. #define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
  764. #define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
  765. #define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
  766. #define FIELD_TYPE_STRING MYSQL_TYPE_STRING
  767. #define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
  768. #define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
  769. #define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY
  770. #define FIELD_TYPE_BIT MYSQL_TYPE_BIT
  771. /** @}*/
  772. /**
  773. @addtogroup group_cs_shutdown_kill_constants Shutdown/kill enums and constants
  774. @ingroup group_cs
  775. @sa THD::is_killable
  776. @{
  777. */
  778. #define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
  779. #define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
  780. #define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
  781. #define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
  782. /**
  783. We want levels to be in growing order of hardness (because we use number
  784. comparisons).
  785. @note ::SHUTDOWN_DEFAULT does not respect the growing property, but it's ok.
  786. */
  787. enum mysql_enum_shutdown_level {
  788. SHUTDOWN_DEFAULT = 0,
  789. /** Wait for existing connections to finish */
  790. SHUTDOWN_WAIT_CONNECTIONS = MYSQL_SHUTDOWN_KILLABLE_CONNECT,
  791. /** Wait for existing transactons to finish */
  792. SHUTDOWN_WAIT_TRANSACTIONS = MYSQL_SHUTDOWN_KILLABLE_TRANS,
  793. /** Wait for existing updates to finish (=> no partial MyISAM update) */
  794. SHUTDOWN_WAIT_UPDATES = MYSQL_SHUTDOWN_KILLABLE_UPDATE,
  795. /** Flush InnoDB buffers and other storage engines' buffers*/
  796. SHUTDOWN_WAIT_ALL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
  797. /** Don't flush InnoDB buffers, flush other storage engines' buffers*/
  798. SHUTDOWN_WAIT_CRITICAL_BUFFERS = (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
  799. /** Query level of the KILL command */
  800. KILL_QUERY = 254,
  801. /** Connection level of the KILL command */
  802. KILL_CONNECTION = 255
  803. };
  804. /** @}*/
  805. enum enum_resultset_metadata {
  806. /** No metadata will be sent. */
  807. RESULTSET_METADATA_NONE = 0,
  808. /** The server will send all metadata. */
  809. RESULTSET_METADATA_FULL = 1
  810. };
  811. #if defined(__clang__)
  812. // disable -Wdocumentation to workaround
  813. // https://bugs.llvm.org/show_bug.cgi?id=38905
  814. #pragma clang diagnostic push
  815. #pragma clang diagnostic ignored "-Wdocumentation"
  816. #endif
  817. /**
  818. The flags used in COM_STMT_EXECUTE.
  819. @sa @ref Protocol_classic::parse_packet, @ref mysql_int_serialize_param_data
  820. */
  821. #if defined(__clang__)
  822. #pragma clang diagnostic pop
  823. #endif
  824. enum enum_cursor_type {
  825. CURSOR_TYPE_NO_CURSOR = 0,
  826. CURSOR_TYPE_READ_ONLY = 1,
  827. CURSOR_TYPE_FOR_UPDATE = 2,
  828. CURSOR_TYPE_SCROLLABLE = 4,
  829. /**
  830. On when the client will send the parameter count
  831. even for 0 parameters.
  832. */
  833. PARAMETER_COUNT_AVAILABLE = 8
  834. };
  835. /** options for ::mysql_options() */
  836. enum enum_mysql_set_option {
  837. MYSQL_OPTION_MULTI_STATEMENTS_ON,
  838. MYSQL_OPTION_MULTI_STATEMENTS_OFF
  839. };
  840. /**
  841. Type of state change information that the server can include in the Ok
  842. packet.
  843. @note
  844. - session_state_type shouldn't go past 255 (i.e. 1-byte boundary).
  845. - Modify the definition of ::SESSION_TRACK_END when a new member is added.
  846. */
  847. enum enum_session_state_type {
  848. SESSION_TRACK_SYSTEM_VARIABLES, /**< Session system variables */
  849. SESSION_TRACK_SCHEMA, /**< Current schema */
  850. SESSION_TRACK_STATE_CHANGE, /**< track session state changes */
  851. SESSION_TRACK_GTIDS, /**< See also: session_track_gtids */
  852. SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /**< Transaction chistics */
  853. SESSION_TRACK_TRANSACTION_STATE /**< Transaction state */
  854. };
  855. /** start of ::enum_session_state_type */
  856. #define SESSION_TRACK_BEGIN SESSION_TRACK_SYSTEM_VARIABLES
  857. /** End of ::enum_session_state_type */
  858. #define SESSION_TRACK_END SESSION_TRACK_TRANSACTION_STATE
  859. /** is T a valid session state type */
  860. #define IS_SESSION_STATE_TYPE(T) \
  861. (((int)(T) >= SESSION_TRACK_BEGIN) && ((T) <= SESSION_TRACK_END))
  862. #define net_new_transaction(net) ((net)->pkt_nr = 0)
  863. bool my_net_init(struct NET *net, MYSQL_VIO vio);
  864. void my_net_local_init(struct NET *net);
  865. void net_end(struct NET *net);
  866. void net_clear(struct NET *net, bool check_buffer);
  867. void net_claim_memory_ownership(struct NET *net, bool claim);
  868. bool net_realloc(struct NET *net, size_t length);
  869. bool net_flush(struct NET *net);
  870. bool my_net_write(struct NET *net, const unsigned char *packet, size_t len);
  871. bool net_write_command(struct NET *net, unsigned char command,
  872. const unsigned char *header, size_t head_len,
  873. const unsigned char *packet, size_t len);
  874. bool net_write_packet(struct NET *net, const unsigned char *packet,
  875. size_t length);
  876. unsigned long my_net_read(struct NET *net);
  877. void my_net_set_write_timeout(struct NET *net, unsigned int timeout);
  878. void my_net_set_read_timeout(struct NET *net, unsigned int timeout);
  879. void my_net_set_retry_count(struct NET *net, unsigned int retry_count);
  880. struct rand_struct {
  881. unsigned long seed1, seed2, max_value;
  882. double max_value_dbl;
  883. };
  884. /* Include the types here so existing UDFs can keep compiling */
  885. #include "mysql/udf_registration_types.h"
  886. /**
  887. @addtogroup group_cs_compresson_constants Constants when using compression
  888. @ingroup group_cs
  889. @{
  890. */
  891. #define NET_HEADER_SIZE 4 /**< standard header size */
  892. #define COMP_HEADER_SIZE 3 /**< compression header extra size */
  893. /** @}*/
  894. /* Prototypes to password functions */
  895. /*
  896. These functions are used for authentication by client and server and
  897. implemented in sql/password.c
  898. */
  899. void randominit(struct rand_struct *, unsigned long seed1, unsigned long seed2);
  900. double my_rnd(struct rand_struct *);
  901. void create_random_string(char *to, unsigned int length,
  902. struct rand_struct *rand_st);
  903. void hash_password(unsigned long *to, const char *password,
  904. unsigned int password_len);
  905. void make_scrambled_password_323(char *to, const char *password);
  906. void scramble_323(char *to, const char *message, const char *password);
  907. bool check_scramble_323(const unsigned char *reply, const char *message,
  908. unsigned long *salt);
  909. void get_salt_from_password_323(unsigned long *res, const char *password);
  910. void make_password_from_salt_323(char *to, const unsigned long *salt);
  911. void make_scrambled_password(char *to, const char *password);
  912. void scramble(char *to, const char *message, const char *password);
  913. bool check_scramble(const unsigned char *reply, const char *message,
  914. const unsigned char *hash_stage2);
  915. void get_salt_from_password(unsigned char *res, const char *password);
  916. void make_password_from_salt(char *to, const unsigned char *hash_stage2);
  917. char *octet2hex(char *to, const char *str, unsigned int len);
  918. /* end of password.c */
  919. bool generate_sha256_scramble(unsigned char *dst, size_t dst_size,
  920. const char *src, size_t src_size, const char *rnd,
  921. size_t rnd_size);
  922. // extern "C" since it is an (undocumented) part of the libmysql ABI.
  923. #ifdef __cplusplus
  924. extern "C" {
  925. #endif
  926. char *get_tty_password(const char *opt_message);
  927. #ifdef __cplusplus
  928. }
  929. #endif
  930. const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
  931. /* Some other useful functions */
  932. // Need to be extern "C" for the time being, due to memcached.
  933. #ifdef __cplusplus
  934. extern "C" {
  935. #endif
  936. bool my_thread_init(void);
  937. void my_thread_end(void);
  938. #ifdef __cplusplus
  939. }
  940. #endif
  941. #ifdef STDCALL
  942. unsigned long STDCALL net_field_length(unsigned char **packet);
  943. unsigned long STDCALL net_field_length_checked(unsigned char **packet,
  944. unsigned long max_length);
  945. #endif
  946. uint64_t net_field_length_ll(unsigned char **packet);
  947. unsigned char *net_store_length(unsigned char *pkg, unsigned long long length);
  948. unsigned int net_length_size(unsigned long long num);
  949. unsigned int net_field_length_size(const unsigned char *pos);
  950. #define NULL_LENGTH ((unsigned long)~0) /**< For ::net_store_length() */
  951. #define MYSQL_STMT_HEADER 4
  952. #define MYSQL_LONG_DATA_HEADER 6
  953. #endif