~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/common.h

  • Committer: Brian Aker
  • Date: 2010-05-27 01:25:56 UTC
  • mfrom: (1567.1.4 new-staging)
  • Revision ID: brian@gaz-20100527012556-5zgkirkl7swbigd6
Merge of Brian, Paul. PBXT compile issue, and test framework cleanup. 

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
 
 *  Copyright (C) 2008 MySQL
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2 of the License, or
9
 
 *  (at your option) any later version.
 
8
 *  the Free Software Foundation; version 2 of the License.
10
9
 *
11
10
 *  This program is distributed in the hope that it will be useful,
12
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
21
** Common definition between mysql server & client
23
22
*/
24
23
 
25
 
#ifndef _libdrizzle_drizzle_com_h
26
 
#define _libdrizzle_drizzle_com_h
 
24
#ifndef DRIZZLED_COMMON_H
 
25
#define DRIZZLED_COMMON_H
 
26
 
 
27
#include <unistd.h>
 
28
#include <stdint.h>
 
29
#include <drizzled/korr.h>
27
30
 
28
31
/*
29
32
   This is included in the server and in the client.
35
38
   values, or it will break replication between version.
36
39
 
37
40
   context is encoded as following:
38
 
   SELECT - SELECT_LEX_NODE::options
 
41
   SELECT - Select_Lex_Node::options
39
42
   THD    - THD::options
40
43
   intern - neither. used only as
41
44
            func(..., select_node->options | thd->options | OPTION_XXX, ...)
43
46
   TODO: separate three contexts above, move them to separate bitfields.
44
47
*/
45
48
 
46
 
#define SELECT_DISTINCT         (1ULL << 0)     // SELECT, user
47
 
#define SELECT_STRAIGHT_JOIN    (1ULL << 1)     // SELECT, user
48
 
#define SELECT_DESCRIBE         (1ULL << 2)     // SELECT, user
49
 
#define SELECT_SMALL_RESULT     (1ULL << 3)     // SELECT, user
50
 
#define SELECT_BIG_RESULT       (1ULL << 4)     // SELECT, user
51
 
#define OPTION_FOUND_ROWS       (1ULL << 5)     // SELECT, user
52
 
#define SELECT_NO_JOIN_CACHE    (1ULL << 7)     // intern
53
 
#define OPTION_BIG_TABLES       (1ULL << 8)     // THD, user
54
 
#define OPTION_BIG_SELECTS      (1ULL << 9)     // THD, user
55
 
#define OPTION_LOG_OFF          (1ULL << 10)    // THD, user
56
 
#define OPTION_QUOTE_SHOW_CREATE (1ULL << 11)   // THD, user, unused
57
 
#define TMP_TABLE_ALL_COLUMNS   (1ULL << 12)    // SELECT, intern
58
 
#define OPTION_WARNINGS         (1ULL << 13)    // THD, user
59
 
#define OPTION_AUTO_IS_NULL     (1ULL << 14)    // THD, user, binlog
60
 
#define OPTION_FOUND_COMMENT    (1ULL << 15)    // SELECT, intern, parser
61
 
#define OPTION_SAFE_UPDATES     (1ULL << 16)    // THD, user
62
 
#define OPTION_BUFFER_RESULT    (1ULL << 17)    // SELECT, user
63
 
#define OPTION_BIN_LOG          (1ULL << 18)    // THD, user
64
 
#define OPTION_NOT_AUTOCOMMIT   (1ULL << 19)    // THD, user
65
 
#define OPTION_BEGIN            (1ULL << 20)    // THD, intern
66
 
#define OPTION_TABLE_LOCK       (1ULL << 21)    // THD, intern
67
 
#define OPTION_QUICK            (1ULL << 22)    // SELECT (for DELETE)
68
 
#define OPTION_KEEP_LOG         (1ULL << 23)    // THD, user
 
49
#define SELECT_DISTINCT         (UINT64_C(1) << 0)     // SELECT, user
 
50
#define SELECT_STRAIGHT_JOIN    (UINT64_C(1) << 1)     // SELECT, user
 
51
#define SELECT_DESCRIBE         (UINT64_C(1) << 2)     // SELECT, user
 
52
#define SELECT_SMALL_RESULT     (UINT64_C(1) << 3)     // SELECT, user
 
53
#define SELECT_BIG_RESULT       (UINT64_C(1) << 4)     // SELECT, user
 
54
#define OPTION_FOUND_ROWS       (UINT64_C(1) << 5)     // SELECT, user
 
55
#define SELECT_NO_JOIN_CACHE    (UINT64_C(1) << 7)     // intern
 
56
#define OPTION_BIG_TABLES       (UINT64_C(1) << 8)     // THD, user
 
57
#define OPTION_BIG_SELECTS      (UINT64_C(1) << 9)     // THD, user
 
58
#define TMP_TABLE_ALL_COLUMNS   (UINT64_C(1) << 12)    // SELECT, intern
 
59
#define OPTION_WARNINGS         (UINT64_C(1) << 13)    // THD, user
 
60
#define OPTION_AUTO_IS_NULL     (UINT64_C(1) << 14)    // THD, user, binlog
 
61
#define OPTION_FOUND_COMMENT    (UINT64_C(1) << 15)    // SELECT, intern, parser
 
62
#define OPTION_BUFFER_RESULT    (UINT64_C(1) << 17)    // SELECT, user
 
63
#define OPTION_NOT_AUTOCOMMIT   (UINT64_C(1) << 19)    // THD, user
 
64
#define OPTION_BEGIN            (UINT64_C(1) << 20)    // THD, intern
69
65
 
70
66
/* The following is used to detect a conflict with DISTINCT */
71
 
#define SELECT_ALL              (1ULL << 24)    // SELECT, user, parser
 
67
#define SELECT_ALL              (UINT64_C(1) << 24)    // SELECT, user, parser
72
68
 
73
69
/** The following can be set when importing tables in a 'wrong order'
74
70
   to suppress foreign key checks */
75
 
#define OPTION_NO_FOREIGN_KEY_CHECKS    (1ULL << 26) // THD, user, binlog
 
71
#define OPTION_NO_FOREIGN_KEY_CHECKS    (UINT64_C(1) << 26) // THD, user, binlog
76
72
/** The following speeds up inserts to InnoDB tables by suppressing unique
77
73
   key checks in some cases */
78
 
#define OPTION_RELAXED_UNIQUE_CHECKS    (1ULL << 27) // THD, user, binlog
79
 
#define SELECT_NO_UNLOCK                (1ULL << 28) // SELECT, intern
80
 
#define OPTION_SCHEMA_TABLE             (1ULL << 29) // SELECT, intern
 
74
#define OPTION_RELAXED_UNIQUE_CHECKS    (UINT64_C(1) << 27) // THD, user, binlog
 
75
#define SELECT_NO_UNLOCK                (UINT64_C(1) << 28) // SELECT, intern
81
76
/** Flag set if setup_tables already done */
82
 
#define OPTION_SETUP_TABLES_DONE        (1ULL << 30) // intern
 
77
#define OPTION_SETUP_TABLES_DONE        (UINT64_C(1) << 30) // intern
83
78
/** If not set then the thread will ignore all warnings with level notes. */
84
 
#define OPTION_SQL_NOTES                (1ULL << 31) // THD, user
85
 
/**
86
 
  Force the used temporary table to be a MyISAM table (because we will use
87
 
  fulltext functions when reading from it.
88
 
*/
89
 
#define TMP_TABLE_FORCE_MYISAM          (1ULL << 32)
90
 
#define OPTION_PROFILING                (1ULL << 33)
91
 
 
92
 
/*
93
 
  Dont report errors for individual rows,
94
 
  But just report error on commit (or read ofcourse)
95
 
*/
96
 
#define OPTION_ALLOW_BATCH              (1ULL << 33) // THD, intern (slave)
 
79
#define OPTION_SQL_NOTES                (UINT64_C(1) << 31) // THD, user
97
80
 
98
81
/**
99
82
  Maximum length of time zone name that we support
103
86
 
104
87
#define HOSTNAME_LENGTH 60
105
88
#define SYSTEM_CHARSET_MBMAXLEN 4
 
89
#define USERNAME_CHAR_LENGTH 16
106
90
#define NAME_CHAR_LEN   64              /* Field/table name length */
107
 
#define USERNAME_CHAR_LENGTH 16
108
91
#define NAME_LEN                (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
 
92
#define MAXIMUM_IDENTIFIER_LENGTH NAME_LEN
109
93
#define USERNAME_LENGTH         (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
110
94
 
111
95
#define SERVER_VERSION_LENGTH 60
112
96
#define SQLSTATE_LENGTH 5
113
97
 
114
98
/*
115
 
  Maximum length of comments
116
 
*/
117
 
#define TABLE_COMMENT_MAXLEN 2048
118
 
#define COLUMN_COMMENT_MAXLEN 1024
119
 
#define INDEX_COMMENT_MAXLEN 1024
120
 
 
121
 
 
122
 
/*
123
99
  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
124
100
  username and hostname parts of the user identifier with trailing zero in
125
101
  MySQL standard format:
127
103
*/
128
104
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
129
105
 
130
 
#define LOCAL_HOST      "localhost"
131
 
#define LOCAL_HOST_NAMEDPIPE "."
132
 
 
133
106
/*
134
107
  You should add new commands to the end of this list, otherwise old
135
108
  servers won't be able to handle them as 'unsupported'.
136
109
*/
137
110
 
138
 
enum enum_server_command
139
 
{
140
 
  COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
141
 
  COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN,
142
 
  COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_PING,
143
 
  COM_TIME, COM_CHANGE_USER, COM_BINLOG_DUMP,
144
 
  COM_CONNECT_OUT, COM_REGISTER_SLAVE,
145
 
  COM_SET_OPTION, COM_DAEMON,
146
 
  /* don't forget to update const char *command_name[] in sql_parse.cc */
147
 
 
148
 
  /* Must be last */
149
 
  COM_END
150
 
};
151
 
 
152
 
 
153
111
/*
154
112
  Length of random string sent by server on handshake; this is also length of
155
113
  obfuscated password, recieved from client
156
114
*/
157
115
#define SCRAMBLE_LENGTH 20
158
116
#define SCRAMBLE_LENGTH_323 8
159
 
/* length of password stored in the db: new passwords are preceeded with '*' */
160
 
#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1)
161
 
#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
162
 
 
163
117
 
164
118
#define NOT_NULL_FLAG   1               /* Field can't be NULL */
165
119
#define PRI_KEY_FLAG    2               /* Field is part of a primary key */
167
121
#define MULTIPLE_KEY_FLAG 8             /* Field is part of a key */
168
122
#define BLOB_FLAG       16              /* Field is a blob */
169
123
#define UNSIGNED_FLAG   32              /* Field is unsigned */
170
 
#define DECIMAL_FLAG    64              /* Field is zerofill */
171
124
#define BINARY_FLAG     128             /* Field is binary   */
172
125
 
173
126
/* The following are only sent to new clients */
174
127
#define ENUM_FLAG       256             /* field is an enum */
175
128
#define AUTO_INCREMENT_FLAG 512         /* field is a autoincrement field */
176
129
#define TIMESTAMP_FLAG  1024            /* Field is a timestamp */
177
 
#define SET_FLAG        2048            /* field is a set */
178
130
#define NO_DEFAULT_VALUE_FLAG 4096      /* Field doesn't have default value */
179
131
#define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
180
 
#define NUM_FLAG        32768           /* Field is num (for clients) */
181
132
#define PART_KEY_FLAG   16384           /* Intern; Part of some key */
182
133
#define GROUP_FLAG      32768           /* Intern: Group field */
183
134
#define UNIQUE_FLAG     65536           /* Intern: Used by sql_yacc */
184
135
#define BINCMP_FLAG     131072          /* Intern: Used by sql_yacc */
185
 
#define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
186
 
#define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
187
 
#define FIELD_IN_ADD_INDEX (1<< 20)     /* Intern: Field used in ADD INDEX */
188
 
#define FIELD_IS_RENAMED (1<< 21)       /* Intern: Field is being renamed */
189
 
#define FIELD_STORAGE_FLAGS 22          /* Storage type: bit 22, 23 and 24 */
190
136
#define COLUMN_FORMAT_FLAGS 25          /* Column format: bit 25, 26 and 27 */
191
 
 
192
 
#define REFRESH_GRANT           1       /* Refresh grant tables */
193
 
#define REFRESH_LOG             2       /* Start on new log file */
194
 
#define REFRESH_TABLES          4       /* close all tables */
195
 
#define REFRESH_HOSTS           8       /* Flush host cache */
196
 
#define REFRESH_STATUS          16      /* Flush status variables */
197
 
#define REFRESH_THREADS         32      /* Flush thread cache */
198
 
#define REFRESH_SLAVE           64      /* Reset master info and restart slave
199
 
                                           thread */
200
 
#define REFRESH_MASTER          128     /* Remove all bin logs in the index
201
 
                                           and truncate the index */
202
 
 
203
 
/* The following can't be set with mysql_refresh() */
204
 
#define REFRESH_READ_LOCK       16384   /* Lock tables for read */
205
 
#define REFRESH_FAST            32768   /* Intern flag */
206
 
 
207
 
/* RESET (remove all queries) from query cache */
208
 
#define REFRESH_QUERY_CACHE     65536
209
 
#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
210
 
#define REFRESH_DES_KEY_FILE    0x40000L
211
 
#define REFRESH_USER_RESOURCES  0x80000L
212
 
 
213
 
#define CLIENT_LONG_PASSWORD    1       /* new more secure passwords */
214
 
#define CLIENT_FOUND_ROWS       2       /* Found instead of affected rows */
215
 
#define CLIENT_LONG_FLAG        4       /* Get all column flags */
216
 
#define CLIENT_CONNECT_WITH_DB  8       /* One can specify db on connect */
217
 
#define CLIENT_NO_SCHEMA        16      /* Don't allow database.table.column */
218
 
#define CLIENT_COMPRESS         32      /* Can use compression protocol */
219
 
#define CLIENT_ODBC             64      /* Odbc client */
220
 
#define CLIENT_LOCAL_FILES      128     /* Can use LOAD DATA LOCAL */
221
 
#define CLIENT_IGNORE_SPACE     256     /* Ignore spaces before '(' */
222
 
#define UNUSED_CLIENT_PROTOCOL_41       512     /* New 4.1 protocol */
223
 
#define CLIENT_INTERACTIVE      1024    /* This is an interactive client */
224
 
#define CLIENT_SSL              2048    /* Switch to SSL after handshake */
225
 
#define CLIENT_IGNORE_SIGPIPE   4096    /* IGNORE sigpipes */
226
 
#define CLIENT_TRANSACTIONS     8192    /* Client knows about transactions */
227
 
#define CLIENT_RESERVED         16384   /* Old flag for 4.1 protocol  */
228
 
#define CLIENT_SECURE_CONNECTION 32768  /* New 4.1 authentication */
229
 
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
230
 
#define CLIENT_MULTI_RESULTS    (1UL << 17) /* Enable/disable multi-results */
231
 
 
232
 
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
233
 
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
234
 
 
235
 
/* Gather all possible capabilites (flags) supported by the server */
236
 
#define CLIENT_ALL_FLAGS  (CLIENT_LONG_PASSWORD | \
237
 
                           CLIENT_FOUND_ROWS | \
238
 
                           CLIENT_LONG_FLAG | \
239
 
                           CLIENT_CONNECT_WITH_DB | \
240
 
                           CLIENT_NO_SCHEMA | \
241
 
                           CLIENT_COMPRESS | \
242
 
                           CLIENT_ODBC | \
243
 
                           CLIENT_LOCAL_FILES | \
244
 
                           CLIENT_IGNORE_SPACE | \
245
 
                           CLIENT_INTERACTIVE | \
246
 
                           CLIENT_SSL | \
247
 
                           CLIENT_IGNORE_SIGPIPE | \
248
 
                           CLIENT_TRANSACTIONS | \
249
 
                           CLIENT_RESERVED | \
250
 
                           CLIENT_SECURE_CONNECTION | \
251
 
                           CLIENT_MULTI_STATEMENTS | \
252
 
                           CLIENT_MULTI_RESULTS | \
253
 
                           CLIENT_SSL_VERIFY_SERVER_CERT | \
254
 
                           CLIENT_REMEMBER_OPTIONS)
255
 
 
256
 
/*
257
 
  Switch off the flags that are optional and depending on build flags
258
 
  If any of the optional flags is supported by the build it will be switched
259
 
  on before sending to the client during the connection handshake.
260
 
*/
261
 
#define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
262
 
                                               & ~CLIENT_COMPRESS) \
263
 
                                               & ~CLIENT_SSL_VERIFY_SERVER_CERT)
 
137
#define COLUMN_FORMAT_MASK 7
264
138
 
265
139
#define SERVER_STATUS_IN_TRANS     1    /* Transaction has started */
266
140
#define SERVER_STATUS_AUTOCOMMIT   2    /* Server in auto_commit mode */
267
141
#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
268
142
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
269
143
#define SERVER_QUERY_NO_INDEX_USED      32
270
 
/*
271
 
  The server was able to fulfill the clients request and opened a
272
 
  read-only non-scrollable cursor for a query. This flag comes
273
 
  in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
274
 
*/
275
 
#define SERVER_STATUS_CURSOR_EXISTS 64
276
 
/*
277
 
  This flag is sent when a read-only cursor is exhausted, in reply to
278
 
  COM_STMT_FETCH command.
279
 
*/
280
 
#define SERVER_STATUS_LAST_ROW_SENT 128
281
144
#define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
282
 
#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
283
 
/*
284
 
  Tell clients that this query was logged to the slow query log.
285
 
  Not yet set in the server, but interface is defined for applications
286
 
  to use.  See WorkLog 4098.
287
 
*/
288
 
#define SERVER_QUERY_WAS_SLOW           1024
289
145
 
290
146
#define DRIZZLE_ERRMSG_SIZE     512
291
 
#define NET_READ_TIMEOUT        30              /* Timeout on read */
292
 
#define NET_WRITE_TIMEOUT       60              /* Timeout on write */
293
 
#define NET_WAIT_TIMEOUT        8*60*60         /* Wait for new query */
294
147
 
295
148
#define ONLY_KILL_QUERY         1
296
149
 
297
 
struct st_vio;                                  /* Only C */
298
 
typedef struct st_vio Vio;
299
 
 
300
 
#define MAX_TINYINT_WIDTH       3       /* Max width for a TINY w.o. sign */
301
 
#define MAX_SMALLINT_WIDTH      5       /* Max width for a SHORT w.o. sign */
302
 
#define MAX_MEDIUMINT_WIDTH     8       /* Max width for a INT24 w.o. sign */
303
150
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
304
151
#define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
305
 
#define MAX_CHAR_WIDTH          255     /* Max length for a CHAR colum */
306
 
#define MAX_BLOB_WIDTH          16777216        /* Default width for blob */
 
152
#define MAX_BLOB_WIDTH          (uint32_t)16777216      /* Default width for blob */
307
153
 
308
154
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
309
155
 
310
156
 
311
 
typedef struct st_net {
312
 
  Vio *vio;
313
 
  unsigned char *buff,*buff_end,*write_pos,*read_pos;
314
 
  int fd;                                       /* For Perl DBI/dbd */
315
 
  /*
316
 
    The following variable is set if we are doing several queries in one
317
 
    command ( as in LOAD TABLE ... FROM MASTER ),
318
 
    and do not want to confuse the client with OK at the wrong time
319
 
  */
320
 
  unsigned long remain_in_buf,length, buf_length, where_b;
321
 
  unsigned long max_packet,max_packet_size;
322
 
  unsigned int pkt_nr,compress_pkt_nr;
323
 
  unsigned int write_timeout;
324
 
  unsigned int read_timeout;
325
 
  unsigned int retry_count;
326
 
  int fcntl;
327
 
  unsigned int *return_status;
328
 
  unsigned char reading_or_writing;
329
 
  char save_char;
330
 
  bool compress;
331
 
  /*
332
 
    Pointer to query object in query cache, do not equal NULL (0) for
333
 
    queries in cache that have not stored its results yet
334
 
  */
335
 
  /*
336
 
    Unused, please remove with the next incompatible ABI change.
337
 
  */
338
 
  unsigned char *unused;
339
 
  unsigned int last_errno;
340
 
  unsigned char error; 
341
 
  /** Client library error message buffer. Actually belongs to struct MYSQL. */
342
 
  char last_error[DRIZZLE_ERRMSG_SIZE];
343
 
  /** Client library sqlstate buffer. Set along with the error message. */
344
 
  char sqlstate[SQLSTATE_LENGTH+1];
345
 
  void *extension;
346
 
} NET;
347
157
 
348
158
 
349
159
#define packet_error (~(uint32_t) 0)
350
160
 
351
 
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
352
 
enum enum_field_types { DRIZZLE_TYPE_TINY=1,
353
 
                        DRIZZLE_TYPE_SHORT,  DRIZZLE_TYPE_LONG,
354
 
                        DRIZZLE_TYPE_DOUBLE,
355
 
                        DRIZZLE_TYPE_NULL,   DRIZZLE_TYPE_TIMESTAMP,
356
 
                        DRIZZLE_TYPE_LONGLONG,
357
 
                        DRIZZLE_TYPE_DATE,   DRIZZLE_TYPE_TIME,
358
 
                        DRIZZLE_TYPE_DATETIME,
359
 
                        DRIZZLE_TYPE_NEWDATE, DRIZZLE_TYPE_VARCHAR,
360
 
      DRIZZLE_TYPE_NEWDECIMAL=253,
361
 
                        DRIZZLE_TYPE_ENUM=254,
362
 
                        DRIZZLE_TYPE_BLOB=255
363
 
};
364
 
 
365
 
 
366
 
/* Shutdown/kill enums and constants */ 
367
 
 
368
 
/* Bits for THD::killable. */
369
 
#define DRIZZLE_SHUTDOWN_KILLABLE_CONNECT    (unsigned char)(1 << 0)
370
 
#define DRIZZLE_SHUTDOWN_KILLABLE_TRANS      (unsigned char)(1 << 1)
371
 
#define DRIZZLE_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
372
 
#define DRIZZLE_SHUTDOWN_KILLABLE_UPDATE     (unsigned char)(1 << 3)
373
 
 
374
 
enum drizzle_enum_shutdown_level {
375
 
  /*
376
 
    We want levels to be in growing order of hardness (because we use number
377
 
    comparisons). Note that DEFAULT does not respect the growing property, but
378
 
    it's ok.
379
 
  */
380
 
  SHUTDOWN_DEFAULT = 0,
381
 
  /* wait for existing connections to finish */
382
 
  SHUTDOWN_WAIT_CONNECTIONS= DRIZZLE_SHUTDOWN_KILLABLE_CONNECT,
383
 
  /* wait for existing trans to finish */
384
 
  SHUTDOWN_WAIT_TRANSACTIONS= DRIZZLE_SHUTDOWN_KILLABLE_TRANS,
385
 
  /* wait for existing updates to finish (=> no partial MyISAM update) */
386
 
  SHUTDOWN_WAIT_UPDATES= DRIZZLE_SHUTDOWN_KILLABLE_UPDATE,
387
 
  /* flush InnoDB buffers and other storage engines' buffers*/
388
 
  SHUTDOWN_WAIT_ALL_BUFFERS= (DRIZZLE_SHUTDOWN_KILLABLE_UPDATE << 1),
389
 
  /* don't flush InnoDB buffers, flush other storage engines' buffers*/
390
 
  SHUTDOWN_WAIT_CRITICAL_BUFFERS= (DRIZZLE_SHUTDOWN_KILLABLE_UPDATE << 1) + 1,
391
 
  /* Now the 2 levels of the KILL command */
392
 
  KILL_QUERY= 254,
393
 
  KILL_CONNECTION= 255
394
 
};
395
 
 
396
 
 
397
 
enum enum_cursor_type
398
 
{
399
 
  CURSOR_TYPE_NO_CURSOR= 0,
400
 
  CURSOR_TYPE_READ_ONLY= 1,
401
 
  CURSOR_TYPE_FOR_UPDATE= 2,
402
 
  CURSOR_TYPE_SCROLLABLE= 4
403
 
};
404
 
 
405
 
 
406
 
/* options for mysql_set_option */
407
 
enum enum_drizzle_set_option
408
 
{
409
 
  DRIZZLE_OPTION_MULTI_STATEMENTS_ON,
410
 
  DRIZZLE_OPTION_MULTI_STATEMENTS_OFF
411
 
};
412
 
 
413
 
#define net_new_transaction(net) ((net)->pkt_nr=0)
414
 
 
415
 
#ifdef __cplusplus
416
 
extern "C" {
417
 
#endif
418
 
 
419
 
bool    my_net_init(NET *net, Vio* vio);
420
 
void    my_net_local_init(NET *net);
421
 
void    net_end(NET *net);
422
 
void    net_clear(NET *net, bool clear_buffer);
423
 
bool    net_realloc(NET *net, size_t length);
424
 
bool    net_flush(NET *net);
425
 
bool    my_net_write(NET *net,const unsigned char *packet, size_t len);
426
 
bool    net_write_command(NET *net,unsigned char command,
427
 
                          const unsigned char *header, size_t head_len,
428
 
                          const unsigned char *packet, size_t len);
429
 
int32_t net_real_write(NET *net,const unsigned char *packet, size_t len);
430
 
uint32_t my_net_read(NET *net);
431
 
 
432
 
 
433
 
/** @TODO global.h is actually not needed here... only stdint and protocol.h */
434
 
#ifdef DRIZZLE_SERVER_GLOBAL_H
435
 
void my_net_set_write_timeout(NET *net, uint timeout);
436
 
void my_net_set_read_timeout(NET *net, uint timeout);
437
 
#endif
438
 
 
439
 
struct rand_struct {
440
 
  unsigned long seed1,seed2,max_value;
441
 
  double max_value_dbl;
442
 
};
443
 
 
444
 
#ifdef __cplusplus
445
 
}
446
 
#endif
447
 
 
448
 
  /* The following is for user defined functions */
449
 
 
450
 
enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
451
 
                  DECIMAL_RESULT};
452
 
 
453
 
typedef struct st_udf_args
454
 
{
455
 
  unsigned int arg_count;               /* Number of arguments */
456
 
  enum Item_result *arg_type;           /* Pointer to item_results */
457
 
  char **args;                          /* Pointer to argument */
458
 
  unsigned long *lengths;               /* Length of string arguments */
459
 
  char *maybe_null;                     /* Set to 1 for all maybe_null args */
460
 
  char **attributes;                    /* Pointer to attribute name */
461
 
  unsigned long *attribute_lengths;     /* Length of attribute arguments */
462
 
  void *extension;
463
 
} UDF_ARGS;
464
 
 
465
 
  /* This holds information about the result */
466
 
 
467
 
typedef struct st_udf_init
468
 
{
469
 
  bool maybe_null;          /* 1 if function can return NULL */
470
 
  unsigned int decimals;       /* for real functions */
471
 
  unsigned long max_length;    /* For string functions */
472
 
  char *ptr;                   /* free pointer for function data */
473
 
  bool const_item;          /* 1 if function always returns the same value */
474
 
  void *extension;
475
 
} UDF_INIT;
476
 
/* 
477
 
  TODO: add a notion for determinism of the UDF. 
478
 
  See Item_udf_func::update_used_tables ()
479
 
*/
480
 
 
481
 
  /* Constants when using compression */
482
 
#define NET_HEADER_SIZE 4               /* standard header size */
483
 
#define COMP_HEADER_SIZE 3              /* compression header extra size */
484
 
 
485
 
  /* Prototypes to password functions */
486
 
 
487
 
#ifdef __cplusplus
488
 
extern "C" {
489
 
#endif
490
 
 
491
 
/*
492
 
  These functions are used for authentication by client and server and
493
 
  implemented in sql/password.c
494
 
*/
495
 
 
496
 
void randominit(struct rand_struct *, uint32_t seed1, uint32_t seed2);
497
 
double my_rnd(struct rand_struct *);
498
 
void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st);
499
 
 
500
 
void hash_password(uint32_t *to, const char *password, uint32_t password_len);
501
 
 
502
 
void make_scrambled_password(char *to, const char *password);
503
 
void scramble(char *to, const char *message, const char *password);
504
 
bool check_scramble(const char *reply, const char *message,
505
 
                       const unsigned char *hash_stage2);
506
 
void get_salt_from_password(unsigned char *res, const char *password);
507
 
void make_password_from_salt(char *to, const unsigned char *hash_stage2);
508
 
char *octet2hex(char *to, const char *str, unsigned int len);
509
 
 
510
 
/* end of password.c */
511
 
 
512
 
char *get_tty_password(const char *opt_message);
513
 
const char *drizzle_errno_to_sqlstate(unsigned int drizzle_errno);
514
 
 
515
 
/** @TODO Is it necessary to include all of drizzled/global.h here? */
516
 
#ifdef DRIZZLE_SERVER_GLOBAL_H
517
 
uint32_t net_field_length(uchar **packet);
518
 
uint64_t net_field_length_ll(uchar **packet);
519
 
uchar *net_store_length(uchar *pkg, uint64_t length);
520
 
#endif
521
 
 
522
 
#ifdef __cplusplus
523
 
}
524
 
#endif
525
 
 
526
 
#define NULL_LENGTH UINT32_MAX /* For net_store_length */
527
 
#define DRIZZLE_STMT_HEADER       4
528
 
#define DRIZZLE_LONG_DATA_HEADER  6
529
 
 
530
 
#endif
 
161
#if defined(__cplusplus)
 
162
 
 
163
namespace drizzled
 
164
{
 
165
 
 
166
enum enum_server_command
 
167
{
 
168
  COM_SLEEP,
 
169
  COM_QUIT,
 
170
  COM_INIT_DB,
 
171
  COM_QUERY,
 
172
  COM_SHUTDOWN,
 
173
  COM_CONNECT,
 
174
  COM_PING,
 
175
  /* don't forget to update const char *command_name[] in sql_parse.cc */
 
176
  /* Must be last */
 
177
  COM_END
 
178
};
 
179
 
 
180
 
 
181
enum enum_field_types { DRIZZLE_TYPE_LONG,
 
182
                        DRIZZLE_TYPE_DOUBLE,
 
183
                        DRIZZLE_TYPE_NULL,
 
184
                        DRIZZLE_TYPE_TIMESTAMP,
 
185
                        DRIZZLE_TYPE_LONGLONG,
 
186
                        DRIZZLE_TYPE_DATETIME,
 
187
                        DRIZZLE_TYPE_DATE,
 
188
                        DRIZZLE_TYPE_VARCHAR,
 
189
                        DRIZZLE_TYPE_DECIMAL,
 
190
                        DRIZZLE_TYPE_ENUM,
 
191
                        DRIZZLE_TYPE_BLOB,
 
192
                        DRIZZLE_TYPE_MAX=DRIZZLE_TYPE_BLOB
 
193
};
 
194
 
 
195
} /* namespace drizzled */
 
196
 
 
197
#endif /* defined(__cplusplus) */
 
198
 
 
199
#endif /* DRIZZLED_COMMON_H */