~mdcallag/+junk/5.1-map

« back to all changes in this revision

Viewing changes to sql/mysql_priv.h

  • Committer: msvensson at pilot
  • Date: 2007-04-24 09:11:45 UTC
  • mfrom: (2469.1.106)
  • Revision ID: sp1r-msvensson@pilot.blaudden-20070424091145-10463
Merge pilot.blaudden:/home/msvensson/mysql/my51-m-mysql_upgrade
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
#else
48
48
typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
49
49
#endif
50
 
typedef ulong key_part_map;           /* Used for finding key parts */
51
50
typedef ulong nesting_map;  /* Used for flags of nesting constructs */
52
51
/*
53
52
  Used to identify NESTED_JOIN structures within a join (applicable only to
148
147
 
149
148
extern MY_LOCALE my_locale_en_US;
150
149
extern MY_LOCALE *my_locales[];
 
150
extern MY_LOCALE *my_default_lc_time_names;
151
151
 
152
152
MY_LOCALE *my_locale_by_name(const char *name);
153
153
MY_LOCALE *my_locale_by_number(uint number);
264
264
#endif
265
265
 
266
266
#if defined(__WIN__)
267
 
#define IF_WIN(A,B) (A)
268
267
#undef  FLUSH_TIME
269
268
#define FLUSH_TIME      1800                    /* Flush every half hour */
270
269
 
273
272
#define WAIT_PRIOR      0
274
273
#define QUERY_PRIOR     2
275
274
#else
276
 
#define IF_WIN(A,B) (B)
277
275
#define INTERRUPT_PRIOR 10
278
276
#define CONNECT_PRIOR   9
279
277
#define WAIT_PRIOR      8
341
339
/* The following is used to detect a conflict with DISTINCT */
342
340
#define SELECT_ALL              (ULL(1) << 24)    // SELECT, user, parser
343
341
 
344
 
/* Set if we are updating a non-transaction safe table */
345
 
#define OPTION_STATUS_NO_TRANS_UPDATE   (ULL(1) << 25) // THD, intern
346
 
 
347
342
/* The following can be set when importing tables in a 'wrong order'
348
343
   to suppress foreign key checks */
349
344
#define OPTION_NO_FOREIGN_KEY_CHECKS    (ULL(1) << 26) // THD, user, binlog
367
362
  Maximum length of time zone name that we support
368
363
  (Time zone name is char(64) in db). mysqlbinlog needs it.
369
364
*/
370
 
#define MAX_TIME_ZONE_NAME_LENGTH 72
 
365
#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
371
366
 
372
367
/* The rest of the file is included in the server only */
373
368
#ifndef MYSQL_CLIENT
411
406
  updated (to store more bytes on disk).
412
407
 
413
408
  NOTE: When adding new SQL_MODE types, make sure to also add them to
414
 
  ../scripts/mysql_create_system_tables.sh and
415
 
  ../scripts/mysql_fix_privilege_tables.sql
 
409
  the scripts used for creating the MySQL system tables
 
410
  in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
 
411
 
416
412
*/
417
413
 
418
414
#define RAID_BLOCK_SIZE 1024
599
595
void close_thread_tables(THD *thd, bool locked=0, bool skip_derived=0);
600
596
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
601
597
bool check_single_table_access(THD *thd, ulong privilege,
602
 
                           TABLE_LIST *tables);
 
598
                           TABLE_LIST *tables, bool no_errors);
603
599
bool check_routine_access(THD *thd,ulong want_access,char *db,char *name,
604
600
                          bool is_proc, bool no_errors);
605
601
bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table);
622
618
LEX_USER *create_default_definer(THD *thd);
623
619
LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name);
624
620
LEX_USER *get_current_user(THD *thd, LEX_USER *user);
625
 
bool check_string_length(LEX_STRING *str,
626
 
                         const char *err_msg, uint max_length);
 
621
bool check_string_byte_length(LEX_STRING *str, const char *err_msg,
 
622
                              uint max_byte_length);
 
623
bool check_string_char_length(LEX_STRING *str, const char *err_msg,
 
624
                              uint max_char_length, CHARSET_INFO *cs,
 
625
                              bool no_error);
627
626
 
628
627
enum enum_mysql_completiontype {
629
628
  ROLLBACK_RELEASE=-2, ROLLBACK=1,  ROLLBACK_AND_CHAIN=7,
647
646
{
648
647
  unsigned int client_long_flag:1;
649
648
  unsigned int client_protocol_41:1;
 
649
  unsigned int result_in_binary_protocol:1;
650
650
  unsigned int more_results_exists:1;
651
651
  unsigned int pkt_nr;
652
652
  uint character_set_client_num;
673
673
  query_cache.send_result_to_client(A, B, C)
674
674
#define query_cache_invalidate_by_MyISAM_filename_ref \
675
675
  &query_cache_invalidate_by_MyISAM_filename
 
676
/* note the "maybe": it's a read without mutex */
 
677
#define query_cache_maybe_disabled(T)                                 \
 
678
  (T->variables.query_cache_type == 0 || query_cache.query_cache_size == 0)
 
679
#define query_cache_is_cacheable_query(L) \
 
680
  (((L)->sql_command == SQLCOM_SELECT) && (L)->safe_to_cache_query)
676
681
#else
677
682
#define QUERY_CACHE_FLAGS_SIZE 0
678
683
#define query_cache_store_query(A, B)
689
694
#define query_cache_abort(A)
690
695
#define query_cache_end_of_result(A)
691
696
#define query_cache_invalidate_by_MyISAM_filename_ref NULL
 
697
#define query_cache_maybe_disabled(T) 1
 
698
#define query_cache_is_cacheable_query(L) 0
692
699
#endif /*HAVE_QUERY_CACHE*/
693
700
 
694
701
/*
827
834
bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
828
835
                      char *new_table_name, char *new_table_alias,
829
836
                      bool skip_error);
830
 
bool mysql_change_db(THD *thd,const char *name,bool no_access_check);
 
837
bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
 
838
                     bool force_switch);
831
839
void mysql_parse(THD *thd,char *inBuf,uint length);
832
840
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
833
841
bool is_update_query(enum enum_sql_command command);
834
842
bool alloc_query(THD *thd, const char *packet, uint packet_length);
835
843
void mysql_init_select(LEX *lex);
836
844
void mysql_reset_thd_for_next_command(THD *thd);
837
 
void mysql_init_query(THD *thd, uchar *buf, uint length);
 
845
void mysql_init_query(THD *thd, const char *buf, uint length);
838
846
bool mysql_new_select(LEX *lex, bool move_down);
839
847
void create_select_for_variable(const char *var_name);
840
848
void mysql_init_multi_delete(LEX *lex);
991
999
                          List<Item> &fields, List_item *values,
992
1000
                          List<Item> &update_fields,
993
1001
                          List<Item> &update_values, enum_duplicates duplic,
994
 
                          COND **where, bool select_insert);
 
1002
                          COND **where, bool select_insert,
 
1003
                          bool check_fields, bool abort_on_warning);
995
1004
bool mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields,
996
1005
                  List<List_item> &values, List<Item> &update_fields,
997
1006
                  List<Item> &update_values, enum_duplicates flag,
998
1007
                  bool ignore);
999
1008
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
1000
1009
                                           TABLE_LIST *table_list);
 
1010
void prepare_triggers_for_insert_stmt(TABLE *table);
1001
1011
bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
1002
1012
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
1003
1013
                  SQL_LIST *order, ha_rows rows, ulonglong options,
1105
1115
void free_status_vars();
1106
1116
 
1107
1117
/* information schema */
1108
 
extern LEX_STRING information_schema_name;
 
1118
extern LEX_STRING INFORMATION_SCHEMA_NAME;
1109
1119
extern const LEX_STRING partition_keywords[];
1110
1120
LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str,
1111
1121
                            const char* str, uint length,
1123
1133
int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
1124
1134
bool get_schema_tables_result(JOIN *join,
1125
1135
                              enum enum_schema_table_state executed_place);
 
1136
enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
 
1137
 
1126
1138
#define is_schema_db(X) \
1127
 
  !my_strcasecmp(system_charset_info, information_schema_name.str, (X))
 
1139
  !my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))
1128
1140
 
1129
1141
/* sql_prepare.cc */
1130
1142
 
1155
1167
/* sql_base.cc */
1156
1168
#define TMP_TABLE_KEY_EXTRA 8
1157
1169
void set_item_name(Item *item,char *pos,uint length);
1158
 
bool add_field_to_list(THD *thd, char *field_name, enum enum_field_types type,
 
1170
bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types type,
1159
1171
                       char *length, char *decimal,
1160
1172
                       uint type_modifier,
1161
1173
                       Item *default_value, Item *on_update_value,
1188
1200
                        table_map read_tables, COND *conds,
1189
1201
                        bool allow_null_cond,  int *error);
1190
1202
extern Item **not_found_item;
 
1203
 
 
1204
/*
 
1205
  This enumeration type is used only by the function find_item_in_list
 
1206
  to return the info on how an item has been resolved against a list
 
1207
  of possibly aliased items.
 
1208
  The item can be resolved: 
 
1209
   - against an alias name of the list's element (RESOLVED_AGAINST_ALIAS)
 
1210
   - against non-aliased field name of the list  (RESOLVED_WITH_NO_ALIAS)
 
1211
   - against an aliased field name of the list   (RESOLVED_BEHIND_ALIAS)
 
1212
   - ignoring the alias name in cases when SQL requires to ignore aliases
 
1213
     (e.g. when the resolved field reference contains a table name or
 
1214
     when the resolved item is an expression)   (RESOLVED_IGNORING_ALIAS)    
 
1215
*/
 
1216
enum enum_resolution_type {
 
1217
  NOT_RESOLVED=0,
 
1218
  RESOLVED_IGNORING_ALIAS,
 
1219
  RESOLVED_BEHIND_ALIAS,
 
1220
  RESOLVED_WITH_NO_ALIAS,
 
1221
  RESOLVED_AGAINST_ALIAS
 
1222
};
1191
1223
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,
1192
1224
                          find_item_error_report_type report_error,
1193
 
                          bool *unaliased);
 
1225
                          enum_resolution_type *resolution);
1194
1226
bool get_key_map_from_key_list(key_map *map, TABLE *table,
1195
1227
                               List<String> *index_list);
1196
1228
bool insert_fields(THD *thd, Name_resolution_context *context,
1248
1280
                               st_table_list *TABLE_LIST::*link,
1249
1281
                               const char *db_name,
1250
1282
                               const char *table_name);
1251
 
TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list);
 
1283
TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
 
1284
                         bool check_alias);
1252
1285
TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name);
1253
1286
TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list);
1254
1287
bool close_temporary_table(THD *thd, TABLE_LIST *table_list);
1408
1441
void close_open_tables_and_downgrade(ALTER_PARTITION_PARAM_TYPE *lpt);
1409
1442
void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table);
1410
1443
 
 
1444
/* Functions to work with system tables. */
 
1445
bool open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
 
1446
                                 Open_tables_state *backup);
 
1447
void close_system_tables(THD *thd, Open_tables_state *backup);
 
1448
TABLE *open_system_table_for_update(THD *thd, TABLE_LIST *one_table);
 
1449
 
1411
1450
bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables, bool have_lock = FALSE);
 
1451
bool close_cached_connection_tables(THD *thd, bool wait_for_refresh,
 
1452
                                    LEX_STRING *connect_string,
 
1453
                                    bool have_lock = FALSE);
1412
1454
void copy_field_from_tmp_record(Field *field,int offset);
1413
1455
bool fill_record(THD *thd, Field **field, List<Item> &values,
1414
1456
                 bool ignore_errors);
1471
1513
void mysql_print_status();
1472
1514
/* key.cc */
1473
1515
int find_ref_key(KEY *key, uint key_count, byte *record, Field *field,
1474
 
                 uint *key_length);
 
1516
                 uint *key_length, uint *keypart);
1475
1517
void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length);
1476
1518
void key_restore(byte *to_record, byte *from_key, KEY *key_info,
1477
1519
                 uint key_length);
1526
1568
/* strfunc.cc */
1527
1569
ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs,
1528
1570
                   char **err_pos, uint *err_len, bool *set_warning);
1529
 
uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match);
1530
 
uint find_type2(TYPELIB *lib, const char *find, uint length, CHARSET_INFO *cs);
 
1571
uint find_type(const TYPELIB *lib, const char *find, uint length,
 
1572
               bool part_match);
 
1573
uint find_type2(const TYPELIB *lib, const char *find, uint length,
 
1574
                CHARSET_INFO *cs);
1531
1575
void unhex_type2(TYPELIB *lib);
1532
1576
uint check_word(TYPELIB *lib, const char *val, const char *end,
1533
1577
                const char **end_of_word);
1797
1841
ulong convert_month_to_period(ulong month);
1798
1842
void get_date_from_daynr(long daynr,uint *year, uint *month,
1799
1843
                         uint *day);
1800
 
my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *not_exist);
1801
 
bool str_to_time_with_warn(const char *str,uint length,TIME *l_time);
 
1844
my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *not_exist);
 
1845
bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time);
1802
1846
timestamp_type str_to_datetime_with_warn(const char *str, uint length,
1803
 
                                         TIME *l_time, uint flags);
1804
 
void localtime_to_TIME(TIME *to, struct tm *from);
1805
 
void calc_time_from_sec(TIME *to, long seconds, long microseconds);
 
1847
                                         MYSQL_TIME *l_time, uint flags);
 
1848
void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
 
1849
void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds);
1806
1850
 
1807
 
void make_truncated_value_warning(THD *thd, const char *str_val,
 
1851
void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
 
1852
                                  const char *str_val,
1808
1853
                                  uint str_length, timestamp_type time_type,
1809
1854
                                  const char *field_name);
1810
1855
 
1811
 
bool date_add_interval(TIME *ltime, interval_type int_type, INTERVAL interval);
1812
 
bool calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign,
 
1856
bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval);
 
1857
bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign,
1813
1858
                    longlong *seconds_out, long *microseconds_out);
1814
1859
 
1815
1860
extern LEX_STRING interval_type_to_name[];
1821
1866
                                               DATE_TIME_FORMAT *format);
1822
1867
const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
1823
1868
                                     timestamp_type type);
1824
 
extern bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time,
 
1869
extern bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
1825
1870
                           timestamp_type type, String *str);
1826
 
void make_datetime(const DATE_TIME_FORMAT *format, const TIME *l_time,
 
1871
void make_datetime(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
1827
1872
                   String *str);
1828
 
void make_date(const DATE_TIME_FORMAT *format, const TIME *l_time,
1829
 
               String *str);
1830
 
void make_time(const DATE_TIME_FORMAT *format, const TIME *l_time,
1831
 
               String *str);
1832
 
int my_time_compare(TIME *a, TIME *b);
 
1873
void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
 
1874
               String *str);
 
1875
void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
 
1876
               String *str);
 
1877
int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
1833
1878
 
1834
1879
int test_if_number(char *str,int *res,bool allow_wildcards);
1835
1880
void change_byte(byte *,uint,char,char);
1849
1894
int get_quick_record(SQL_SELECT *select);
1850
1895
 
1851
1896
int calc_weekday(long daynr,bool sunday_first_day_of_week);
1852
 
uint calc_week(TIME *l_time, uint week_behaviour, uint *year);
 
1897
uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year);
1853
1898
void find_date(char *pos,uint *vek,uint flag);
1854
1899
TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end);
1855
1900
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);
2000
2045
  table->const_table= 0;
2001
2046
  table->null_row= 0;
2002
2047
  table->status= STATUS_NO_RECORD;
2003
 
  table->keys_in_use_for_query= table->s->keys_in_use;
2004
2048
  table->maybe_null= table_list->outer_join;
2005
2049
  TABLE_LIST *embedding= table_list->embedding;
2006
2050
  while (!table->maybe_null && embedding)
2011
2055
  table->tablenr= tablenr;
2012
2056
  table->map= (table_map) 1 << tablenr;
2013
2057
  table->force_index= table_list->force_index;
 
2058
  table->covering_keys= table->s->keys_for_keyread;
 
2059
  table->merge_keys.clear_all();
2014
2060
}
2015
2061
 
2016
2062