~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/common.h

  • Committer: Brian Aker
  • Date: 2009-06-03 19:30:45 UTC
  • mfrom: (1046.1.6 merge)
  • Revision ID: brian@gaz-20090603193045-4xgeczyfixh07beg
MergeĀ forĀ Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
** Common definition between mysql server & client
22
22
*/
23
23
 
24
 
#ifndef DRIZZLED_COMMON_H
25
 
#define DRIZZLED_COMMON_H
 
24
#ifndef DRIZZLED_DRIZZLE_COMMON_H
 
25
#define DRIZZLED_DRIZZLE_COMMON_H
26
26
 
27
27
#include <unistd.h>
28
28
#include <stdint.h>
55
55
#define SELECT_NO_JOIN_CACHE    (UINT64_C(1) << 7)     // intern
56
56
#define OPTION_BIG_TABLES       (UINT64_C(1) << 8)     // THD, user
57
57
#define OPTION_BIG_SELECTS      (UINT64_C(1) << 9)     // THD, user
 
58
#define OPTION_LOG_OFF          (UINT64_C(1) << 10)    // THD, user
58
59
#define TMP_TABLE_ALL_COLUMNS   (UINT64_C(1) << 12)    // SELECT, intern
59
60
#define OPTION_WARNINGS         (UINT64_C(1) << 13)    // THD, user
60
61
#define OPTION_AUTO_IS_NULL     (UINT64_C(1) << 14)    // THD, user, binlog
61
62
#define OPTION_FOUND_COMMENT    (UINT64_C(1) << 15)    // SELECT, intern, parser
 
63
#define OPTION_SAFE_UPDATES     (UINT64_C(1) << 16)    // THD, user
62
64
#define OPTION_BUFFER_RESULT    (UINT64_C(1) << 17)    // SELECT, user
63
65
#define OPTION_NOT_AUTOCOMMIT   (UINT64_C(1) << 19)    // THD, user
64
66
#define OPTION_BEGIN            (UINT64_C(1) << 20)    // THD, intern
 
67
#define OPTION_TABLE_LOCK       (UINT64_C(1) << 21)    // THD, intern
 
68
#define OPTION_QUICK            (UINT64_C(1) << 22)    // SELECT (for DELETE)
 
69
#define OPTION_KEEP_LOG         (UINT64_C(1) << 23)    // THD, user
65
70
 
66
71
/* The following is used to detect a conflict with DISTINCT */
67
72
#define SELECT_ALL              (UINT64_C(1) << 24)    // SELECT, user, parser
73
78
   key checks in some cases */
74
79
#define OPTION_RELAXED_UNIQUE_CHECKS    (UINT64_C(1) << 27) // THD, user, binlog
75
80
#define SELECT_NO_UNLOCK                (UINT64_C(1) << 28) // SELECT, intern
 
81
#define OPTION_SCHEMA_TABLE             (UINT64_C(1) << 29) // SELECT, intern
76
82
/** Flag set if setup_tables already done */
77
83
#define OPTION_SETUP_TABLES_DONE        (UINT64_C(1) << 30) // intern
78
84
/** If not set then the thread will ignore all warnings with level notes. */
79
85
#define OPTION_SQL_NOTES                (UINT64_C(1) << 31) // THD, user
 
86
/**
 
87
  Force the used temporary table to be a MyISAM table (because we will use
 
88
  fulltext functions when reading from it.
 
89
*/
 
90
#define TMP_TABLE_FORCE_MYISAM          (UINT64_C(1) << 32)
 
91
#define OPTION_PROFILING                (UINT64_C(1) << 33)
 
92
 
 
93
/*
 
94
  Dont report errors for individual rows,
 
95
  But just report error on commit (or read ofcourse)
 
96
*/
 
97
#define OPTION_ALLOW_BATCH              (UINT64_C(1) << 33) // THD, intern (slave)
80
98
 
81
99
/**
82
100
  Maximum length of time zone name that we support
89
107
#define USERNAME_CHAR_LENGTH 16
90
108
#define NAME_CHAR_LEN   64              /* Field/table name length */
91
109
#define NAME_LEN                (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
92
 
#define MAXIMUM_IDENTIFIER_LENGTH NAME_LEN
93
110
#define USERNAME_LENGTH         (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
94
111
 
95
112
#define SERVER_VERSION_LENGTH 60
96
113
#define SQLSTATE_LENGTH 5
97
114
 
98
115
/*
 
116
  Maximum length of comments
 
117
*/
 
118
#define TABLE_COMMENT_MAXLEN 2048
 
119
#define COLUMN_COMMENT_MAXLEN 1024
 
120
#define INDEX_COMMENT_MAXLEN 1024
 
121
 
 
122
/*
99
123
  USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain
100
124
  username and hostname parts of the user identifier with trailing zero in
101
125
  MySQL standard format:
103
127
*/
104
128
#define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2
105
129
 
 
130
#define LOCAL_HOST      "localhost"
 
131
#define LOCAL_HOST_NAMEDPIPE "."
 
132
 
106
133
/*
107
134
  You should add new commands to the end of this list, otherwise old
108
135
  servers won't be able to handle them as 'unsupported'.
109
136
*/
110
137
 
 
138
enum enum_server_command
 
139
{
 
140
  COM_SLEEP,
 
141
  COM_QUIT,
 
142
  COM_INIT_DB,
 
143
  COM_QUERY,
 
144
  COM_SHUTDOWN,
 
145
  COM_CONNECT,
 
146
  COM_PING,
 
147
  /* don't forget to update const char *command_name[] in sql_parse.cc */
 
148
  /* Must be last */
 
149
  COM_END
 
150
};
 
151
 
 
152
 
111
153
/*
112
154
  Length of random string sent by server on handshake; this is also length of
113
155
  obfuscated password, recieved from client
114
156
*/
115
157
#define SCRAMBLE_LENGTH 20
116
158
#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
 
117
163
 
118
164
#define NOT_NULL_FLAG   1               /* Field can't be NULL */
119
165
#define PRI_KEY_FLAG    2               /* Field is part of a primary key */
121
167
#define MULTIPLE_KEY_FLAG 8             /* Field is part of a key */
122
168
#define BLOB_FLAG       16              /* Field is a blob */
123
169
#define UNSIGNED_FLAG   32              /* Field is unsigned */
 
170
#define DECIMAL_FLAG    64              /* Field is zerofill */
124
171
#define BINARY_FLAG     128             /* Field is binary   */
125
172
 
126
173
/* The following are only sent to new clients */
127
174
#define ENUM_FLAG       256             /* field is an enum */
128
175
#define AUTO_INCREMENT_FLAG 512         /* field is a autoincrement field */
129
 
#define FUNCTION_DEFAULT_FLAG   1024            /* Field is a timestamp, uses a function to generate the value. */
 
176
#define TIMESTAMP_FLAG  1024            /* Field is a timestamp */
 
177
#define SET_FLAG        2048            /* field is a set */
130
178
#define NO_DEFAULT_VALUE_FLAG 4096      /* Field doesn't have default value */
131
179
#define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
 
180
#define NUM_FLAG        32768           /* Field is num (for clients) */
132
181
#define PART_KEY_FLAG   16384           /* Intern; Part of some key */
133
182
#define GROUP_FLAG      32768           /* Intern: Group field */
134
183
#define UNIQUE_FLAG     65536           /* Intern: Used by sql_yacc */
135
184
#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 */
136
190
#define COLUMN_FORMAT_FLAGS 25          /* Column format: bit 25, 26 and 27 */
137
 
#define COLUMN_FORMAT_MASK 7
 
191
 
 
192
#define REFRESH_LOG             2       /* Start on new log file */
 
193
#define REFRESH_TABLES          4       /* close all tables */
 
194
#define REFRESH_STATUS          16      /* Flush status variables */
 
195
 
 
196
/* The following can't be set with mysql_refresh() */
 
197
#define REFRESH_READ_LOCK       16384   /* Lock tables for read */
 
198
#define REFRESH_FAST            32768   /* Intern flag */
 
199
 
 
200
#define CLIENT_LONG_PASSWORD    1       /* new more secure passwords */
 
201
#define CLIENT_FOUND_ROWS       2       /* Found instead of affected rows */
 
202
#define CLIENT_LONG_FLAG        4       /* Get all column flags */
 
203
#define CLIENT_CONNECT_WITH_DB  8       /* One can specify db on connect */
 
204
#define CLIENT_NO_SCHEMA        16      /* Don't allow database.table.column */
 
205
#define CLIENT_COMPRESS         32      /* Can use compression protocol */
 
206
#define CLIENT_ODBC             64      /* Odbc client */
 
207
#define CLIENT_IGNORE_SPACE     256     /* Ignore spaces before '(' */
 
208
#define UNUSED_CLIENT_PROTOCOL_41       512     /* New 4.1 protocol */
 
209
#define CLIENT_SSL              2048    /* Switch to SSL after handshake */
 
210
#define CLIENT_IGNORE_SIGPIPE   4096    /* IGNORE sigpipes */
 
211
#define CLIENT_RESERVED         16384   /* Old flag for 4.1 protocol  */
 
212
#define CLIENT_SECURE_CONNECTION 32768  /* New 4.1 authentication */
 
213
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
 
214
#define CLIENT_MULTI_RESULTS    (1UL << 17) /* Enable/disable multi-results */
 
215
 
 
216
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
 
217
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
 
218
 
 
219
/* Gather all possible capabilites (flags) supported by the server */
 
220
#define CLIENT_ALL_FLAGS  (CLIENT_LONG_PASSWORD | \
 
221
                           CLIENT_FOUND_ROWS | \
 
222
                           CLIENT_LONG_FLAG | \
 
223
                           CLIENT_CONNECT_WITH_DB | \
 
224
                           CLIENT_NO_SCHEMA | \
 
225
                           CLIENT_COMPRESS | \
 
226
                           CLIENT_ODBC | \
 
227
                           CLIENT_IGNORE_SPACE | \
 
228
                           CLIENT_SSL | \
 
229
                           CLIENT_IGNORE_SIGPIPE | \
 
230
                           CLIENT_RESERVED | \
 
231
                           CLIENT_SECURE_CONNECTION | \
 
232
                           CLIENT_MULTI_STATEMENTS | \
 
233
                           CLIENT_MULTI_RESULTS | \
 
234
                           CLIENT_SSL_VERIFY_SERVER_CERT | \
 
235
                           CLIENT_REMEMBER_OPTIONS)
 
236
 
 
237
/*
 
238
  Switch off the flags that are optional and depending on build flags
 
239
  If any of the optional flags is supported by the build it will be switched
 
240
  on before sending to the client during the connection handshake.
 
241
*/
 
242
#define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
 
243
                                               & ~CLIENT_COMPRESS) \
 
244
                                               & ~CLIENT_SSL_VERIFY_SERVER_CERT)
138
245
 
139
246
#define SERVER_STATUS_IN_TRANS     1    /* Transaction has started */
140
247
#define SERVER_STATUS_AUTOCOMMIT   2    /* Server in auto_commit mode */
141
248
#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
142
249
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
143
250
#define SERVER_QUERY_NO_INDEX_USED      32
 
251
/*
 
252
  The server was able to fulfill the clients request and opened a
 
253
  read-only non-scrollable cursor for a query. This flag comes
 
254
  in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
 
255
*/
 
256
#define SERVER_STATUS_CURSOR_EXISTS 64
 
257
/*
 
258
  This flag is sent when a read-only cursor is exhausted, in reply to
 
259
  COM_STMT_FETCH command.
 
260
*/
 
261
#define SERVER_STATUS_LAST_ROW_SENT 128
144
262
#define SERVER_STATUS_DB_DROPPED        256 /* A database was dropped */
 
263
#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512
 
264
/*
 
265
  Tell clients that this query was logged to the slow query log.
 
266
  Not yet set in the server, but interface is defined for applications
 
267
  to use.  See WorkLog 4098.
 
268
*/
 
269
#define SERVER_QUERY_WAS_SLOW           1024
145
270
 
146
271
#define DRIZZLE_ERRMSG_SIZE     512
 
272
#define NET_READ_TIMEOUT        30              /* Timeout on read */
 
273
#define NET_WRITE_TIMEOUT       60              /* Timeout on write */
 
274
#define NET_WAIT_TIMEOUT        8*60*60         /* Wait for new query */
147
275
 
148
276
#define ONLY_KILL_QUERY         1
149
277
 
 
278
#define MAX_TINYINT_WIDTH       3       /* Max width for a TINY w.o. sign */
 
279
#define MAX_SMALLINT_WIDTH      5       /* Max width for a SHORT w.o. sign */
 
280
#define MAX_MEDIUMINT_WIDTH     8       /* Max width for a INT24 w.o. sign */
150
281
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
151
282
#define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
 
283
#define MAX_CHAR_WIDTH          255     /* Max length for a CHAR colum */
152
284
#define MAX_BLOB_WIDTH          (uint32_t)16777216      /* Default width for blob */
153
285
 
154
286
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
156
288
 
157
289
 
158
290
 
159
 
#define packet_error UINT32_MAX
160
 
 
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 { 
 
291
#define packet_error (~(uint32_t) 0)
 
292
 
 
293
 
 
294
/* Shutdown/kill enums and constants */
 
295
 
 
296
/* Bits for THD::killable. */
 
297
#define DRIZZLE_SHUTDOWN_KILLABLE_CONNECT    (unsigned char)(1 << 0)
 
298
#define DRIZZLE_SHUTDOWN_KILLABLE_TRANS      (unsigned char)(1 << 1)
 
299
#define DRIZZLE_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2)
 
300
#define DRIZZLE_SHUTDOWN_KILLABLE_UPDATE     (unsigned char)(1 << 3)
 
301
 
 
302
/* Start TINY at 1 because we removed DECIMAL from off the front of the enum */
 
303
enum enum_field_types { DRIZZLE_TYPE_TINY,
182
304
                        DRIZZLE_TYPE_LONG,
183
305
                        DRIZZLE_TYPE_DOUBLE,
184
306
                        DRIZZLE_TYPE_NULL,
187
309
                        DRIZZLE_TYPE_DATETIME,
188
310
                        DRIZZLE_TYPE_DATE,
189
311
                        DRIZZLE_TYPE_VARCHAR,
190
 
                        DRIZZLE_TYPE_DECIMAL,
 
312
                        DRIZZLE_TYPE_NEWDECIMAL,
191
313
                        DRIZZLE_TYPE_ENUM,
192
314
                        DRIZZLE_TYPE_BLOB,
193
 
                        DRIZZLE_TYPE_UUID
 
315
                        DRIZZLE_TYPE_MAX=DRIZZLE_TYPE_BLOB
194
316
};
195
 
const int enum_field_types_size= DRIZZLE_TYPE_UUID + 1;
196
 
 
197
 
} /* namespace drizzled */
198
 
 
199
 
#endif /* defined(__cplusplus) */
200
 
 
201
 
#endif /* DRIZZLED_COMMON_H */
 
317
 
 
318
 
 
319
  /* The following is for user defined functions */
 
320
 
 
321
enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
 
322
                  DECIMAL_RESULT};
 
323
 
 
324
typedef struct st_udf_args
 
325
{
 
326
  unsigned int arg_count;               /* Number of arguments */
 
327
  enum Item_result *arg_type;           /* Pointer to item_results */
 
328
  char **args;                          /* Pointer to argument */
 
329
  unsigned long *lengths;               /* Length of string arguments */
 
330
  char *maybe_null;                     /* Set to 1 for all maybe_null args */
 
331
  char **attributes;                    /* Pointer to attribute name */
 
332
  unsigned long *attribute_lengths;     /* Length of attribute arguments */
 
333
  void *extension;
 
334
} UDF_ARGS;
 
335
 
 
336
  /* This holds information about the result */
 
337
 
 
338
typedef struct st_udf_init
 
339
{
 
340
  bool maybe_null;          /* 1 if function can return NULL */
 
341
  unsigned int decimals;       /* for real functions */
 
342
  unsigned long max_length;    /* For string functions */
 
343
  char *ptr;                   /* free pointer for function data */
 
344
  bool const_item;          /* 1 if function always returns the same value */
 
345
  void *extension;
 
346
} UDF_INIT;
 
347
/*
 
348
  TODO: add a notion for determinism of the UDF.
 
349
  See Item_udf_func::update_used_tables ()
 
350
*/
 
351
 
 
352
  /* Constants when using compression */
 
353
#define NET_HEADER_SIZE 4               /* standard header size */
 
354
#define COMP_HEADER_SIZE 3              /* compression header extra size */
 
355
 
 
356
#endif