~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/mysql_priv.h

Merged from Jay.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
 
24
 
 
25
  @TODO Name this file better. "priv" could mean private, privileged, privileges.
 
26
 
 
27
  @TODO Get rid of the MYSQL_CLIENT and MYSQL_SERVER conditionals
24
28
*/
25
29
 
26
30
#ifndef DRIZZLE_SERVER_MYSQL_PRIV_H
27
31
#define DRIZZLE_SERVER_MYSQL_PRIV_H
28
32
 
29
 
#ifndef MYSQL_CLIENT
30
 
 
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>
37
 
#include <signal.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"
46
 
 
47
 
#ifdef HAVE_DTRACE
48
 
#define _DTRACE_VERSION 1
49
 
#endif
50
 
#include "probes.h"
51
 
 
52
 
#include <netdb.h>
53
 
 
54
 
/**
55
 
  Query type constants.
56
 
 
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).
60
 
*/
61
 
enum enum_query_type
62
 
{
63
 
  QT_ORDINARY,
64
 
  QT_IS
65
 
};
66
 
 
67
 
/* TODO convert all these three maps to Bitmap classes */
68
 
typedef uint64_t table_map;          /* Used for table bits in join */
69
 
#if MAX_INDEXES <= 64
70
 
typedef Bitmap<64>  key_map;          /* Used for finding keys */
71
 
#else
72
 
typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
73
 
#endif
74
 
typedef uint32_t nesting_map;  /* Used for flags of nesting constructs */
75
 
/*
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
78
 
  element)
79
 
*/
80
 
typedef uint64_t nested_join_map;
81
 
 
82
 
/* query_id */
83
 
typedef uint64_t query_id_t;
84
 
extern query_id_t global_query_id;
85
 
 
86
 
/* increment query_id and return it.  */
87
 
inline query_id_t next_query_id() { return global_query_id++; }
88
 
 
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;
93
 
 
94
 
#include <libdrizzle/drizzle_com.h>
95
 
#include <vio/violite.h>
96
 
#include "unireg.h"
97
 
 
98
 
#include <drizzled/sql_alloc.h>
99
 
 
100
 
#define PREV_BITS(type,A)       ((type) (((type) 1 << (A)) -1))
101
 
#define all_bits_set(A,B) ((A) & (B) != (B))
102
 
 
103
 
extern const CHARSET_INFO *system_charset_info, *files_charset_info ;
104
 
extern const CHARSET_INFO *national_charset_info, *table_alias_charset;
105
 
 
106
 
enum Derivation
107
 
{
108
 
  DERIVATION_IGNORABLE= 5,
109
 
  DERIVATION_COERCIBLE= 4,
110
 
  DERIVATION_SYSCONST= 3,
111
 
  DERIVATION_IMPLICIT= 2,
112
 
  DERIVATION_NONE= 1,
113
 
  DERIVATION_EXPLICIT= 0
114
 
};
115
 
 
116
 
#include <drizzled/sql_locale.h>
117
 
#include <drizzled/object_creation_ctx.h>
118
 
/**
119
 
  Opening modes for open_temporary_table and open_table_from_share
120
 
*/
121
 
 
122
 
enum open_table_mode
123
 
{
124
 
  OTM_OPEN= 0,
125
 
  OTM_CREATE= 1,
126
 
  OTM_ALTER= 2
127
 
};
128
 
 
129
 
/***************************************************************************
130
 
  Configuration parameters
131
 
****************************************************************************/
132
 
 
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
141
 
 
142
 
/* 
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'
146
 
 requirements.)
147
 
 
148
 
 Feel free to raise this by the smallest amount you can to get the
149
 
 "execution_constants" test to pass.
150
 
 */
151
 
#define STACK_MIN_SIZE          12000   ///< Abort if less stack during eval.
152
 
 
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.
157
 
#endif
158
 
#define TEMP_POOL_SIZE          128
159
 
 
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
173
 
 
174
 
/*
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
177
 
*/
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
181
 
 
182
 
/**
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.
186
 
*/
187
 
#define TIME_FOR_COMPARE   5    // 5 compares == one read
188
 
 
189
 
/**
190
 
  Number of comparisons of table rowids equivalent to reading one row from a 
191
 
  table.
192
 
*/
193
 
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
194
 
 
195
 
/*
196
 
  For sequential disk seeks the cost formula is:
197
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
198
 
  
199
 
  The cost of average seek 
200
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
201
 
*/
202
 
#define DISK_SEEK_BASE_COST ((double)0.9)
203
 
 
204
 
#define BLOCKS_IN_AVG_SEEK  128
205
 
 
206
 
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
207
 
 
208
 
 
209
 
/**
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
212
 
  distribution.
213
 
*/
214
 
#define MATCHING_ROWS_IN_OTHER_TABLE 10
215
 
 
216
 
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
217
 
#define KEY_DEFAULT_PACK_LENGTH 8
218
 
 
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
223
 
 
224
 
#define PRECISION_FOR_DOUBLE 53
225
 
#define PRECISION_FOR_FLOAT  24
226
 
 
227
 
/*
228
 
  Default time to wait before aborting a new client connection
229
 
  that does not respond to "initial server greeting" timely
230
 
*/
231
 
#define CONNECT_TIMEOUT         10
232
 
 
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
237
 
 
238
 
#define INTERRUPT_PRIOR 10
239
 
#define CONNECT_PRIOR   9
240
 
#define WAIT_PRIOR      8
241
 
#define QUERY_PRIOR     6
242
 
 
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
255
 
                                           some places */
256
 
#endif
257
 
 
258
 
/*
259
 
   This is included in the server and in the client.
260
 
   Options for select set by the yacc parser (stored in lex->options).
261
 
 
262
 
   XXX:
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.
266
 
 
267
 
   context is encoded as following:
268
 
   SELECT - SELECT_LEX_NODE::options
269
 
   THD    - THD::options
270
 
   intern - neither. used only as
271
 
            func(..., select_node->options | thd->options | OPTION_XXX, ...)
272
 
 
273
 
   TODO: separate three contexts above, move them to separate bitfields.
274
 
*/
275
 
 
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
299
 
 
300
 
/* The following is used to detect a conflict with DISTINCT */
301
 
#define SELECT_ALL              (1ULL << 24)    // SELECT, user, parser
302
 
 
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
315
 
/**
316
 
  Force the used temporary table to be a MyISAM table (because we will use
317
 
  fulltext functions when reading from it.
318
 
*/
319
 
#define TMP_TABLE_FORCE_MYISAM          (1ULL << 32)
320
 
#define OPTION_PROFILING                (1ULL << 33)
321
 
 
322
 
/*
323
 
  Dont report errors for individual rows,
324
 
  But just report error on commit (or read ofcourse)
325
 
*/
326
 
#define OPTION_ALLOW_BATCH              (1ULL << 33) // THD, intern (slave)
327
 
 
328
 
/**
329
 
  Maximum length of time zone name that we support
330
 
  (Time zone name is char(64) in db). mysqlbinlog needs it.
331
 
*/
332
 
#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
333
 
 
334
 
/* The rest of the file is included in the server only */
335
 
#ifndef MYSQL_CLIENT
336
 
 
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)
370
 
 
371
 
/* @@optimizer_switch flags */
372
 
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
373
 
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
374
 
 
375
 
/*
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).
380
 
 
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
384
 
 
385
 
*/
386
 
#define RAID_BLOCK_SIZE 1024
387
 
 
388
 
#define MY_CHARSET_BIN_MB_MAXLEN 1
389
 
 
390
 
// uncachable cause
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
400
 
 
401
 
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
402
 
#define UNDEF_POS (-1)
403
 
 
404
 
/* BINLOG_DUMP options */
405
 
 
406
 
#define BINLOG_DUMP_NON_BLOCK   1
407
 
 
408
 
/* sql_show.cc:show_log_files() */
409
 
#define SHOW_LOG_STATUS_FREE "FREE"
410
 
#define SHOW_LOG_STATUS_INUSE "IN USE"
411
 
 
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
417
 
 
418
 
/* Some portable defines */
419
 
 
420
 
#define portable_sizeof_char_ptr 8
421
 
 
422
 
#define tmp_file_prefix "#sql"                  /**< Prefix for tmp tables */
423
 
#define tmp_file_prefix_length 4
424
 
 
425
 
/* Flags for calc_week() function.  */
426
 
#define WEEK_MONDAY_FIRST    1
427
 
#define WEEK_YEAR            2
428
 
#define WEEK_FIRST_WEEKDAY   4
429
 
 
430
 
#define STRING_BUFFER_USUAL_SIZE 80
431
 
 
432
 
/*
433
 
  Some defines for exit codes for ::is_equal class functions.
434
 
*/
435
 
#define IS_EQUAL_NO 0
436
 
#define IS_EQUAL_YES 1
437
 
#define IS_EQUAL_PACK_LENGTH 2
438
 
 
439
 
enum enum_parsing_place
440
 
{
441
 
  NO_MATTER
442
 
  , IN_HAVING
443
 
  , SELECT_LIST
444
 
  , IN_WHERE
445
 
  , IN_ON
446
 
};
447
 
 
448
 
enum enum_mysql_completiontype {
449
 
  ROLLBACK_RELEASE= -2
450
 
  , ROLLBACK= 1
451
 
  , ROLLBACK_AND_CHAIN= 7
452
 
  , COMMIT_RELEASE= -1
453
 
  , COMMIT= 0
454
 
  , COMMIT_AND_CHAIN= 6
455
 
};
456
 
 
457
 
enum enum_check_fields
458
 
{
459
 
  CHECK_FIELD_IGNORE
460
 
  , CHECK_FIELD_WARN
461
 
  , CHECK_FIELD_ERROR_FOR_NULL
462
 
};
463
 
 
464
 
enum enum_var_type
465
 
{
466
 
  OPT_DEFAULT= 0
467
 
  , OPT_SESSION
468
 
  , OPT_GLOBAL
469
 
};
470
 
 
471
 
/* Forward declarations */
472
 
 
473
 
struct TABLE_LIST;
474
 
class String;
475
 
struct st_table;
476
 
class THD;
477
 
class user_var_entry;
478
 
class Security_context;
479
 
 
480
 
#ifdef MYSQL_SERVER
 
33
/* Some forward declarations just for the server */
 
34
 
481
35
class Comp_creator;
482
36
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
483
 
#endif
484
 
 
485
 
#define thd_proc_info(thd, msg)  set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
486
 
 
487
 
extern pthread_key(THD*, THR_THD);
488
 
inline THD *_current_thd(void)
489
 
{
490
 
  return (THD *)pthread_getspecific(THR_THD);
491
 
}
492
 
#define current_thd _current_thd()
493
 
 
494
 
/** 
495
 
  The meat of thd_proc_info(THD*, char*), a macro that packs the last
496
 
  three calling-info parameters. 
497
 
*/
498
 
extern "C"
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);
503
 
 
504
 
/*
505
 
  External variables
506
 
*/
507
 
extern ulong server_id;
508
 
 
509
 
#include <drizzled/sql_string.h>
510
 
#include "sql_list.h"
511
 
#include "sql_map.h"
512
 
#include "my_decimal.h"
513
 
#include "handler.h"
514
 
#include "table.h"
515
 
#include "sql_error.h"
516
 
#include "field.h"
517
 
#include "protocol.h"
518
 
#include "sql_udf.h"
519
 
#include "item.h"
520
 
 
521
 
extern my_decimal decimal_zero;
522
 
 
523
 
/** @TODO Find a good header to put this guy... */
524
 
void close_thread_tables(THD *thd);
525
 
 
526
 
#include <drizzled/sql_parse.h>
527
 
 
528
 
#include "sql_class.h"
529
 
#include "slave.h" // for tables_ok(), rpl_filter
530
 
#include "tztime.h"
531
 
#ifdef MYSQL_SERVER
 
37
 
 
38
/**
 
39
 * Contains all headers, definitions, and declarations common to 
 
40
 * the server and the plugin infrastructure, and not the client 
 
41
 */
 
42
#include <drizzled/common_includes.h>       
 
43
 
532
44
#include "opt_range.h"
533
45
 
534
 
 
535
46
/*
536
47
  Error injector Macros to enable easy testing of recovery after failures
537
48
  in various error cases.
626
137
void write_bin_log(THD *thd, bool clear_error,
627
138
                   char const *query, ulong query_length);
628
139
 
629
 
/* sql_connect.cc */
630
 
int check_user(THD *thd, enum enum_server_command command, 
631
 
               const char *passwd, uint passwd_len, const char *db,
632
 
               bool check_count);
633
 
pthread_handler_t handle_one_connection(void *arg);
634
 
bool init_new_connection_handler_thread();
635
 
void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
636
 
void decrease_user_connections(USER_CONN *uc);
637
 
void thd_init_client_charset(THD *thd, uint cs_number);
638
 
bool setup_connection_thread_globals(THD *thd);
639
 
bool login_connection(THD *thd);
640
 
void prepare_new_connection_state(THD* thd);
641
 
void end_connection(THD *thd);
642
 
 
 
140
#include <drizzled/connect.h>
643
141
 
644
142
int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
645
143
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
709
207
                        bool any_combination_of_privileges_will_do,
710
208
                        uint number);
711
209
 
712
 
#endif /* MYSQL_SERVER */
713
 
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
714
 
bool check_global_access(THD *thd, ulong want_access);
715
 
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
716
 
#ifdef MYSQL_SERVER
717
 
 
718
210
/*
719
211
  General routine to change field->ptr of a NULL-terminated array of Field
720
212
  objects. Useful when needed to call val_int, val_str or similar and the
722
214
  set_key_field_ptr changes all fields of an index using a key_info object.
723
215
  All methods presume that there is at least one field to change.
724
216
*/
725
 
 
726
217
void set_field_ptr(Field **ptr, const uchar *new_buf, const uchar *old_buf);
727
218
void set_key_field_ptr(KEY *key_info, const uchar *new_buf,
728
219
                       const uchar *old_buf);
902
393
Field *
903
394
find_field_in_table_sef(TABLE *table, const char *name);
904
395
 
905
 
#endif /* MYSQL_SERVER */
906
 
 
907
 
#ifdef MYSQL_SERVER
908
396
/* sql_do.cc */
909
397
bool mysql_do(THD *thd, List<Item> &values);
910
398
 
911
399
/* sql_analyse.h */
912
400
bool append_escaped(String *to_str, String *from_str);
913
401
 
914
 
/* sql_show.cc */
915
 
bool mysqld_show_open_tables(THD *thd,const char *wild);
916
 
bool mysqld_show_logs(THD *thd);
917
 
void append_identifier(THD *thd, String *packet, const char *name,
918
 
                       uint length);
919
 
#endif /* MYSQL_SERVER */
920
 
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
921
 
int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
922
 
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
923
 
#ifdef MYSQL_SERVER
924
 
void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
925
 
int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
926
 
bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
927
 
bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
928
 
 
929
 
void mysqld_list_processes(THD *thd,const char *user,bool verbose);
930
 
int mysqld_show_status(THD *thd);
931
 
int mysqld_show_variables(THD *thd,const char *wild);
932
 
bool mysqld_show_storage_engines(THD *thd);
933
 
bool mysqld_show_authors(THD *thd);
934
 
bool mysqld_show_contributors(THD *thd);
935
 
bool mysqld_show_privileges(THD *thd);
936
 
bool mysqld_show_column_types(THD *thd);
937
 
bool mysqld_help (THD *thd, const char *text);
938
 
void calc_sum_of_all_status(STATUS_VAR *to);
939
 
 
940
 
void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
941
 
                    const LEX_STRING *definer_host);
942
 
 
943
 
int add_status_vars(SHOW_VAR *list);
944
 
void remove_status_vars(SHOW_VAR *list);
945
 
void init_status_vars();
946
 
void free_status_vars();
947
 
void reset_status_vars();
 
402
#include <drizzled/show.h>
948
403
 
949
404
/* information schema */
950
405
extern LEX_STRING INFORMATION_SCHEMA_NAME;
1228
683
extern "C" int key_rec_cmp(void *key_info, uchar *a, uchar *b);
1229
684
 
1230
685
bool init_errmessage(void);
1231
 
#endif /* MYSQL_SERVER */
1232
 
void sql_perror(const char *message);
1233
 
 
1234
 
bool fn_format_relative_to_data_home(char * to, const char *name,
1235
 
                                     const char *dir, const char *extension);
1236
 
#ifdef MYSQL_SERVER
1237
686
File open_binlog(IO_CACHE *log, const char *log_file_name,
1238
687
                 const char **errmsg);
1239
688
 
1285
734
*/
1286
735
 
1287
736
extern time_t server_start_time, flush_status_time;
1288
 
#endif /* MYSQL_SERVER */
1289
 
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1290
 
extern uint mysql_data_home_len;
1291
 
extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
1292
 
            mysql_real_data_home[], mysql_unpacked_real_data_home[];
1293
 
extern const CHARSET_INFO *character_set_filesystem;
1294
 
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
1295
 
#ifdef MYSQL_SERVER
1296
737
extern char *opt_mysql_tmpdir, mysql_charsets_dir[];
1297
738
            
1298
739
#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
1310
751
extern Ge_creator ge_creator;
1311
752
extern Le_creator le_creator;
1312
753
extern char language[FN_REFLEN];
1313
 
#endif /* MYSQL_SERVER */
1314
 
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1315
 
extern char reg_ext[FN_EXTLEN];
1316
 
extern uint reg_ext_length;
1317
 
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
1318
 
#ifdef MYSQL_SERVER
1319
754
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
1320
755
extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
1321
756
extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
1341
776
extern ulong opt_binlog_rows_event_max_size;
1342
777
extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
1343
778
extern ulong back_log;
1344
 
#endif /* MYSQL_SERVER */
1345
 
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1346
 
extern ulong specialflag;
1347
 
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
1348
 
#ifdef MYSQL_SERVER
1349
779
extern ulong current_pid;
1350
780
extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
1351
781
extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
1355
785
extern uint test_flags,select_errors,ha_open_options;
1356
786
extern uint protocol_version, mysqld_port, dropping_tables;
1357
787
extern uint delay_key_write_options;
1358
 
#endif /* MYSQL_SERVER */
1359
 
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1360
 
extern uint lower_case_table_names;
1361
 
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
1362
 
#ifdef MYSQL_SERVER
1363
788
extern bool opt_endinfo, using_udf_functions;
1364
789
extern bool locked_in_memory;
1365
790
extern bool opt_using_transactions;
1366
 
#endif /* MYSQL_SERVER */
1367
 
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1368
 
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
1369
 
#ifdef MYSQL_SERVER
1370
791
extern bool using_update_log, server_id_supplied;
1371
792
extern bool opt_update_log, opt_bin_log, opt_error_log;
1372
793
extern bool opt_log; 
1395
816
extern bool opt_old_style_user_limits;
1396
817
extern uint opt_crash_binlog_innodb;
1397
818
extern char *default_tz_name;
1398
 
#endif /* MYSQL_SERVER */
1399
 
#ifdef MYSQL_SERVER
1400
819
extern char *opt_logname, *opt_slow_logname;
1401
820
extern const char *log_output_str;
1402
821
 
1424
843
extern String my_empty_string;
1425
844
extern const String my_null_string;
1426
845
extern SHOW_VAR status_vars[];
1427
 
#endif /* MYSQL_SERVER */
1428
 
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1429
 
extern struct system_variables global_system_variables;
1430
 
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
1431
 
#ifdef MYSQL_SERVER
1432
846
extern struct system_variables max_system_variables;
1433
847
extern struct system_status_var global_status_var;
1434
848
extern struct rand_struct sql_rand;
1629
1043
char *fn_rext(char *name);
1630
1044
 
1631
1045
/* Conversion functions */
1632
 
#endif /* MYSQL_SERVER */
1633
 
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1634
 
uint strconvert(const CHARSET_INFO * const from_cs, const char *from,
1635
 
                const CHARSET_INFO * const to_cs, char *to, uint to_length, uint *errors);
1636
 
uint filename_to_tablename(const char *from, char *to, uint to_length);
1637
 
uint tablename_to_filename(const char *from, char *to, uint to_length);
1638
 
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
1639
 
#ifdef MYSQL_SERVER
1640
1046
uint build_table_filename(char *buff, size_t bufflen, const char *db,
1641
1047
                          const char *table, const char *ext, uint flags);
1642
1048
 
1795
1201
void kill_delayed_threads(void);
1796
1202
bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
1797
1203
 
1798
 
/* Used by handlers to store things in schema tables */
 
1204
/** 
 
1205
 * Used by handlers to store things in schema tables 
 
1206
 *
 
1207
 * @TODO These should be placed in an information_schema.h header
 
1208
 * file once the new information schema design is finalized.
 
1209
 */
1799
1210
#define IS_FILES_FILE_ID              0
1800
1211
#define IS_FILES_FILE_NAME            1
1801
1212
#define IS_FILES_FILE_TYPE            2
1835
1246
#define IS_FILES_STATUS              36
1836
1247
#define IS_FILES_EXTRA               37
1837
1248
 
1838
 
#endif /* MYSQL_SERVER */
1839
 
#endif /* MYSQL_CLIENT */
1840
 
 
1841
1249
#endif /* DRIZZLE_SERVER_MYSQL_PRIV_H */