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;
152
152
MY_LOCALE *my_locale_by_name(const char *name);
153
153
MY_LOCALE *my_locale_by_number(uint number);
341
339
/* The following is used to detect a conflict with DISTINCT */
342
340
#define SELECT_ALL (ULL(1) << 24) // SELECT, user, parser
344
/* Set if we are updating a non-transaction safe table */
345
#define OPTION_STATUS_NO_TRANS_UPDATE (ULL(1) << 25) // THD, intern
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.
370
#define MAX_TIME_ZONE_NAME_LENGTH 72
365
#define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1)
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).
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
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,
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,
628
627
enum enum_mysql_completiontype {
629
628
ROLLBACK_RELEASE=-2, ROLLBACK=1, ROLLBACK_AND_CHAIN=7,
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)
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*/
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,
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,
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();
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);
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))
1129
1141
/* sql_prepare.cc */
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;
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)
1216
enum enum_resolution_type {
1218
RESOLVED_IGNORING_ALIAS,
1219
RESOLVED_BEHIND_ALIAS,
1220
RESOLVED_WITH_NO_ALIAS,
1221
RESOLVED_AGAINST_ALIAS
1191
1223
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,
1192
1224
find_item_error_report_type report_error,
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,
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);
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);
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();
1473
1515
int find_ref_key(KEY *key, uint key_count, byte *record, Field *field,
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,
1573
uint find_type2(const TYPELIB *lib, const char *find, uint length,
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,
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);
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);
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);
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,
1828
void make_date(const DATE_TIME_FORMAT *format, const TIME *l_time,
1830
void make_time(const DATE_TIME_FORMAT *format, const TIME *l_time,
1832
int my_time_compare(TIME *a, TIME *b);
1873
void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
1875
void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
1877
int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
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);
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)