~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/common.h

  • Committer: Stewart Smith
  • Date: 2009-06-16 03:02:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1065.
  • Revision ID: stewart@flamingspork.com-20090616030259-tn2thqrajk6cappd
ER_NISAMCHK is unused, mark it as so. Thanks to Paul DuBois for researching this for MySQL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
21
21
** Common definition between mysql server & client
22
22
*/
23
23
 
24
 
#ifndef _libdrizzle_drizzle_com_h
25
 
#define _libdrizzle_drizzle_com_h
 
24
#ifndef DRIZZLED_DRIZZLE_COMMON_H
 
25
#define DRIZZLED_DRIZZLE_COMMON_H
26
26
 
27
 
#include <config.h>
28
27
#include <unistd.h>
29
 
#include <stdbool.h>
30
28
#include <stdint.h>
 
29
#include <drizzled/korr.h>
31
30
 
32
31
/*
33
32
   This is included in the server and in the client.
39
38
   values, or it will break replication between version.
40
39
 
41
40
   context is encoded as following:
42
 
   SELECT - SELECT_LEX_NODE::options
 
41
   SELECT - Select_Lex_Node::options
43
42
   THD    - THD::options
44
43
   intern - neither. used only as
45
44
            func(..., select_node->options | thd->options | OPTION_XXX, ...)
57
56
#define OPTION_BIG_TABLES       (UINT64_C(1) << 8)     // THD, user
58
57
#define OPTION_BIG_SELECTS      (UINT64_C(1) << 9)     // THD, user
59
58
#define OPTION_LOG_OFF          (UINT64_C(1) << 10)    // THD, user
60
 
#define OPTION_QUOTE_SHOW_CREATE (UINT64_C(1) << 11)   // THD, user, unused
61
59
#define TMP_TABLE_ALL_COLUMNS   (UINT64_C(1) << 12)    // SELECT, intern
62
60
#define OPTION_WARNINGS         (UINT64_C(1) << 13)    // THD, user
63
61
#define OPTION_AUTO_IS_NULL     (UINT64_C(1) << 14)    // THD, user, binlog
64
62
#define OPTION_FOUND_COMMENT    (UINT64_C(1) << 15)    // SELECT, intern, parser
65
63
#define OPTION_SAFE_UPDATES     (UINT64_C(1) << 16)    // THD, user
66
64
#define OPTION_BUFFER_RESULT    (UINT64_C(1) << 17)    // SELECT, user
67
 
#define OPTION_BIN_LOG          (UINT64_C(1) << 18)    // THD, user
68
65
#define OPTION_NOT_AUTOCOMMIT   (UINT64_C(1) << 19)    // THD, user
69
66
#define OPTION_BEGIN            (UINT64_C(1) << 20)    // THD, intern
70
 
#define OPTION_TABLE_LOCK       (UINT64_C(1) << 21)    // THD, intern
71
67
#define OPTION_QUICK            (UINT64_C(1) << 22)    // SELECT (for DELETE)
72
68
#define OPTION_KEEP_LOG         (UINT64_C(1) << 23)    // THD, user
73
69
 
107
103
 
108
104
#define HOSTNAME_LENGTH 60
109
105
#define SYSTEM_CHARSET_MBMAXLEN 4
 
106
#define USERNAME_CHAR_LENGTH 16
110
107
#define NAME_CHAR_LEN   64              /* Field/table name length */
111
 
#define USERNAME_CHAR_LENGTH 16
112
108
#define NAME_LEN                (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
113
109
#define USERNAME_LENGTH         (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
114
110
 
122
118
#define COLUMN_COMMENT_MAXLEN 1024
123
119
#define INDEX_COMMENT_MAXLEN 1024
124
120
 
125
 
 
126
121
/*
127
122
  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
128
123
  username and hostname parts of the user identifier with trailing zero in
141
136
 
142
137
enum enum_server_command
143
138
{
144
 
  COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
145
 
  COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN,
146
 
  COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_PING,
147
 
  COM_TIME, COM_CHANGE_USER, COM_BINLOG_DUMP,
148
 
  COM_CONNECT_OUT, COM_REGISTER_SLAVE,
149
 
  COM_SET_OPTION, COM_DAEMON,
 
139
  COM_SLEEP,
 
140
  COM_QUIT,
 
141
  COM_INIT_DB,
 
142
  COM_QUERY,
 
143
  COM_SHUTDOWN,
 
144
  COM_CONNECT,
 
145
  COM_PING,
150
146
  /* don't forget to update const char *command_name[] in sql_parse.cc */
151
 
 
152
147
  /* Must be last */
153
148
  COM_END
154
149
};
193
188
#define FIELD_STORAGE_FLAGS 22          /* Storage type: bit 22, 23 and 24 */
194
189
#define COLUMN_FORMAT_FLAGS 25          /* Column format: bit 25, 26 and 27 */
195
190
 
196
 
#define REFRESH_GRANT           1       /* Refresh grant tables */
197
191
#define REFRESH_LOG             2       /* Start on new log file */
198
192
#define REFRESH_TABLES          4       /* close all tables */
199
 
#define REFRESH_HOSTS           8       /* Flush host cache */
200
193
#define REFRESH_STATUS          16      /* Flush status variables */
201
 
#define REFRESH_THREADS         32      /* Flush thread cache */
202
 
#define REFRESH_SLAVE           64      /* Reset master info and restart slave
203
 
                                           thread */
204
 
#define REFRESH_MASTER          128     /* Remove all bin logs in the index
205
 
                                           and truncate the index */
206
194
 
207
195
/* The following can't be set with mysql_refresh() */
208
196
#define REFRESH_READ_LOCK       16384   /* Lock tables for read */
209
197
#define REFRESH_FAST            32768   /* Intern flag */
210
198
 
211
 
/* RESET (remove all queries) from query cache */
212
 
#define REFRESH_QUERY_CACHE     65536
213
 
#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
214
 
#define REFRESH_DES_KEY_FILE    0x40000L
215
 
#define REFRESH_USER_RESOURCES  0x80000L
216
 
 
217
199
#define CLIENT_LONG_PASSWORD    1       /* new more secure passwords */
218
200
#define CLIENT_FOUND_ROWS       2       /* Found instead of affected rows */
219
201
#define CLIENT_LONG_FLAG        4       /* Get all column flags */
221
203
#define CLIENT_NO_SCHEMA        16      /* Don't allow database.table.column */
222
204
#define CLIENT_COMPRESS         32      /* Can use compression protocol */
223
205
#define CLIENT_ODBC             64      /* Odbc client */
224
 
#define CLIENT_LOCAL_FILES      128     /* Can use LOAD DATA LOCAL */
225
206
#define CLIENT_IGNORE_SPACE     256     /* Ignore spaces before '(' */
226
207
#define UNUSED_CLIENT_PROTOCOL_41       512     /* New 4.1 protocol */
227
 
#define CLIENT_INTERACTIVE      1024    /* This is an interactive client */
228
208
#define CLIENT_SSL              2048    /* Switch to SSL after handshake */
229
209
#define CLIENT_IGNORE_SIGPIPE   4096    /* IGNORE sigpipes */
230
 
#define CLIENT_TRANSACTIONS     8192    /* Client knows about transactions */
231
210
#define CLIENT_RESERVED         16384   /* Old flag for 4.1 protocol  */
232
211
#define CLIENT_SECURE_CONNECTION 32768  /* New 4.1 authentication */
233
212
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
244
223
                           CLIENT_NO_SCHEMA | \
245
224
                           CLIENT_COMPRESS | \
246
225
                           CLIENT_ODBC | \
247
 
                           CLIENT_LOCAL_FILES | \
248
226
                           CLIENT_IGNORE_SPACE | \
249
 
                           CLIENT_INTERACTIVE | \
250
227
                           CLIENT_SSL | \
251
228
                           CLIENT_IGNORE_SIGPIPE | \
252
 
                           CLIENT_TRANSACTIONS | \
253
229
                           CLIENT_RESERVED | \
254
230
                           CLIENT_SECURE_CONNECTION | \
255
231
                           CLIENT_MULTI_STATEMENTS | \
298
274
 
299
275
#define ONLY_KILL_QUERY         1
300
276
 
301
 
struct st_vio;                                  /* Only C */
302
 
typedef struct st_vio Vio;
303
 
 
304
277
#define MAX_TINYINT_WIDTH       3       /* Max width for a TINY w.o. sign */
305
278
#define MAX_SMALLINT_WIDTH      5       /* Max width for a SHORT w.o. sign */
306
279
#define MAX_MEDIUMINT_WIDTH     8       /* Max width for a INT24 w.o. sign */
307
280
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
308
281
#define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
309
282
#define MAX_CHAR_WIDTH          255     /* Max length for a CHAR colum */
310
 
#define MAX_BLOB_WIDTH          16777216        /* Default width for blob */
 
283
#define MAX_BLOB_WIDTH          (uint32_t)16777216      /* Default width for blob */
311
284
 
312
285
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
313
286
 
317
290
#define packet_error (~(uint32_t) 0)
318
291
 
319
292
 
320
 
/* Shutdown/kill enums and constants */ 
 
293
/* Shutdown/kill enums and constants */
321
294
 
322
295
/* Bits for THD::killable. */
323
296
#define DRIZZLE_SHUTDOWN_KILLABLE_CONNECT    (unsigned char)(1 << 0)
326
299
#define DRIZZLE_SHUTDOWN_KILLABLE_UPDATE     (unsigned char)(1 << 3)
327
300
 
328
301
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
329
 
enum enum_field_types { DRIZZLE_TYPE_TINY=1,
 
302
enum enum_field_types { DRIZZLE_TYPE_TINY,
330
303
                        DRIZZLE_TYPE_LONG,
331
304
                        DRIZZLE_TYPE_DOUBLE,
332
 
                        DRIZZLE_TYPE_NULL,   DRIZZLE_TYPE_TIMESTAMP,
 
305
                        DRIZZLE_TYPE_NULL,
 
306
                        DRIZZLE_TYPE_TIMESTAMP,
333
307
                        DRIZZLE_TYPE_LONGLONG,
334
 
                        DRIZZLE_TYPE_TIME,
335
308
                        DRIZZLE_TYPE_DATETIME,
336
 
                        DRIZZLE_TYPE_NEWDATE, DRIZZLE_TYPE_VARCHAR,
337
 
                        DRIZZLE_TYPE_NEWDECIMAL=253,
338
 
                        DRIZZLE_TYPE_ENUM=254,
339
 
                        DRIZZLE_TYPE_BLOB=255
340
 
};
341
 
 
342
 
 
343
 
enum enum_cursor_type
344
 
{
345
 
  CURSOR_TYPE_NO_CURSOR= 0,
346
 
  CURSOR_TYPE_READ_ONLY= 1,
347
 
  CURSOR_TYPE_FOR_UPDATE= 2,
348
 
  CURSOR_TYPE_SCROLLABLE= 4
349
 
};
350
 
 
351
 
 
352
 
/* options for mysql_set_option */
353
 
enum enum_drizzle_set_option
354
 
{
355
 
  DRIZZLE_OPTION_MULTI_STATEMENTS_ON,
356
 
  DRIZZLE_OPTION_MULTI_STATEMENTS_OFF
357
 
};
358
 
 
359
 
#define net_new_transaction(net) ((net)->pkt_nr=0)
360
 
 
361
 
#ifdef __cplusplus
362
 
extern "C" {
363
 
#endif
364
 
 
365
 
 
366
 
  struct rand_struct {
367
 
    unsigned long seed1,seed2,max_value;
368
 
    double max_value_dbl;
369
 
  };
370
 
 
371
 
#ifdef __cplusplus
372
 
}
373
 
#endif
 
309
                        DRIZZLE_TYPE_DATE,
 
310
                        DRIZZLE_TYPE_VARCHAR,
 
311
                        DRIZZLE_TYPE_NEWDECIMAL,
 
312
                        DRIZZLE_TYPE_ENUM,
 
313
                        DRIZZLE_TYPE_BLOB,
 
314
                        DRIZZLE_TYPE_MAX=DRIZZLE_TYPE_BLOB
 
315
};
 
316
 
374
317
 
375
318
  /* The following is for user defined functions */
376
319
 
400
343
  bool const_item;          /* 1 if function always returns the same value */
401
344
  void *extension;
402
345
} UDF_INIT;
403
 
/* 
404
 
  TODO: add a notion for determinism of the UDF. 
 
346
/*
 
347
  TODO: add a notion for determinism of the UDF.
405
348
  See Item_udf_func::update_used_tables ()
406
349
*/
407
350
 
409
352
#define NET_HEADER_SIZE 4               /* standard header size */
410
353
#define COMP_HEADER_SIZE 3              /* compression header extra size */
411
354
 
412
 
  /* Prototypes to password functions */
413
 
 
414
 
#ifdef __cplusplus
415
 
extern "C" {
416
 
#endif
417
 
 
418
 
/*
419
 
  These functions are used for authentication by client and server and
420
 
  implemented in sql/password.c
421
 
*/
422
 
 
423
 
  void randominit(struct rand_struct *, uint32_t seed1, uint32_t seed2);
424
 
  double my_rnd(struct rand_struct *);
425
 
  void create_random_string(char *to, unsigned int length,
426
 
                            struct rand_struct *rand_st);
427
 
 
428
 
  void hash_password(uint32_t *to, const char *password, uint32_t password_len);
429
 
 
430
 
  void make_scrambled_password(char *to, const char *password);
431
 
  void scramble(char *to, const char *message, const char *password);
432
 
  bool check_scramble(const char *reply, const char *message,
433
 
                      const unsigned char *hash_stage2);
434
 
  void get_salt_from_password(unsigned char *res, const char *password);
435
 
  void make_password_from_salt(char *to, const unsigned char *hash_stage2);
436
 
  char *octet2hex(char *to, const char *str, unsigned int len);
437
 
 
438
 
/* end of password.c */
439
 
 
440
 
  char *get_tty_password(const char *opt_message);
441
 
 
442
 
  uint32_t net_field_length(unsigned char **packet);
443
 
  uint64_t net_field_length_ll(unsigned char **packet);
444
 
  unsigned char *net_store_length(unsigned char *pkg, uint64_t length);
445
 
 
446
 
/*
447
 
  Define-funktions for reading and storing in machine independent format
448
 
  (low byte first)
449
 
*/
450
 
 
451
 
/* Optimized store functions for Intel x86 */
452
 
#if defined(__i386__)
453
 
#define sint2korr(A)    (*((int16_t *) (A)))
454
 
#define sint3korr(A)    ((int32_t) ((((unsigned char) (A)[2]) & 128) ? \
455
 
                                  (((uint32_t) 255L << 24) | \
456
 
                                   (((uint32_t) (unsigned char) (A)[2]) << 16) |\
457
 
                                   (((uint32_t) (unsigned char) (A)[1]) << 8) | \
458
 
                                   ((uint32_t) (unsigned char) (A)[0])) : \
459
 
                                  (((uint32_t) (unsigned char) (A)[2]) << 16) |\
460
 
                                  (((uint32_t) (unsigned char) (A)[1]) << 8) | \
461
 
                                  ((uint32_t) (unsigned char) (A)[0])))
462
 
#define sint4korr(A)    (*((long *) (A)))
463
 
#define uint2korr(A)    (*((uint16_t *) (A)))
464
 
#if defined(HAVE_purify)
465
 
#define uint3korr(A)    (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) +\
466
 
                                  (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
467
 
                                  (((uint32_t) ((unsigned char) (A)[2])) << 16))
468
 
#else
469
 
/*
470
 
   ATTENTION !
471
 
   
472
 
    Please, note, uint3korr reads 4 bytes (not 3) !
473
 
    It means, that you have to provide enough allocated space !
474
 
*/
475
 
#define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
476
 
#endif /* HAVE_purify */
477
 
#define uint4korr(A)    (*((uint32_t *) (A)))
478
 
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
479
 
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
480
 
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) +\
481
 
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
482
 
                                    (((uint64_t) ((unsigned char) (A)[4])) << 32))
483
 
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((unsigned char) (A)[0]))          + \
484
 
                                     (((uint32_t)    ((unsigned char) (A)[1])) << 8)   + \
485
 
                                     (((uint32_t)    ((unsigned char) (A)[2])) << 16)  + \
486
 
                                     (((uint32_t)    ((unsigned char) (A)[3])) << 24)) + \
487
 
                         (((uint64_t) ((unsigned char) (A)[4])) << 32) +       \
488
 
                         (((uint64_t) ((unsigned char) (A)[5])) << 40))
489
 
#define uint8korr(A)    (*((uint64_t *) (A)))
490
 
#define sint8korr(A)    (*((int64_t *) (A)))
491
 
#define int2store(T,A)  *((uint16_t*) (T))= (uint16_t) (A)
492
 
#define int3store(T,A)  do { *(T)=  (unsigned char) ((A));\
493
 
                            *(T+1)=(unsigned char) (((uint32_t) (A) >> 8));\
494
 
                            *(T+2)=(unsigned char) (((A) >> 16)); } while (0)
495
 
#define int4store(T,A)  *((long *) (T))= (long) (A)
496
 
#define int5store(T,A)  do { *(T)= (unsigned char)((A));\
497
 
                             *((T)+1)=(unsigned char) (((A) >> 8));\
498
 
                             *((T)+2)=(unsigned char) (((A) >> 16));\
499
 
                             *((T)+3)=(unsigned char) (((A) >> 24)); \
500
 
                             *((T)+4)=(unsigned char) (((A) >> 32)); } while(0)
501
 
#define int6store(T,A)  do { *(T)=    (unsigned char)((A));          \
502
 
                             *((T)+1)=(unsigned char) (((A) >> 8));  \
503
 
                             *((T)+2)=(unsigned char) (((A) >> 16)); \
504
 
                             *((T)+3)=(unsigned char) (((A) >> 24)); \
505
 
                             *((T)+4)=(unsigned char) (((A) >> 32)); \
506
 
                             *((T)+5)=(unsigned char) (((A) >> 40)); } while(0)
507
 
#define int8store(T,A)  *((uint64_t *) (T))= (uint64_t) (A)
508
 
 
509
 
typedef union {
510
 
  double v;
511
 
  long m[2];
512
 
} doubleget_union;
513
 
#define doubleget(V,M)  \
514
 
do { doubleget_union _tmp; \
515
 
     _tmp.m[0] = *((long*)(M)); \
516
 
     _tmp.m[1] = *(((long*) (M))+1); \
517
 
     (V) = _tmp.v; } while(0)
518
 
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
519
 
                             *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
520
 
                         } while (0)
521
 
#define float4get(V,M)   do { *((float *) &(V)) = *((float*) (M)); } while(0)
522
 
#define float8get(V,M)   doubleget((V),(M))
523
 
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
524
 
#define floatstore(T,V)  memcpy((T), (&V), sizeof(float))
525
 
#define floatget(V,M)    memcpy(&V, (M), sizeof(float))
526
 
#define float8store(V,M) doublestore((V),(M))
527
 
#else
528
 
 
529
 
/*
530
 
  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
531
 
  were done before)
532
 
*/
533
 
#define sint2korr(A)    (int16_t) (((int16_t) ((unsigned char) (A)[0])) +\
534
 
                                 ((int16_t) ((int16_t) (A)[1]) << 8))
535
 
#define sint3korr(A)    ((int32_t) ((((unsigned char) (A)[2]) & 128) ? \
536
 
                                  (((uint32_t) 255L << 24) | \
537
 
                                   (((uint32_t) (unsigned char) (A)[2]) << 16) |\
538
 
                                   (((uint32_t) (unsigned char) (A)[1]) << 8) | \
539
 
                                   ((uint32_t) (unsigned char) (A)[0])) : \
540
 
                                  (((uint32_t) (unsigned char) (A)[2]) << 16) |\
541
 
                                  (((uint32_t) (unsigned char) (A)[1]) << 8) | \
542
 
                                  ((uint32_t) (unsigned char) (A)[0])))
543
 
#define sint4korr(A)    (int32_t) (((int32_t) ((unsigned char) (A)[0])) +\
544
 
                                (((int32_t) ((unsigned char) (A)[1]) << 8)) +\
545
 
                                (((int32_t) ((unsigned char) (A)[2]) << 16)) +\
546
 
                                (((int32_t) ((int16_t) (A)[3]) << 24)))
547
 
#define sint8korr(A)    (int64_t) uint8korr(A)
548
 
#define uint2korr(A)    (uint16_t) (((uint16_t) ((unsigned char) (A)[0])) +\
549
 
                                  ((uint16_t) ((unsigned char) (A)[1]) << 8))
550
 
#define uint3korr(A)    (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) +\
551
 
                                  (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
552
 
                                  (((uint32_t) ((unsigned char) (A)[2])) << 16))
553
 
#define uint4korr(A)    (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) +\
554
 
                                  (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
555
 
                                  (((uint32_t) ((unsigned char) (A)[2])) << 16) +\
556
 
                                  (((uint32_t) ((unsigned char) (A)[3])) << 24))
557
 
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
558
 
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
559
 
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) +\
560
 
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
561
 
                                    (((uint64_t) ((unsigned char) (A)[4])) << 32))
562
 
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((unsigned char) (A)[0]))          + \
563
 
                                     (((uint32_t)    ((unsigned char) (A)[1])) << 8)   + \
564
 
                                     (((uint32_t)    ((unsigned char) (A)[2])) << 16)  + \
565
 
                                     (((uint32_t)    ((unsigned char) (A)[3])) << 24)) + \
566
 
                         (((uint64_t) ((unsigned char) (A)[4])) << 32) +       \
567
 
                         (((uint64_t) ((unsigned char) (A)[5])) << 40))
568
 
#define uint8korr(A)    ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
569
 
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
570
 
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) +\
571
 
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
572
 
                        (((uint64_t) (((uint32_t) ((unsigned char) (A)[4])) +\
573
 
                                    (((uint32_t) ((unsigned char) (A)[5])) << 8) +\
574
 
                                    (((uint32_t) ((unsigned char) (A)[6])) << 16) +\
575
 
                                    (((uint32_t) ((unsigned char) (A)[7])) << 24))) <<\
576
 
                                    32))
577
 
#define int2store(T,A)       do { uint32_t def_temp= (uint32_t) (A) ;\
578
 
                                  *((unsigned char*) (T))=  (unsigned char)(def_temp); \
579
 
                                   *((unsigned char*) (T)+1)=(unsigned char)((def_temp >> 8)); \
580
 
                             } while(0)
581
 
#define int3store(T,A)       do { /*lint -save -e734 */\
582
 
                                  *((unsigned char*)(T))=(unsigned char) ((A));\
583
 
                                  *((unsigned char*) (T)+1)=(unsigned char) (((A) >> 8));\
584
 
                                  *((unsigned char*)(T)+2)=(unsigned char) (((A) >> 16)); \
585
 
                                  /*lint -restore */} while(0)
586
 
#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
587
 
                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
588
 
                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
589
 
                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
590
 
#define int5store(T,A)       do { *((char *)(T))=     (char)((A));  \
591
 
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
592
 
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
593
 
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
594
 
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
595
 
                                } while(0)
596
 
#define int6store(T,A)       do { *((char *)(T))=     (char)((A)); \
597
 
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
598
 
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
599
 
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
600
 
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
601
 
                                  *(((char *)(T))+5)= (char)(((A) >> 40)); \
602
 
                                } while(0)
603
 
#define int8store(T,A)       do { uint32_t def_temp= (uint32_t) (A), def_temp2= (uint32_t) ((A) >> 32); \
604
 
                                  int4store((T),def_temp); \
605
 
                                  int4store((T+4),def_temp2); } while(0)
606
 
#ifdef WORDS_BIGENDIAN
607
 
#define float4store(T,A) do { *(T)= ((unsigned char *) &A)[3];\
608
 
                              *((T)+1)=(char) ((unsigned char *) &A)[2];\
609
 
                              *((T)+2)=(char) ((unsigned char *) &A)[1];\
610
 
                              *((T)+3)=(char) ((unsigned char *) &A)[0]; } while(0)
611
 
 
612
 
#define float4get(V,M)   do { float def_temp;\
613
 
                              ((unsigned char*) &def_temp)[0]=(M)[3];\
614
 
                              ((unsigned char*) &def_temp)[1]=(M)[2];\
615
 
                              ((unsigned char*) &def_temp)[2]=(M)[1];\
616
 
                              ((unsigned char*) &def_temp)[3]=(M)[0];\
617
 
                              (V)=def_temp; } while(0)
618
 
#define float8store(T,V) do { *(T)= ((unsigned char *) &V)[7];\
619
 
                              *((T)+1)=(char) ((unsigned char *) &V)[6];\
620
 
                              *((T)+2)=(char) ((unsigned char *) &V)[5];\
621
 
                              *((T)+3)=(char) ((unsigned char *) &V)[4];\
622
 
                              *((T)+4)=(char) ((unsigned char *) &V)[3];\
623
 
                              *((T)+5)=(char) ((unsigned char *) &V)[2];\
624
 
                              *((T)+6)=(char) ((unsigned char *) &V)[1];\
625
 
                              *((T)+7)=(char) ((unsigned char *) &V)[0]; } while(0)
626
 
 
627
 
#define float8get(V,M)   do { double def_temp;\
628
 
                              ((unsigned char*) &def_temp)[0]=(M)[7];\
629
 
                              ((unsigned char*) &def_temp)[1]=(M)[6];\
630
 
                              ((unsigned char*) &def_temp)[2]=(M)[5];\
631
 
                              ((unsigned char*) &def_temp)[3]=(M)[4];\
632
 
                              ((unsigned char*) &def_temp)[4]=(M)[3];\
633
 
                              ((unsigned char*) &def_temp)[5]=(M)[2];\
634
 
                              ((unsigned char*) &def_temp)[6]=(M)[1];\
635
 
                              ((unsigned char*) &def_temp)[7]=(M)[0];\
636
 
                              (V) = def_temp; } while(0)
637
 
#else
638
 
#define float4get(V,M)   memcpy(&V, (M), sizeof(float))
639
 
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
640
 
 
641
 
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
642
 
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((unsigned char *) &V)[4];\
643
 
                              *(((char*)T)+1)=(char) ((unsigned char *) &V)[5];\
644
 
                              *(((char*)T)+2)=(char) ((unsigned char *) &V)[6];\
645
 
                              *(((char*)T)+3)=(char) ((unsigned char *) &V)[7];\
646
 
                              *(((char*)T)+4)=(char) ((unsigned char *) &V)[0];\
647
 
                              *(((char*)T)+5)=(char) ((unsigned char *) &V)[1];\
648
 
                              *(((char*)T)+6)=(char) ((unsigned char *) &V)[2];\
649
 
                              *(((char*)T)+7)=(char) ((unsigned char *) &V)[3]; }\
650
 
                         while(0)
651
 
#define doubleget(V,M)   do { double def_temp;\
652
 
                              ((unsigned char*) &def_temp)[0]=(M)[4];\
653
 
                              ((unsigned char*) &def_temp)[1]=(M)[5];\
654
 
                              ((unsigned char*) &def_temp)[2]=(M)[6];\
655
 
                              ((unsigned char*) &def_temp)[3]=(M)[7];\
656
 
                              ((unsigned char*) &def_temp)[4]=(M)[0];\
657
 
                              ((unsigned char*) &def_temp)[5]=(M)[1];\
658
 
                              ((unsigned char*) &def_temp)[6]=(M)[2];\
659
 
                              ((unsigned char*) &def_temp)[7]=(M)[3];\
660
 
                              (V) = def_temp; } while(0)
661
 
#endif /* __FLOAT_WORD_ORDER */
662
 
 
663
 
#define float8get(V,M)   doubleget((V),(M))
664
 
#define float8store(V,M) doublestore((V),(M))
665
 
#endif /* WORDS_BIGENDIAN */
666
 
 
667
 
#endif /* __i386__ */
668
 
 
669
 
/*
670
 
  Macro for reading 32-bit integer from network byte order (big-endian)
671
 
  from unaligned memory location.
672
 
*/
673
 
#define int4net(A)        (int32_t) (((uint32_t) ((unsigned char) (A)[3]))        |\
674
 
                                  (((uint32_t) ((unsigned char) (A)[2])) << 8)  |\
675
 
                                  (((uint32_t) ((unsigned char) (A)[1])) << 16) |\
676
 
                                  (((uint32_t) ((unsigned char) (A)[0])) << 24))
677
 
/*
678
 
  Define-funktions for reading and storing in machine format from/to
679
 
  short/long to/from some place in memory V should be a (not
680
 
  register) variable, M is a pointer to byte
681
 
*/
682
 
 
683
 
#ifdef WORDS_BIGENDIAN
684
 
 
685
 
#define ushortget(V,M)  do { V = (uint16_t) (((uint16_t) ((unsigned char) (M)[1]))+\
686
 
                                 ((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
687
 
#define shortget(V,M)   do { V = (short) (((short) ((unsigned char) (M)[1]))+\
688
 
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
689
 
#define longget(V,M)    do { int32_t def_temp;\
690
 
                             ((unsigned char*) &def_temp)[0]=(M)[0];\
691
 
                             ((unsigned char*) &def_temp)[1]=(M)[1];\
692
 
                             ((unsigned char*) &def_temp)[2]=(M)[2];\
693
 
                             ((unsigned char*) &def_temp)[3]=(M)[3];\
694
 
                             (V)=def_temp; } while(0)
695
 
#define ulongget(V,M)   do { uint32_t def_temp;\
696
 
                            ((unsigned char*) &def_temp)[0]=(M)[0];\
697
 
                            ((unsigned char*) &def_temp)[1]=(M)[1];\
698
 
                            ((unsigned char*) &def_temp)[2]=(M)[2];\
699
 
                            ((unsigned char*) &def_temp)[3]=(M)[3];\
700
 
                            (V)=def_temp; } while(0)
701
 
#define shortstore(T,A) do { uint32_t def_temp=(uint32_t) (A) ;\
702
 
                             *(((char*)T)+1)=(char)(def_temp); \
703
 
                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
704
 
#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
705
 
                             *(((char*)T)+2)=(((A) >> 8));\
706
 
                             *(((char*)T)+1)=(((A) >> 16));\
707
 
                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
708
 
 
709
 
#define floatget(V,M)     memcpy(&V, (M), sizeof(float))
710
 
#define floatstore(T, V)   memcpy((T), (&V), sizeof(float))
711
 
#define doubleget(V, M)   memcpy(&V, (M), sizeof(double))
712
 
#define doublestore(T, V)  memcpy((T), &V, sizeof(double))
713
 
#define int64_tget(V, M)   memcpy(&V, (M), sizeof(uint64_t))
714
 
#define int64_tstore(T, V) memcpy((T), &V, sizeof(uint64_t))
715
 
 
716
 
#else
717
 
 
718
 
#define ushortget(V,M)  do { V = uint2korr(M); } while(0)
719
 
#define shortget(V,M)   do { V = sint2korr(M); } while(0)
720
 
#define longget(V,M)    do { V = sint4korr(M); } while(0)
721
 
#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
722
 
#define shortstore(T,V) int2store(T,V)
723
 
#define longstore(T,V)  int4store(T,V)
724
 
#ifndef floatstore
725
 
#define floatstore(T,V)   memcpy((T), (&V), sizeof(float))
726
 
#define floatget(V,M)     memcpy(&V, (M), sizeof(float))
727
 
#endif
728
 
#ifndef doubleget
729
 
#define doubleget(V, M)   memcpy(&V, (M), sizeof(double))
730
 
#define doublestore(T,V)  memcpy((T), &V, sizeof(double))
731
 
#endif /* doubleget */
732
 
#define int64_tget(V,M)   memcpy(&V, (M), sizeof(uint64_t))
733
 
#define int64_tstore(T,V) memcpy((T), &V, sizeof(uint64_t))
734
 
 
735
 
#endif /* WORDS_BIGENDIAN */
736
 
 
737
 
 
738
 
#ifdef __cplusplus
739
 
}
740
 
#endif
741
 
 
742
 
#define NULL_LENGTH UINT32_MAX /* For net_store_length */
743
 
#define DRIZZLE_STMT_HEADER       4
744
 
#define DRIZZLE_LONG_DATA_HEADER  6
745
 
 
746
355
#endif