21
21
mysqlbinlog too (definition of SELECT_DISTINCT and others).
22
22
The consequence is that 90% of the file is wrapped in \#ifndef MYSQL_CLIENT,
23
23
except the part which must be in the server and in the client.
25
@TODO Name this file better. "priv" could mean private, privileged, privileges.
27
@TODO Get rid of the MYSQL_CLIENT and MYSQL_SERVER conditionals
26
30
#ifndef DRIZZLE_SERVER_MYSQL_PRIV_H
27
31
#define DRIZZLE_SERVER_MYSQL_PRIV_H
31
#include <drizzled/global.h>
32
#include <drizzled/version.h>
33
#include <mysys/my_sys.h>
34
#include <libdrizzle/my_time.h>
35
#include <mystrings/m_string.h>
36
#include <mysys/hash.h>
38
#include <mysys/thr_lock.h>
39
#include <drizzled/error.h>
40
#include <drizzled/base.h> /* Needed by field.h */
41
#include <mysys/queues.h>
42
#include <drizzled/sql_bitmap.h> /* Custom bitmap API */
43
#include "sql_array.h"
44
#include "sql_plugin.h"
45
#include "scheduler.h"
48
#define _DTRACE_VERSION 1
57
QT_ORDINARY -- ordinary SQL query.
58
QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
59
character set introducers).
67
/* TODO convert all these three maps to Bitmap classes */
68
typedef uint64_t table_map; /* Used for table bits in join */
70
typedef Bitmap<64> key_map; /* Used for finding keys */
72
typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
74
typedef uint32_t nesting_map; /* Used for flags of nesting constructs */
76
Used to identify NESTED_JOIN structures within a join (applicable only to
77
structures that have not been simplified away and embed more the one
80
typedef uint64_t nested_join_map;
83
typedef uint64_t query_id_t;
84
extern query_id_t global_query_id;
86
/* increment query_id and return it. */
87
inline query_id_t next_query_id() { return global_query_id++; }
89
/* useful constants */
90
extern const key_map key_map_empty;
91
extern key_map key_map_full; /* Should be threaded as const */
92
extern const char *primary_key_name;
94
#include <libdrizzle/drizzle_com.h>
95
#include <vio/violite.h>
98
#include <drizzled/sql_alloc.h>
100
#define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1))
101
#define all_bits_set(A,B) ((A) & (B) != (B))
103
extern const CHARSET_INFO *system_charset_info, *files_charset_info ;
104
extern const CHARSET_INFO *national_charset_info, *table_alias_charset;
108
DERIVATION_IGNORABLE= 5,
109
DERIVATION_COERCIBLE= 4,
110
DERIVATION_SYSCONST= 3,
111
DERIVATION_IMPLICIT= 2,
113
DERIVATION_EXPLICIT= 0
116
#include <drizzled/sql_locale.h>
117
#include <drizzled/object_creation_ctx.h>
119
Opening modes for open_temporary_table and open_table_from_share
129
/***************************************************************************
130
Configuration parameters
131
****************************************************************************/
133
#define ACL_CACHE_SIZE 256
134
#define MAX_PASSWORD_LENGTH 32
135
#define HOST_CACHE_SIZE 128
136
#define MAX_ACCEPT_RETRY 10 // Test accept this many times
137
#define MAX_FIELDS_BEFORE_HASH 32
138
#define USER_VARS_HASH_SIZE 16
139
#define TABLE_OPEN_CACHE_MIN 64
140
#define TABLE_OPEN_CACHE_DEFAULT 64
143
Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
144
Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86. (Added
145
100 bytes as reasonable buffer against growth and other environments'
148
Feel free to raise this by the smallest amount you can to get the
149
"execution_constants" test to pass.
151
#define STACK_MIN_SIZE 12000 ///< Abort if less stack during eval.
153
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
154
#define STACK_BUFF_ALLOC 352 ///< For stack overrun checks
155
#ifndef MYSQLD_NET_RETRY_COUNT
156
#define MYSQLD_NET_RETRY_COUNT 10 ///< Abort read after this many int.
158
#define TEMP_POOL_SIZE 128
160
#define QUERY_ALLOC_BLOCK_SIZE 8192
161
#define QUERY_ALLOC_PREALLOC_SIZE 8192
162
#define TRANS_ALLOC_BLOCK_SIZE 4096
163
#define TRANS_ALLOC_PREALLOC_SIZE 4096
164
#define RANGE_ALLOC_BLOCK_SIZE 4096
165
#define ACL_ALLOC_BLOCK_SIZE 1024
166
#define UDF_ALLOC_BLOCK_SIZE 1024
167
#define TABLE_ALLOC_BLOCK_SIZE 1024
168
#define BDB_LOG_ALLOC_BLOCK_SIZE 1024
169
#define WARN_ALLOC_BLOCK_SIZE 2048
170
#define WARN_ALLOC_PREALLOC_SIZE 1024
171
#define PROFILE_ALLOC_BLOCK_SIZE 2048
172
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
175
The following parameters is to decide when to use an extra cache to
176
optimise seeks when reading a big table in sorted order
178
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
179
#define MIN_ROWS_TO_USE_TABLE_CACHE 100
180
#define MIN_ROWS_TO_USE_BULK_INSERT 100
183
The following is used to decide if MySQL should use table scanning
184
instead of reading with keys. The number says how many evaluation of the
185
WHERE clause is comparable to reading one extra row from a table.
187
#define TIME_FOR_COMPARE 5 // 5 compares == one read
190
Number of comparisons of table rowids equivalent to reading one row from a
193
#define TIME_FOR_COMPARE_ROWID (TIME_FOR_COMPARE*2)
196
For sequential disk seeks the cost formula is:
197
DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
199
The cost of average seek
200
DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
202
#define DISK_SEEK_BASE_COST ((double)0.9)
204
#define BLOCKS_IN_AVG_SEEK 128
206
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
210
Number of rows in a reference table when refereed through a not unique key.
211
This value is only used when we don't know anything about the key
214
#define MATCHING_ROWS_IN_OTHER_TABLE 10
216
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
217
#define KEY_DEFAULT_PACK_LENGTH 8
219
/** Characters shown for the command in 'show processlist'. */
220
#define PROCESS_LIST_WIDTH 100
221
/* Characters shown for the command in 'information_schema.processlist' */
222
#define PROCESS_LIST_INFO_WIDTH 65535
224
#define PRECISION_FOR_DOUBLE 53
225
#define PRECISION_FOR_FLOAT 24
228
Default time to wait before aborting a new client connection
229
that does not respond to "initial server greeting" timely
231
#define CONNECT_TIMEOUT 10
233
/* The following can also be changed from the command line */
234
#define DEFAULT_CONCURRENCY 10
235
#define FLUSH_TIME 0 /**< Don't flush tables */
236
#define MAX_CONNECT_ERRORS 10 ///< errors before disabling host
238
#define INTERRUPT_PRIOR 10
239
#define CONNECT_PRIOR 9
241
#define QUERY_PRIOR 6
243
/* Bits from testflag */
244
#define TEST_PRINT_CACHED_TABLES 1
245
#define TEST_NO_KEY_GROUP 2
246
#define TEST_MIT_THREAD 4
247
#define TEST_BLOCKING 8
248
#define TEST_KEEP_TMP_TABLES 16
249
#define TEST_READCHECK 64 /**< Force use of readcheck */
250
#define TEST_NO_EXTRA 128
251
#define TEST_CORE_ON_SIGNAL 256 /**< Give core if signal */
252
#define TEST_NO_STACKTRACE 512
253
#define TEST_SIGINT 1024 /**< Allow sigint on threads */
254
#define TEST_SYNCHRONIZATION 2048 /**< get server to do sleep in
259
This is included in the server and in the client.
260
Options for select set by the yacc parser (stored in lex->options).
263
log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
264
options list are written into binlog. These options can NOT change their
265
values, or it will break replication between version.
267
context is encoded as following:
268
SELECT - SELECT_LEX_NODE::options
270
intern - neither. used only as
271
func(..., select_node->options | thd->options | OPTION_XXX, ...)
273
TODO: separate three contexts above, move them to separate bitfields.
276
#define SELECT_DISTINCT (1ULL << 0) // SELECT, user
277
#define SELECT_STRAIGHT_JOIN (1ULL << 1) // SELECT, user
278
#define SELECT_DESCRIBE (1ULL << 2) // SELECT, user
279
#define SELECT_SMALL_RESULT (1ULL << 3) // SELECT, user
280
#define SELECT_BIG_RESULT (1ULL << 4) // SELECT, user
281
#define OPTION_FOUND_ROWS (1ULL << 5) // SELECT, user
282
#define SELECT_NO_JOIN_CACHE (1ULL << 7) // intern
283
#define OPTION_BIG_TABLES (1ULL << 8) // THD, user
284
#define OPTION_BIG_SELECTS (1ULL << 9) // THD, user
285
#define OPTION_LOG_OFF (1ULL << 10) // THD, user
286
#define OPTION_QUOTE_SHOW_CREATE (1ULL << 11) // THD, user, unused
287
#define TMP_TABLE_ALL_COLUMNS (1ULL << 12) // SELECT, intern
288
#define OPTION_WARNINGS (1ULL << 13) // THD, user
289
#define OPTION_AUTO_IS_NULL (1ULL << 14) // THD, user, binlog
290
#define OPTION_FOUND_COMMENT (1ULL << 15) // SELECT, intern, parser
291
#define OPTION_SAFE_UPDATES (1ULL << 16) // THD, user
292
#define OPTION_BUFFER_RESULT (1ULL << 17) // SELECT, user
293
#define OPTION_BIN_LOG (1ULL << 18) // THD, user
294
#define OPTION_NOT_AUTOCOMMIT (1ULL << 19) // THD, user
295
#define OPTION_BEGIN (1ULL << 20) // THD, intern
296
#define OPTION_TABLE_LOCK (1ULL << 21) // THD, intern
297
#define OPTION_QUICK (1ULL << 22) // SELECT (for DELETE)
298
#define OPTION_KEEP_LOG (1ULL << 23) // THD, user
300
/* The following is used to detect a conflict with DISTINCT */
301
#define SELECT_ALL (1ULL << 24) // SELECT, user, parser
303
/** The following can be set when importing tables in a 'wrong order'
304
to suppress foreign key checks */
305
#define OPTION_NO_FOREIGN_KEY_CHECKS (1ULL << 26) // THD, user, binlog
306
/** The following speeds up inserts to InnoDB tables by suppressing unique
307
key checks in some cases */
308
#define OPTION_RELAXED_UNIQUE_CHECKS (1ULL << 27) // THD, user, binlog
309
#define SELECT_NO_UNLOCK (1ULL << 28) // SELECT, intern
310
#define OPTION_SCHEMA_TABLE (1ULL << 29) // SELECT, intern
311
/** Flag set if setup_tables already done */
312
#define OPTION_SETUP_TABLES_DONE (1ULL << 30) // intern
313
/** If not set then the thread will ignore all warnings with level notes. */
314
#define OPTION_SQL_NOTES (1ULL << 31) // THD, user
316
Force the used temporary table to be a MyISAM table (because we will use
317
fulltext functions when reading from it.
319
#define TMP_TABLE_FORCE_MYISAM (1ULL << 32)
320
#define OPTION_PROFILING (1ULL << 33)
323
Dont report errors for individual rows,
324
But just report error on commit (or read ofcourse)
326
#define OPTION_ALLOW_BATCH (1ULL << 33) // THD, intern (slave)
329
Maximum length of time zone name that we support
330
(Time zone name is char(64) in db). mysqlbinlog needs it.
332
#define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1)
334
/* The rest of the file is included in the server only */
337
/* Bits for different SQL modes modes (including ANSI mode) */
338
#define MODE_REAL_AS_FLOAT 1
339
#define MODE_PIPES_AS_CONCAT 2
340
#define MODE_ANSI_QUOTES 4
341
#define MODE_IGNORE_SPACE 8
342
#define MODE_NOT_USED 16
343
#define MODE_ONLY_FULL_GROUP_BY 32
344
#define MODE_NO_UNSIGNED_SUBTRACTION 64
345
#define MODE_NO_DIR_IN_CREATE 128
346
#define MODE_POSTGRESQL 256
347
#define MODE_ORACLE 512
348
#define MODE_MSSQL 1024
349
#define MODE_DB2 2048
350
#define MODE_MAXDB 4096
351
#define MODE_NO_KEY_OPTIONS 8192
352
#define MODE_NO_TABLE_OPTIONS 16384
353
#define MODE_NO_FIELD_OPTIONS 32768
354
#define MODE_MYSQL323 65536L
355
#define MODE_MYSQL40 (MODE_MYSQL323*2)
356
#define MODE_ANSI (MODE_MYSQL40*2)
357
#define MODE_NO_AUTO_VALUE_ON_ZERO (MODE_ANSI*2)
358
#define MODE_NO_BACKSLASH_ESCAPES (MODE_NO_AUTO_VALUE_ON_ZERO*2)
359
#define MODE_STRICT_TRANS_TABLES (MODE_NO_BACKSLASH_ESCAPES*2)
360
#define MODE_STRICT_ALL_TABLES (MODE_STRICT_TRANS_TABLES*2)
361
#define MODE_NO_ZERO_IN_DATE (MODE_STRICT_ALL_TABLES*2)
362
#define MODE_NO_ZERO_DATE (MODE_NO_ZERO_IN_DATE*2)
363
#define MODE_INVALID_DATES (MODE_NO_ZERO_DATE*2)
364
#define MODE_ERROR_FOR_DIVISION_BY_ZERO (MODE_INVALID_DATES*2)
365
#define MODE_TRADITIONAL (MODE_ERROR_FOR_DIVISION_BY_ZERO*2)
366
#define MODE_NO_AUTO_CREATE_USER (MODE_TRADITIONAL*2)
367
#define MODE_HIGH_NOT_PRECEDENCE (MODE_NO_AUTO_CREATE_USER*2)
368
#define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2)
369
#define MODE_PAD_CHAR_TO_FULL_LENGTH (1ULL << 31)
371
/* @@optimizer_switch flags */
372
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
373
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
376
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
377
use strictly more than 64 bits by adding one more define above, you should
378
contact the replication team because the replication code should then be
379
updated (to store more bytes on disk).
381
NOTE: When adding new SQL_MODE types, make sure to also add them to
382
the scripts used for creating the MySQL system tables
383
in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
386
#define RAID_BLOCK_SIZE 1024
388
#define MY_CHARSET_BIN_MB_MAXLEN 1
391
#define UNCACHEABLE_DEPENDENT 1
392
#define UNCACHEABLE_RAND 2
393
#define UNCACHEABLE_SIDEEFFECT 4
394
/// forcing to save JOIN for explain
395
#define UNCACHEABLE_EXPLAIN 8
396
/** Don't evaluate subqueries in prepare even if they're not correlated */
397
#define UNCACHEABLE_PREPARE 16
398
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
399
#define UNCACHEABLE_UNITED 32
401
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
402
#define UNDEF_POS (-1)
404
/* BINLOG_DUMP options */
406
#define BINLOG_DUMP_NON_BLOCK 1
408
/* sql_show.cc:show_log_files() */
409
#define SHOW_LOG_STATUS_FREE "FREE"
410
#define SHOW_LOG_STATUS_INUSE "IN USE"
412
/* Options to add_table_to_list() */
413
#define TL_OPTION_UPDATING 1
414
#define TL_OPTION_FORCE_INDEX 2
415
#define TL_OPTION_IGNORE_LEAVES 4
416
#define TL_OPTION_ALIAS 8
418
/* Some portable defines */
420
#define portable_sizeof_char_ptr 8
422
#define tmp_file_prefix "#sql" /**< Prefix for tmp tables */
423
#define tmp_file_prefix_length 4
425
/* Flags for calc_week() function. */
426
#define WEEK_MONDAY_FIRST 1
428
#define WEEK_FIRST_WEEKDAY 4
430
#define STRING_BUFFER_USUAL_SIZE 80
433
Some defines for exit codes for ::is_equal class functions.
435
#define IS_EQUAL_NO 0
436
#define IS_EQUAL_YES 1
437
#define IS_EQUAL_PACK_LENGTH 2
439
enum enum_parsing_place
448
enum enum_mysql_completiontype {
451
, ROLLBACK_AND_CHAIN= 7
454
, COMMIT_AND_CHAIN= 6
457
enum enum_check_fields
461
, CHECK_FIELD_ERROR_FOR_NULL
471
/* Forward declarations */
477
class user_var_entry;
478
class Security_context;
33
/* Some forward declarations just for the server */
481
35
class Comp_creator;
482
36
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
485
#define thd_proc_info(thd, msg) set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
487
extern pthread_key(THD*, THR_THD);
488
inline THD *_current_thd(void)
490
return (THD *)pthread_getspecific(THR_THD);
492
#define current_thd _current_thd()
495
The meat of thd_proc_info(THD*, char*), a macro that packs the last
496
three calling-info parameters.
499
const char *set_thd_proc_info(THD *thd, const char *info,
500
const char *calling_func,
501
const char *calling_file,
502
const unsigned int calling_line);
507
extern ulong server_id;
509
#include <drizzled/sql_string.h>
510
#include "sql_list.h"
512
#include "my_decimal.h"
515
#include "sql_error.h"
517
#include "protocol.h"
521
extern my_decimal decimal_zero;
523
/** @TODO Find a good header to put this guy... */
524
void close_thread_tables(THD *thd);
526
#include <drizzled/sql_parse.h>
528
#include "sql_class.h"
529
#include "slave.h" // for tables_ok(), rpl_filter
39
* Contains all headers, definitions, and declarations common to
40
* the server and the plugin infrastructure, and not the client
42
#include <drizzled/common_includes.h>
532
44
#include "opt_range.h"
536
47
Error injector Macros to enable easy testing of recovery after failures
537
48
in various error cases.