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