1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1
/* Copyright (C) 2000 MySQL AB
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.
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.
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 */
21
17
** Common definition between mysql server & client
24
#ifndef _libdrizzle_drizzle_com_h
25
#define _libdrizzle_drizzle_com_h
33
This is included in the server and in the client.
34
Options for select set by the yacc parser (stored in lex->options).
37
log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
38
options list are written into binlog. These options can NOT change their
39
values, or it will break replication between version.
41
context is encoded as following:
42
SELECT - SELECT_LEX_NODE::options
44
intern - neither. used only as
45
func(..., select_node->options | thd->options | OPTION_XXX, ...)
47
TODO: separate three contexts above, move them to separate bitfields.
50
#define SELECT_DISTINCT (UINT64_C(1) << 0) // SELECT, user
51
#define SELECT_STRAIGHT_JOIN (UINT64_C(1) << 1) // SELECT, user
52
#define SELECT_DESCRIBE (UINT64_C(1) << 2) // SELECT, user
53
#define SELECT_SMALL_RESULT (UINT64_C(1) << 3) // SELECT, user
54
#define SELECT_BIG_RESULT (UINT64_C(1) << 4) // SELECT, user
55
#define OPTION_FOUND_ROWS (UINT64_C(1) << 5) // SELECT, user
56
#define SELECT_NO_JOIN_CACHE (UINT64_C(1) << 7) // intern
57
#define OPTION_BIG_TABLES (UINT64_C(1) << 8) // THD, user
58
#define OPTION_BIG_SELECTS (UINT64_C(1) << 9) // THD, user
59
#define OPTION_LOG_OFF (UINT64_C(1) << 10) // THD, user
60
#define OPTION_QUOTE_SHOW_CREATE (UINT64_C(1) << 11) // THD, user, unused
61
#define TMP_TABLE_ALL_COLUMNS (UINT64_C(1) << 12) // SELECT, intern
62
#define OPTION_WARNINGS (UINT64_C(1) << 13) // THD, user
63
#define OPTION_AUTO_IS_NULL (UINT64_C(1) << 14) // THD, user, binlog
64
#define OPTION_FOUND_COMMENT (UINT64_C(1) << 15) // SELECT, intern, parser
65
#define OPTION_SAFE_UPDATES (UINT64_C(1) << 16) // THD, user
66
#define OPTION_BUFFER_RESULT (UINT64_C(1) << 17) // SELECT, user
67
#define OPTION_BIN_LOG (UINT64_C(1) << 18) // THD, user
68
#define OPTION_NOT_AUTOCOMMIT (UINT64_C(1) << 19) // THD, user
69
#define OPTION_BEGIN (UINT64_C(1) << 20) // THD, intern
70
#define OPTION_TABLE_LOCK (UINT64_C(1) << 21) // THD, intern
71
#define OPTION_QUICK (UINT64_C(1) << 22) // SELECT (for DELETE)
72
#define OPTION_KEEP_LOG (UINT64_C(1) << 23) // THD, user
74
/* The following is used to detect a conflict with DISTINCT */
75
#define SELECT_ALL (UINT64_C(1) << 24) // SELECT, user, parser
77
/** The following can be set when importing tables in a 'wrong order'
78
to suppress foreign key checks */
79
#define OPTION_NO_FOREIGN_KEY_CHECKS (UINT64_C(1) << 26) // THD, user, binlog
80
/** The following speeds up inserts to InnoDB tables by suppressing unique
81
key checks in some cases */
82
#define OPTION_RELAXED_UNIQUE_CHECKS (UINT64_C(1) << 27) // THD, user, binlog
83
#define SELECT_NO_UNLOCK (UINT64_C(1) << 28) // SELECT, intern
84
#define OPTION_SCHEMA_TABLE (UINT64_C(1) << 29) // SELECT, intern
85
/** Flag set if setup_tables already done */
86
#define OPTION_SETUP_TABLES_DONE (UINT64_C(1) << 30) // intern
87
/** If not set then the thread will ignore all warnings with level notes. */
88
#define OPTION_SQL_NOTES (UINT64_C(1) << 31) // THD, user
90
Force the used temporary table to be a MyISAM table (because we will use
91
fulltext functions when reading from it.
93
#define TMP_TABLE_FORCE_MYISAM (UINT64_C(1) << 32)
94
#define OPTION_PROFILING (UINT64_C(1) << 33)
97
Dont report errors for individual rows,
98
But just report error on commit (or read ofcourse)
100
#define OPTION_ALLOW_BATCH (UINT64_C(1) << 33) // THD, intern (slave)
103
Maximum length of time zone name that we support
104
(Time zone name is char(64) in db). mysqlbinlog needs it.
106
#define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1)
108
23
#define HOSTNAME_LENGTH 60
109
24
#define SYSTEM_CHARSET_MBMAXLEN 4
315
226
#define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */
316
227
#define MAX_BLOB_WIDTH 16777216 /* Default width for blob */
318
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
229
typedef struct st_net {
231
unsigned char *buff,*buff_end,*write_pos,*read_pos;
232
my_socket fd; /* For Perl DBI/dbd */
234
The following variable is set if we are doing several queries in one
235
command ( as in LOAD TABLE ... FROM MASTER ),
236
and do not want to confuse the client with OK at the wrong time
238
unsigned long remain_in_buf,length, buf_length, where_b;
239
unsigned long max_packet,max_packet_size;
240
unsigned int pkt_nr,compress_pkt_nr;
241
unsigned int write_timeout;
242
unsigned int read_timeout;
243
unsigned int retry_count;
245
unsigned int *return_status;
246
unsigned char reading_or_writing;
250
Pointer to query object in query cache, do not equal NULL (0) for
251
queries in cache that have not stored its results yet
254
Unused, please remove with the next incompatible ABI change.
256
unsigned char *unused;
257
unsigned int last_errno;
259
/** Client library error message buffer. Actually belongs to struct MYSQL. */
260
char last_error[MYSQL_ERRMSG_SIZE];
261
/** Client library sqlstate buffer. Set along with the error message. */
262
char sqlstate[SQLSTATE_LENGTH+1];
323
267
#define packet_error (~(uint32_t) 0)
269
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
270
enum enum_field_types { MYSQL_TYPE_TINY=1,
271
MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
273
MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
275
MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
276
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
277
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
278
MYSQL_TYPE_NEWDECIMAL=250,
282
MYSQL_TYPE_VAR_STRING=254,
283
MYSQL_TYPE_STRING=255
286
/* For backward compatibility */
287
#define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS
288
#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL
289
#define FIELD_TYPE_TINY MYSQL_TYPE_TINY
290
#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT
291
#define FIELD_TYPE_LONG MYSQL_TYPE_LONG
292
#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE
293
#define FIELD_TYPE_NULL MYSQL_TYPE_NULL
294
#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP
295
#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG
296
#define FIELD_TYPE_TIME MYSQL_TYPE_TIME
297
#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME
298
#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR
299
#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
300
#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
301
#define FIELD_TYPE_SET MYSQL_TYPE_SET
302
#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
303
#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB
304
#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING
305
#define FIELD_TYPE_STRING MYSQL_TYPE_STRING
306
#define FIELD_TYPE_CHAR MYSQL_TYPE_TINY
307
#define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM
326
310
/* Shutdown/kill enums and constants */
328
312
/* Bits for THD::killable. */
329
#define DRIZZLE_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
330
#define DRIZZLE_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
331
#define DRIZZLE_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
332
#define DRIZZLE_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
313
#define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0)
314
#define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1)
315
#define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
316
#define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3)
334
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
335
enum enum_field_types { DRIZZLE_TYPE_TINY=1,
338
DRIZZLE_TYPE_NULL, DRIZZLE_TYPE_TIMESTAMP,
339
DRIZZLE_TYPE_LONGLONG,
341
DRIZZLE_TYPE_DATETIME,
342
DRIZZLE_TYPE_NEWDATE, DRIZZLE_TYPE_VARCHAR,
343
DRIZZLE_TYPE_VIRTUAL=252,
344
DRIZZLE_TYPE_NEWDECIMAL=253,
345
DRIZZLE_TYPE_ENUM=254,
346
DRIZZLE_TYPE_BLOB=255
318
enum mysql_enum_shutdown_level {
320
We want levels to be in growing order of hardness (because we use number
321
comparisons). Note that DEFAULT does not respect the growing property, but
324
SHUTDOWN_DEFAULT = 0,
325
/* wait for existing connections to finish */
326
SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT,
327
/* wait for existing trans to finish */
328
SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS,
329
/* wait for existing updates to finish (=> no partial MyISAM update) */
330
SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE,
331
/* flush InnoDB buffers and other storage engines' buffers*/
332
SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1),
333
/* don't flush InnoDB buffers, flush other storage engines' buffers*/
334
SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
335
/* Now the 2 levels of the KILL command */
427
439
implemented in sql/password.c
430
void randominit(struct rand_struct *, uint32_t seed1, uint32_t seed2);
431
double my_rnd(struct rand_struct *);
432
void create_random_string(char *to, unsigned int length,
433
struct rand_struct *rand_st);
435
void hash_password(uint32_t *to, const char *password, uint32_t password_len);
437
void make_scrambled_password(char *to, const char *password);
438
void scramble(char *to, const char *message, const char *password);
439
bool check_scramble(const char *reply, const char *message,
440
const unsigned char *hash_stage2);
441
void get_salt_from_password(unsigned char *res, const char *password);
442
void make_password_from_salt(char *to, const unsigned char *hash_stage2);
443
char *octet2hex(char *to, const char *str, unsigned int len);
442
void randominit(struct rand_struct *, uint32_t seed1, uint32_t seed2);
443
double my_rnd(struct rand_struct *);
444
void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
446
void hash_password(uint32_t *to, const char *password, uint32_t password_len);
448
void make_scrambled_password(char *to, const char *password);
449
void scramble(char *to, const char *message, const char *password);
450
my_bool check_scramble(const char *reply, const char *message,
451
const unsigned char *hash_stage2);
452
void get_salt_from_password(unsigned char *res, const char *password);
453
void make_password_from_salt(char *to, const unsigned char *hash_stage2);
454
char *octet2hex(char *to, const char *str, unsigned int len);
445
456
/* end of password.c */
447
char *get_tty_password(const char *opt_message);
449
uint32_t net_field_length(unsigned char **packet);
450
uint64_t net_field_length_ll(unsigned char **packet);
451
unsigned char *net_store_length(unsigned char *pkg, uint64_t length);
454
Define-funktions for reading and storing in machine independent format
458
/* Optimized store functions for Intel x86 */
459
#if defined(__i386__)
460
#define sint2korr(A) (*((int16_t *) (A)))
461
#define sint3korr(A) ((int32_t) ((((unsigned char) (A)[2]) & 128) ? \
462
(((uint32_t) 255L << 24) | \
463
(((uint32_t) (unsigned char) (A)[2]) << 16) |\
464
(((uint32_t) (unsigned char) (A)[1]) << 8) | \
465
((uint32_t) (unsigned char) (A)[0])) : \
466
(((uint32_t) (unsigned char) (A)[2]) << 16) |\
467
(((uint32_t) (unsigned char) (A)[1]) << 8) | \
468
((uint32_t) (unsigned char) (A)[0])))
469
#define sint4korr(A) (*((long *) (A)))
470
#define uint2korr(A) (*((uint16_t *) (A)))
471
#if defined(HAVE_purify)
472
#define uint3korr(A) (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) +\
473
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
474
(((uint32_t) ((unsigned char) (A)[2])) << 16))
479
Please, note, uint3korr reads 4 bytes (not 3) !
480
It means, that you have to provide enough allocated space !
482
#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF)
483
#endif /* HAVE_purify */
484
#define uint4korr(A) (*((uint32_t *) (A)))
485
#define uint5korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
486
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
487
(((uint32_t) ((unsigned char) (A)[2])) << 16) +\
488
(((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
489
(((uint64_t) ((unsigned char) (A)[4])) << 32))
490
#define uint6korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) + \
491
(((uint32_t) ((unsigned char) (A)[1])) << 8) + \
492
(((uint32_t) ((unsigned char) (A)[2])) << 16) + \
493
(((uint32_t) ((unsigned char) (A)[3])) << 24)) + \
494
(((uint64_t) ((unsigned char) (A)[4])) << 32) + \
495
(((uint64_t) ((unsigned char) (A)[5])) << 40))
496
#define uint8korr(A) (*((uint64_t *) (A)))
497
#define sint8korr(A) (*((int64_t *) (A)))
498
#define int2store(T,A) *((uint16_t*) (T))= (uint16_t) (A)
499
#define int3store(T,A) do { *(T)= (unsigned char) ((A));\
500
*(T+1)=(unsigned char) (((uint32_t) (A) >> 8));\
501
*(T+2)=(unsigned char) (((A) >> 16)); } while (0)
502
#define int4store(T,A) *((long *) (T))= (long) (A)
503
#define int5store(T,A) do { *(T)= (unsigned char)((A));\
504
*((T)+1)=(unsigned char) (((A) >> 8));\
505
*((T)+2)=(unsigned char) (((A) >> 16));\
506
*((T)+3)=(unsigned char) (((A) >> 24)); \
507
*((T)+4)=(unsigned char) (((A) >> 32)); } while(0)
508
#define int6store(T,A) do { *(T)= (unsigned char)((A)); \
509
*((T)+1)=(unsigned char) (((A) >> 8)); \
510
*((T)+2)=(unsigned char) (((A) >> 16)); \
511
*((T)+3)=(unsigned char) (((A) >> 24)); \
512
*((T)+4)=(unsigned char) (((A) >> 32)); \
513
*((T)+5)=(unsigned char) (((A) >> 40)); } while(0)
514
#define int8store(T,A) *((uint64_t *) (T))= (uint64_t) (A)
520
#define doubleget(V,M) \
521
do { doubleget_union _tmp; \
522
_tmp.m[0] = *((long*)(M)); \
523
_tmp.m[1] = *(((long*) (M))+1); \
524
(V) = _tmp.v; } while(0)
525
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
526
*(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
528
#define float4get(V,M) do { *((float *) &(V)) = *((float*) (M)); } while(0)
529
#define float8get(V,M) doubleget((V),(M))
530
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
531
#define floatstore(T,V) memcpy((T), (&V), sizeof(float))
532
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
533
#define float8store(V,M) doublestore((V),(M))
537
We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
540
#define sint2korr(A) (int16_t) (((int16_t) ((unsigned char) (A)[0])) +\
541
((int16_t) ((int16_t) (A)[1]) << 8))
542
#define sint3korr(A) ((int32_t) ((((unsigned char) (A)[2]) & 128) ? \
543
(((uint32_t) 255L << 24) | \
544
(((uint32_t) (unsigned char) (A)[2]) << 16) |\
545
(((uint32_t) (unsigned char) (A)[1]) << 8) | \
546
((uint32_t) (unsigned char) (A)[0])) : \
547
(((uint32_t) (unsigned char) (A)[2]) << 16) |\
548
(((uint32_t) (unsigned char) (A)[1]) << 8) | \
549
((uint32_t) (unsigned char) (A)[0])))
550
#define sint4korr(A) (int32_t) (((int32_t) ((unsigned char) (A)[0])) +\
551
(((int32_t) ((unsigned char) (A)[1]) << 8)) +\
552
(((int32_t) ((unsigned char) (A)[2]) << 16)) +\
553
(((int32_t) ((int16_t) (A)[3]) << 24)))
554
#define sint8korr(A) (int64_t) uint8korr(A)
555
#define uint2korr(A) (uint16_t) (((uint16_t) ((unsigned char) (A)[0])) +\
556
((uint16_t) ((unsigned char) (A)[1]) << 8))
557
#define uint3korr(A) (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) +\
558
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
559
(((uint32_t) ((unsigned char) (A)[2])) << 16))
560
#define uint4korr(A) (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) +\
561
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
562
(((uint32_t) ((unsigned char) (A)[2])) << 16) +\
563
(((uint32_t) ((unsigned char) (A)[3])) << 24))
564
#define uint5korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
565
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
566
(((uint32_t) ((unsigned char) (A)[2])) << 16) +\
567
(((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
568
(((uint64_t) ((unsigned char) (A)[4])) << 32))
569
#define uint6korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) + \
570
(((uint32_t) ((unsigned char) (A)[1])) << 8) + \
571
(((uint32_t) ((unsigned char) (A)[2])) << 16) + \
572
(((uint32_t) ((unsigned char) (A)[3])) << 24)) + \
573
(((uint64_t) ((unsigned char) (A)[4])) << 32) + \
574
(((uint64_t) ((unsigned char) (A)[5])) << 40))
575
#define uint8korr(A) ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
576
(((uint32_t) ((unsigned char) (A)[1])) << 8) +\
577
(((uint32_t) ((unsigned char) (A)[2])) << 16) +\
578
(((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
579
(((uint64_t) (((uint32_t) ((unsigned char) (A)[4])) +\
580
(((uint32_t) ((unsigned char) (A)[5])) << 8) +\
581
(((uint32_t) ((unsigned char) (A)[6])) << 16) +\
582
(((uint32_t) ((unsigned char) (A)[7])) << 24))) <<\
584
#define int2store(T,A) do { uint32_t def_temp= (uint32_t) (A) ;\
585
*((unsigned char*) (T))= (unsigned char)(def_temp); \
586
*((unsigned char*) (T)+1)=(unsigned char)((def_temp >> 8)); \
588
#define int3store(T,A) do { /*lint -save -e734 */\
589
*((unsigned char*)(T))=(unsigned char) ((A));\
590
*((unsigned char*) (T)+1)=(unsigned char) (((A) >> 8));\
591
*((unsigned char*)(T)+2)=(unsigned char) (((A) >> 16)); \
592
/*lint -restore */} while(0)
593
#define int4store(T,A) do { *((char *)(T))=(char) ((A));\
594
*(((char *)(T))+1)=(char) (((A) >> 8));\
595
*(((char *)(T))+2)=(char) (((A) >> 16));\
596
*(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
597
#define int5store(T,A) do { *((char *)(T))= (char)((A)); \
598
*(((char *)(T))+1)= (char)(((A) >> 8)); \
599
*(((char *)(T))+2)= (char)(((A) >> 16)); \
600
*(((char *)(T))+3)= (char)(((A) >> 24)); \
601
*(((char *)(T))+4)= (char)(((A) >> 32)); \
603
#define int6store(T,A) do { *((char *)(T))= (char)((A)); \
604
*(((char *)(T))+1)= (char)(((A) >> 8)); \
605
*(((char *)(T))+2)= (char)(((A) >> 16)); \
606
*(((char *)(T))+3)= (char)(((A) >> 24)); \
607
*(((char *)(T))+4)= (char)(((A) >> 32)); \
608
*(((char *)(T))+5)= (char)(((A) >> 40)); \
610
#define int8store(T,A) do { uint32_t def_temp= (uint32_t) (A), def_temp2= (uint32_t) ((A) >> 32); \
611
int4store((T),def_temp); \
612
int4store((T+4),def_temp2); } while(0)
613
#ifdef WORDS_BIGENDIAN
614
#define float4store(T,A) do { *(T)= ((unsigned char *) &A)[3];\
615
*((T)+1)=(char) ((unsigned char *) &A)[2];\
616
*((T)+2)=(char) ((unsigned char *) &A)[1];\
617
*((T)+3)=(char) ((unsigned char *) &A)[0]; } while(0)
619
#define float4get(V,M) do { float def_temp;\
620
((unsigned char*) &def_temp)[0]=(M)[3];\
621
((unsigned char*) &def_temp)[1]=(M)[2];\
622
((unsigned char*) &def_temp)[2]=(M)[1];\
623
((unsigned char*) &def_temp)[3]=(M)[0];\
624
(V)=def_temp; } while(0)
625
#define float8store(T,V) do { *(T)= ((unsigned char *) &V)[7];\
626
*((T)+1)=(char) ((unsigned char *) &V)[6];\
627
*((T)+2)=(char) ((unsigned char *) &V)[5];\
628
*((T)+3)=(char) ((unsigned char *) &V)[4];\
629
*((T)+4)=(char) ((unsigned char *) &V)[3];\
630
*((T)+5)=(char) ((unsigned char *) &V)[2];\
631
*((T)+6)=(char) ((unsigned char *) &V)[1];\
632
*((T)+7)=(char) ((unsigned char *) &V)[0]; } while(0)
634
#define float8get(V,M) do { double def_temp;\
635
((unsigned char*) &def_temp)[0]=(M)[7];\
636
((unsigned char*) &def_temp)[1]=(M)[6];\
637
((unsigned char*) &def_temp)[2]=(M)[5];\
638
((unsigned char*) &def_temp)[3]=(M)[4];\
639
((unsigned char*) &def_temp)[4]=(M)[3];\
640
((unsigned char*) &def_temp)[5]=(M)[2];\
641
((unsigned char*) &def_temp)[6]=(M)[1];\
642
((unsigned char*) &def_temp)[7]=(M)[0];\
643
(V) = def_temp; } while(0)
645
#define float4get(V,M) memcpy(&V, (M), sizeof(float))
646
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
648
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
649
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((unsigned char *) &V)[4];\
650
*(((char*)T)+1)=(char) ((unsigned char *) &V)[5];\
651
*(((char*)T)+2)=(char) ((unsigned char *) &V)[6];\
652
*(((char*)T)+3)=(char) ((unsigned char *) &V)[7];\
653
*(((char*)T)+4)=(char) ((unsigned char *) &V)[0];\
654
*(((char*)T)+5)=(char) ((unsigned char *) &V)[1];\
655
*(((char*)T)+6)=(char) ((unsigned char *) &V)[2];\
656
*(((char*)T)+7)=(char) ((unsigned char *) &V)[3]; }\
658
#define doubleget(V,M) do { double def_temp;\
659
((unsigned char*) &def_temp)[0]=(M)[4];\
660
((unsigned char*) &def_temp)[1]=(M)[5];\
661
((unsigned char*) &def_temp)[2]=(M)[6];\
662
((unsigned char*) &def_temp)[3]=(M)[7];\
663
((unsigned char*) &def_temp)[4]=(M)[0];\
664
((unsigned char*) &def_temp)[5]=(M)[1];\
665
((unsigned char*) &def_temp)[6]=(M)[2];\
666
((unsigned char*) &def_temp)[7]=(M)[3];\
667
(V) = def_temp; } while(0)
668
#endif /* __FLOAT_WORD_ORDER */
670
#define float8get(V,M) doubleget((V),(M))
671
#define float8store(V,M) doublestore((V),(M))
672
#endif /* WORDS_BIGENDIAN */
674
#endif /* __i386__ */
677
Macro for reading 32-bit integer from network byte order (big-endian)
678
from unaligned memory location.
680
#define int4net(A) (int32_t) (((uint32_t) ((unsigned char) (A)[3])) |\
681
(((uint32_t) ((unsigned char) (A)[2])) << 8) |\
682
(((uint32_t) ((unsigned char) (A)[1])) << 16) |\
683
(((uint32_t) ((unsigned char) (A)[0])) << 24))
685
Define-funktions for reading and storing in machine format from/to
686
short/long to/from some place in memory V should be a (not
687
register) variable, M is a pointer to byte
690
#ifdef WORDS_BIGENDIAN
692
#define ushortget(V,M) do { V = (uint16_t) (((uint16_t) ((unsigned char) (M)[1]))+\
693
((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
694
#define shortget(V,M) do { V = (short) (((short) ((unsigned char) (M)[1]))+\
695
((short) ((short) (M)[0]) << 8)); } while(0)
696
#define longget(V,M) do { int32_t def_temp;\
697
((unsigned char*) &def_temp)[0]=(M)[0];\
698
((unsigned char*) &def_temp)[1]=(M)[1];\
699
((unsigned char*) &def_temp)[2]=(M)[2];\
700
((unsigned char*) &def_temp)[3]=(M)[3];\
701
(V)=def_temp; } while(0)
702
#define ulongget(V,M) do { uint32_t def_temp;\
703
((unsigned char*) &def_temp)[0]=(M)[0];\
704
((unsigned char*) &def_temp)[1]=(M)[1];\
705
((unsigned char*) &def_temp)[2]=(M)[2];\
706
((unsigned char*) &def_temp)[3]=(M)[3];\
707
(V)=def_temp; } while(0)
708
#define shortstore(T,A) do { uint32_t def_temp=(uint32_t) (A) ;\
709
*(((char*)T)+1)=(char)(def_temp); \
710
*(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
711
#define longstore(T,A) do { *(((char*)T)+3)=((A));\
712
*(((char*)T)+2)=(((A) >> 8));\
713
*(((char*)T)+1)=(((A) >> 16));\
714
*(((char*)T)+0)=(((A) >> 24)); } while(0)
716
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
717
#define floatstore(T, V) memcpy((T), (&V), sizeof(float))
718
#define doubleget(V, M) memcpy(&V, (M), sizeof(double))
719
#define doublestore(T, V) memcpy((T), &V, sizeof(double))
720
#define int64_tget(V, M) memcpy(&V, (M), sizeof(uint64_t))
721
#define int64_tstore(T, V) memcpy((T), &V, sizeof(uint64_t))
725
#define ushortget(V,M) do { V = uint2korr(M); } while(0)
726
#define shortget(V,M) do { V = sint2korr(M); } while(0)
727
#define longget(V,M) do { V = sint4korr(M); } while(0)
728
#define ulongget(V,M) do { V = uint4korr(M); } while(0)
729
#define shortstore(T,V) int2store(T,V)
730
#define longstore(T,V) int4store(T,V)
732
#define floatstore(T,V) memcpy((T), (&V), sizeof(float))
733
#define floatget(V,M) memcpy(&V, (M), sizeof(float))
458
char *get_tty_password(const char *opt_message);
459
const char *mysql_errno_to_sqlstate(unsigned int mysql_errno);
463
ulong STDCALL net_field_length(uchar **packet);
464
uint64_t net_field_length_ll(uchar **packet);
465
uchar *net_store_length(uchar *pkg, uint64_t length);
736
#define doubleget(V, M) memcpy(&V, (M), sizeof(double))
737
#define doublestore(T,V) memcpy((T), &V, sizeof(double))
738
#endif /* doubleget */
739
#define int64_tget(V,M) memcpy(&V, (M), sizeof(uint64_t))
740
#define int64_tstore(T,V) memcpy((T), &V, sizeof(uint64_t))
742
#endif /* WORDS_BIGENDIAN */
745
468
#ifdef __cplusplus
749
#define NULL_LENGTH UINT32_MAX /* For net_store_length */
750
#define DRIZZLE_STMT_HEADER 4
751
#define DRIZZLE_LONG_DATA_HEADER 6
472
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
473
#define MYSQL_STMT_HEADER 4
474
#define MYSQL_LONG_DATA_HEADER 6