35
35
#define DRIZZLE_YACC
36
36
#define YYINITDEPTH 100
37
37
#define YYMAXDEPTH 3200 /* Because of 64K stack */
38
#define Lex (YYTHD->lex)
38
#define Lex (YYSession->lex)
39
39
#define Select Lex->current_select
40
40
#include <drizzled/server_includes.h>
41
#include "lex_symbol.h"
42
#include <storage/myisam/myisam.h>
43
#include <drizzled/drizzled_error_messages.h>
45
int yylex(void *yylval, void *yythd);
41
#include <drizzled/lex_symbol.h>
42
#include <drizzled/function/locate.h>
43
#include <drizzled/function/str/char.h>
44
#include <drizzled/function/str/collation.h>
45
#include <drizzled/function/str/database.h>
46
#include <drizzled/function/str/insert.h>
47
#include <drizzled/function/str/left.h>
48
#include <drizzled/function/str/repeat.h>
49
#include <drizzled/function/str/replace.h>
50
#include <drizzled/function/str/reverse.h>
51
#include <drizzled/function/str/right.h>
52
#include <drizzled/function/str/set_collation.h>
53
#include <drizzled/function/str/substr.h>
54
#include <drizzled/function/str/trim.h>
55
#include <drizzled/function/str/user.h>
56
#include <drizzled/function/str/weight_string.h>
58
#include <drizzled/function/time/curdate.h>
59
#include <drizzled/function/time/date_add_interval.h>
60
#include <drizzled/function/time/dayofmonth.h>
61
#include <drizzled/function/time/extract.h>
62
#include <drizzled/function/time/hour.h>
63
#include <drizzled/function/time/microsecond.h>
64
#include <drizzled/function/time/minute.h>
65
#include <drizzled/function/time/month.h>
66
#include <drizzled/function/time/now.h>
67
#include <drizzled/function/time/quarter.h>
68
#include <drizzled/function/time/second.h>
69
#include <drizzled/function/time/sysdate_local.h>
70
#include <drizzled/function/time/timestamp_diff.h>
71
#include <drizzled/function/time/typecast.h>
72
#include <drizzled/function/time/year.h>
74
#include <drizzled/error.h>
75
#include <drizzled/nested_join.h>
76
#include <drizzled/sql_parse.h>
77
#include <drizzled/item/copy_string.h>
78
#include <drizzled/item/cmpfunc.h>
79
#include <drizzled/item/uint.h>
80
#include <drizzled/item/null.h>
81
#include <drizzled/session.h>
82
#include <drizzled/item/func.h>
83
#include <drizzled/sql_base.h>
84
#include <drizzled/item/create.h>
85
#include <drizzled/item/default_value.h>
86
#include <drizzled/item/insert_value.h>
87
#include <drizzled/lex_string.h>
88
#include <drizzled/function/get_system_var.h>
89
#include <mysys/thr_lock.h>
90
#include <drizzled/message/table.pb.h>
96
int yylex(void *yylval, void *yysession);
47
98
#define yyoverflow(A,B,C,D,E,F) \
212
243
Item_in_subselect(left, subselect)
214
245
subselect= expr3->invalidate_and_restore_select_lex();
215
result= new (thd->mem_root) Item_in_subselect(left, subselect);
246
result= new (session->mem_root) Item_in_subselect(left, subselect);
218
result = negate_expression(thd, result);
249
result = negate_expression(session, result);
225
result= new (thd->mem_root) Item_func_eq(left, expr);
256
result= new (session->mem_root) Item_func_eq(left, expr);
227
result= new (thd->mem_root) Item_func_ne(left, expr);
258
result= new (session->mem_root) Item_func_ne(left, expr);
233
@brief Creates a new SELECT_LEX for a UNION branch.
264
@brief Creates a new Select_Lex for a UNION branch.
235
Sets up and initializes a SELECT_LEX structure for a query once the parser
236
discovers a UNION token. The current SELECT_LEX is pushed on the stack and
237
the new SELECT_LEX becomes the current one..=
266
Sets up and initializes a Select_Lex structure for a query once the parser
267
discovers a UNION token. The current Select_Lex is pushed on the stack and
268
the new Select_Lex becomes the current one..=
239
270
@lex The parser state.
1016
989
%type <build_method> build_method
1019
query verb_clause create change select drop insert replace insert2
992
query verb_clause create select drop insert replace insert2
1020
993
insert_values update delete truncate rename
1021
994
show describe load alter optimize keycache flush
1022
reset purge begin commit rollback savepoint release
1023
slave master_def master_defs master_file_def slave_until_opts
1024
repair analyze check start checksum
995
begin commit rollback savepoint release
996
analyze check start checksum
1025
997
field_list field_list_item field_spec kill column_def key_def
1026
998
keycache_list assign_to_keycache
1027
999
select_item_list select_item values_list no_braces
1028
1000
opt_limit_clause delete_limit_clause fields opt_values values
1029
1001
opt_precision opt_ignore opt_column
1030
set lock unlock string_list field_options field_option
1031
field_opt_list opt_binary table_lock_list table_lock
1002
set unlock string_list
1032
1004
ref_list opt_match_clause opt_on_update_delete use
1033
1005
opt_delete_options opt_delete_option varchar
1034
1006
opt_outer table_list table_name table_alias_ref_list table_alias_ref
1149
CHANGE MASTER_SYM TO_SYM
1152
lex->sql_command = SQLCOM_CHANGE_MASTER;
1153
memset(&lex->mi, 0, sizeof(lex->mi));
1161
| master_defs ',' master_def
1165
MASTER_HOST_SYM EQ TEXT_STRING_sys
1167
Lex->mi.host = $3.str;
1169
| MASTER_USER_SYM EQ TEXT_STRING_sys
1171
Lex->mi.user = $3.str;
1173
| MASTER_PASSWORD_SYM EQ TEXT_STRING_sys
1175
Lex->mi.password = $3.str;
1177
| MASTER_PORT_SYM EQ ulong_num
1181
| MASTER_CONNECT_RETRY_SYM EQ ulong_num
1183
Lex->mi.connect_retry = $3;
1185
| MASTER_HEARTBEAT_PERIOD_SYM EQ NUM_literal
1187
Lex->mi.heartbeat_period= (float) $3->val_real();
1188
if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD ||
1189
Lex->mi.heartbeat_period < 0.0)
1191
char buf[sizeof(SLAVE_MAX_HEARTBEAT_PERIOD*4)];
1192
sprintf(buf, "%d seconds", SLAVE_MAX_HEARTBEAT_PERIOD);
1193
my_error(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1195
" is negative or exceeds the maximum ",
1199
if (Lex->mi.heartbeat_period > slave_net_timeout)
1201
push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1202
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1203
ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1204
" exceeds the value of `slave_net_timeout' sec.",
1205
" A sensible value for the period should be"
1206
" less than the timeout.");
1208
if (Lex->mi.heartbeat_period < 0.001)
1210
if (Lex->mi.heartbeat_period != 0.0)
1212
push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1213
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1214
ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1215
" is less than 1 msec.",
1216
" The period is reset to zero which means"
1217
" no heartbeats will be sending");
1218
Lex->mi.heartbeat_period= 0.0;
1220
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_DISABLE;
1222
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
1229
MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
1231
Lex->mi.log_file_name = $3.str;
1233
| MASTER_LOG_POS_SYM EQ ulonglong_num
1237
If the user specified a value < BIN_LOG_HEADER_SIZE, adjust it
1238
instead of causing subsequent errors.
1239
We need to do it in this file, because only there we know that
1240
MASTER_LOG_POS has been explicitely specified. On the contrary
1241
in change_master() (sql_repl.cc) we cannot distinguish between 0
1242
(MASTER_LOG_POS explicitely specified as 0) and 0 (unspecified),
1243
whereas we want to distinguish (specified 0 means "read the binlog
1244
from 0" (4 in fact), unspecified means "don't change the position
1245
(keep the preceding value)").
1247
Lex->mi.pos = max((uint64_t)BIN_LOG_HEADER_SIZE, Lex->mi.pos);
1249
| RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
1251
Lex->mi.relay_log_name = $3.str;
1253
| RELAY_LOG_POS_SYM EQ ulong_num
1255
Lex->mi.relay_log_pos = $3;
1256
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
1257
Lex->mi.relay_log_pos = max((uint32_t)BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
1261
1108
/* create a table */
1264
1111
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
1113
Session *session= YYSession;
1114
LEX *lex= session->lex;
1268
1115
lex->sql_command= SQLCOM_CREATE_TABLE;
1269
if (!lex->select_lex.add_table_to_list(thd, $5, NULL,
1116
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1270
1117
TL_OPTION_UPDATING,
1272
1119
DRIZZLE_YYABORT;
1273
1120
lex->alter_info.reset();
1274
1121
lex->col_list.empty();
1276
1123
memset(&lex->create_info, 0, sizeof(lex->create_info));
1277
1124
lex->create_info.options=$2 | $4;
1278
lex->create_info.db_type= ha_default_handlerton(thd);
1125
lex->create_info.db_type= ha_default_storage_engine(session);
1279
1126
lex->create_info.default_table_charset= NULL;
1280
1127
lex->name.str= 0;
1281
lex->name.length= 0;
1129
drizzled::message::Table *proto=
1130
lex->create_table_proto= new drizzled::message::Table();
1132
proto->set_name($5->table.str);
1133
if($2 & HA_LEX_CREATE_TMP_TABLE)
1134
proto->set_type(drizzled::message::Table::TEMPORARY);
1136
proto->set_type(drizzled::message::Table::STANDARD);
1139
drizzled::message::Table::StorageEngine *protoengine;
1140
protoengine= proto->mutable_engine();
1141
StorageEngine *engine= ha_default_storage_engine(session);
1143
protoengine->set_name(engine->getName());
1285
LEX *lex= YYTHD->lex;
1148
LEX *lex= YYSession->lex;
1286
1149
lex->current_select= &lex->select_lex;
1287
if (!lex->create_info.db_type)
1289
lex->create_info.db_type= ha_default_handlerton(YYTHD);
1290
push_warning_printf(YYTHD, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1291
ER_WARN_USING_OTHER_HANDLER,
1292
ER(ER_WARN_USING_OTHER_HANDLER),
1293
ha_resolve_storage_engine_name(lex->create_info.db_type),
1150
assert(lex->create_info.db_type);
1297
1152
| CREATE build_method opt_unique INDEX_SYM ident key_alg
1301
1156
lex->sql_command= SQLCOM_CREATE_INDEX;
1302
if (!lex->current_select->add_table_to_list(lex->thd, $8,
1157
if (!lex->current_select->add_table_to_list(lex->session, $8,
1304
1159
TL_OPTION_UPDATING))
1305
1160
DRIZZLE_YYABORT;
1306
1161
lex->alter_info.reset();
1307
lex->alter_info.flags= ALTER_ADD_INDEX;
1162
lex->alter_info.flags.set(ALTER_ADD_INDEX);
1308
1163
lex->alter_info.build_method= $2;
1309
1164
lex->col_list.empty();
1312
1167
'(' key_list ')' key_options
2368
2088
ALTER build_method opt_ignore TABLE_SYM table_ident
2090
Session *session= YYSession;
2091
LEX *lex= session->lex;
2372
2092
lex->name.str= 0;
2373
2093
lex->name.length= 0;
2374
2094
lex->sql_command= SQLCOM_ALTER_TABLE;
2375
2095
lex->duplicates= DUP_ERROR;
2376
if (!lex->select_lex.add_table_to_list(thd, $5, NULL,
2096
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
2377
2097
TL_OPTION_UPDATING))
2378
2098
DRIZZLE_YYABORT;
2379
2099
lex->alter_info.reset();
2380
2100
lex->col_list.empty();
2381
2101
lex->select_lex.init_order();
2382
2102
lex->select_lex.db=
2383
((TABLE_LIST*) lex->select_lex.table_list.first)->db;
2103
((TableList*) lex->select_lex.table_list.first)->db;
2384
2104
memset(&lex->create_info, 0, sizeof(lex->create_info));
2385
2105
lex->create_info.db_type= 0;
2386
2106
lex->create_info.default_table_charset= NULL;
2387
2107
lex->create_info.row_type= ROW_TYPE_NOT_USED;
2388
2108
lex->alter_info.reset();
2389
lex->no_write_to_binlog= 0;
2390
2109
lex->alter_info.build_method= $2;
2111
lex->create_table_proto= new drizzled::message::Table();
2494
2216
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2496
lex->alter_info.flags|= ALTER_DROP_COLUMN;
2218
lex->alter_info.flags.set(ALTER_DROP_COLUMN);
2498
2220
| DROP FOREIGN KEY_SYM opt_ident
2500
Lex->alter_info.flags|= ALTER_DROP_INDEX | ALTER_FOREIGN_KEY;
2222
Lex->alter_info.flags.set(ALTER_DROP_INDEX);
2223
Lex->alter_info.flags.set(ALTER_FOREIGN_KEY);
2502
2225
| DROP PRIMARY_SYM KEY_SYM
2505
2228
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2507
lex->alter_info.flags|= ALTER_DROP_INDEX;
2230
lex->alter_info.flags.set(ALTER_DROP_INDEX);
2509
2232
| DROP key_or_index field_ident
2512
2235
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2514
lex->alter_info.flags|= ALTER_DROP_INDEX;
2237
lex->alter_info.flags.set(ALTER_DROP_INDEX);
2516
2239
| DISABLE_SYM KEYS
2519
2242
lex->alter_info.keys_onoff= DISABLE;
2520
lex->alter_info.flags|= ALTER_KEYS_ONOFF;
2243
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
2522
2245
| ENABLE_SYM KEYS
2525
2248
lex->alter_info.keys_onoff= ENABLE;
2526
lex->alter_info.flags|= ALTER_KEYS_ONOFF;
2249
lex->alter_info.flags.set(ALTER_KEYS_ONOFF);
2528
2251
| ALTER opt_column field_ident SET DEFAULT signed_literal
2531
2254
lex->alter_info.alter_list.push_back(new Alter_column($3.str,$6));
2532
lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
2255
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2534
2257
| ALTER opt_column field_ident DROP DEFAULT
2537
2260
lex->alter_info.alter_list.push_back(new Alter_column($3.str,
2539
lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
2262
lex->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2541
2264
| RENAME opt_to table_ident
2554
2277
DRIZZLE_YYABORT;
2556
2279
lex->name= $3->table;
2557
lex->alter_info.flags|= ALTER_RENAME;
2280
lex->alter_info.flags.set(ALTER_RENAME);
2559
| CONVERT_SYM TO_SYM charset charset_name_or_default opt_collate
2282
| CONVERT_SYM TO_SYM collation_name_or_default
2564
$4= thd->variables.collation_database;
2567
if (!my_charset_same($4,$5))
2569
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
2570
$5->name, $4->csname);
2574
2285
lex->create_info.table_charset=
2575
lex->create_info.default_table_charset= $5;
2286
lex->create_info.default_table_charset= $3;
2576
2287
lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
2577
2288
HA_CREATE_USED_DEFAULT_CHARSET);
2578
lex->alter_info.flags|= ALTER_CONVERT;
2289
lex->alter_info.flags.set(ALTER_CONVERT);
2580
2291
| create_table_options_space_separated
2583
lex->alter_info.flags|= ALTER_OPTIONS;
2294
lex->alter_info.flags.set(ALTER_OPTIONS);
2587
Lex->alter_info.flags|= ALTER_FORCE;
2298
Lex->alter_info.flags.set(ALTER_FORCE);
2589
2300
| alter_order_clause
2592
lex->alter_info.flags|= ALTER_ORDER;
2303
lex->alter_info.flags.set(ALTER_ORDER);
3221
$$ = new (YYTHD->mem_root) Item_cond_and($1, $3);
2800
$$ = new (YYSession->mem_root) Item_cond_and($1, $3);
3224
2803
| NOT_SYM expr %prec NOT_SYM
3225
{ $$= negate_expression(YYTHD, $2); }
2804
{ $$= negate_expression(YYSession, $2); }
3226
2805
| bool_pri IS TRUE_SYM %prec IS
3227
{ $$= new (YYTHD->mem_root) Item_func_istrue($1); }
2806
{ $$= new (YYSession->mem_root) Item_func_istrue($1); }
3228
2807
| bool_pri IS not TRUE_SYM %prec IS
3229
{ $$= new (YYTHD->mem_root) Item_func_isnottrue($1); }
2808
{ $$= new (YYSession->mem_root) Item_func_isnottrue($1); }
3230
2809
| bool_pri IS FALSE_SYM %prec IS
3231
{ $$= new (YYTHD->mem_root) Item_func_isfalse($1); }
2810
{ $$= new (YYSession->mem_root) Item_func_isfalse($1); }
3232
2811
| bool_pri IS not FALSE_SYM %prec IS
3233
{ $$= new (YYTHD->mem_root) Item_func_isnotfalse($1); }
2812
{ $$= new (YYSession->mem_root) Item_func_isnotfalse($1); }
3234
2813
| bool_pri IS UNKNOWN_SYM %prec IS
3235
2814
{ $$= new Item_func_isnull($1); }
3236
2815
| bool_pri IS not UNKNOWN_SYM %prec IS
3256
2835
bit_expr IN_SYM '(' subselect ')'
3258
$$= new (YYTHD->mem_root) Item_in_subselect($1, $4);
2837
$$= new (YYSession->mem_root) Item_in_subselect($1, $4);
3260
2839
| bit_expr not IN_SYM '(' subselect ')'
3263
Item *item= new (thd->mem_root) Item_in_subselect($1, $5);
3264
$$= negate_expression(thd, item);
2841
Session *session= YYSession;
2842
Item *item= new (session->mem_root) Item_in_subselect($1, $5);
2843
$$= negate_expression(session, item);
3266
2845
| bit_expr IN_SYM '(' expr ')'
3268
$$= handle_sql2003_note184_exception(YYTHD, $1, true, $4);
2847
$$= handle_sql2003_note184_exception(YYSession, $1, true, $4);
3270
2849
| bit_expr IN_SYM '(' expr ',' expr_list ')'
3272
2851
$6->push_front($4);
3273
2852
$6->push_front($1);
3274
$$= new (YYTHD->mem_root) Item_func_in(*$6);
2853
$$= new (YYSession->mem_root) Item_func_in(*$6);
3276
2855
| bit_expr not IN_SYM '(' expr ')'
3278
$$= handle_sql2003_note184_exception(YYTHD, $1, false, $5);
2857
$$= handle_sql2003_note184_exception(YYSession, $1, false, $5);
3280
2859
| bit_expr not IN_SYM '(' expr ',' expr_list ')'
3282
2861
$7->push_front($5);
3283
2862
$7->push_front($1);
3284
Item_func_in *item = new (YYTHD->mem_root) Item_func_in(*$7);
2863
Item_func_in *item = new (YYSession->mem_root) Item_func_in(*$7);
3285
2864
item->negate();
3356
2935
| function_call_conflict
3357
2936
| simple_expr COLLATE_SYM ident_or_text %prec NEG
3360
Item *i1= new (thd->mem_root) Item_string($3.str,
2938
Session *session= YYSession;
2939
Item *i1= new (session->mem_root) Item_string($3.str,
3363
$$= new (thd->mem_root) Item_func_set_collation($1, i1);
2941
session->charset());
2942
$$= new (session->mem_root) Item_func_set_collation($1, i1);
3368
2947
| '+' simple_expr %prec NEG { $$= $2; }
3369
2948
| '-' simple_expr %prec NEG
3370
{ $$= new (YYTHD->mem_root) Item_func_neg($2); }
2949
{ $$= new (YYSession->mem_root) Item_func_neg($2); }
3371
2950
| '(' subselect ')'
3373
$$= new (YYTHD->mem_root) Item_singlerow_subselect($2);
2952
$$= new (YYSession->mem_root) Item_singlerow_subselect($2);
3375
2954
| '(' expr ')' { $$= $2; }
3376
2955
| '(' expr ',' expr_list ')'
3378
2957
$4->push_front($2);
3379
$$= new (YYTHD->mem_root) Item_row(*$4);
2958
$$= new (YYSession->mem_root) Item_row(*$4);
3381
2960
| ROW_SYM '(' expr ',' expr_list ')'
3383
2962
$5->push_front($3);
3384
$$= new (YYTHD->mem_root) Item_row(*$5);
2963
$$= new (YYSession->mem_root) Item_row(*$5);
3386
2965
| EXISTS '(' subselect ')'
3388
$$= new (YYTHD->mem_root) Item_exists_subselect($3);
2967
$$= new (YYSession->mem_root) Item_exists_subselect($3);
3390
2969
| '{' ident expr '}' { $$= $3; }
3391
2970
| BINARY simple_expr %prec NEG
3393
$$= create_func_cast(YYTHD, $2, ITEM_CAST_CHAR, NULL, NULL,
2972
$$= create_func_cast(YYSession, $2, ITEM_CAST_CHAR, NULL, NULL,
3394
2973
&my_charset_bin);
3396
2975
| CAST_SYM '(' expr AS cast_type ')'
3399
$$= create_func_cast(YYTHD, $3, $5, lex->length, lex->dec,
2978
$$= create_func_cast(YYSession, $3, $5, lex->length, lex->dec,
3402
2981
DRIZZLE_YYABORT;
3404
2983
| CASE_SYM opt_expr when_list opt_else END
3405
{ $$= new (YYTHD->mem_root) Item_func_case(* $3, $2, $4 ); }
2984
{ $$= new (YYSession->mem_root) Item_func_case(* $3, $2, $4 ); }
3406
2985
| CONVERT_SYM '(' expr ',' cast_type ')'
3408
$$= create_func_cast(YYTHD, $3, $5, Lex->length, Lex->dec,
2987
$$= create_func_cast(YYSession, $3, $5, Lex->length, Lex->dec,
3411
2990
DRIZZLE_YYABORT;
3413
| CONVERT_SYM '(' expr USING charset_name ')'
3414
{ $$= new (YYTHD->mem_root) Item_func_conv_charset($3,$5); }
3415
2992
| DEFAULT '(' simple_ident ')'
3417
$$= new (YYTHD->mem_root) Item_default_value(Lex->current_context(),
2994
$$= new (YYSession->mem_root) Item_default_value(Lex->current_context(),
3420
2997
| VALUES '(' simple_ident_nospvar ')'
3422
$$= new (YYTHD->mem_root) Item_insert_value(Lex->current_context(),
2999
$$= new (YYSession->mem_root) Item_insert_value(Lex->current_context(),
3425
3002
| INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM
3426
3003
/* we cannot put interval before - */
3427
{ $$= new (YYTHD->mem_root) Item_date_add_interval($5,$2,$3,0); }
3004
{ $$= new (YYSession->mem_root) Item_date_add_interval($5,$2,$3,0); }
3436
3013
function_call_keyword:
3437
3014
CHAR_SYM '(' expr_list ')'
3438
{ $$= new (YYTHD->mem_root) Item_func_char(*$3); }
3439
| CHAR_SYM '(' expr_list USING charset_name ')'
3440
{ $$= new (YYTHD->mem_root) Item_func_char(*$3, $5); }
3015
{ $$= new (YYSession->mem_root) Item_func_char(*$3); }
3441
3016
| CURRENT_USER optional_braces
3443
$$= new (YYTHD->mem_root) Item_func_current_user(Lex->current_context());
3444
Lex->set_stmt_unsafe();
3018
$$= new (YYSession->mem_root) Item_func_current_user(Lex->current_context());
3446
3020
| DATE_SYM '(' expr ')'
3447
{ $$= new (YYTHD->mem_root) Item_date_typecast($3); }
3021
{ $$= new (YYSession->mem_root) Item_date_typecast($3); }
3448
3022
| DAY_SYM '(' expr ')'
3449
{ $$= new (YYTHD->mem_root) Item_func_dayofmonth($3); }
3023
{ $$= new (YYSession->mem_root) Item_func_dayofmonth($3); }
3450
3024
| HOUR_SYM '(' expr ')'
3451
{ $$= new (YYTHD->mem_root) Item_func_hour($3); }
3025
{ $$= new (YYSession->mem_root) Item_func_hour($3); }
3452
3026
| INSERT '(' expr ',' expr ',' expr ',' expr ')'
3453
{ $$= new (YYTHD->mem_root) Item_func_insert($3,$5,$7,$9); }
3027
{ $$= new (YYSession->mem_root) Item_func_insert($3,$5,$7,$9); }
3454
3028
| INTERVAL_SYM '(' expr ',' expr ')' %prec INTERVAL_SYM
3457
List<Item> *list= new (thd->mem_root) List<Item>;
3030
Session *session= YYSession;
3031
List<Item> *list= new (session->mem_root) List<Item>;
3458
3032
list->push_front($5);
3459
3033
list->push_front($3);
3460
Item_row *item= new (thd->mem_root) Item_row(*list);
3461
$$= new (thd->mem_root) Item_func_interval(item);
3034
Item_row *item= new (session->mem_root) Item_row(*list);
3035
$$= new (session->mem_root) Item_func_interval(item);
3463
3037
| INTERVAL_SYM '(' expr ',' expr ',' expr_list ')' %prec INTERVAL_SYM
3039
Session *session= YYSession;
3466
3040
$7->push_front($5);
3467
3041
$7->push_front($3);
3468
Item_row *item= new (thd->mem_root) Item_row(*$7);
3469
$$= new (thd->mem_root) Item_func_interval(item);
3042
Item_row *item= new (session->mem_root) Item_row(*$7);
3043
$$= new (session->mem_root) Item_func_interval(item);
3471
3045
| LEFT '(' expr ',' expr ')'
3472
{ $$= new (YYTHD->mem_root) Item_func_left($3,$5); }
3046
{ $$= new (YYSession->mem_root) Item_func_left($3,$5); }
3473
3047
| MINUTE_SYM '(' expr ')'
3474
{ $$= new (YYTHD->mem_root) Item_func_minute($3); }
3048
{ $$= new (YYSession->mem_root) Item_func_minute($3); }
3475
3049
| MONTH_SYM '(' expr ')'
3476
{ $$= new (YYTHD->mem_root) Item_func_month($3); }
3050
{ $$= new (YYSession->mem_root) Item_func_month($3); }
3477
3051
| RIGHT '(' expr ',' expr ')'
3478
{ $$= new (YYTHD->mem_root) Item_func_right($3,$5); }
3052
{ $$= new (YYSession->mem_root) Item_func_right($3,$5); }
3479
3053
| SECOND_SYM '(' expr ')'
3480
{ $$= new (YYTHD->mem_root) Item_func_second($3); }
3481
| TIME_SYM '(' expr ')'
3482
{ $$= new (YYTHD->mem_root) Item_time_typecast($3); }
3483
| TIMESTAMP '(' expr ')'
3484
{ $$= new (YYTHD->mem_root) Item_datetime_typecast($3); }
3485
| TIMESTAMP '(' expr ',' expr ')'
3486
{ $$= new (YYTHD->mem_root) Item_func_add_time($3, $5, 1, 0); }
3054
{ $$= new (YYSession->mem_root) Item_func_second($3); }
3055
| TIMESTAMP_SYM '(' expr ')'
3056
{ $$= new (YYSession->mem_root) Item_datetime_typecast($3); }
3487
3057
| TRIM '(' expr ')'
3488
{ $$= new (YYTHD->mem_root) Item_func_trim($3); }
3058
{ $$= new (YYSession->mem_root) Item_func_trim($3); }
3489
3059
| TRIM '(' LEADING expr FROM expr ')'
3490
{ $$= new (YYTHD->mem_root) Item_func_ltrim($6,$4); }
3060
{ $$= new (YYSession->mem_root) Item_func_ltrim($6,$4); }
3491
3061
| TRIM '(' TRAILING expr FROM expr ')'
3492
{ $$= new (YYTHD->mem_root) Item_func_rtrim($6,$4); }
3062
{ $$= new (YYSession->mem_root) Item_func_rtrim($6,$4); }
3493
3063
| TRIM '(' BOTH expr FROM expr ')'
3494
{ $$= new (YYTHD->mem_root) Item_func_trim($6,$4); }
3064
{ $$= new (YYSession->mem_root) Item_func_trim($6,$4); }
3495
3065
| TRIM '(' LEADING FROM expr ')'
3496
{ $$= new (YYTHD->mem_root) Item_func_ltrim($5); }
3066
{ $$= new (YYSession->mem_root) Item_func_ltrim($5); }
3497
3067
| TRIM '(' TRAILING FROM expr ')'
3498
{ $$= new (YYTHD->mem_root) Item_func_rtrim($5); }
3068
{ $$= new (YYSession->mem_root) Item_func_rtrim($5); }
3499
3069
| TRIM '(' BOTH FROM expr ')'
3500
{ $$= new (YYTHD->mem_root) Item_func_trim($5); }
3070
{ $$= new (YYSession->mem_root) Item_func_trim($5); }
3501
3071
| TRIM '(' expr FROM expr ')'
3502
{ $$= new (YYTHD->mem_root) Item_func_trim($5,$3); }
3072
{ $$= new (YYSession->mem_root) Item_func_trim($5,$3); }
3505
$$= new (YYTHD->mem_root) Item_func_user();
3506
Lex->set_stmt_unsafe();
3075
$$= new (YYSession->mem_root) Item_func_user();
3508
3077
| YEAR_SYM '(' expr ')'
3509
{ $$= new (YYTHD->mem_root) Item_func_year($3); }
3078
{ $$= new (YYSession->mem_root) Item_func_year($3); }
3518
3087
The only reasons a function should be added here are:
3519
3088
- for compatibility reasons with another SQL syntax (CURDATE),
3520
- for typing reasons (GET_FORMAT)
3521
3089
Any other 'Syntaxic sugar' enhancements should be *STRONGLY*
3524
3092
function_call_nonkeyword:
3525
3093
ADDDATE_SYM '(' expr ',' expr ')'
3527
$$= new (YYTHD->mem_root) Item_date_add_interval($3, $5,
3095
$$= new (YYSession->mem_root) Item_date_add_interval($3, $5,
3528
3096
INTERVAL_DAY, 0);
3530
3098
| ADDDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
3531
{ $$= new (YYTHD->mem_root) Item_date_add_interval($3, $6, $7, 0); }
3099
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 0); }
3532
3100
| CURDATE optional_braces
3534
$$= new (YYTHD->mem_root) Item_func_curdate_local();
3536
| CURTIME optional_braces
3538
$$= new (YYTHD->mem_root) Item_func_curtime_local();
3540
| CURTIME '(' expr ')'
3542
$$= new (YYTHD->mem_root) Item_func_curtime_local($3);
3102
$$= new (YYSession->mem_root) Item_func_curdate_local();
3544
3104
| DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
3545
{ $$= new (YYTHD->mem_root) Item_date_add_interval($3,$6,$7,0); }
3105
{ $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,0); }
3546
3106
| DATE_SUB_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM
3547
{ $$= new (YYTHD->mem_root) Item_date_add_interval($3,$6,$7,1); }
3107
{ $$= new (YYSession->mem_root) Item_date_add_interval($3,$6,$7,1); }
3548
3108
| EXTRACT_SYM '(' interval FROM expr ')'
3549
{ $$=new (YYTHD->mem_root) Item_extract( $3, $5); }
3550
| GET_FORMAT '(' date_time_type ',' expr ')'
3551
{ $$= new (YYTHD->mem_root) Item_func_get_format($3, $5); }
3109
{ $$=new (YYSession->mem_root) Item_extract( $3, $5); }
3552
3110
| NOW_SYM optional_braces
3554
$$= new (YYTHD->mem_root) Item_func_now_local();
3112
$$= new (YYSession->mem_root) Item_func_now_local();
3556
3114
| NOW_SYM '(' expr ')'
3558
$$= new (YYTHD->mem_root) Item_func_now_local($3);
3116
$$= new (YYSession->mem_root) Item_func_now_local($3);
3560
3118
| POSITION_SYM '(' bit_expr IN_SYM expr ')'
3561
{ $$ = new (YYTHD->mem_root) Item_func_locate($5,$3); }
3119
{ $$ = new (YYSession->mem_root) Item_func_locate($5,$3); }
3562
3120
| SUBDATE_SYM '(' expr ',' expr ')'
3564
$$= new (YYTHD->mem_root) Item_date_add_interval($3, $5,
3122
$$= new (YYSession->mem_root) Item_date_add_interval($3, $5,
3565
3123
INTERVAL_DAY, 1);
3567
3125
| SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
3568
{ $$= new (YYTHD->mem_root) Item_date_add_interval($3, $6, $7, 1); }
3126
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 1); }
3569
3127
| SUBSTRING '(' expr ',' expr ',' expr ')'
3570
{ $$= new (YYTHD->mem_root) Item_func_substr($3,$5,$7); }
3128
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
3571
3129
| SUBSTRING '(' expr ',' expr ')'
3572
{ $$= new (YYTHD->mem_root) Item_func_substr($3,$5); }
3130
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
3573
3131
| SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
3574
{ $$= new (YYTHD->mem_root) Item_func_substr($3,$5,$7); }
3132
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
3575
3133
| SUBSTRING '(' expr FROM expr ')'
3576
{ $$= new (YYTHD->mem_root) Item_func_substr($3,$5); }
3134
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
3577
3135
| SYSDATE optional_braces
3579
if (global_system_variables.sysdate_is_now == 0)
3580
$$= new (YYTHD->mem_root) Item_func_sysdate_local();
3582
$$= new (YYTHD->mem_root) Item_func_now_local();
3136
{ $$= new (YYSession->mem_root) Item_func_sysdate_local(); }
3584
3137
| SYSDATE '(' expr ')'
3586
if (global_system_variables.sysdate_is_now == 0)
3587
$$= new (YYTHD->mem_root) Item_func_sysdate_local($3);
3589
$$= new (YYTHD->mem_root) Item_func_now_local($3);
3138
{ $$= new (YYSession->mem_root) Item_func_sysdate_local($3); }
3591
3139
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
3592
{ $$= new (YYTHD->mem_root) Item_date_add_interval($7,$5,$3,0); }
3140
{ $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
3593
3141
| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
3594
{ $$= new (YYTHD->mem_root) Item_func_timestamp_diff($5,$7,$3); }
3142
{ $$= new (YYSession->mem_root) Item_func_timestamp_diff($5,$7,$3); }
3595
3143
| UTC_DATE_SYM optional_braces
3597
$$= new (YYTHD->mem_root) Item_func_curdate_utc();
3599
| UTC_TIME_SYM optional_braces
3601
$$= new (YYTHD->mem_root) Item_func_curtime_utc();
3145
$$= new (YYSession->mem_root) Item_func_curdate_utc();
3603
3147
| UTC_TIMESTAMP_SYM optional_braces
3605
$$= new (YYTHD->mem_root) Item_func_now_utc();
3149
$$= new (YYSession->mem_root) Item_func_now_utc();
3614
3158
function_call_conflict:
3615
3159
ASCII_SYM '(' expr ')'
3616
{ $$= new (YYTHD->mem_root) Item_func_ascii($3); }
3617
| CHARSET '(' expr ')'
3618
{ $$= new (YYTHD->mem_root) Item_func_charset($3); }
3160
{ $$= new (YYSession->mem_root) Item_func_ascii($3); }
3619
3161
| COALESCE '(' expr_list ')'
3620
{ $$= new (YYTHD->mem_root) Item_func_coalesce(* $3); }
3162
{ $$= new (YYSession->mem_root) Item_func_coalesce(* $3); }
3621
3163
| COLLATION_SYM '(' expr ')'
3622
{ $$= new (YYTHD->mem_root) Item_func_collation($3); }
3164
{ $$= new (YYSession->mem_root) Item_func_collation($3); }
3623
3165
| DATABASE '(' ')'
3625
$$= new (YYTHD->mem_root) Item_func_database();
3167
$$= new (YYSession->mem_root) Item_func_database();
3627
3169
| IF '(' expr ',' expr ',' expr ')'
3628
{ $$= new (YYTHD->mem_root) Item_func_if($3,$5,$7); }
3170
{ $$= new (YYSession->mem_root) Item_func_if($3,$5,$7); }
3629
3171
| MICROSECOND_SYM '(' expr ')'
3630
{ $$= new (YYTHD->mem_root) Item_func_microsecond($3); }
3172
{ $$= new (YYSession->mem_root) Item_func_microsecond($3); }
3631
3173
| MOD_SYM '(' expr ',' expr ')'
3632
{ $$ = new (YYTHD->mem_root) Item_func_mod( $3, $5); }
3174
{ $$ = new (YYSession->mem_root) Item_func_mod( $3, $5); }
3633
3175
| QUARTER_SYM '(' expr ')'
3634
{ $$ = new (YYTHD->mem_root) Item_func_quarter($3); }
3176
{ $$ = new (YYSession->mem_root) Item_func_quarter($3); }
3635
3177
| REPEAT_SYM '(' expr ',' expr ')'
3636
{ $$= new (YYTHD->mem_root) Item_func_repeat($3,$5); }
3178
{ $$= new (YYSession->mem_root) Item_func_repeat($3,$5); }
3637
3179
| REPLACE '(' expr ',' expr ',' expr ')'
3638
{ $$= new (YYTHD->mem_root) Item_func_replace($3,$5,$7); }
3180
{ $$= new (YYSession->mem_root) Item_func_replace($3,$5,$7); }
3639
3181
| REVERSE_SYM '(' expr ')'
3640
{ $$= new (YYTHD->mem_root) Item_func_reverse($3); }
3182
{ $$= new (YYSession->mem_root) Item_func_reverse($3); }
3641
3183
| TRUNCATE_SYM '(' expr ',' expr ')'
3642
{ $$= new (YYTHD->mem_root) Item_func_round($3,$5,1); }
3643
| WEEK_SYM '(' expr ')'
3646
Item *i1= new (thd->mem_root) Item_int((char*) "0",
3647
thd->variables.default_week_format,
3650
$$= new (thd->mem_root) Item_func_week($3, i1);
3652
| WEEK_SYM '(' expr ',' expr ')'
3653
{ $$= new (YYTHD->mem_root) Item_func_week($3,$5); }
3184
{ $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
3654
3185
| WEIGHT_STRING_SYM '(' expr opt_ws_levels ')'
3655
{ $$= new (YYTHD->mem_root) Item_func_weight_string($3, 0, $4); }
3186
{ $$= new (YYSession->mem_root) Item_func_weight_string($3, 0, $4); }
3656
3187
| WEIGHT_STRING_SYM '(' expr AS CHAR_SYM ws_nweights opt_ws_levels ')'
3658
$$= new (YYTHD->mem_root)
3189
$$= new (YYSession->mem_root)
3659
3190
Item_func_weight_string($3, $6, $7|MY_STRXFRM_PAD_WITH_SPACE);
3661
3192
| WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')'
3663
$3= create_func_char_cast(YYTHD, $3, $6, &my_charset_bin);
3664
$$= new (YYTHD->mem_root)
3194
$3= create_func_char_cast(YYSession, $3, $6, &my_charset_bin);
3195
$$= new (YYSession->mem_root)
3665
3196
Item_func_weight_string($3, $6, MY_STRXFRM_PAD_WITH_SPACE);
4606
4089
group_list ',' order_ident order_dir
4607
{ if (add_group_to_list(YYTHD, $3,(bool) $4)) DRIZZLE_YYABORT; }
4090
{ if (YYSession->add_group_to_list($3,(bool) $4)) DRIZZLE_YYABORT; }
4608
4091
| order_ident order_dir
4609
{ if (add_group_to_list(YYTHD, $1,(bool) $2)) DRIZZLE_YYABORT; }
4092
{ if (YYSession->add_group_to_list($1,(bool) $2)) DRIZZLE_YYABORT; }
4617
'WITH CUBE' is reserved in the MySQL syntax, but not implemented,
4618
and cause LALR(2) conflicts.
4619
This syntax is not standard.
4620
MySQL syntax: GROUP BY col1, col2, col3 WITH CUBE
4621
SQL-2003: GROUP BY ... CUBE(col1, col2, col3)
4624
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
4626
my_error(ER_WRONG_USAGE, MYF(0), "WITH CUBE",
4627
"global union parameters");
4630
lex->current_select->olap= CUBE_TYPE;
4631
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "CUBE");
4634
4097
| WITH_ROLLUP_SYM
5326
DATABASES wild_and_where
5329
4764
lex->sql_command= SQLCOM_SHOW_DATABASES;
5330
if (prepare_schema_table(YYTHD, lex, 0, SCH_SCHEMATA))
4765
if (prepare_schema_table(YYSession, lex, 0, "SCHEMATA"))
5331
4766
DRIZZLE_YYABORT;
5333
| opt_full TABLES opt_db wild_and_where
4768
| opt_full TABLES opt_db show_wild
5336
4771
lex->sql_command= SQLCOM_SHOW_TABLES;
5337
4772
lex->select_lex.db= $3;
5338
if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES))
4773
if (prepare_schema_table(YYSession, lex, 0, "TABLE_NAMES"))
5339
4774
DRIZZLE_YYABORT;
5341
| TABLE_SYM STATUS_SYM opt_db wild_and_where
4776
| TABLE_SYM STATUS_SYM opt_db show_wild
5344
4779
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
5345
4780
lex->select_lex.db= $3;
5346
if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLES))
4781
if (prepare_schema_table(YYSession, lex, 0, "TABLES"))
5347
4782
DRIZZLE_YYABORT;
5349
| OPEN_SYM TABLES opt_db wild_and_where
4784
| OPEN_SYM TABLES opt_db show_wild
5352
4787
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
5353
4788
lex->select_lex.db= $3;
5354
if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
4789
if (prepare_schema_table(YYSession, lex, 0, "OPEN_TABLES"))
5355
4790
DRIZZLE_YYABORT;
5357
4792
| ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
5359
Lex->create_info.db_type= $2;
4794
Lex->show_engine= $2;
5360
4795
Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
5362
| opt_full COLUMNS from_or_in table_ident opt_db wild_and_where
4797
| opt_full COLUMNS from_or_in table_ident opt_db show_wild
5365
4800
lex->sql_command= SQLCOM_SHOW_FIELDS;
5367
4802
$4->change_db($5);
5368
if (prepare_schema_table(YYTHD, lex, $4, SCH_COLUMNS))
4803
if (prepare_schema_table(YYSession, lex, $4, "COLUMNS"))
5369
4804
DRIZZLE_YYABORT;
5371
| master_or_binary LOGS_SYM
5373
Lex->sql_command = SQLCOM_SHOW_BINLOGS;
5377
Lex->sql_command = SQLCOM_SHOW_SLAVE_HOSTS;
5379
| BINLOG_SYM EVENTS_SYM binlog_in binlog_from
5382
lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS;
5383
} opt_limit_clause_init
5384
4806
| keys_or_index from_or_in table_ident opt_db where_clause
5387
4809
lex->sql_command= SQLCOM_SHOW_KEYS;
5389
4811
$3->change_db($4);
5390
if (prepare_schema_table(YYTHD, lex, $3, SCH_STATISTICS))
4812
if (prepare_schema_table(YYSession, lex, $3, "STATISTICS"))
5391
4813
DRIZZLE_YYABORT;
5393
4815
| COUNT_SYM '(' '*' ')' WARNINGS
5398
4820
{ Lex->sql_command = SQLCOM_SHOW_WARNS;}
5399
4821
| ERRORS opt_limit_clause_init
5400
4822
{ Lex->sql_command = SQLCOM_SHOW_ERRORS;}
5401
| opt_var_type STATUS_SYM wild_and_where
4823
| opt_var_type STATUS_SYM show_wild
5404
4826
lex->sql_command= SQLCOM_SHOW_STATUS;
5405
4827
lex->option_type= $1;
5406
if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
4828
if (prepare_schema_table(YYSession, lex, 0, "STATUS"))
5407
4829
DRIZZLE_YYABORT;
5409
4831
| opt_full PROCESSLIST_SYM
5410
4832
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
5411
| opt_var_type VARIABLES wild_and_where
4833
| opt_var_type VARIABLES show_wild
5414
4836
lex->sql_command= SQLCOM_SHOW_VARIABLES;
5415
4837
lex->option_type= $1;
5416
if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES))
5419
| charset wild_and_where
5422
lex->sql_command= SQLCOM_SHOW_CHARSETS;
5423
if (prepare_schema_table(YYTHD, lex, 0, SCH_CHARSETS))
5426
| COLLATION_SYM wild_and_where
5429
lex->sql_command= SQLCOM_SHOW_COLLATIONS;
5430
if (prepare_schema_table(YYTHD, lex, 0, SCH_COLLATIONS))
4838
if (prepare_schema_table(YYSession, lex, 0, "VARIABLES"))
5431
4839
DRIZZLE_YYABORT;
5433
4841
| CREATE DATABASE opt_if_not_exists ident
5678
Lex_input_stream *lip= thd->m_lip;
5002
Session *session= YYSession;
5003
LEX *lex= session->lex;
5004
Lex_input_stream *lip= session->m_lip;
5680
5006
lex->fname_start= lip->get_ptr();
5682
load_data_lock opt_local INFILE TEXT_STRING_filesystem
5008
load_data_lock INFILE TEXT_STRING_filesystem
5685
5011
lex->sql_command= SQLCOM_LOAD;
5686
5012
lex->lock_option= $4;
5687
lex->local_file= $5;
5688
5013
lex->duplicates= DUP_ERROR;
5689
5014
lex->ignore= 0;
5690
if (!(lex->exchange= new sql_exchange($7.str, 0, $2)))
5015
if (!(lex->exchange= new file_exchange($6.str, 0, $2)))
5691
5016
DRIZZLE_YYABORT;
5693
5018
opt_duplicate INTO
5697
Lex_input_stream *lip= thd->m_lip;
5020
Session *session= YYSession;
5021
LEX *lex= session->lex;
5022
Lex_input_stream *lip= session->m_lip;
5698
5023
lex->fname_end= lip->get_ptr();
5700
5025
TABLE_SYM table_ident
5703
if (!Select->add_table_to_list(YYTHD, $13, NULL, TL_OPTION_UPDATING,
5028
if (!Select->add_table_to_list(YYSession, $12, NULL, TL_OPTION_UPDATING,
5704
5029
lex->lock_option))
5705
5030
DRIZZLE_YYABORT;
5706
5031
lex->field_list.empty();
5707
5032
lex->update_list.empty();
5708
5033
lex->value_list.empty();
5710
opt_load_data_charset
5711
{ Lex->exchange->cs= $15; }
5712
5035
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
5713
5036
opt_load_data_set_spec
5836
5153
/* Common definitions */
5843
const CHARSET_INFO * const cs_con= thd->variables.collation_connection;
5844
const CHARSET_INFO * const cs_cli= thd->variables.character_set_client;
5845
uint repertoire= thd->lex->text_string_is_7bit &&
5846
my_charset_is_ascii_based(cs_cli) ?
5847
MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
5848
if (thd->charset_is_collation_connection ||
5849
(repertoire == MY_REPERTOIRE_ASCII &&
5850
my_charset_is_ascii_based(cs_con)))
5853
thd->convert_string(&tmp, cs_con, $1.str, $1.length, cs_cli);
5854
$$= new Item_string(tmp.str, tmp.length, cs_con,
5855
DERIVATION_COERCIBLE, repertoire);
5857
| UNDERSCORE_CHARSET TEXT_STRING
5859
Item_string *str= new Item_string($2.str, $2.length, $1);
5860
str->set_repertoire_from_value();
5861
str->set_cs_specified(true);
5158
Session *session= YYSession;
5159
$$ = new Item_string($1.str, $1.length, session->variables.getCollation());
5865
5161
| text_literal TEXT_STRING_literal
5867
Item_string* item= (Item_string*) $1;
5868
item->append($2.str, $2.length);
5869
if (!(item->collation.repertoire & MY_REPERTOIRE_EXTENDED))
5872
If the string has been pure ASCII so far,
5875
const CHARSET_INFO * const cs= YYTHD->variables.collation_connection;
5876
item->collation.repertoire|= my_string_repertoire(cs,
5163
((Item_string*) $1)->append($2.str, $2.length);
5884
5168
TEXT_STRING_literal
5886
$$= new (YYTHD->mem_root) String($1.str,
5170
$$= new (YYSession->mem_root) String($1.str,
5888
YYTHD->variables.collation_connection);
5172
YYSession->variables.getCollation());
5928
5212
$$ = new Item_null();
5929
YYTHD->m_lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
5213
YYSession->m_lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
5931
5215
| FALSE_SYM { $$= new Item_int((char*) "FALSE",0,1); }
5932
5216
| TRUE_SYM { $$= new Item_int((char*) "TRUE",1,1); }
5933
5217
| HEX_NUM { $$ = new Item_hex_string($1.str, $1.length);}
5934
5218
| BIN_NUM { $$= new Item_bin_string($1.str, $1.length); }
5935
| UNDERSCORE_CHARSET HEX_NUM
5937
Item *tmp= new Item_hex_string($2.str, $2.length);
5939
it is OK only emulate fix_fieds, because we need only
5943
tmp->quick_fix_field(), tmp->val_str((String*) 0) :
5946
Item_string *item_str=
5947
new Item_string(NULL, /* name will be set in select_item */
5948
str ? str->ptr() : "",
5949
str ? str->length() : 0,
5952
!item_str->check_well_formed_result(&item_str->str_value, true))
5957
item_str->set_repertoire_from_value();
5958
item_str->set_cs_specified(true);
5962
| UNDERSCORE_CHARSET BIN_NUM
5964
Item *tmp= new Item_bin_string($2.str, $2.length);
5966
it is OK only emulate fix_fieds, because we need only
5970
tmp->quick_fix_field(), tmp->val_str((String*) 0) :
5973
Item_string *item_str=
5974
new Item_string(NULL, /* name will be set in select_item */
5975
str ? str->ptr() : "",
5976
str ? str->length() : 0,
5979
!item_str->check_well_formed_result(&item_str->str_value, true))
5984
item_str->set_cs_specified(true);
5988
5219
| DATE_SYM text_literal { $$ = $2; }
5989
| TIME_SYM text_literal { $$ = $2; }
5990
| TIMESTAMP text_literal { $$ = $2; }
5220
| TIMESTAMP_SYM text_literal { $$ = $2; }
6080
5314
simple_ident_q:
6081
5315
ident '.' ident
5317
Session *session= YYSession;
5318
LEX *lex= session->lex;
6087
SELECT_LEX *sel= lex->current_select;
5321
Select_Lex *sel= lex->current_select;
6088
5322
if (sel->no_table_names_allowed)
6090
5324
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
6091
MYF(0), $1.str, thd->where);
5325
MYF(0), $1.str, session->where);
6093
5327
$$= (sel->parsing_place != IN_HAVING ||
6094
5328
sel->get_in_sum_expr() > 0) ?
6095
(Item*) new Item_field(Lex->current_context(), NullS, $1.str, $3.str) :
6096
(Item*) new Item_ref(Lex->current_context(), NullS, $1.str, $3.str);
5329
(Item*) new Item_field(Lex->current_context(),
5330
(const char *)NULL, $1.str, $3.str) :
5331
(Item*) new Item_ref(Lex->current_context(),
5332
(const char *)NULL, $1.str, $3.str);
6099
5335
| '.' ident '.' ident
6103
SELECT_LEX *sel= lex->current_select;
5337
Session *session= YYSession;
5338
LEX *lex= session->lex;
5339
Select_Lex *sel= lex->current_select;
6104
5340
if (sel->no_table_names_allowed)
6106
5342
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
6107
MYF(0), $2.str, thd->where);
5343
MYF(0), $2.str, session->where);
6109
5345
$$= (sel->parsing_place != IN_HAVING ||
6110
5346
sel->get_in_sum_expr() > 0) ?
6111
(Item*) new Item_field(Lex->current_context(), NullS, $2.str, $4.str) :
6112
(Item*) new Item_ref(Lex->current_context(), NullS, $2.str, $4.str);
5347
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5348
(Item*) new Item_ref(Lex->current_context(),
5349
(const char *)NULL, $2.str, $4.str);
6114
5351
| ident '.' ident '.' ident
6118
SELECT_LEX *sel= lex->current_select;
5353
Session *session= YYSession;
5354
LEX *lex= session->lex;
5355
Select_Lex *sel= lex->current_select;
6119
5356
if (sel->no_table_names_allowed)
6121
5358
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
6122
MYF(0), $3.str, thd->where);
5359
MYF(0), $3.str, session->where);
6124
5361
$$= (sel->parsing_place != IN_HAVING ||
6125
5362
sel->get_in_sum_expr() > 0) ?
6126
5363
(Item*) new Item_field(Lex->current_context(),
6127
(YYTHD->client_capabilities &
6128
CLIENT_NO_SCHEMA ? NullS : $1.str),
5364
(YYSession->client_capabilities &
5365
CLIENT_NO_SCHEMA ? NULL : $1.str),
6129
5366
$3.str, $5.str) :
6130
5367
(Item*) new Item_ref(Lex->current_context(),
6131
(YYTHD->client_capabilities &
6132
CLIENT_NO_SCHEMA ? NullS : $1.str),
5368
(YYSession->client_capabilities &
5369
CLIENT_NO_SCHEMA ? NULL : $1.str),
6133
5370
$3.str, $5.str);
6175
5412
IDENT { $$= $1; }
6180
if (thd->charset_is_system_charset)
5415
const CHARSET_INFO * const cs= system_charset_info;
5417
uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
5419
$1.length, &dummy_error);
5420
if (wlen < $1.length)
6182
const CHARSET_INFO * const cs= system_charset_info;
6184
uint wlen= cs->cset->well_formed_len(cs, $1.str,
6186
$1.length, &dummy_error);
6187
if (wlen < $1.length)
6189
my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
6190
cs->csname, $1.str + wlen);
5422
my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
5423
cs->csname, $1.str + wlen);
6196
thd->convert_string(&$$, system_charset_info,
6197
$1.str, $1.length, thd->charset());
6201
5430
TEXT_STRING_sys:
6206
if (thd->charset_is_system_charset)
6209
thd->convert_string(&$$, system_charset_info,
6210
$1.str, $1.length, thd->charset());
6214
5437
TEXT_STRING_literal:
6219
if (thd->charset_is_collation_connection)
6222
thd->convert_string(&$$, thd->variables.collation_connection,
6223
$1.str, $1.length, thd->charset());
6227
5444
TEXT_STRING_filesystem:
6232
if (thd->charset_is_character_set_filesystem)
6235
thd->convert_string(&$$, thd->variables.character_set_filesystem,
6236
$1.str, $1.length, thd->charset());
6618
5797
lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
6620
| charset old_or_new_charset_name_or_default
6624
$2= $2 ? $2: global_system_variables.character_set_client;
6625
lex->var_list.push_back(new set_var_collation_client($2,thd->variables.collation_database,$2));
6627
| NAMES_SYM charset_name_or_default opt_collate
6630
$2= $2 ? $2 : global_system_variables.character_set_client;
6632
if (!my_charset_same($2,$3))
6634
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
6635
$3->name, $2->csname);
6638
lex->var_list.push_back(new set_var_collation_client($3,$3,$3));
6642
5801
internal_variable_name:
5804
Session *session= YYSession;
6647
5806
/* We have to lookup here since local vars can shadow sysvars */
6649
5808
/* Not an SP local variable */
6650
sys_var *tmp=find_sys_var(thd, $1.str, $1.length);
5809
sys_var *tmp=find_sys_var(session, $1.str, $1.length);
6652
5811
DRIZZLE_YYABORT;
6699
5858
| BINARY { $$=new Item_string("binary", 6, system_charset_info); }
6708
Transactional locks can be taken only if all requested locks
6709
are transactional. Initialize lex->lock_transactional as
6710
TRUE. Any non-transactional lock request turns this to FALSE.
6711
Table specific variables keep track of the locking method
6712
requested for the table. This is used to warn about a
6713
changed locking method later.
6715
Lex->lock_transactional= true;
6720
lex->sql_command= SQLCOM_LOCK_TABLES;
6726
5861
table_or_tables:
6733
| table_lock_list ',' table_lock
6737
table_ident opt_table_alias table_lock_info
6740
if (!(tlist= Select->add_table_to_list(YYTHD, $1, $2, 0,
6742
DRIZZLE_YYABORT; /* purecov: inspected */
6743
tlist->lock_timeout= $3.lock_timeout;
6744
/* Store the requested lock method for later warning. */
6745
tlist->lock_transactional= $3.lock_transactional;
6746
/* Compute the resulting lock method for all tables. */
6747
if (!$3.lock_transactional)
6748
Lex->lock_transactional= false;
6755
$$.lock_type= TL_READ_NO_INSERT;
6756
$$.lock_timeout= -1;
6757
$$.lock_transactional= false;
6761
$$.lock_type= TL_WRITE_DEFAULT;
6762
$$.lock_timeout= -1;
6763
$$.lock_transactional= false;
6765
| LOW_PRIORITY WRITE_SYM
6767
$$.lock_type= TL_WRITE_LOW_PRIORITY;
6768
$$.lock_timeout= -1;
6769
$$.lock_transactional= false;
6771
| READ_SYM LOCAL_SYM
6773
$$.lock_type= TL_READ;
6774
$$.lock_timeout= -1;
6775
$$.lock_transactional= false;
6777
| IN_SYM transactional_lock_mode MODE_SYM opt_transactional_lock_timeout
6780
$$.lock_timeout= $4;
6781
$$.lock_transactional= true;
6785
/* Use thr_lock_type here for easier fallback to non-trans locking. */
6786
transactional_lock_mode:
6787
SHARE_SYM { $$= TL_READ_NO_INSERT; }
6788
| EXCLUSIVE_SYM { $$= TL_WRITE_DEFAULT; }
6791
opt_transactional_lock_timeout:
6792
/* empty */ { $$= -1; }
6793
| NOWAIT_SYM { $$= 0; }
6794
/* | WAIT_SYM opt_lock_timeout_value { $$= $2; } */
6798
We have a timeout resolution of milliseconds. The WAIT argument is in
6799
seconds with decimal fragments for sub-second resolution. E.g. 22.5, 0.015
6801
/* opt_lock_timeout_value: */
6802
/* empty { $$= -1; } */
6803
/* | NUM { $$= (int) (atof($1.str) * 1000.0 + 0.5); } */