16
16
#define DRIZZLE_LEX 1
17
17
#include <drizzled/server_includes.h>
18
#include <drizzled/sql_repl.h>
19
#include <drizzled/rpl_filter.h>
18
#include <libdrizzleclient/libdrizzle.h>
19
#include <mysys/hash.h>
20
20
#include <drizzled/logging.h>
21
#include <drizzled/db.h>
21
22
#include <drizzled/error.h>
22
23
#include <drizzled/nested_join.h>
23
24
#include <drizzled/query_id.h>
24
25
#include <drizzled/sql_parse.h>
25
26
#include <drizzled/data_home.h>
27
#include <drizzled/sql_base.h>
28
#include <drizzled/show.h>
29
#include <drizzled/rename.h>
30
#include <drizzled/function/time/unix_timestamp.h>
31
#include <drizzled/function/get_system_var.h>
32
#include <drizzled/item/cmpfunc.h>
33
#include <drizzled/item/null.h>
34
#include <drizzled/session.h>
35
#include <drizzled/sql_load.h>
36
#include <drizzled/connect.h>
37
#include <drizzled/lock.h>
38
#include <drizzled/select_send.h>
28
44
@defgroup Runtime_Environment Runtime Environment
48
extern size_t my_thread_stack_size;
32
49
extern const CHARSET_INFO *character_set_filesystem;
33
50
const char *any_db="*any*"; // Special symbol for check_access
48
65
{ C_STRING_WITH_LEN("Ping") },
49
66
{ C_STRING_WITH_LEN("Time") },
50
67
{ C_STRING_WITH_LEN("Change user") },
51
{ C_STRING_WITH_LEN("Binlog Dump") },
52
68
{ C_STRING_WITH_LEN("Connect Out") },
53
{ C_STRING_WITH_LEN("Register Slave") },
54
69
{ C_STRING_WITH_LEN("Set option") },
55
70
{ C_STRING_WITH_LEN("Daemon") },
56
71
{ C_STRING_WITH_LEN("Error") } // Last command number
123
138
Returns true if all tables should be ignored.
125
inline bool all_tables_not_ok(Session *session, TableList *tables)
127
return rpl_filter->is_on() && tables &&
128
!rpl_filter->tables_ok(session->db, tables);
132
static bool some_non_temp_table_to_be_updated(Session *session, TableList *tables)
134
for (TableList *table= tables; table; table= table->next_global)
136
assert(table->db && table->table_name);
137
if (table->updating &&
138
!find_temporary_table(session, table->db, table->table_name))
140
inline bool all_tables_not_ok(Session *, TableList *)
146
146
Mark all commands that somehow changes a table.
155
155
a number of modified rows
158
uint32_t sql_command_flags[SQLCOM_END+1];
158
bitset<CF_BIT_SIZE> sql_command_flags[SQLCOM_END+1];
160
160
void init_update_queries(void)
162
memset(&sql_command_flags, 0, sizeof(sql_command_flags));
164
for (x= 0; x <= SQLCOM_END; x++)
165
sql_command_flags[x].reset();
164
167
sql_command_flags[SQLCOM_CREATE_TABLE]= CF_CHANGES_DATA;
165
168
sql_command_flags[SQLCOM_CREATE_INDEX]= CF_CHANGES_DATA;
187
190
sql_command_flags[SQLCOM_SHOW_FIELDS]= CF_STATUS_COMMAND;
188
191
sql_command_flags[SQLCOM_SHOW_KEYS]= CF_STATUS_COMMAND;
189
192
sql_command_flags[SQLCOM_SHOW_VARIABLES]= CF_STATUS_COMMAND;
190
sql_command_flags[SQLCOM_SHOW_BINLOGS]= CF_STATUS_COMMAND;
191
193
sql_command_flags[SQLCOM_SHOW_WARNS]= CF_STATUS_COMMAND;
192
194
sql_command_flags[SQLCOM_SHOW_ERRORS]= CF_STATUS_COMMAND;
193
195
sql_command_flags[SQLCOM_SHOW_ENGINE_STATUS]= CF_STATUS_COMMAND;
194
196
sql_command_flags[SQLCOM_SHOW_PROCESSLIST]= CF_STATUS_COMMAND;
195
197
sql_command_flags[SQLCOM_SHOW_CREATE_DB]= CF_STATUS_COMMAND;
196
198
sql_command_flags[SQLCOM_SHOW_CREATE]= CF_STATUS_COMMAND;
197
sql_command_flags[SQLCOM_SHOW_MASTER_STAT]= CF_STATUS_COMMAND;
198
sql_command_flags[SQLCOM_SHOW_SLAVE_STAT]= CF_STATUS_COMMAND;
200
200
sql_command_flags[SQLCOM_SHOW_TABLES]= (CF_STATUS_COMMAND |
201
201
CF_SHOW_TABLE_COMMAND);
214
214
bool is_update_query(enum enum_sql_command command)
216
216
assert(command >= 0 && command <= SQLCOM_END);
217
return (sql_command_flags[command] & CF_CHANGES_DATA) != 0;
217
return (sql_command_flags[command].test(CF_BIT_CHANGES_DATA));
220
220
void execute_init_command(Session *session, sys_var_str *init_command_var,
221
rw_lock_t *var_mutex)
221
pthread_rwlock_t *var_mutex)
224
224
ulong save_client_capabilities;
229
229
during execution of init_command_var query
230
230
values of init_command_var can't be changed
232
rw_rdlock(var_mutex);
232
pthread_rwlock_rdlock(var_mutex);
233
233
save_client_capabilities= session->client_capabilities;
234
234
session->client_capabilities|= CLIENT_MULTI_STATEMENTS;
241
241
dispatch_command(COM_QUERY, session,
242
242
init_command_var->value,
243
243
init_command_var->value_length);
244
rw_unlock(var_mutex);
244
pthread_rwlock_unlock(var_mutex);
245
245
session->client_capabilities= save_client_capabilities;
246
246
session->net.vio= save_vio;
347
347
the client, the connection is closed or "net_wait_timeout"
348
348
number of seconds has passed
350
my_net_set_read_timeout(net, session->variables.net_wait_timeout);
350
drizzleclient_net_set_read_timeout(net, session->variables.net_wait_timeout);
353
XXX: this code is here only to clear possible errors of init_connect.
353
XXX: this code is here only to clear possible errors of init_connect.
354
354
Consider moving to init_connect() instead.
356
356
session->clear_error(); // Clear error message
359
359
net_new_transaction(net);
361
packet_length= my_net_read(net);
361
packet_length= drizzleclient_net_read(net);
362
362
if (packet_length == packet_error)
364
364
/* Check if we can continue without closing the connection */
366
366
/* The error must be set. */
367
assert(session->is_error());
368
net_end_statement(session);
367
/* This assert is killing me - and tracking down why the error isn't
368
* set here is a waste since the protocol lib is being replaced. */
369
//assert(session->is_error());
370
drizzleclient_net_end_statement(session);
370
372
if (net->error != 3)
381
383
packet= (char*) net->read_pos;
383
385
'packet_length' contains length of data, as it was stored in packet
384
header. In case of malformed header, my_net_read returns zero.
385
If packet_length is not zero, my_net_read ensures that the returned
386
header. In case of malformed header, drizzleclient_net_read returns zero.
387
If packet_length is not zero, drizzleclient_net_read ensures that the returned
386
388
number of bytes was actually read from network.
387
There is also an extra safety measure in my_net_read:
389
There is also an extra safety measure in drizzleclient_net_read:
388
390
it sets packet[packet_length]= 0, but only for non-zero packets.
390
392
if (packet_length == 0) /* safety */
393
395
packet[0]= (unsigned char) COM_SLEEP;
394
396
packet_length= 1;
396
/* Do not rely on my_net_read, extra safety against programming errors. */
398
/* Do not rely on drizzleclient_net_read, extra safety against programming errors. */
397
399
packet[packet_length]= '\0'; /* safety */
399
401
command= (enum enum_server_command) (unsigned char) packet[0];
402
404
command= COM_END; // Wrong command
404
406
/* Restore read timeout value */
405
my_net_set_read_timeout(net, session->variables.net_read_timeout);
407
drizzleclient_net_set_read_timeout(net, session->variables.net_read_timeout);
407
409
assert(packet_length);
408
410
return_value= dispatch_command(command, session, packet+1, (uint32_t) (packet_length-1));
415
Determine if an attempt to update a non-temporary table while the
416
read-only option was enabled has been made.
418
This is a helper function to mysql_execute_command.
420
@note SQLCOM_MULTI_UPDATE is an exception and dealt with elsewhere.
422
@see mysql_execute_command
425
@retval true The statement should be denied.
426
@retval false The statement isn't updating any relevant tables.
429
static bool deny_updates_if_read_only_option(Session *session,
430
TableList *all_tables)
435
LEX *lex= session->lex;
437
if (!(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA))
440
/* Multi update is an exception and is dealt with later. */
441
if (lex->sql_command == SQLCOM_UPDATE_MULTI)
444
const bool create_temp_tables=
445
(lex->sql_command == SQLCOM_CREATE_TABLE) &&
446
(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE);
448
const bool drop_temp_tables=
449
(lex->sql_command == SQLCOM_DROP_TABLE) &&
452
const bool update_real_tables=
453
some_non_temp_table_to_be_updated(session, all_tables) &&
454
!(create_temp_tables || drop_temp_tables);
457
const bool create_or_drop_databases=
458
(lex->sql_command == SQLCOM_CREATE_DB) ||
459
(lex->sql_command == SQLCOM_DROP_DB);
461
if (update_real_tables || create_or_drop_databases)
464
An attempt was made to modify one or more non-temporary tables.
470
/* Assuming that only temporary tables are modified. */
475
417
Perform one connection-level (COM_XXXX) command.
477
419
@param command type of command to perform
610
552
save_db= session->db;
611
553
save_user_connect= session->user_connect;
613
if (!(session->security_ctx->user= my_strdup(user, MYF(0))))
615
session->security_ctx->user= save_security_ctx.user;
616
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
555
old_username= session->security_ctx.user;
556
session->security_ctx.user.assign(user);
620
558
/* Clear variables that are allocated */
621
559
session->user_connect= 0;
622
res= check_user(session, passwd, passwd_len, db, false);
560
res= check_user(session, passwd, passwd_len, db);
626
if (session->security_ctx->user)
627
free(session->security_ctx->user);
628
*session->security_ctx= save_security_ctx;
564
session->security_ctx.user= old_username;
629
565
session->user_connect= save_user_connect;
630
566
session->db= save_db;
631
567
session->db_length= save_db_length;
714
647
packet= arg_end + 1;
716
649
if (!my_strcasecmp(system_charset_info, table_list.db,
717
INFORMATION_SCHEMA_NAME.str))
650
INFORMATION_SCHEMA_NAME.c_str()))
719
652
ST_SCHEMA_TABLE *schema_table= find_schema_table(session, table_list.alias);
720
653
if (schema_table)
751
684
session->main_da.disable_status(); // Don't send anything back
752
685
error=true; // End server
754
case COM_BINLOG_DUMP:
758
uint32_t slave_server_id;
760
status_var_increment(session->status_var.com_other);
761
/* TODO: The following has to be changed to an 8 byte integer */
762
pos = uint4korr(packet);
763
flags = uint2korr(packet + 4);
764
session->server_id=0; /* avoid suicide */
765
if ((slave_server_id= uint4korr(packet+6))) // mysqlbinlog.server_id==0
766
kill_zombie_dump_threads(slave_server_id);
767
session->server_id = slave_server_id;
769
mysql_binlog_send(session, session->strdup(packet + 10), (my_off_t) pos, flags);
770
/* fake COM_QUIT -- if we get here, the thread needs to terminate */
774
687
case COM_SHUTDOWN:
776
689
status_var_increment(session->status_var.com_other);
778
691
close_thread_tables(session); // Free before kill
784
697
status_var_increment(session->status_var.com_other);
785
my_ok(session); // Tell client we are alive
698
session->my_ok(); // Tell client we are alive
787
700
case COM_PROCESS_INFO:
788
701
status_var_increment(session->status_var.com_stat[SQLCOM_SHOW_PROCESSLIST]);
803
716
switch (opt_command) {
804
717
case (int) DRIZZLE_OPTION_MULTI_STATEMENTS_ON:
805
718
session->client_capabilities|= CLIENT_MULTI_STATEMENTS;
808
721
case (int) DRIZZLE_OPTION_MULTI_STATEMENTS_OFF:
809
722
session->client_capabilities&= ~CLIENT_MULTI_STATEMENTS;
813
726
my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
880
793
This function is used in the parser to convert a SHOW or DESCRIBE
881
794
table_name command to a SELECT from INFORMATION_SCHEMA.
882
It prepares a SELECT_LEX and a TableList object to represent the
795
It prepares a Select_Lex and a TableList object to represent the
883
796
given command as a SELECT parse tree.
885
798
@param session thread handle
903
816
int prepare_schema_table(Session *session, LEX *lex, Table_ident *table_ident,
904
817
enum enum_schema_tables schema_table_idx)
906
SELECT_LEX *schema_select_lex= NULL;
819
Select_Lex *schema_select_lex= NULL;
908
821
switch (schema_table_idx) {
909
822
case SCH_SCHEMATA:
936
849
assert(table_ident);
937
850
TableList **query_tables_last= lex->query_tables_last;
938
schema_select_lex= new SELECT_LEX();
851
schema_select_lex= new Select_Lex();
939
852
/* 'parent_lex' is used in init_query() so it must be before it. */
940
853
schema_select_lex->parent_lex= lex;
941
854
schema_select_lex->init_query();
1018
static void reset_one_shot_variables(Session *session)
1020
session->variables.character_set_client=
1021
global_system_variables.character_set_client;
1022
session->variables.collation_connection=
1023
global_system_variables.collation_connection;
1024
session->variables.collation_database=
1025
global_system_variables.collation_database;
1026
session->variables.collation_server=
1027
global_system_variables.collation_server;
1028
session->update_charset();
1029
session->variables.time_zone=
1030
global_system_variables.time_zone;
1031
session->variables.lc_time_names= &my_locale_en_US;
1032
session->one_shot_set= 0;
1037
932
Execute command saved in session and lex->sql_command.
1070
965
bool need_start_waiting= false; // have protection against global read lock
1072
966
LEX *lex= session->lex;
1073
/* first SELECT_LEX (have special meaning for many of non-SELECTcommands) */
1074
SELECT_LEX *select_lex= &lex->select_lex;
1075
/* first table of first SELECT_LEX */
967
/* first Select_Lex (have special meaning for many of non-SELECTcommands) */
968
Select_Lex *select_lex= &lex->select_lex;
969
/* first table of first Select_Lex */
1076
970
TableList *first_table= (TableList*) select_lex->table_list.first;
1077
971
/* list of all tables in query */
1078
972
TableList *all_tables;
1079
/* most outer SELECT_LEX_UNIT of query */
1080
SELECT_LEX_UNIT *unit= &lex->unit;
973
/* most outer Select_Lex_Unit of query */
974
Select_Lex_Unit *unit= &lex->unit;
1081
975
/* Saved variable value */
1084
In many cases first table of main SELECT_LEX have special meaning =>
1085
check that it is first table in global list and relink it first in
978
In many cases first table of main Select_Lex have special meaning =>
979
check that it is first table in global list and relink it first in
1086
980
queries_tables list if it is necessary (we need such relinking only
1087
981
for queries with subqueries in select list, in this case tables of
1088
982
subqueries will go to global list first)
1090
all_tables will differ from first_table only if most upper SELECT_LEX
984
all_tables will differ from first_table only if most upper Select_Lex
1091
985
do not contain tables.
1093
987
Because of above in place where should be at least one table in most
1094
outer SELECT_LEX we have following check:
988
outer Select_Lex we have following check:
1095
989
assert(first_table == all_tables);
1096
990
assert(first_table == all_tables && first_table != 0);
1113
1007
if (all_tables || !lex->is_single_level_stmt())
1114
1008
drizzle_reset_errors(session, 0);
1116
if (unlikely(session->slave_thread))
1119
Check if statment should be skipped because of slave filtering
1123
- UPDATE MULTI: For this statement, we want to check the filtering
1124
rules later in the code
1125
- SET: we always execute it (Not that many SET commands exists in
1126
the binary log anyway -- only 4.1 masters write SET statements,
1127
in 5.0 there are no SET statements in the binary log)
1128
- DROP TEMPORARY TABLE IF EXISTS: we always execute it (otherwise we
1129
have stale files on slave caused by exclusion of one tmp table).
1131
if (!(lex->sql_command == SQLCOM_UPDATE_MULTI) &&
1132
!(lex->sql_command == SQLCOM_SET_OPTION) &&
1133
!(lex->sql_command == SQLCOM_DROP_TABLE &&
1134
lex->drop_temporary && lex->drop_if_exists) &&
1135
all_tables_not_ok(session, all_tables))
1137
/* we warn the slave SQL thread */
1138
my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
1139
if (session->one_shot_set)
1142
It's ok to check session->one_shot_set here:
1144
The charsets in a MySQL 5.0 slave can change by both a binlogged
1145
SET ONE_SHOT statement and the event-internal charset setting,
1146
and these two ways to change charsets do not seems to work
1149
At least there seems to be problems in the rli cache for
1150
charsets if we are using ONE_SHOT. Note that this is normally no
1151
problem because either the >= 5.0 slave reads a 4.1 binlog (with
1152
ONE_SHOT) *or* or 5.0 binlog (without ONE_SHOT) but never both."
1154
reset_one_shot_variables(session);
1162
When option readonly is set deny operations which change non-temporary
1163
tables. Except for the replication thread and the 'super' users.
1165
if (deny_updates_if_read_only_option(session, all_tables))
1167
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
1170
} /* endif unlikely slave */
1171
1010
status_var_increment(session->status_var.com_stat[lex->sql_command]);
1173
1012
assert(session->transaction.stmt.modified_non_trans_table == false);
1175
1014
switch (lex->sql_command) {
1176
1015
case SQLCOM_SHOW_STATUS:
1208
1047
case SQLCOM_EMPTY_QUERY:
1214
res = purge_master_logs(session, lex->to_log);
1217
case SQLCOM_PURGE_BEFORE:
1221
/* PURGE MASTER LOGS BEFORE 'data' */
1222
it= (Item *)lex->value_list.head();
1223
if ((!it->fixed && it->fix_fields(lex->session, &it)) ||
1226
my_error(ER_WRONG_ARGUMENTS, MYF(0), "PURGE LOGS BEFORE");
1229
it= new Item_func_unix_timestamp(it);
1231
it is OK only emulate fix_fieds, because we need only
1234
it->quick_fix_field();
1235
res = purge_master_logs_before_date(session, (ulong)it->val_int());
1238
1051
case SQLCOM_SHOW_WARNS:
1240
1053
res= mysqld_show_warnings(session, (uint32_t)
1256
1069
res= mysql_assign_to_keycache(session, first_table, &lex->ident);
1259
case SQLCOM_CHANGE_MASTER:
1261
pthread_mutex_lock(&LOCK_active_mi);
1262
res = change_master(session,active_mi);
1263
pthread_mutex_unlock(&LOCK_active_mi);
1266
case SQLCOM_SHOW_SLAVE_STAT:
1268
pthread_mutex_lock(&LOCK_active_mi);
1269
if (active_mi != NULL)
1271
res = show_master_info(session, active_mi);
1275
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, 0,
1276
"the master info structure does not exist");
1279
pthread_mutex_unlock(&LOCK_active_mi);
1282
case SQLCOM_SHOW_MASTER_STAT:
1284
res = show_binlog_info(session);
1288
1072
case SQLCOM_SHOW_ENGINE_STATUS:
1290
1074
res = ha_show_status(session, lex->create_info.db_type, HA_ENGINE_STATUS);
1418
1202
select_tables)))
1421
CREATE from SELECT give its SELECT_LEX for SELECT,
1205
CREATE from SELECT give its Select_Lex for SELECT,
1422
1206
and item_list belong to SELECT
1424
1208
res= handle_select(session, lex, result, 0);
1486
1270
0, (order_st*) 0, 0);
1489
case SQLCOM_SLAVE_START:
1491
pthread_mutex_lock(&LOCK_active_mi);
1492
start_slave(session,active_mi,1 /* net report*/);
1493
pthread_mutex_unlock(&LOCK_active_mi);
1496
case SQLCOM_SLAVE_STOP:
1498
If the client thread has locked tables, a deadlock is possible.
1500
- the client thread does LOCK TABLE t READ.
1501
- then the master updates t.
1502
- then the SQL slave thread wants to update t,
1503
so it waits for the client thread because t is locked by it.
1504
- then the client thread does SLAVE STOP.
1505
SLAVE STOP waits for the SQL slave thread to terminate its
1506
update t, which waits for the client thread because t is locked by it.
1507
To prevent that, refuse SLAVE STOP if the
1508
client thread has locked tables
1510
if (session->locked_tables || session->active_transaction() || session->global_read_lock)
1512
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
1513
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
1517
pthread_mutex_lock(&LOCK_active_mi);
1518
stop_slave(session,active_mi,1/* net report*/);
1519
pthread_mutex_unlock(&LOCK_active_mi);
1523
1273
case SQLCOM_ALTER_TABLE:
1524
1274
assert(first_table == all_tables && first_table != 0);
1658
1403
case SQLCOM_UPDATE:
1659
1404
assert(first_table == all_tables && first_table != 0);
1660
if (update_precheck(session, all_tables))
1405
if ((res= update_precheck(session, all_tables)))
1662
1407
assert(select_lex->offset_limit == 0);
1663
1408
unit->set_limit(select_lex);
1664
res= (up_result= mysql_update(session, all_tables,
1665
select_lex->item_list,
1668
select_lex->order_list.elements,
1669
(order_st *) select_lex->order_list.first,
1670
unit->select_limit_cnt,
1671
lex->duplicates, lex->ignore));
1672
/* mysql_update return 2 if we need to switch to multi-update */
1409
res= mysql_update(session, all_tables,
1410
select_lex->item_list,
1413
select_lex->order_list.elements,
1414
(order_st *) select_lex->order_list.first,
1415
unit->select_limit_cnt,
1416
lex->duplicates, lex->ignore);
1676
1418
case SQLCOM_UPDATE_MULTI:
1678
1420
assert(first_table == all_tables && first_table != 0);
1679
/* if we switched from normal update, rights are checked */
1682
if ((res= multi_update_precheck(session, all_tables)))
1688
res= mysql_multi_update_prepare(session);
1690
/* Check slave filtering rules */
1691
if (unlikely(session->slave_thread))
1693
if (all_tables_not_ok(session, all_tables))
1697
res= 0; /* don't care of prev failure */
1698
session->clear_error(); /* filters are of highest prior */
1700
/* we warn the slave SQL thread */
1701
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
1712
some_non_temp_table_to_be_updated(session, all_tables))
1714
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
1421
if ((res= update_precheck(session, all_tables)))
1424
if ((res= mysql_multi_update_prepare(session)))
1719
1427
res= mysql_multi_update(session, all_tables,
1720
1428
&select_lex->item_list,
1773
1481
/* Skip first table, which is the table we are inserting in */
1774
1482
TableList *second_table= first_table->next_local;
1775
1483
select_lex->table_list.first= (unsigned char*) second_table;
1776
select_lex->context.table_list=
1484
select_lex->context.table_list=
1777
1485
select_lex->context.first_name_resolution_table= second_table;
1778
1486
res= mysql_insert_select_prepare(session);
1779
1487
if (!res && (sel_result= new select_insert(first_table,
1867
1575
/* condition will be true on SP re-excuting */
1868
1576
if (select_lex->item_list.elements != 0)
1869
1577
select_lex->item_list.empty();
1870
if (add_item_to_list(session, new Item_null()))
1578
if (session->add_item_to_list(new Item_null()))
1873
1581
session->set_proc_info("init");
1914
If this is a slave thread, we may sometimes execute some
1915
DROP / * 40005 TEMPORARY * / TABLE
1916
that come from parts of binlogs (likely if we use RESET SLAVE or CHANGE
1917
MASTER TO), while the temporary table has already been dropped.
1918
To not generate such irrelevant "table does not exist errors",
1919
we silently add IF EXISTS if TEMPORARY was used.
1921
if (session->slave_thread)
1922
lex->drop_if_exists= 1;
1924
1621
/* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */
1925
1622
session->options|= OPTION_KEEP_LOG;
1975
1672
if (open_and_lock_tables(session, all_tables))
1977
if (lex->one_shot_set && not_all_support_one_shot(lex_var_list))
1979
my_error(ER_RESERVED_SYNTAX, MYF(0), "SET ONE_SHOT");
1982
1674
if (!(res= sql_set_variables(session, lex_var_list)))
1985
If the previous command was a SET ONE_SHOT, we don't want to forget
1986
about the ONE_SHOT property of that SET. So we use a |= instead of = .
1988
session->one_shot_set|= lex->one_shot_set;
2068
1755
session->locked_tables=session->lock;
2069
1756
session->lock=0;
2070
1757
(void) set_handler_table_locks(session, all_tables, false);
2076
1763
Need to end the current transaction, so the storage engine (InnoDB)
2077
1764
can free its locks if LOCK TABLES locked some tables before finding
2078
1765
that it can't lock a table in its list
2103
1790
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
2107
If in a slave thread :
2108
CREATE DATABASE DB was certainly not preceded by USE DB.
2109
For that reason, db_ok() in sql/slave.cc did not check the
2110
do_db/ignore_db. And as this query involves no tables, tables_ok()
2111
above was not called. So we have to check rules again here.
2113
if (session->slave_thread &&
2114
(!rpl_filter->db_ok(lex->name.str) ||
2115
!rpl_filter->db_ok_with_wild_table(lex->name.str)))
2117
my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
2120
1793
res= mysql_create_db(session,(lower_case_table_names == 2 ? alias :
2121
1794
lex->name.str), &create_info, 0);
2133
1806
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
2137
If in a slave thread :
2138
DROP DATABASE DB may not be preceded by USE DB.
2139
For that reason, maybe db_ok() in sql/slave.cc did not check the
2140
do_db/ignore_db. And as this query involves no tables, tables_ok()
2141
above was not called. So we have to check rules again here.
2143
if (session->slave_thread &&
2144
(!rpl_filter->db_ok(lex->name.str) ||
2145
!rpl_filter->db_ok_with_wild_table(lex->name.str)))
2147
my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
2150
1809
if (session->locked_tables || session->active_transaction())
2152
1811
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
2165
1824
my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
2169
If in a slave thread :
2170
ALTER DATABASE DB may not be preceded by USE DB.
2171
For that reason, maybe db_ok() in sql/slave.cc did not check the
2172
do_db/ignore_db. And as this query involves no tables, tables_ok()
2173
above was not called. So we have to check rules again here.
2175
if (session->slave_thread &&
2176
(!rpl_filter->db_ok(db->str) ||
2177
!rpl_filter->db_ok_with_wild_table(db->str)))
2179
my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
2182
1827
if (session->locked_tables || session->active_transaction())
2184
1829
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
2217
1861
Presumably, RESET and binlog writing doesn't require synchronization
2219
1863
write_bin_log(session, false, session->query, session->query_length);
2225
1869
case SQLCOM_KILL:
2227
1871
Item *it= (Item *)lex->value_list.head();
2229
if (lex->table_or_sp_used())
2231
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries or stored "
2232
"function calls as part of this statement");
2236
1873
if ((!it->fixed && it->fix_fields(lex->session, &it)) || it->check_cols(1))
2238
1875
my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY),
2255
1892
if (begin_trans(session))
2259
1896
case SQLCOM_COMMIT:
2260
1897
if (end_trans(session, lex->tx_release ? COMMIT_RELEASE :
2261
1898
lex->tx_chain ? COMMIT_AND_CHAIN : COMMIT))
2265
1902
case SQLCOM_ROLLBACK:
2266
1903
if (end_trans(session, lex->tx_release ? ROLLBACK_RELEASE :
2267
1904
lex->tx_chain ? ROLLBACK_AND_CHAIN : ROLLBACK))
2271
1908
case SQLCOM_RELEASE_SAVEPOINT:
2306
1943
res= true; // cannot happen
2309
if (((session->options & OPTION_KEEP_LOG) ||
2310
session->transaction.all.modified_non_trans_table) &&
2311
!session->slave_thread)
1946
if ((session->options & OPTION_KEEP_LOG) || session->transaction.all.modified_non_trans_table)
2312
1947
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2313
1948
ER_WARNING_NOT_COMPLETE_ROLLBACK,
2314
1949
ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
2317
1952
session->transaction.savepoints=sv;
2360
1995
newsv->prev=session->transaction.savepoints;
2361
1996
session->transaction.savepoints=newsv;
2366
case SQLCOM_BINLOG_BASE64_EVENT:
2368
mysql_client_binlog_statement(session);
2372
2002
assert(0); /* Impossible */
2376
2006
session->set_proc_info("query end");
2379
Binlog-related cleanup:
2380
Reset system variables temporarily modified by SET ONE SHOT.
2382
Exception: If this is a SET, do nothing. This is to allow
2383
mysqlbinlog to print many SET commands (in this case we want the
2384
charset temp setting to live until the real query). This is also
2385
needed so that SET CHARACTER_SET_CLIENT... does not cancel itself
2388
if (session->one_shot_set && lex->sql_command != SQLCOM_SET_OPTION)
2389
reset_one_shot_variables(session);
2392
2009
The return value for ROW_COUNT() is "implementation dependent" if the
2393
2010
statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC
2394
2011
wants. We also keep the last value in case of SQLCOM_CALL or
2395
2012
SQLCOM_EXECUTE.
2397
if (!(sql_command_flags[lex->sql_command] & CF_HAS_ROW_COUNT))
2014
if (!(sql_command_flags[lex->sql_command].test(CF_BIT_HAS_ROW_COUNT)))
2398
2015
session->row_count_func= -1;
2422
2039
/* assign global limit variable if limit is not given */
2424
SELECT_LEX *param= lex->unit.global_parameters;
2041
Select_Lex *param= lex->unit.global_parameters;
2425
2042
if (!param->explicit_limit)
2426
2043
param->select_limit=
2427
2044
new Item_int((uint64_t) session->variables.select_limit);
2471
/****************************************************************************
2472
Check stack size; Send error if there isn't enough stack to continue
2473
****************************************************************************/
2474
#if STACK_DIRECTION < 0
2475
#define used_stack(A,B) (long) (A - B)
2477
#define used_stack(A,B) (long) (B - A)
2482
Note: The 'buf' parameter is necessary, even if it is unused here.
2483
- fix_fields functions has a "dummy" buffer large enough for the
2484
corresponding exec. (Thus we only have to check in fix_fields.)
2485
- Passing to check_stack_overrun() prevents the compiler from removing it.
2487
bool check_stack_overrun(Session *session, long margin, unsigned char *)
2490
assert(session == current_session);
2491
if ((stack_used=used_stack(session->thread_stack,(char*) &stack_used)) >=
2492
(long) (my_thread_stack_size - margin))
2494
sprintf(errbuff[0],ER(ER_STACK_OVERRUN_NEED_MORE),
2495
stack_used,my_thread_stack_size,margin);
2496
my_message(ER_STACK_OVERRUN_NEED_MORE,errbuff[0],MYF(ME_FATALERROR));
2502
2089
#define MY_YACC_INIT 1000 // Start with big alloc
2503
2090
#define MY_YACC_MAX 32000 // Because of 'short'
2511
2098
if (!lex->yacc_yyvs)
2512
2099
old_info= *yystacksize;
2513
2100
*yystacksize= set_zone((*yystacksize)*2,MY_YACC_INIT,MY_YACC_MAX);
2514
if (!(lex->yacc_yyvs= (unsigned char*)
2515
my_realloc(lex->yacc_yyvs,
2516
*yystacksize*sizeof(**yyvs),
2517
MYF(MY_ALLOW_ZERO_PTR | MY_FREE_ON_ERROR))) ||
2518
!(lex->yacc_yyss= (unsigned char*)
2519
my_realloc(lex->yacc_yyss,
2520
*yystacksize*sizeof(**yyss),
2521
MYF(MY_ALLOW_ZERO_PTR | MY_FREE_ON_ERROR))))
2101
unsigned char *tmpptr= NULL;
2102
if (!(tmpptr= (unsigned char *)realloc(lex->yacc_yyvs,
2103
*yystacksize* sizeof(**yyvs))))
2105
lex->yacc_yyvs= tmpptr;
2107
if (!(tmpptr= (unsigned char*)realloc(lex->yacc_yyss,
2108
*yystacksize* sizeof(**yyss))))
2110
lex->yacc_yyss= tmpptr;
2524
2112
{ // Copy old info from stack
2525
2113
memcpy(lex->yacc_yyss, *yyss, old_info*sizeof(**yyss));
2535
Reset Session part responsible for command processing state.
2537
This needs to be called before execution of every statement
2538
(prepared or conventional).
2539
It is not called by substatements of routines.
2542
Make it a method of Session and align its name with the rest of
2543
reset/end/start/init methods.
2545
Call it after we use Session for queries, not before.
2548
void mysql_reset_session_for_next_command(Session *session)
2550
session->free_list= 0;
2551
session->select_number= 1;
2553
Those two lines below are theoretically unneeded as
2554
Session::cleanup_after_query() should take care of this already.
2556
session->auto_inc_intervals_in_cur_stmt_for_binlog.empty();
2557
session->stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0;
2559
session->query_start_used= 0;
2560
session->is_fatal_error= session->time_zone_used= 0;
2561
session->server_status&= ~ (SERVER_MORE_RESULTS_EXISTS |
2562
SERVER_QUERY_NO_INDEX_USED |
2563
SERVER_QUERY_NO_GOOD_INDEX_USED);
2565
If in autocommit mode and not in a transaction, reset
2566
OPTION_STATUS_NO_TRANS_UPDATE | OPTION_KEEP_LOG to not get warnings
2567
in ha_rollback_trans() about some tables couldn't be rolled back.
2569
if (!(session->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
2571
session->options&= ~OPTION_KEEP_LOG;
2572
session->transaction.all.modified_non_trans_table= false;
2574
assert(session->security_ctx== &session->main_security_ctx);
2575
session->thread_specific_used= false;
2579
reset_dynamic(&session->user_var_events);
2580
session->user_var_events_alloc= session->mem_root;
2582
session->clear_error();
2583
session->main_da.reset_diagnostics_area();
2584
session->total_warn_count=0; // Warnings for this query
2585
session->rand_used= 0;
2586
session->sent_row_count= session->examined_row_count= 0;
2589
Because we come here only for start of top-statements, binlog format is
2590
constant inside a complex statement (using stored functions) etc.
2592
session->reset_current_stmt_binlog_row_based();
2599
2123
mysql_init_select(LEX *lex)
2601
SELECT_LEX *select_lex= lex->current_select;
2125
Select_Lex *select_lex= lex->current_select;
2602
2126
select_lex->init_select();
2604
2128
if (select_lex == &lex->select_lex)
2613
2137
mysql_new_select(LEX *lex, bool move_down)
2615
SELECT_LEX *select_lex;
2139
Select_Lex *select_lex;
2616
2140
Session *session= lex->session;
2618
if (!(select_lex= new (session->mem_root) SELECT_LEX()))
2142
if (!(select_lex= new (session->mem_root) Select_Lex()))
2620
2144
select_lex->select_number= ++session->select_number;
2621
2145
select_lex->parent_lex= lex; /* Used in init_query. */
2660
2184
select_lex->include_neighbour(lex->current_select);
2661
SELECT_LEX_UNIT *unit= select_lex->master_unit();
2185
Select_Lex_Unit *unit= select_lex->master_unit();
2662
2186
if (!unit->fake_select_lex && unit->add_fake_select_lex(lex->session))
2664
select_lex->context.outer_context=
2188
select_lex->context.outer_context=
2665
2189
unit->first_select()->context.outer_context;
2668
2192
select_lex->master_unit()->global_parameters= select_lex;
2669
select_lex->include_global((st_select_lex_node**)&lex->all_selects_list);
2193
select_lex->include_global((Select_Lex_Node**)&lex->all_selects_list);
2670
2194
lex->current_select= select_lex;
2672
2196
in subquery is SELECT query and we allow resolution of names in SELECT
2708
2233
if ((var= get_system_var(session, OPT_SESSION, tmp, null_lex_string)))
2710
end= strxmov(buff, "@@session.", var_name, NULL);
2235
end+= sprintf(buff, "@@session.%s", var_name);
2711
2236
var->set_name(buff, end-buff, system_charset_info);
2712
add_item_to_list(session, var);
2237
session->add_item_to_list(var);
2722
2247
lex->select_lex.select_limit= 0;
2723
2248
lex->unit.select_limit_cnt= HA_POS_ERROR;
2724
2249
lex->select_lex.table_list.save_and_clear(&lex->auxiliary_table_list);
2725
lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ;
2250
lex->lock_option= TL_READ;
2726
2251
lex->query_tables= 0;
2727
2252
lex->query_tables_last= &lex->query_tables;
2829
2354
Lex_input_stream lip(session, inBuf, length);
2830
2355
lex_start(session);
2831
mysql_reset_session_for_next_command(session);
2356
session->reset_for_next_command();
2833
2358
if (!parse_sql(session, &lip) &&
2834
2359
all_tables_not_ok(session,(TableList*) lex->select_lex.table_list.first))
2887
2412
if (default_value)
2890
2415
Default value should be literal => basic constants =>
2891
2416
no need fix_fields()
2893
We allow only one function as part of default value -
2418
We allow only one function as part of default value -
2894
2419
NOW() as default for TIMESTAMP type.
2896
if (default_value->type() == Item::FUNC_ITEM &&
2421
if (default_value->type() == Item::FUNC_ITEM &&
2897
2422
!(((Item_func*)default_value)->functype() == Item_func::NOW_FUNC &&
2898
2423
type == DRIZZLE_TYPE_TIMESTAMP))
3016
2541
return(0); // End of memory
3017
2542
alias_str= alias ? alias->str : table->table.str;
3018
if (!test(table_options & TL_OPTION_ALIAS) &&
2543
if (!test(table_options & TL_OPTION_ALIAS) &&
3019
2544
check_table_name(table->table.str, table->table.length))
3021
2546
my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.str);
3067
2592
ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES);
3068
2593
ptr->derived= table->sel;
3069
2594
if (!ptr->derived && !my_strcasecmp(system_charset_info, ptr->db,
3070
INFORMATION_SCHEMA_NAME.str))
2595
INFORMATION_SCHEMA_NAME.c_str()))
3072
2597
ST_SCHEMA_TABLE *schema_table= find_schema_table(session, ptr->table_name);
3073
2598
if (!schema_table ||
3074
(schema_table->hidden &&
3075
((sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0 ||
2599
(schema_table->hidden &&
2600
((sql_command_flags[lex->sql_command].test(CF_BIT_STATUS_COMMAND)) == 0 ||
3077
2602
this check is used for show columns|keys from I_S hidden table
3080
2605
lex->sql_command == SQLCOM_SHOW_KEYS)))
3082
2607
my_error(ER_UNKNOWN_TABLE, MYF(0),
3083
ptr->table_name, INFORMATION_SCHEMA_NAME.str);
2608
ptr->table_name, INFORMATION_SCHEMA_NAME.c_str());
3086
2611
ptr->schema_table_name= ptr->table_name;
3147
2672
The function initializes a structure of the TableList type
3148
2673
for a nested join. It sets up its nested join list as empty.
3149
2674
The created structure is added to the front of the current
3150
join list in the st_select_lex object. Then the function
2675
join list in the Select_Lex object. Then the function
3151
2676
changes the current nest level for joins to refer to the newly
3152
2677
created empty list after having saved the info on the old level
3153
2678
in the initialized structure.
3374
Create a fake SELECT_LEX for a unit.
2899
Create a fake Select_Lex for a unit.
3376
The method create a fake SELECT_LEX object for a unit.
2901
The method create a fake Select_Lex object for a unit.
3377
2902
This object is created for any union construct containing a union
3378
2903
operation and also for any single select union construct of the form
3380
(SELECT ... order_st BY order_list [LIMIT n]) order_st BY ...
2905
(SELECT ... order_st BY order_list [LIMIT n]) order_st BY ...
3384
2909
(SELECT ... order_st BY LIMIT n) order_st BY ...
3387
2912
@param session_arg thread handle
3399
bool st_select_lex_unit::add_fake_select_lex(Session *session_arg)
2924
bool Select_Lex_Unit::add_fake_select_lex(Session *session_arg)
3401
SELECT_LEX *first_sl= first_select();
2926
Select_Lex *first_sl= first_select();
3402
2927
assert(!fake_select_lex);
3404
if (!(fake_select_lex= new (session_arg->mem_root) SELECT_LEX()))
2929
if (!(fake_select_lex= new (session_arg->mem_root) Select_Lex()))
3406
fake_select_lex->include_standalone(this,
3407
(SELECT_LEX_NODE**)&fake_select_lex);
2931
fake_select_lex->include_standalone(this,
2932
(Select_Lex_Node**)&fake_select_lex);
3408
2933
fake_select_lex->select_number= INT_MAX;
3409
2934
fake_select_lex->parent_lex= session_arg->lex; /* Used in init_query. */
3410
2935
fake_select_lex->make_empty_select();
3419
2944
if (!is_union())
3423
2948
(SELECT ... order_st BY list [LIMIT n]) order_st BY order_list [LIMIT m],
3424
2949
(SELECT ... LIMIT n) order_st BY order_list [LIMIT m]
3425
2950
just before the parser starts processing order_list
3427
2952
global_parameters= fake_select_lex;
3428
2953
fake_select_lex->no_table_names_allowed= 1;
3429
2954
session_arg->lex->current_select= fake_select_lex;
3550
3075
@param options What should be reset/reloaded (tables, privileges, slave...)
3551
3076
@param tables Tables to flush (if any)
3552
3077
@param write_to_binlog True if we can write to the binlog.
3554
3079
@note Depending on 'options', it may be very bad to write the
3555
3080
query to the binlog (e.g. FLUSH SLAVE); this is a
3556
3081
pointer where reload_cache() will put 0 if
3562
3087
@retval !=0 Error; session->killed is set or session->is_error() is true
3565
bool reload_cache(Session *session, ulong options, TableList *tables,
3566
bool *write_to_binlog)
3090
bool reload_cache(Session *session, ulong options, TableList *tables, bool *write_to_binlog)
3569
3093
select_errors=0; /* Write if more errors */
3584
3108
than it would help them)
3586
3110
tmp_write_to_binlog= 0;
3587
if( mysql_bin_log.is_open() )
3589
mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE);
3591
pthread_mutex_lock(&LOCK_active_mi);
3592
rotate_relay_log(active_mi);
3593
pthread_mutex_unlock(&LOCK_active_mi);
3595
/* flush slow and general logs */
3596
logger.flush_logs(session);
3598
3112
if (ha_flush_logs(NULL))
3600
if (flush_error_log())
3604
3116
Note that if REFRESH_READ_LOCK bit is set then REFRESH_TABLES is set too
3605
3117
(see sql_yacc.yy)
3607
if (options & (REFRESH_TABLES | REFRESH_READ_LOCK))
3119
if (options & (REFRESH_TABLES | REFRESH_READ_LOCK))
3609
3121
if ((options & REFRESH_READ_LOCK) && session)
3647
3159
result= close_cached_tables(session, tables, false, (options & REFRESH_FAST) ?
3648
3160
false : true, false);
3651
3162
if (session && (options & REFRESH_STATUS))
3652
refresh_status(session);
3653
if (options & REFRESH_MASTER)
3656
tmp_write_to_binlog= 0;
3657
if (reset_master(session))
3662
if (options & REFRESH_SLAVE)
3664
tmp_write_to_binlog= 0;
3665
pthread_mutex_lock(&LOCK_active_mi);
3666
if (reset_slave(session, active_mi))
3668
pthread_mutex_unlock(&LOCK_active_mi);
3163
session->refresh_status();
3670
3164
*write_to_binlog= tmp_write_to_binlog;
3750
3245
/* Fix is using unix filename format on dos */
3751
my_stpcpy(buff,*filename_ptr);
3246
strcpy(buff,*filename_ptr);
3752
3247
end=convert_dirname(buff, *filename_ptr, NULL);
3753
3248
if (!(ptr= (char*) session->alloc((size_t) (end-buff) + strlen(table_name)+1)))
3754
3249
return 1; // End of memory
3755
3250
*filename_ptr=ptr;
3756
strxmov(ptr,buff,table_name,NULL);
3251
sprintf(ptr,"%s%s",buff,table_name);
3776
3271
char command[80];
3777
3272
Lex_input_stream *lip= session->m_lip;
3778
strmake(command, lip->yylval->symbol.str,
3779
cmin((ulong)lip->yylval->symbol.length, sizeof(command)-1));
3273
strncpy(command, lip->yylval->symbol.str,
3274
cmin(lip->yylval->symbol.length, sizeof(command)-1));
3275
command[cmin(lip->yylval->symbol.length, sizeof(command)-1)]=0;
3780
3276
my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command);
3787
Comp_creator *comp_eq_creator(bool invert)
3789
return invert?(Comp_creator *)&ne_creator:(Comp_creator *)&eq_creator;
3793
Comp_creator *comp_ge_creator(bool invert)
3795
return invert?(Comp_creator *)<_creator:(Comp_creator *)&ge_creator;
3799
Comp_creator *comp_gt_creator(bool invert)
3801
return invert?(Comp_creator *)&le_creator:(Comp_creator *)>_creator;
3805
Comp_creator *comp_le_creator(bool invert)
3807
return invert?(Comp_creator *)>_creator:(Comp_creator *)&le_creator;
3811
Comp_creator *comp_lt_creator(bool invert)
3813
return invert?(Comp_creator *)&ge_creator:(Comp_creator *)<_creator;
3817
Comp_creator *comp_ne_creator(bool invert)
3819
return invert?(Comp_creator *)&eq_creator:(Comp_creator *)&ne_creator;
3824
3284
Construct ALL/ANY/SOME subquery Item.
3832
3292
constructed Item (or 0 if out of memory)
3834
3294
Item * all_any_subquery_creator(Item *left_expr,
3835
chooser_compare_func_creator cmp,
3837
SELECT_LEX *select_lex)
3295
chooser_compare_func_creator cmp,
3297
Select_Lex *select_lex)
3839
3299
if ((cmp == &comp_eq_creator) && !all) // = ANY <=> IN
3840
3300
return new Item_in_subselect(left_expr, select_lex);
3866
bool multi_update_precheck(Session *session, TableList *)
3326
bool update_precheck(Session *session, TableList *)
3868
3328
const char *msg= 0;
3869
3329
LEX *lex= session->lex;
3870
SELECT_LEX *select_lex= &lex->select_lex;
3330
Select_Lex *select_lex= &lex->select_lex;
3872
if (select_lex->item_list.elements != lex->value_list.elements)
3332
if (session->lex->select_lex.item_list.elements != session->lex->value_list.elements)
3874
3334
my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
3878
if (select_lex->order_list.elements)
3880
else if (select_lex->select_limit)
3338
if (session->lex->select_lex.table_list.elements > 1)
3884
my_error(ER_WRONG_USAGE, MYF(0), "UPDATE", msg);
3340
if (select_lex->order_list.elements)
3342
else if (select_lex->select_limit)
3346
my_error(ER_WRONG_USAGE, MYF(0), "UPDATE", msg);
3902
3365
bool multi_delete_precheck(Session *session, TableList *)
3904
SELECT_LEX *select_lex= &session->lex->select_lex;
3367
Select_Lex *select_lex= &session->lex->select_lex;
3905
3368
TableList **save_query_tables_own_last= session->lex->query_tables_own_last;
3907
3370
session->lex->query_tables_own_last= 0;
4017
simple UPDATE query pre-check.
4019
@param session Thread handler
4020
@param tables Global table list
4028
bool update_precheck(Session *session, TableList *)
4030
if (session->lex->select_lex.item_list.elements != session->lex->value_list.elements)
4032
my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
4040
3480
simple INSERT query pre-check.
4042
3482
@param session Thread handler
4086
3526
if (create_table && (strcmp(create_table->db, "information_schema") == 0))
4088
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), "", "", INFORMATION_SCHEMA_NAME.str);
3528
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), "", "", INFORMATION_SCHEMA_NAME.c_str());
4165
bool check_identifier_name(LEX_STRING *str, uint32_t max_char_length,
4166
uint32_t err_code, const char *param_for_err_msg)
3605
bool check_identifier_name(LEX_STRING *str, uint32_t err_code,
3606
uint32_t max_char_length,
3607
const char *param_for_err_msg)
4168
#ifdef HAVE_CHARSET_utf8mb3
4170
3610
We don't support non-BMP characters in identifiers at the moment,
4171
3611
so they should be prohibited until such support is done.
4172
3612
This is why we use the 3-byte utf8 to check well-formedness here.
4174
const CHARSET_INFO * const cs= &my_charset_utf8mb3_general_ci;
4176
const CHARSET_INFO * const cs= system_charset_info;
3614
const CHARSET_INFO * const cs= &my_charset_utf8mb4_general_ci;
4178
3616
int well_formed_error;
4179
3617
uint32_t res= cs->cset->well_formed_len(cs, str->str, str->str + str->length,
4180
3618
max_char_length, &well_formed_error);