1 | /* Copyright (c) 2000, 2019, 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, version 2.0, |
5 | as published by the Free Software Foundation. |
6 | |
7 | This program is also distributed with certain software (including |
8 | but not limited to OpenSSL) that is licensed under separate terms, |
9 | as designated in a particular file or component or in included license |
10 | documentation. The authors of MySQL hereby grant you an additional |
11 | permission to link the program and your derivative works with the |
12 | separately licensed software that they have included with MySQL. |
13 | |
14 | Without limiting anything contained in the foregoing, this file, |
15 | which is part of C Driver for MySQL (Connector/C), is also subject to the |
16 | Universal FOSS Exception, version 1.0, a copy of which can be found at |
17 | http://oss.oracle.com/licenses/universal-foss-exception. |
18 | |
19 | This program is distributed in the hope that it will be useful, |
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | GNU General Public License, version 2.0, for more details. |
23 | |
24 | You should have received a copy of the GNU General Public License |
25 | along with this program; if not, write to the Free Software |
26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
27 | |
28 | /* |
29 | ** Common definition between mysql server & client |
30 | */ |
31 | |
32 | #ifndef _mysql_com_h |
33 | #define _mysql_com_h |
34 | #include "binary_log_types.h" |
35 | #include "my_command.h" |
36 | #define HOSTNAME_LENGTH 60 |
37 | #define SYSTEM_CHARSET_MBMAXLEN 3 |
38 | #define FILENAME_CHARSET_MBMAXLEN 5 |
39 | #define NAME_CHAR_LEN 64 /* Field/table name length */ |
40 | #define USERNAME_CHAR_LENGTH 32 |
41 | #define USERNAME_CHAR_LENGTH_STR "32" |
42 | #ifndef NAME_LEN |
43 | #define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN) |
44 | #endif |
45 | #define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN) |
46 | #define CONNECT_STRING_MAXLEN 1024 |
47 | |
48 | #define MYSQL_AUTODETECT_CHARSET_NAME "auto" |
49 | |
50 | #define SERVER_VERSION_LENGTH 60 |
51 | #define SQLSTATE_LENGTH 5 |
52 | |
53 | /* |
54 | Maximum length of comments |
55 | */ |
56 | #define 180 /* pre 6.0: 60 characters */ |
57 | #define 2048 |
58 | #define COLUMN_COMMENT_MAXLEN 1024 |
59 | #define 1024 |
60 | #define 1024 |
61 | |
62 | /* |
63 | Maximum length of protocol packet. |
64 | OK packet length limit also restricted to this value as any length greater |
65 | than this value will have first byte of OK packet to be 254 thus does not |
66 | provide a means to identify if this is OK or EOF packet. |
67 | */ |
68 | #define MAX_PACKET_LENGTH (256L*256L*256L-1) |
69 | |
70 | /* |
71 | USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain |
72 | username and hostname parts of the user identifier with trailing zero in |
73 | MySQL standard format: |
74 | user_name_part@host_name_part\0 |
75 | */ |
76 | #define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2 |
77 | |
78 | #define LOCAL_HOST "localhost" |
79 | #define LOCAL_HOST_NAMEDPIPE "." |
80 | |
81 | |
82 | #if defined(_WIN32) |
83 | #define MYSQL_NAMEDPIPE "MySQL" |
84 | #define MYSQL_SERVICENAME "MySQL" |
85 | #endif /* _WIN32 */ |
86 | |
87 | /* The length of the header part for each generated column in the .frm file. */ |
88 | #define 4 |
89 | /* |
90 | Maximum length of the expression statement defined for generated columns. |
91 | */ |
92 | #define GENERATED_COLUMN_EXPRESSION_MAXLEN 65535 - FRM_GCOL_HEADER_SIZE |
93 | /* |
94 | Length of random string sent by server on handshake; this is also length of |
95 | obfuscated password, received from client |
96 | */ |
97 | #define SCRAMBLE_LENGTH 20 |
98 | #define AUTH_PLUGIN_DATA_PART_1_LENGTH 8 |
99 | /* length of password stored in the db: new passwords are preceeded with '*' */ |
100 | #define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1) |
101 | |
102 | |
103 | #define NOT_NULL_FLAG 1 /* Field can't be NULL */ |
104 | #define PRI_KEY_FLAG 2 /* Field is part of a primary key */ |
105 | #define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */ |
106 | #define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */ |
107 | #define BLOB_FLAG 16 /* Field is a blob */ |
108 | #define UNSIGNED_FLAG 32 /* Field is unsigned */ |
109 | #define ZEROFILL_FLAG 64 /* Field is zerofill */ |
110 | #define BINARY_FLAG 128 /* Field is binary */ |
111 | |
112 | /* The following are only sent to new clients */ |
113 | #define ENUM_FLAG 256 /* field is an enum */ |
114 | #define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */ |
115 | #define TIMESTAMP_FLAG 1024 /* Field is a timestamp */ |
116 | #define SET_FLAG 2048 /* field is a set */ |
117 | #define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */ |
118 | #define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */ |
119 | #define NUM_FLAG 32768 /* Field is num (for clients) */ |
120 | #define PART_KEY_FLAG 16384 /* Intern; Part of some key */ |
121 | #define GROUP_FLAG 32768 /* Intern: Group field */ |
122 | #define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */ |
123 | #define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */ |
124 | #define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */ |
125 | #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */ |
126 | /** |
127 | Intern: Field in TABLE object for new version of altered table, |
128 | which participates in a newly added index. |
129 | */ |
130 | #define FIELD_IN_ADD_INDEX (1 << 20) |
131 | #define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */ |
132 | #define FIELD_FLAGS_STORAGE_MEDIA 22 /* Field storage media, bit 22-23 */ |
133 | #define FIELD_FLAGS_STORAGE_MEDIA_MASK (3 << FIELD_FLAGS_STORAGE_MEDIA) |
134 | #define FIELD_FLAGS_COLUMN_FORMAT 24 /* Field column format, bit 24-25 */ |
135 | #define FIELD_FLAGS_COLUMN_FORMAT_MASK (3 << FIELD_FLAGS_COLUMN_FORMAT) |
136 | #define FIELD_IS_DROPPED (1<< 26) /* Intern: Field is being dropped */ |
137 | #define EXPLICIT_NULL_FLAG (1<< 27) /* Field is explicitly specified as |
138 | NULL by the user */ |
139 | |
140 | #define REFRESH_GRANT 1 /* Refresh grant tables */ |
141 | #define REFRESH_LOG 2 /* Start on new log file */ |
142 | #define REFRESH_TABLES 4 /* close all tables */ |
143 | #define REFRESH_HOSTS 8 /* Flush host cache */ |
144 | #define REFRESH_STATUS 16 /* Flush status variables */ |
145 | #define REFRESH_THREADS 32 /* Flush thread cache */ |
146 | #define REFRESH_SLAVE 64 /* Reset master info and restart slave |
147 | thread */ |
148 | #define REFRESH_MASTER 128 /* Remove all bin logs in the index |
149 | and truncate the index */ |
150 | #define REFRESH_ERROR_LOG 256 /* Rotate only the erorr log */ |
151 | #define REFRESH_ENGINE_LOG 512 /* Flush all storage engine logs */ |
152 | #define REFRESH_BINARY_LOG 1024 /* Flush the binary log */ |
153 | #define REFRESH_RELAY_LOG 2048 /* Flush the relay log */ |
154 | #define REFRESH_GENERAL_LOG 4096 /* Flush the general log */ |
155 | #define REFRESH_SLOW_LOG 8192 /* Flush the slow query log */ |
156 | |
157 | /* The following can't be set with mysql_refresh() */ |
158 | #define REFRESH_READ_LOCK 16384 /* Lock tables for read */ |
159 | #define REFRESH_FAST 32768 /* Intern flag */ |
160 | |
161 | /* RESET (remove all queries) from query cache */ |
162 | #define REFRESH_QUERY_CACHE 65536 |
163 | #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */ |
164 | #define REFRESH_DES_KEY_FILE 0x40000L |
165 | #define REFRESH_USER_RESOURCES 0x80000L |
166 | #define REFRESH_FOR_EXPORT 0x100000L /* FLUSH TABLES ... FOR EXPORT */ |
167 | #define REFRESH_OPTIMIZER_COSTS 0x200000L /* FLUSH OPTIMIZER_COSTS */ |
168 | |
169 | #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */ |
170 | #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ |
171 | #define CLIENT_LONG_FLAG 4 /* Get all column flags */ |
172 | #define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */ |
173 | #define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */ |
174 | #define CLIENT_COMPRESS 32 /* Can use compression protocol */ |
175 | #define CLIENT_ODBC 64 /* Odbc client */ |
176 | #define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */ |
177 | #define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */ |
178 | #define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */ |
179 | #define CLIENT_INTERACTIVE 1024 /* This is an interactive client */ |
180 | #define CLIENT_SSL 2048 /* Switch to SSL after handshake */ |
181 | #define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */ |
182 | #define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ |
183 | #define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */ |
184 | #define CLIENT_RESERVED2 32768 /* Old flag for 4.1 authentication */ |
185 | #define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */ |
186 | #define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */ |
187 | #define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */ |
188 | |
189 | #define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */ |
190 | #define CLIENT_CONNECT_ATTRS (1UL << 20) /* Client supports connection attributes */ |
191 | |
192 | /* Enable authentication response packet to be larger than 255 bytes. */ |
193 | #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21) |
194 | |
195 | /* Don't close the connection for a connection with expired password. */ |
196 | #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) |
197 | |
198 | /** |
199 | Capable of handling server state change information. Its a hint to the |
200 | server to include the state change information in Ok packet. |
201 | */ |
202 | #define CLIENT_SESSION_TRACK (1UL << 23) |
203 | /* Client no longer needs EOF packet */ |
204 | #define CLIENT_DEPRECATE_EOF (1UL << 24) |
205 | |
206 | #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) |
207 | #define CLIENT_REMEMBER_OPTIONS (1UL << 31) |
208 | |
209 | #ifdef HAVE_COMPRESS |
210 | #define CAN_CLIENT_COMPRESS CLIENT_COMPRESS |
211 | #else |
212 | #define CAN_CLIENT_COMPRESS 0 |
213 | #endif |
214 | |
215 | /* Gather all possible capabilites (flags) supported by the server */ |
216 | #define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD \ |
217 | | CLIENT_FOUND_ROWS \ |
218 | | CLIENT_LONG_FLAG \ |
219 | | CLIENT_CONNECT_WITH_DB \ |
220 | | CLIENT_NO_SCHEMA \ |
221 | | CLIENT_COMPRESS \ |
222 | | CLIENT_ODBC \ |
223 | | CLIENT_LOCAL_FILES \ |
224 | | CLIENT_IGNORE_SPACE \ |
225 | | CLIENT_PROTOCOL_41 \ |
226 | | CLIENT_INTERACTIVE \ |
227 | | CLIENT_SSL \ |
228 | | CLIENT_IGNORE_SIGPIPE \ |
229 | | CLIENT_TRANSACTIONS \ |
230 | | CLIENT_RESERVED \ |
231 | | CLIENT_RESERVED2 \ |
232 | | CLIENT_MULTI_STATEMENTS \ |
233 | | CLIENT_MULTI_RESULTS \ |
234 | | CLIENT_PS_MULTI_RESULTS \ |
235 | | CLIENT_SSL_VERIFY_SERVER_CERT \ |
236 | | CLIENT_REMEMBER_OPTIONS \ |
237 | | CLIENT_PLUGIN_AUTH \ |
238 | | CLIENT_CONNECT_ATTRS \ |
239 | | CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA \ |
240 | | CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS \ |
241 | | CLIENT_SESSION_TRACK \ |
242 | | CLIENT_DEPRECATE_EOF \ |
243 | ) |
244 | |
245 | /* |
246 | Switch off the flags that are optional and depending on build flags |
247 | If any of the optional flags is supported by the build it will be switched |
248 | on before sending to the client during the connection handshake. |
249 | */ |
250 | #define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \ |
251 | & ~CLIENT_COMPRESS) \ |
252 | & ~CLIENT_SSL_VERIFY_SERVER_CERT) |
253 | |
254 | /** |
255 | Is raised when a multi-statement transaction |
256 | has been started, either explicitly, by means |
257 | of BEGIN or COMMIT AND CHAIN, or |
258 | implicitly, by the first transactional |
259 | statement, when autocommit=off. |
260 | */ |
261 | #define SERVER_STATUS_IN_TRANS 1 |
262 | #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ |
263 | #define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */ |
264 | #define SERVER_QUERY_NO_GOOD_INDEX_USED 16 |
265 | #define SERVER_QUERY_NO_INDEX_USED 32 |
266 | /** |
267 | The server was able to fulfill the clients request and opened a |
268 | read-only non-scrollable cursor for a query. This flag comes |
269 | in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. |
270 | */ |
271 | #define SERVER_STATUS_CURSOR_EXISTS 64 |
272 | /** |
273 | This flag is sent when a read-only cursor is exhausted, in reply to |
274 | COM_STMT_FETCH command. |
275 | */ |
276 | #define SERVER_STATUS_LAST_ROW_SENT 128 |
277 | #define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */ |
278 | #define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512 |
279 | /** |
280 | Sent to the client if after a prepared statement reprepare |
281 | we discovered that the new statement returns a different |
282 | number of result set columns. |
283 | */ |
284 | #define SERVER_STATUS_METADATA_CHANGED 1024 |
285 | #define SERVER_QUERY_WAS_SLOW 2048 |
286 | |
287 | /** |
288 | To mark ResultSet containing output parameter values. |
289 | */ |
290 | #define SERVER_PS_OUT_PARAMS 4096 |
291 | |
292 | /** |
293 | Set at the same time as SERVER_STATUS_IN_TRANS if the started |
294 | multi-statement transaction is a read-only transaction. Cleared |
295 | when the transaction commits or aborts. Since this flag is sent |
296 | to clients in OK and EOF packets, the flag indicates the |
297 | transaction status at the end of command execution. |
298 | */ |
299 | #define SERVER_STATUS_IN_TRANS_READONLY 8192 |
300 | |
301 | /** |
302 | This status flag, when on, implies that one of the state information has |
303 | changed on the server because of the execution of the last statement. |
304 | */ |
305 | #define SERVER_SESSION_STATE_CHANGED (1UL << 14) |
306 | |
307 | /** |
308 | Server status flags that must be cleared when starting |
309 | execution of a new SQL statement. |
310 | Flags from this set are only added to the |
311 | current server status by the execution engine, but |
312 | never removed -- the execution engine expects them |
313 | to disappear automagically by the next command. |
314 | */ |
315 | #define SERVER_STATUS_CLEAR_SET (SERVER_QUERY_NO_GOOD_INDEX_USED| \ |
316 | SERVER_QUERY_NO_INDEX_USED|\ |
317 | SERVER_MORE_RESULTS_EXISTS|\ |
318 | SERVER_STATUS_METADATA_CHANGED |\ |
319 | SERVER_QUERY_WAS_SLOW |\ |
320 | SERVER_STATUS_DB_DROPPED |\ |
321 | SERVER_STATUS_CURSOR_EXISTS|\ |
322 | SERVER_STATUS_LAST_ROW_SENT|\ |
323 | SERVER_SESSION_STATE_CHANGED) |
324 | |
325 | #define MYSQL_ERRMSG_SIZE 512 |
326 | #define NET_READ_TIMEOUT 30 /* Timeout on read */ |
327 | #define NET_WRITE_TIMEOUT 60 /* Timeout on write */ |
328 | #define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */ |
329 | |
330 | #define ONLY_KILL_QUERY 1 |
331 | |
332 | |
333 | struct st_vio; /* Only C */ |
334 | typedef struct st_vio Vio; |
335 | |
336 | #define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */ |
337 | #define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */ |
338 | #define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */ |
339 | #define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */ |
340 | #define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */ |
341 | #define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */ |
342 | #define MAX_BLOB_WIDTH 16777216 /* Default width for blob */ |
343 | |
344 | typedef struct st_net { |
345 | Vio *vio; |
346 | unsigned char *buff,*buff_end,*write_pos,*read_pos; |
347 | my_socket fd; /* For Perl DBI/dbd */ |
348 | /* |
349 | The following variable is set if we are doing several queries in one |
350 | command ( as in LOAD TABLE ... FROM MASTER ), |
351 | and do not want to confuse the client with OK at the wrong time |
352 | */ |
353 | unsigned long remain_in_buf,length, buf_length, where_b; |
354 | unsigned long max_packet,max_packet_size; |
355 | unsigned int pkt_nr,compress_pkt_nr; |
356 | unsigned int write_timeout, read_timeout, retry_count; |
357 | int fcntl; |
358 | unsigned int *return_status; |
359 | unsigned char reading_or_writing; |
360 | char save_char; |
361 | my_bool unused1; /* Please remove with the next incompatible ABI change */ |
362 | my_bool unused2; /* Please remove with the next incompatible ABI change */ |
363 | my_bool compress; |
364 | my_bool unused3; /* Please remove with the next incompatible ABI change. */ |
365 | /* |
366 | Pointer to query object in query cache, do not equal NULL (0) for |
367 | queries in cache that have not stored its results yet |
368 | */ |
369 | /* |
370 | Unused, please remove with the next incompatible ABI change. |
371 | */ |
372 | unsigned char *unused; |
373 | unsigned int last_errno; |
374 | unsigned char error; |
375 | my_bool unused4; /* Please remove with the next incompatible ABI change. */ |
376 | my_bool unused5; /* Please remove with the next incompatible ABI change. */ |
377 | /** Client library error message buffer. Actually belongs to struct MYSQL. */ |
378 | char last_error[MYSQL_ERRMSG_SIZE]; |
379 | /** Client library sqlstate buffer. Set along with the error message. */ |
380 | char sqlstate[SQLSTATE_LENGTH+1]; |
381 | /** |
382 | Extension pointer, for the caller private use. |
383 | Any program linking with the networking library can use this pointer, |
384 | which is handy when private connection specific data needs to be |
385 | maintained. |
386 | The mysqld server process uses this pointer internally, |
387 | to maintain the server internal instrumentation for the connection. |
388 | */ |
389 | void *extension; |
390 | } NET; |
391 | |
392 | |
393 | #define packet_error (~(unsigned long) 0) |
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 | KILL_QUERY= 254, |
453 | KILL_CONNECTION= 255 |
454 | }; |
455 | |
456 | |
457 | enum enum_cursor_type |
458 | { |
459 | CURSOR_TYPE_NO_CURSOR= 0, |
460 | CURSOR_TYPE_READ_ONLY= 1, |
461 | CURSOR_TYPE_FOR_UPDATE= 2, |
462 | CURSOR_TYPE_SCROLLABLE= 4 |
463 | }; |
464 | |
465 | |
466 | /* options for mysql_set_option */ |
467 | enum enum_mysql_set_option |
468 | { |
469 | MYSQL_OPTION_MULTI_STATEMENTS_ON, |
470 | MYSQL_OPTION_MULTI_STATEMENTS_OFF |
471 | }; |
472 | |
473 | /* |
474 | Type of state change information that the server can include in the Ok |
475 | packet. |
476 | Note : 1) session_state_type shouldn't go past 255 (i.e. 1-byte boundary). |
477 | 2) Modify the definition of SESSION_TRACK_END when a new member is |
478 | added. |
479 | */ |
480 | enum enum_session_state_type |
481 | { |
482 | SESSION_TRACK_SYSTEM_VARIABLES, /* Session system variables */ |
483 | SESSION_TRACK_SCHEMA, /* Current schema */ |
484 | SESSION_TRACK_STATE_CHANGE, /* track session state changes */ |
485 | SESSION_TRACK_GTIDS, |
486 | SESSION_TRACK_TRANSACTION_CHARACTERISTICS, /* Transaction chistics */ |
487 | SESSION_TRACK_TRANSACTION_STATE /* Transaction state */ |
488 | }; |
489 | |
490 | #define SESSION_TRACK_BEGIN SESSION_TRACK_SYSTEM_VARIABLES |
491 | |
492 | #define SESSION_TRACK_END SESSION_TRACK_TRANSACTION_STATE |
493 | |
494 | #define IS_SESSION_STATE_TYPE(T) \ |
495 | (((int)(T) >= SESSION_TRACK_BEGIN) && ((T) <= SESSION_TRACK_END)) |
496 | |
497 | #define net_new_transaction(net) ((net)->pkt_nr=0) |
498 | |
499 | #ifdef __cplusplus |
500 | extern "C" { |
501 | #endif |
502 | |
503 | my_bool my_net_init(NET *net, Vio* vio); |
504 | void my_net_local_init(NET *net); |
505 | void net_end(NET *net); |
506 | void net_clear(NET *net, my_bool check_buffer); |
507 | void net_claim_memory_ownership(NET *net); |
508 | my_bool net_realloc(NET *net, size_t length); |
509 | my_bool net_flush(NET *net); |
510 | my_bool my_net_write(NET *net,const unsigned char *packet, size_t len); |
511 | my_bool net_write_command(NET *net,unsigned char command, |
512 | const unsigned char *, size_t head_len, |
513 | const unsigned char *packet, size_t len); |
514 | my_bool net_write_packet(NET *net, const unsigned char *packet, size_t length); |
515 | unsigned long my_net_read(NET *net); |
516 | |
517 | #ifdef MY_GLOBAL_INCLUDED |
518 | void my_net_set_write_timeout(NET *net, uint timeout); |
519 | void my_net_set_read_timeout(NET *net, uint timeout); |
520 | #endif |
521 | |
522 | struct rand_struct { |
523 | unsigned long seed1,seed2,max_value; |
524 | double max_value_dbl; |
525 | }; |
526 | |
527 | #ifdef __cplusplus |
528 | } |
529 | #endif |
530 | |
531 | /* The following is for user defined functions */ |
532 | |
533 | enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, |
534 | DECIMAL_RESULT}; |
535 | |
536 | typedef struct st_udf_args |
537 | { |
538 | unsigned int arg_count; /* Number of arguments */ |
539 | enum Item_result *arg_type; /* Pointer to item_results */ |
540 | char **args; /* Pointer to argument */ |
541 | unsigned long *lengths; /* Length of string arguments */ |
542 | char *maybe_null; /* Set to 1 for all maybe_null args */ |
543 | char **attributes; /* Pointer to attribute name */ |
544 | unsigned long *attribute_lengths; /* Length of attribute arguments */ |
545 | void *extension; |
546 | } UDF_ARGS; |
547 | |
548 | /* This holds information about the result */ |
549 | |
550 | typedef struct st_udf_init |
551 | { |
552 | my_bool maybe_null; /* 1 if function can return NULL */ |
553 | unsigned int decimals; /* for real functions */ |
554 | unsigned long max_length; /* For string functions */ |
555 | char *ptr; /* free pointer for function data */ |
556 | my_bool const_item; /* 1 if function always returns the same value */ |
557 | void *extension; |
558 | } UDF_INIT; |
559 | /* |
560 | TODO: add a notion for determinism of the UDF. |
561 | See Item_udf_func::update_used_tables () |
562 | */ |
563 | |
564 | /* Constants when using compression */ |
565 | #define 4 /* standard header size */ |
566 | #define 3 /* compression header extra size */ |
567 | |
568 | /* Prototypes to password functions */ |
569 | |
570 | #ifdef __cplusplus |
571 | extern "C" { |
572 | #endif |
573 | |
574 | /* |
575 | These functions are used for authentication by client and server and |
576 | implemented in sql/password.c |
577 | */ |
578 | |
579 | void randominit(struct rand_struct *, unsigned long seed1, |
580 | unsigned long seed2); |
581 | double my_rnd(struct rand_struct *); |
582 | void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st); |
583 | |
584 | void hash_password(unsigned long *to, const char *password, unsigned int password_len); |
585 | void make_scrambled_password_323(char *to, const char *password); |
586 | void scramble_323(char *to, const char *message, const char *password); |
587 | my_bool check_scramble_323(const unsigned char *reply, const char *message, |
588 | unsigned long *salt); |
589 | void get_salt_from_password_323(unsigned long *res, const char *password); |
590 | void make_password_from_salt_323(char *to, const unsigned long *salt); |
591 | |
592 | void make_scrambled_password(char *to, const char *password); |
593 | void scramble(char *to, const char *message, const char *password); |
594 | my_bool check_scramble(const unsigned char *reply, const char *message, |
595 | const unsigned char *hash_stage2); |
596 | void get_salt_from_password(unsigned char *res, const char *password); |
597 | void make_password_from_salt(char *to, const unsigned char *hash_stage2); |
598 | char *octet2hex(char *to, const char *str, unsigned int len); |
599 | |
600 | /* end of password.c */ |
601 | |
602 | my_bool generate_sha256_scramble(unsigned char *dst, size_t dst_size, |
603 | const char *src, size_t src_size, const char *rnd, |
604 | size_t rnd_size); |
605 | |
606 | char *get_tty_password(const char *opt_message); |
607 | const char *mysql_errno_to_sqlstate(unsigned int mysql_errno); |
608 | |
609 | /* Some other useful functions */ |
610 | |
611 | my_bool my_thread_init(void); |
612 | void my_thread_end(void); |
613 | |
614 | #ifdef MY_GLOBAL_INCLUDED |
615 | ulong STDCALL net_field_length(uchar **packet); |
616 | ulong STDCALL net_field_length_checked(uchar **packet, ulong max_length); |
617 | my_ulonglong net_field_length_ll(uchar **packet); |
618 | uchar *net_store_length(uchar *pkg, ulonglong length); |
619 | unsigned int net_length_size(ulonglong num); |
620 | unsigned int net_field_length_size(const unsigned char *pos); |
621 | #endif |
622 | |
623 | #ifdef __cplusplus |
624 | } |
625 | #endif |
626 | |
627 | #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */ |
628 | #define 4 |
629 | #define 6 |
630 | |
631 | #define NOT_FIXED_DEC 31 |
632 | #endif |
633 | |