36
36
#define YYINITDEPTH 100
37
37
#define YYMAXDEPTH 3200 /* Because of 64K stack */
38
38
#define Lex (YYSession->lex)
42
#include "drizzled/parser.h"
39
#define Select Lex->current_select
40
#include <drizzled/server_includes.h>
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/add_time.h>
59
#include <drizzled/function/time/curdate.h>
60
#include <drizzled/function/time/curtime.h>
61
#include <drizzled/function/time/date_add_interval.h>
62
#include <drizzled/function/time/dayofmonth.h>
63
#include <drizzled/function/time/extract.h>
64
#include <drizzled/function/time/get_format.h>
65
#include <drizzled/function/time/hour.h>
66
#include <drizzled/function/time/microsecond.h>
67
#include <drizzled/function/time/minute.h>
68
#include <drizzled/function/time/month.h>
69
#include <drizzled/function/time/now.h>
70
#include <drizzled/function/time/quarter.h>
71
#include <drizzled/function/time/second.h>
72
#include <drizzled/function/time/sysdate_local.h>
73
#include <drizzled/function/time/timestamp_diff.h>
74
#include <drizzled/function/time/typecast.h>
75
#include <drizzled/function/time/week.h>
76
#include <drizzled/function/time/year.h>
78
#include <drizzled/error.h>
79
#include <drizzled/nested_join.h>
80
#include <drizzled/sql_parse.h>
81
#include <drizzled/item/copy_string.h>
82
#include <drizzled/item/cmpfunc.h>
83
#include <drizzled/item/uint.h>
84
#include <drizzled/item/null.h>
85
#include <drizzled/virtual_column_info.h>
86
#include <drizzled/session.h>
87
#include <drizzled/item/func.h>
88
#include <drizzled/sql_base.h>
89
#include <drizzled/item/create.h>
90
#include <drizzled/item/insert_value.h>
91
#include <drizzled/lex_string.h>
92
#include <drizzled/function/get_system_var.h>
44
98
int yylex(void *yylval, void *yysession);
46
100
#define yyoverflow(A,B,C,D,E,F) \
48
unsigned long val= *(F); \
49
if (drizzled::my_yyoverflow((B), (D), &val)) \
103
if (my_yyoverflow((B), (D), &val)) \
51
105
yyerror((char*) (A)); \
60
114
#define DRIZZLE_YYABORT \
117
LEX::cleanup_lex_after_parse_error(YYSession);\
66
121
#define DRIZZLE_YYABORT_UNLESS(A) \
69
parser::my_parse_error(YYSession->m_lip);\
124
my_parse_error(ER(ER_SYNTAX_ERROR));\
70
125
DRIZZLE_YYABORT; \
129
Work around for broken code generated by bison 1.875.
131
The code generated by bison 1.875a and later, bison 2.1 and bison 2.2 is ok.
132
With bison 1.875 however, the generated code contains:
135
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
136
__attribute__ ((__unused__))
139
This usage of __attribute__ is illegal, so we remove it.
140
See the following references for details:
141
http://lists.gnu.org/archive/html/bug-bison/2004-02/msg00014.html
142
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14273
145
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
147
#define __attribute__(X)
153
@brief Push an error message into MySQL error stack with line
154
and position information.
156
This function provides semantic action implementers with a way
157
to push the famous "You have a syntax error near..." error
158
message into the error stack, which is normally produced only if
159
a parse error is discovered internally by the Bison generated
163
void my_parse_error(const char *s)
165
Session *session= current_session;
166
Lex_input_stream *lip= session->m_lip;
168
const char *yytext= lip->get_tok_start();
169
/* Push an error into the error stack */
170
my_printf_error(ER_PARSE_ERROR, ER(ER_PARSE_ERROR), MYF(0), s,
171
(yytext ? yytext : ""),
92
176
@brief Bison callback to report a syntax/OOM error
102
186
The parser will abort immediately after invoking this callback.
104
188
This function is not for use in semantic actions and is internal to
105
the parser, as it performs some pre-return cleanup.
106
In semantic actions, please use parser::my_parse_error or my_error to
189
the parser, as it performs some pre-return cleanup.
190
In semantic actions, please use my_parse_error or my_error to
107
191
push an error into the error stack and DRIZZLE_YYABORT
108
192
to abort from the parser.
111
static void DRIZZLEerror(const char *s)
116
} /* namespace drizzled; */
118
using namespace drizzled;
195
void DRIZZLEerror(const char *s)
197
Session *session= current_session;
200
Restore the original LEX if it was replaced when parsing
201
a stored procedure. We must ensure that a parsing error
202
does not leave any side effects in the Session.
204
LEX::cleanup_lex_after_parse_error(session);
206
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
207
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
208
s= ER(ER_SYNTAX_ERROR);
213
Helper to resolve the SQL:2003 Syntax exception 1) in <in predicate>.
214
See SQL:2003, Part 2, section 8.4 <in predicate>, Note 184, page 383.
215
This function returns the proper item for the SQL expression
216
<code>left [NOT] IN ( expr )</code>
217
@param session the current thread
218
@param left the in predicand
219
@param equal true for IN predicates, false for NOT IN predicates
220
@param expr first and only expression of the in value list
221
@return an expression representing the IN predicate.
223
Item* handle_sql2003_note184_exception(Session *session, Item* left, bool equal,
227
Relevant references for this issue:
228
- SQL:2003, Part 2, section 8.4 <in predicate>, page 383,
229
- SQL:2003, Part 2, section 7.2 <row value expression>, page 296,
230
- SQL:2003, Part 2, section 6.3 <value expression primary>, page 174,
231
- SQL:2003, Part 2, section 7.15 <subquery>, page 370,
232
- SQL:2003 Feature F561, "Full value expressions".
234
The exception in SQL:2003 Note 184 means:
235
Item_singlerow_subselect, which corresponds to a <scalar subquery>,
236
should be re-interpreted as an Item_in_subselect, which corresponds
237
to a <table subquery> when used inside an <in predicate>.
239
Our reading of Note 184 is reccursive, so that all:
240
- IN (( <subquery> ))
241
- IN ((( <subquery> )))
242
- IN '('^N <subquery> ')'^N
244
should be interpreted as a <table subquery>, no matter how deep in the
245
expression the <subquery> is.
250
if (expr->type() == Item::SUBSELECT_ITEM)
252
Item_subselect *expr2 = (Item_subselect*) expr;
254
if (expr2->substype() == Item_subselect::SINGLEROW_SUBS)
256
Item_singlerow_subselect *expr3 = (Item_singlerow_subselect*) expr2;
257
st_select_lex *subselect;
260
Implement the mandated change, by altering the semantic tree:
261
left IN Item_singlerow_subselect(subselect)
264
which is represented as
265
Item_in_subselect(left, subselect)
267
subselect= expr3->invalidate_and_restore_select_lex();
268
result= new (session->mem_root) Item_in_subselect(left, subselect);
271
result = negate_expression(session, result);
278
result= new (session->mem_root) Item_func_eq(left, expr);
280
result= new (session->mem_root) Item_func_ne(left, expr);
286
@brief Creates a new SELECT_LEX for a UNION branch.
288
Sets up and initializes a SELECT_LEX structure for a query once the parser
289
discovers a UNION token. The current SELECT_LEX is pushed on the stack and
290
the new SELECT_LEX becomes the current one..=
292
@lex The parser state.
294
@is_union_distinct True if the union preceding the new select statement
297
@return <code>false</code> if successful, <code>true</code> if an error was
298
reported. In the latter case parsing should stop.
300
bool add_select_to_union_list(LEX *lex, bool is_union_distinct)
304
/* Only the last SELECT can have INTO...... */
305
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
308
if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE)
310
my_parse_error(ER(ER_SYNTAX_ERROR));
313
/* This counter shouldn't be incremented for UNION parts */
315
if (mysql_new_select(lex, 0))
317
mysql_init_select(lex);
318
lex->current_select->linkage=UNION_TYPE;
319
if (is_union_distinct) /* UNION DISTINCT - remember position */
320
lex->current_select->master_unit()->union_distinct=
326
@brief Initializes a SELECT_LEX for a query within parentheses (aka
329
@return false if successful, true if an error was reported. In the latter
330
case parsing should stop.
332
bool setup_select_in_parentheses(LEX *lex)
334
SELECT_LEX * sel= lex->current_select;
335
if (sel->set_braces(1))
337
my_parse_error(ER(ER_SYNTAX_ERROR));
340
if (sel->linkage == UNION_TYPE &&
341
!sel->master_unit()->first_select()->braces &&
342
sel->master_unit()->first_select()->linkage ==
345
my_parse_error(ER(ER_SYNTAX_ERROR));
348
if (sel->linkage == UNION_TYPE &&
349
sel->olap != UNSPECIFIED_OLAP_TYPE &&
350
sel->master_unit()->fake_select_lex)
352
my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
355
/* select in braces, can't contain global parameters */
356
if (sel->master_unit()->fake_select_lex)
357
sel->master_unit()->global_parameters=
358
sel->master_unit()->fake_select_lex;
123
unsigned long ulong_num;
124
366
uint64_t ulonglong_number;
125
367
int64_t longlong_number;
126
drizzled::LEX_STRING lex_str;
127
drizzled::LEX_STRING *lex_str_ptr;
128
drizzled::LEX_SYMBOL symbol;
129
drizzled::Table_ident *table;
369
LEX_STRING *lex_str_ptr;
130
372
char *simple_string;
131
drizzled::Item *item;
132
drizzled::Item_num *item_num;
133
drizzled::List<drizzled::Item> *item_list;
134
drizzled::List<drizzled::String> *string_list;
135
drizzled::String *string;
136
drizzled::Key_part_spec *key_part;
137
const drizzled::plugin::Function *udf;
138
drizzled::TableList *table_list;
139
drizzled::enum_field_types field_val;
140
drizzled::sys_var_with_base variable;
141
drizzled::sql_var_t var_type;
142
drizzled::Key::Keytype key_type;
143
drizzled::ha_key_alg key_alg;
144
drizzled::ha_rkey_function ha_rkey_mode;
145
drizzled::enum_tx_isolation tx_isolation;
146
drizzled::Cast_target cast_type;
147
const drizzled::CHARSET_INFO *charset;
148
drizzled::thr_lock_type lock_type;
149
drizzled::interval_type interval, interval_time_st;
150
drizzled::type::timestamp_t date_time_type;
151
drizzled::Select_Lex *select_lex;
152
drizzled::chooser_compare_func_creator boolfunc2creator;
153
drizzled::st_lex *lex;
154
drizzled::index_hint_type index_hint;
155
drizzled::enum_filetype filetype;
156
drizzled::ha_build_method build_method;
157
drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption m_fk_option;
158
drizzled::execute_string_t execute_string;
375
List<Item> *item_list;
376
List<String> *string_list;
378
Key_part_spec *key_part;
379
TableList *table_list;
382
struct sys_var_with_base variable;
383
enum enum_var_type var_type;
384
Key::Keytype key_type;
385
enum ha_key_alg key_alg;
387
enum row_type row_type;
388
enum column_format_type column_format_type;
389
enum ha_rkey_function ha_rkey_mode;
390
enum enum_tx_isolation tx_isolation;
391
enum Cast_target cast_type;
392
enum ha_choice choice;
393
const CHARSET_INFO *charset;
394
thr_lock_type lock_type;
395
struct st_table_lock_info table_lock_info;
396
interval_type interval, interval_time_st;
397
enum enum_drizzle_timestamp_type date_time_type;
398
st_select_lex *select_lex;
399
chooser_compare_func_creator boolfunc2creator;
400
struct sp_cond_type *spcondtype;
401
struct { int vars, conds, hndlrs, curs; } spblock;
403
struct p_elem_val *p_elem_value;
404
enum index_hint_type index_hint;
405
enum enum_filetype filetype;
406
enum ha_build_method build_method;
407
enum Foreign_key::fk_option m_fk_option;
164
bool my_yyoverflow(short **a, YYSTYPE **b, unsigned long *yystacksize);
411
bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
169
414
%pure_parser /* We have threads */
172
Currently there are 70 shift/reduce conflicts.
416
Currently there are 92 shift/reduce conflicts.
173
417
We should not introduce new conflicts any more.
178
422
Comments for TOKENS.
194
438
%token ABORT_SYM /* INTERNAL (used in lex) */
439
%token ACCESSIBLE_SYM
195
440
%token ACTION /* SQL-2003-N */
196
%token ADD_SYM /* SQL-2003-R */
441
%token ADD /* SQL-2003-R */
197
442
%token ADDDATE_SYM /* MYSQL-FUNC */
198
443
%token AFTER_SYM /* SQL-2003-N */
199
444
%token AGGREGATE_SYM
200
446
%token ALL /* SQL-2003-R */
201
%token ALTER_SYM /* SQL-2003-R */
447
%token ALTER /* SQL-2003-R */
202
448
%token ANALYZE_SYM
203
449
%token AND_SYM /* SQL-2003-R */
204
450
%token ANY_SYM /* SQL-2003-R */
205
451
%token AS /* SQL-2003-R */
206
452
%token ASC /* SQL-2003-N */
453
%token ASCII_SYM /* MYSQL-FUNC */
207
454
%token ASENSITIVE_SYM /* FUTURE-USE */
208
455
%token AT_SYM /* SQL-2003-R */
456
%token AUTOEXTEND_SIZE_SYM
458
%token AVG_ROW_LENGTH
210
459
%token AVG_SYM /* SQL-2003-N */
211
460
%token BEFORE_SYM /* SQL-2003-N */
212
461
%token BEGIN_SYM /* SQL-2003-R */
213
462
%token BETWEEN_SYM /* SQL-2003-R */
214
%token BIGINT_SYM /* SQL-2003-R */
463
%token BIGINT /* SQL-2003-R */
215
464
%token BINARY /* SQL-2003-R */
217
467
%token BIT_SYM /* MYSQL-FUNC */
218
468
%token BLOB_SYM /* SQL-2003-R */
469
%token BLOCK_SIZE_SYM
219
471
%token BOOLEAN_SYM /* SQL-2003-R */
221
473
%token BOTH /* SQL-2003-R */
223
475
%token BY /* SQL-2003-R */
224
478
%token CALL_SYM /* SQL-2003-R */
225
479
%token CASCADE /* SQL-2003-N */
226
480
%token CASCADED /* SQL-2003-R */
227
481
%token CASE_SYM /* SQL-2003-R */
228
482
%token CAST_SYM /* SQL-2003-R */
230
483
%token CHAIN_SYM /* SQL-2003-N */
232
487
%token CHAR_SYM /* SQL-2003-R */
233
488
%token CHECKSUM_SYM
234
489
%token CHECK_SYM /* SQL-2003-R */
493
836
%token SUBJECT_SYM
494
837
%token SUBSTRING /* SQL-2003-N */
495
838
%token SUM_SYM /* SQL-2003-N */
496
840
%token SUSPEND_SYM
499
845
%token TABLESPACE
500
846
%token TABLE_REF_PRIORITY
501
847
%token TABLE_SYM /* SQL-2003-R */
502
%token TEMPORARY_SYM /* SQL-2003-N */
848
%token TABLE_CHECKSUM_SYM
849
%token TEMPORARY /* SQL-2003-N */
503
851
%token TERMINATED
504
852
%token TEXT_STRING
506
855
%token THEN_SYM /* SQL-2003-R */
507
%token TIME_SYM /* SQL-2003-R */
508
%token TIMESTAMP_SYM /* SQL-2003-R */
856
%token TIMESTAMP /* SQL-2003-R */
509
857
%token TIMESTAMP_ADD
510
858
%token TIMESTAMP_DIFF
859
%token TIME_SYM /* SQL-2003-R */
511
860
%token TO_SYM /* SQL-2003-R */
512
861
%token TRAILING /* SQL-2003-R */
513
862
%token TRANSACTION_SYM
863
%token TRANSACTIONAL_SYM
514
864
%token TRIM /* SQL-2003-N */
515
865
%token TRUE_SYM /* SQL-2003-R */
516
866
%token TRUNCATE_SYM
517
868
%token TYPE_SYM /* SQL-2003-N */
518
869
%token ULONGLONG_NUM
519
870
%token UNCOMMITTED_SYM /* SQL-2003-N */
872
%token UNDERSCORE_CHARSET
520
873
%token UNDOFILE_SYM
521
874
%token UNDO_SYM /* FUTURE-USE */
522
875
%token UNION_SYM /* SQL-2003-R */
523
876
%token UNIQUE_SYM
524
877
%token UNKNOWN_SYM /* SQL-2003-R */
525
878
%token UNLOCK_SYM
527
880
%token UPDATE_SYM /* SQL-2003-R */
528
882
%token USAGE /* SQL-2003-N */
529
883
%token USER /* SQL-2003-R */
531
886
%token USING /* SQL-2003-R */
532
887
%token UTC_DATE_SYM
533
888
%token UTC_TIMESTAMP_SYM
535
890
%token VALUES /* SQL-2003-R */
536
891
%token VALUE_SYM /* SQL-2003-R */
538
%token VARCHAR_SYM /* SQL-2003-R */
893
%token VARCHAR /* SQL-2003-R */
540
895
%token VARIANCE_SYM
541
896
%token VARYING /* SQL-2003-R */
542
897
%token VAR_SAMP_SYM
902
%token WEIGHT_STRING_SYM
546
903
%token WHEN_SYM /* SQL-2003-R */
547
904
%token WHERE /* SQL-2003-R */
548
905
%token WITH /* SQL-2003-R */
712
1054
%type <build_method> build_method
715
query verb_clause create select drop insert replace insert2
1057
query verb_clause create change select drop insert replace insert2
716
1058
insert_values update delete truncate rename
717
show describe load alter flush
718
begin commit rollback savepoint release
1059
show describe load alter optimize keycache flush
1060
reset purge begin commit rollback savepoint release
1061
slave master_def master_defs master_file_def slave_until_opts
1062
repair analyze check start checksum
720
1063
field_list field_list_item field_spec kill column_def key_def
1064
keycache_list assign_to_keycache
721
1065
select_item_list select_item values_list no_braces
722
1066
opt_limit_clause delete_limit_clause fields opt_values values
723
1067
opt_precision opt_ignore opt_column
724
set unlock string_list
1068
set lock unlock string_list
1069
opt_binary table_lock_list table_lock
725
1070
ref_list opt_match_clause opt_on_update_delete use
726
1071
opt_delete_options opt_delete_option varchar
727
opt_outer table_list table_name
1072
opt_outer table_list table_name table_alias_ref_list table_alias_ref
728
1073
opt_option opt_place
729
1074
opt_attribute opt_attribute_list attribute
730
1075
flush_options flush_option
731
1076
equal optional_braces
733
table_to_table_list table_to_table opt_table_list
1077
opt_mi_check_type opt_to mi_check_types normal_join
1078
table_to_table_list table_to_table opt_table_list opt_as
1079
single_multi table_wild_list table_wild_one opt_wild
735
1080
union_clause union_list
736
1081
precision subselect_start
737
1082
subselect_end select_var_list select_var_list_init opt_len
738
1083
opt_extended_describe
741
1085
opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
742
1087
init_key_options key_options key_opts key_opt key_using_alg
1088
parse_vcol_expr vcol_opt_attribute vcol_opt_attribute_list
745
1092
%type <index_hint> index_hint_type
1189
CHANGE MASTER_SYM TO_SYM
1192
lex->sql_command = SQLCOM_CHANGE_MASTER;
1193
memset(&lex->mi, 0, sizeof(lex->mi));
1201
| master_defs ',' master_def
1205
MASTER_HOST_SYM EQ TEXT_STRING_sys
1207
Lex->mi.host = $3.str;
1209
| MASTER_USER_SYM EQ TEXT_STRING_sys
1211
Lex->mi.user = $3.str;
1213
| MASTER_PASSWORD_SYM EQ TEXT_STRING_sys
1215
Lex->mi.password = $3.str;
1217
| MASTER_PORT_SYM EQ ulong_num
1221
| MASTER_CONNECT_RETRY_SYM EQ ulong_num
1223
Lex->mi.connect_retry = $3;
1225
| MASTER_HEARTBEAT_PERIOD_SYM EQ NUM_literal
1227
Lex->mi.heartbeat_period= (float) $3->val_real();
1228
if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD ||
1229
Lex->mi.heartbeat_period < 0.0)
1231
char buf[sizeof(SLAVE_MAX_HEARTBEAT_PERIOD*4)];
1232
sprintf(buf, "%d seconds", SLAVE_MAX_HEARTBEAT_PERIOD);
1233
my_error(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1235
" is negative or exceeds the maximum ",
1239
if (Lex->mi.heartbeat_period > slave_net_timeout)
1241
push_warning_printf(YYSession, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1242
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1243
ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1244
" exceeds the value of `slave_net_timeout' sec.",
1245
" A sensible value for the period should be"
1246
" less than the timeout.");
1248
if (Lex->mi.heartbeat_period < 0.001)
1250
if (Lex->mi.heartbeat_period != 0.0)
1252
push_warning_printf(YYSession, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1253
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE,
1254
ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE),
1255
" is less than 1 msec.",
1256
" The period is reset to zero which means"
1257
" no heartbeats will be sending");
1258
Lex->mi.heartbeat_period= 0.0;
1260
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_DISABLE;
1262
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
1269
MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
1271
Lex->mi.log_file_name = $3.str;
1273
| MASTER_LOG_POS_SYM EQ ulonglong_num
1277
If the user specified a value < BIN_LOG_HEADER_SIZE, adjust it
1278
instead of causing subsequent errors.
1279
We need to do it in this file, because only there we know that
1280
MASTER_LOG_POS has been explicitely specified. On the contrary
1281
in change_master() (sql_repl.cc) we cannot distinguish between 0
1282
(MASTER_LOG_POS explicitely specified as 0) and 0 (unspecified),
1283
whereas we want to distinguish (specified 0 means "read the binlog
1284
from 0" (4 in fact), unspecified means "don't change the position
1285
(keep the preceding value)").
1287
Lex->mi.pos = cmax((uint64_t)BIN_LOG_HEADER_SIZE, Lex->mi.pos);
1289
| RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
1291
Lex->mi.relay_log_name = $3.str;
1293
| RELAY_LOG_POS_SYM EQ ulong_num
1295
Lex->mi.relay_log_pos = $3;
1296
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
1297
Lex->mi.relay_log_pos = cmax((uint32_t)BIN_LOG_HEADER_SIZE, Lex->mi.relay_log_pos);
828
1301
/* create a table */
831
CREATE CATALOG_SYM catalog_name
833
Lex->statement= new statement::catalog::Create(YYSession, $3);
835
| CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
837
Lex->statement= new statement::CreateTable(YYSession, $5, $2);
839
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL,
843
Lex->col_list.empty();
845
create_table_definition
847
Lex->current_select= &Lex->select_lex;
849
| CREATE build_method
851
Lex->statement= new statement::CreateIndex(YYSession, $2);
853
opt_unique INDEX_SYM ident key_alg ON table_ident '(' key_list ')' key_options
855
if (not Lex->current_select->add_table_to_list(Lex->session, $9,
860
parser::buildKey(Lex, $4, $6);
862
| CREATE DATABASE opt_if_not_exists schema_name
864
Lex->statement= new statement::CreateSchema(YYSession);
1304
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
1306
Session *session= YYSession;
1307
LEX *lex= session->lex;
1308
lex->sql_command= SQLCOM_CREATE_TABLE;
1309
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
1313
lex->alter_info.reset();
1314
lex->col_list.empty();
1316
memset(&lex->create_info, 0, sizeof(lex->create_info));
1317
lex->create_info.options=$2 | $4;
1318
lex->create_info.db_type= ha_default_handlerton(session);
1319
lex->create_info.default_table_charset= NULL;
1321
lex->name.length= 0;
1325
LEX *lex= YYSession->lex;
1326
lex->current_select= &lex->select_lex;
1327
if (!lex->create_info.db_type)
1329
lex->create_info.db_type= ha_default_handlerton(YYSession);
1330
push_warning_printf(YYSession, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1331
ER_WARN_USING_OTHER_HANDLER,
1332
ER(ER_WARN_USING_OTHER_HANDLER),
1333
ha_resolve_storage_engine_name(lex->create_info.db_type),
1337
| CREATE build_method opt_unique INDEX_SYM ident key_alg
1341
lex->sql_command= SQLCOM_CREATE_INDEX;
1342
if (!lex->current_select->add_table_to_list(lex->session, $8,
1344
TL_OPTION_UPDATING))
1346
lex->alter_info.reset();
1347
lex->alter_info.flags= ALTER_ADD_INDEX;
1348
lex->alter_info.build_method= $2;
1349
lex->col_list.empty();
1352
'(' key_list ')' key_options
1356
key= new Key($3, $5, &lex->key_create_info, 0,
1358
lex->alter_info.key_list.push_back(key);
1359
lex->col_list.empty();
1361
| CREATE DATABASE opt_if_not_exists ident
1363
Lex->create_info.default_table_charset= NULL;
1364
Lex->create_info.used_fields= 0;
866
1366
opt_create_database_options
872
create_table_definition:
873
'(' field_list ')' opt_create_table_options create_select_as
875
| '(' create_select ')'
877
Lex->current_select->set_braces(1);
1369
lex->sql_command=SQLCOM_CREATE_DB;
1371
lex->create_info.options=$3;
1377
| opt_create_table_options
1381
Session *session= YYSession;
1382
LEX *lex= session->lex;
1384
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1385
if (!lex->select_lex.add_table_to_list(session, $2, NULL, 0, TL_READ))
1388
| '(' LIKE table_ident ')'
1390
Session *session= YYSession;
1391
LEX *lex= session->lex;
1393
lex->create_info.options|= HA_LEX_CREATE_TABLE_LIKE;
1394
if (!lex->select_lex.add_table_to_list(session, $3, NULL, 0, TL_READ))
1400
field_list ')' opt_create_table_options
1403
{ Select->set_braces(1);}
880
| '(' create_like ')' opt_create_table_options
882
| create_like opt_create_table_options
884
| opt_create_table_options create_select_as
890
| opt_duplicate_as create_select
892
Lex->current_select->set_braces(0);
1409
| opt_duplicate opt_as create_select
1410
{ Select->set_braces(0);}
895
| opt_duplicate_as '(' create_select ')'
897
Lex->current_select->set_braces(1);
1412
| opt_duplicate opt_as '(' create_select ')'
1413
{ Select->set_braces(1);}
905
((statement::CreateTable *)(YYSession->getLex()->statement))->is_create_table_like= true;
907
if (not YYSession->getLex()->select_lex.add_table_to_list(YYSession, $2, NULL, 0, TL_READ))
919
This rule is used for both CREATE TABLE .. SELECT, AND INSERT ... SELECT
924
Lex->lock_option= TL_READ;
925
if (Lex->sql_command == SQLCOM_INSERT)
927
delete Lex->statement;
928
Lex->statement= new statement::InsertSelect(YYSession);
930
else if (Lex->sql_command == SQLCOM_REPLACE)
932
delete Lex->statement;
933
Lex->statement= new statement::ReplaceSelect(YYSession);
1421
lex->lock_option= TL_READ;
1422
if (lex->sql_command == SQLCOM_INSERT)
1423
lex->sql_command= SQLCOM_INSERT_SELECT;
1424
else if (lex->sql_command == SQLCOM_REPLACE)
1425
lex->sql_command= SQLCOM_REPLACE_SELECT;
936
1427
The following work only with the local list, the global list
937
1428
is created correctly in this case
939
Lex->current_select->table_list.save_and_clear(&Lex->save_list);
941
Lex->current_select->parsing_place= SELECT_LIST;
1430
lex->current_select->table_list.save_and_clear(&lex->save_list);
1431
mysql_init_select(lex);
1432
lex->current_select->parsing_place= SELECT_LIST;
943
1434
select_options select_item_list
945
Lex->current_select->parsing_place= NO_MATTER;
1436
Select->parsing_place= NO_MATTER;
1005
1497
create_table_option
1006
1498
| create_table_option create_table_options
1007
1499
| create_table_option ',' create_table_options
1009
1502
create_table_option:
1010
custom_engine_option;
1012
custom_engine_option:
1013
ENGINE_SYM equal ident_or_text
1015
Lex->table()->mutable_engine()->set_name($3.str);
1503
ENGINE_SYM opt_equal storage_engines
1505
Lex->create_info.db_type= $3;
1506
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
1508
| MAX_ROWS opt_equal ulonglong_num
1510
Lex->create_info.max_rows= $3;
1511
Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;
1513
| MIN_ROWS opt_equal ulonglong_num
1515
Lex->create_info.min_rows= $3;
1516
Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;
1518
| AVG_ROW_LENGTH opt_equal ulong_num
1520
Lex->create_info.avg_row_length=$3;
1521
Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;
1523
| BLOCK_SIZE_SYM opt_equal ulong_num
1525
Lex->create_info.block_size= $3;
1526
Lex->create_info.used_fields|= HA_CREATE_USED_BLOCK_SIZE;
1017
1528
| COMMENT_SYM opt_equal TEXT_STRING_sys
1019
Lex->table()->mutable_options()->set_comment($3.str);
1530
Lex->create_info.comment=$3;
1531
Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT;
1021
1533
| AUTO_INC opt_equal ulonglong_num
1023
Lex->table()->mutable_options()->set_auto_increment_value($3);
1025
| ROW_FORMAT_SYM equal row_format_or_text
1027
parser::buildEngineOption(Lex, "ROW_FORMAT", $3);
1029
| FILE_SYM equal TEXT_STRING_sys
1031
parser::buildEngineOption(Lex, "FILE", $3);
1033
| ident_or_text equal engine_option_value
1035
parser::buildEngineOption(Lex, $1.str, $3);
1037
| ident_or_text equal ulonglong_num
1039
parser::buildEngineOption(Lex, $1.str, $3);
1535
Lex->create_info.auto_increment_value=$3;
1536
Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;
1538
| PACK_KEYS_SYM opt_equal ulong_num
1542
Lex->create_info.table_options|= HA_OPTION_NO_PACK_KEYS;
1545
Lex->create_info.table_options|= HA_OPTION_PACK_KEYS;
1548
my_parse_error(ER(ER_SYNTAX_ERROR));
1551
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1553
| PACK_KEYS_SYM opt_equal DEFAULT
1555
Lex->create_info.table_options&=
1556
~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS);
1557
Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;
1559
| CHECKSUM_SYM opt_equal ulong_num
1561
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1562
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1564
| TABLE_CHECKSUM_SYM opt_equal ulong_num
1566
Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM;
1567
Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM;
1569
| PAGE_CHECKSUM_SYM opt_equal choice
1571
Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM;
1572
Lex->create_info.page_checksum= $3;
1574
| DELAY_KEY_WRITE_SYM opt_equal ulong_num
1576
Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE;
1577
Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE;
1579
| ROW_FORMAT_SYM opt_equal row_types
1581
Lex->create_info.row_type= $3;
1582
Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT;
1583
Lex->alter_info.flags|= ALTER_ROW_FORMAT;
1041
1585
| default_collation
1586
| DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1588
Lex->create_info.data_file_name= $4.str;
1589
Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR;
1591
| INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys
1593
Lex->create_info.index_file_name= $4.str;
1594
Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR;
1596
| CONNECTION_SYM opt_equal TEXT_STRING_sys
1598
Lex->create_info.connect_string.str= $3.str;
1599
Lex->create_info.connect_string.length= $3.length;
1600
Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION;
1602
| KEY_BLOCK_SIZE opt_equal ulong_num
1604
Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE;
1605
Lex->create_info.key_block_size= $3;
1044
1609
default_collation:
1045
1610
opt_default COLLATE_SYM opt_equal collation_name_or_default
1047
if (not parser::buildCollation(Lex, $4))
1054
default_collation_schema:
1055
opt_default COLLATE_SYM opt_equal collation_name_or_default
1057
((statement::CreateSchema *)Lex->statement)->schema_message.set_collation($4->name);
1073
$$.str= YYSession->strmake($1.str, $1.length);
1074
$$.length= $1.length;
1612
HA_CREATE_INFO *cinfo= &Lex->create_info;
1613
if ((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) &&
1614
cinfo->default_table_charset && $4 &&
1615
!my_charset_same(cinfo->default_table_charset,$4))
1617
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
1618
$4->name, cinfo->default_table_charset->csname);
1621
Lex->create_info.default_table_charset= $4;
1622
Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET;
1629
plugin_ref plugin= ha_resolve_by_name(YYSession, &$1);
1632
$$= plugin_data(plugin, handlerton*);
1635
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1641
known_storage_engines:
1645
if ((plugin= ha_resolve_by_name(YYSession, &$1)))
1646
$$= plugin_data(plugin, handlerton*);
1649
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
1655
column_format_types:
1656
DEFAULT { $$= COLUMN_FORMAT_TYPE_DEFAULT; }
1657
| FIXED_SYM { $$= COLUMN_FORMAT_TYPE_FIXED; }
1658
| DYNAMIC_SYM { $$= COLUMN_FORMAT_TYPE_DYNAMIC; };
1661
DEFAULT { $$= ROW_TYPE_DEFAULT; }
1662
| FIXED_SYM { $$= ROW_TYPE_FIXED; }
1663
| DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; }
1664
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
1665
| REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; }
1666
| COMPACT_SYM { $$= ROW_TYPE_COMPACT; }
1667
| PAGE_SYM { $$= ROW_TYPE_PAGE; }
1078
1670
opt_select_from:
1094
1686
field_spec opt_check_constraint
1095
1687
| field_spec references
1097
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1689
Lex->col_list.empty(); /* Alloced by sql_alloc */
1102
1694
key_type opt_ident key_alg '(' key_list ')' key_options
1104
parser::buildKey(Lex, $1, $2);
1697
Key *key= new Key($1, $2, &lex->key_create_info, 0,
1699
lex->alter_info.key_list.push_back(key);
1700
lex->col_list.empty(); /* Alloced by sql_alloc */
1106
1702
| opt_constraint constraint_key_type opt_ident key_alg
1107
1703
'(' key_list ')' key_options
1109
parser::buildKey(Lex, $2, $3.str ? $3 : $1);
1706
Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0,
1708
lex->alter_info.key_list.push_back(key);
1709
lex->col_list.empty(); /* Alloced by sql_alloc */
1111
1711
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
1113
parser::buildForeignKey(Lex, $1.str ? $1 : $4, $8);
1714
Key *key= new Foreign_key($4.str ? $4 : $1, lex->col_list,
1719
lex->fk_match_option);
1720
lex->alter_info.key_list.push_back(key);
1721
key= new Key(Key::MULTIPLE, $1.str ? $1 : $4,
1722
&default_key_create_info, 1,
1724
lex->alter_info.key_list.push_back(key);
1725
lex->col_list.empty(); /* Alloced by sql_alloc */
1726
/* Only used for ALTER TABLE. Ignored otherwise. */
1727
lex->alter_info.flags|= ALTER_FOREIGN_KEY;
1115
1729
| constraint opt_check_constraint
1117
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1731
Lex->col_list.empty(); /* Alloced by sql_alloc */
1119
1733
| opt_constraint check_constraint
1121
Lex->col_list.empty(); /* Alloced by memory::sql_alloc */
1735
Lex->col_list.empty(); /* Alloced by sql_alloc */
1146
parser::buildCreateFieldIdent(Lex);
1761
lex->length=lex->dec=0;
1763
lex->default_value= lex->on_update_value= 0;
1764
lex->comment=null_lex_str;
1766
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1767
lex->vcol_info= NULL;
1150
statement::CreateTable *statement= (statement::CreateTable *)Lex->statement;
1154
Lex->field()->set_name($1.str);
1157
if (add_field_to_list(Lex->session, &$1, (enum enum_field_types) $3,
1158
Lex->length, Lex->dec, Lex->type,
1159
statement->column_format,
1160
statement->default_value, statement->on_update_value,
1161
&statement->comment,
1162
statement->change, &Lex->interval_list, Lex->charset))
1772
if (add_field_to_list(lex->session, &$1, (enum enum_field_types) $3,
1773
lex->length,lex->dec,lex->type,
1775
lex->default_value, lex->on_update_value,
1777
lex->change,&lex->interval_list,lex->charset,
1163
1779
DRIZZLE_YYABORT;
1165
Lex->setField(NULL);
1170
field_definition opt_attribute {}
1174
int_type ignored_field_number_length opt_field_number_signed opt_zerofill
1176
$$= parser::buildIntegerColumn(Lex, $1, ($3 or $4));
1178
| real_type opt_precision
1180
assert ($1 == DRIZZLE_TYPE_DOUBLE);
1181
$$= parser::buildDoubleColumn(Lex);
1185
$$= parser::buildVarcharColumn(Lex, $3.str);
1189
$$= parser::buildVarcharColumn(Lex, "1");
1191
| varchar '(' NUM ')'
1193
$$= parser::buildVarcharColumn(Lex, $3.str);
1783
type opt_attribute {}
1784
| VIRTUAL_SYM type AS '(' virtual_column_func ')' vcol_opt_attribute
1786
$$=DRIZZLE_TYPE_VIRTUAL;
1787
Lex->vcol_info->set_field_type((enum enum_field_types) $2);
1793
| vcol_opt_attribute_list {}
1796
vcol_opt_attribute_list:
1797
vcol_opt_attribute_list vcol_attribute {}
1805
lex->type|= UNIQUE_FLAG;
1806
lex->alter_info.flags|= ALTER_ADD_INDEX;
1808
| UNIQUE_SYM KEY_SYM
1811
lex->type|= UNIQUE_KEY_FLAG;
1812
lex->alter_info.flags|= ALTER_ADD_INDEX;
1814
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1817
Lex->vcol_info->set_field_stored(true);
1822
PARSE_VCOL_EXPR_SYM '(' virtual_column_func ')'
1825
"PARSE_VCOL_EXPR" can only be used by the SQL server
1826
when reading a '*.frm' file.
1827
Prevent the end user from invoking this command.
1829
if (not Lex->parse_vcol_expr)
1831
my_message(ER_SYNTAX_ERROR, ER(ER_SYNTAX_ERROR), MYF(0));
1837
virtual_column_func:
1838
remember_name expr remember_end
1840
Lex->vcol_info= new virtual_column_info();
1841
if (not Lex->vcol_info)
1843
my_error(ER_OUTOFMEMORY, MYF(0), sizeof(virtual_column_info));
1846
uint expr_len= (uint)($3 - $1) - 1;
1847
Lex->vcol_info->expr_str.str= (char* ) sql_memdup($1 + 1, expr_len);
1848
Lex->vcol_info->expr_str.length= expr_len;
1849
Lex->vcol_info->expr_item= $2;
1857
Lex->length=(char*) 0; /* use default length */
1859
| real_type opt_precision { $$=$1; }
1860
| char '(' NUM ')' opt_binary
1863
$$=DRIZZLE_TYPE_VARCHAR;
1867
Lex->length=(char*) "1";
1868
$$=DRIZZLE_TYPE_VARCHAR;
1870
| varchar '(' NUM ')' opt_binary
1873
$$= DRIZZLE_TYPE_VARCHAR;
1195
1875
| VARBINARY '(' NUM ')'
1197
$$= parser::buildVarbinaryColumn(Lex, $3.str);
1878
Lex->charset=&my_charset_bin;
1879
$$= DRIZZLE_TYPE_VARCHAR;
1201
$$=DRIZZLE_TYPE_DATE;
1204
Lex->field()->set_type(message::Table::Field::DATE);
1882
{ $$=DRIZZLE_TYPE_DATE; }
1208
$$=DRIZZLE_TYPE_TIME;
1211
Lex->field()->set_type(message::Table::Field::TIME);
1215
$$=parser::buildTimestampColumn(Lex, NULL);
1217
| TIMESTAMP_SYM '(' NUM ')'
1219
$$=parser::buildTimestampColumn(Lex, $3.str);
1223
$$=DRIZZLE_TYPE_DATETIME;
1226
Lex->field()->set_type(message::Table::Field::DATETIME);
1884
{ $$=DRIZZLE_TYPE_TIME; }
1887
/* Unlike other types TIMESTAMP fields are NOT NULL by default */
1888
Lex->type|= NOT_NULL_FLAG;
1889
$$=DRIZZLE_TYPE_TIMESTAMP;
1892
{ $$=DRIZZLE_TYPE_DATETIME; }
1230
$$= parser::buildBlobColumn(Lex);
1895
Lex->charset=&my_charset_bin;
1234
1896
$$=DRIZZLE_TYPE_BLOB;
1235
1897
Lex->length=(char*) 0; /* use default length */
1238
Lex->field()->set_type(message::Table::Field::BLOB);
1899
| TEXT_SYM opt_binary
1901
$$=DRIZZLE_TYPE_BLOB;
1902
Lex->length=(char*) 0; /* use default length */
1240
1904
| DECIMAL_SYM float_options
1242
$$= parser::buildDecimalColumn(Lex);
1905
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1244
1906
| NUMERIC_SYM float_options
1246
$$= parser::buildDecimalColumn(Lex);
1907
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1248
1908
| FIXED_SYM float_options
1250
$$= parser::buildDecimalColumn(Lex);
1254
Lex->interval_list.empty();
1258
$$=DRIZZLE_TYPE_ENUM;
1261
Lex->field()->set_type(message::Table::Field::ENUM);
1265
$$= parser::buildUuidColumn(Lex);
1269
$$= parser::buildBooleanColumn(Lex);
1909
{ $$=DRIZZLE_TYPE_NEWDECIMAL;}
1911
{Lex->interval_list.empty();}
1912
'(' string_list ')' opt_binary
1913
{ $$=DRIZZLE_TYPE_ENUM; }
1273
$$= parser::buildSerialColumn(Lex);
1916
$$=DRIZZLE_TYPE_LONGLONG;
1917
Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG);
1376
Lex->type&= ~ NOT_NULL_FLAG;
1380
Lex->type|= NOT_NULL_FLAG;
1384
Lex->field()->mutable_constraints()->set_is_notnull(true);
1387
| DEFAULT now_or_signed_literal
1389
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1391
statement->default_value=$2;
1392
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1394
| ON UPDATE_SYM NOW_SYM optional_braces
1396
((statement::AlterTable *)Lex->statement)->on_update_value= new Item_func_now_local();
1400
parser::buildAutoOnColumn(Lex);
1985
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
1986
| COLUMN_FORMAT_SYM column_format_types
1988
Lex->column_format= $2;
1989
Lex->alter_info.flags|= ALTER_COLUMN_FORMAT;
1991
| not NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
1992
| DEFAULT now_or_signed_literal
1994
Lex->default_value=$2;
1995
Lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
1997
| ON UPDATE_SYM NOW_SYM optional_braces
1998
{ Lex->on_update_value= new Item_func_now_local(); }
1999
| AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
1402
2000
| SERIAL_SYM DEFAULT VALUE_SYM
1404
(void)parser::buildSerialColumn(Lex);
2003
lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG;
2004
lex->alter_info.flags|= ALTER_ADD_INDEX;
1406
2006
| opt_primary KEY_SYM
1408
parser::buildPrimaryOnColumn(Lex);
2009
lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG;
2010
lex->alter_info.flags|= ALTER_ADD_INDEX;
1412
parser::buildKeyOnColumn(Lex);
2015
lex->type|= UNIQUE_FLAG;
2016
lex->alter_info.flags|= ALTER_ADD_INDEX;
1414
2018
| UNIQUE_SYM KEY_SYM
1416
parser::buildKeyOnColumn(Lex);
1418
| COMMENT_SYM TEXT_STRING_sys
1420
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1421
statement->comment= $2;
1424
Lex->field()->set_comment($2.str);
2021
lex->type|= UNIQUE_KEY_FLAG;
2022
lex->alter_info.flags|= ALTER_ADD_INDEX;
2024
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
1426
2025
| COLLATE_SYM collation_name
1428
2027
if (Lex->charset && !my_charset_same(Lex->charset,$2))
1493
2166
{ Lex->ref_list.push_back(new Key_part_spec($3, 0)); }
1496
Lex->ref_list.empty();
1497
Lex->ref_list.push_back(new Key_part_spec($1, 0));
2170
lex->ref_list.empty();
2171
lex->ref_list.push_back(new Key_part_spec($1, 0));
1501
2175
opt_match_clause:
1503
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_UNDEFINED; }
2177
{ Lex->fk_match_option= Foreign_key::FK_MATCH_UNDEF; }
1505
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_FULL; }
2179
{ Lex->fk_match_option= Foreign_key::FK_MATCH_FULL; }
1506
2180
| MATCH PARTIAL
1507
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_PARTIAL; }
2181
{ Lex->fk_match_option= Foreign_key::FK_MATCH_PARTIAL; }
1508
2182
| MATCH SIMPLE_SYM
1509
{ ((statement::CreateTable *)Lex->statement)->fk_match_option= drizzled::message::Table::ForeignKeyConstraint::MATCH_SIMPLE; }
2183
{ Lex->fk_match_option= Foreign_key::FK_MATCH_SIMPLE; }
1512
2186
opt_on_update_delete:
1515
((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1516
((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
2190
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
2191
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1518
2193
| ON UPDATE_SYM delete_option
1520
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1521
((statement::CreateTable *)Lex->statement)->fk_delete_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
2196
lex->fk_update_opt= $3;
2197
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
1523
2199
| ON DELETE_SYM delete_option
1525
((statement::CreateTable *)Lex->statement)->fk_update_opt= drizzled::message::Table::ForeignKeyConstraint::OPTION_UNDEF;
1526
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
2202
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
2203
lex->fk_delete_opt= $3;
1528
2205
| ON UPDATE_SYM delete_option
1529
2206
ON DELETE_SYM delete_option
1531
((statement::CreateTable *)Lex->statement)->fk_update_opt= $3;
1532
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $6;
2209
lex->fk_update_opt= $3;
2210
lex->fk_delete_opt= $6;
1534
2212
| ON DELETE_SYM delete_option
1535
2213
ON UPDATE_SYM delete_option
1537
((statement::CreateTable *)Lex->statement)->fk_update_opt= $6;
1538
((statement::CreateTable *)Lex->statement)->fk_delete_opt= $3;
2216
lex->fk_update_opt= $6;
2217
lex->fk_delete_opt= $3;
1543
RESTRICT { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_RESTRICT; }
1544
| CASCADE { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_CASCADE; }
1545
| SET_SYM NULL_SYM { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_NULL; }
1546
| NO_SYM ACTION { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_NO_ACTION; }
1547
| SET_SYM DEFAULT { $$= drizzled::message::Table::ForeignKeyConstraint::OPTION_SET_DEFAULT; }
2222
RESTRICT { $$= Foreign_key::FK_OPTION_RESTRICT; }
2223
| CASCADE { $$= Foreign_key::FK_OPTION_CASCADE; }
2224
| SET NULL_SYM { $$= Foreign_key::FK_OPTION_SET_NULL; }
2225
| NO_SYM ACTION { $$= Foreign_key::FK_OPTION_NO_ACTION; }
2226
| SET DEFAULT { $$= Foreign_key::FK_OPTION_DEFAULT; }
1661
ALTER_SYM build_method opt_ignore TABLE_SYM table_ident
2341
ALTER build_method opt_ignore TABLE_SYM table_ident
1663
statement::AlterTable *statement= new statement::AlterTable(YYSession, $5, $2);
1664
Lex->statement= statement;
1665
Lex->duplicates= DUP_ERROR;
1666
if (not Lex->select_lex.add_table_to_list(YYSession, $5, NULL, TL_OPTION_UPDATING))
2343
Session *session= YYSession;
2344
LEX *lex= session->lex;
2346
lex->name.length= 0;
2347
lex->sql_command= SQLCOM_ALTER_TABLE;
2348
lex->duplicates= DUP_ERROR;
2349
if (!lex->select_lex.add_table_to_list(session, $5, NULL,
2350
TL_OPTION_UPDATING))
1668
2351
DRIZZLE_YYABORT;
1671
Lex->col_list.empty();
1672
Lex->select_lex.init_order();
1673
Lex->select_lex.db= const_cast<char *>(((TableList*) Lex->select_lex.table_list.first)->getSchemaName());
2352
lex->alter_info.reset();
2353
lex->col_list.empty();
2354
lex->select_lex.init_order();
2356
((TableList*) lex->select_lex.table_list.first)->db;
2357
memset(&lex->create_info, 0, sizeof(lex->create_info));
2358
lex->create_info.db_type= 0;
2359
lex->create_info.default_table_charset= NULL;
2360
lex->create_info.row_type= ROW_TYPE_NOT_USED;
2361
lex->alter_info.reset();
2362
lex->alter_info.build_method= $2;
1677
| ALTER_SYM DATABASE schema_name
2366
| ALTER DATABASE ident_or_empty
1679
Lex->statement= new statement::AlterSchema(YYSession);
2368
Lex->create_info.default_table_charset= NULL;
2369
Lex->create_info.used_fields= 0;
1681
default_collation_schema
2371
create_database_options
1684
if (Lex->name.str == NULL && Lex->copy_db_to(&Lex->name.str, &Lex->name.length))
2374
lex->sql_command=SQLCOM_ALTER_DB;
2376
if (lex->name.str == NULL &&
2377
lex->copy_db_to(&lex->name.str, &lex->name.length))
1685
2378
DRIZZLE_YYABORT;
2383
/* empty */ { $$.str= 0; $$.length= 0; }
1689
2387
alter_commands:
1691
| DISCARD TABLESPACE
1693
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1694
statement->alter_info.tablespace_op= DISCARD_TABLESPACE;
1698
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1699
statement->alter_info.tablespace_op= IMPORT_TABLESPACE;
2389
| DISCARD TABLESPACE { Lex->alter_info.tablespace_op= DISCARD_TABLESPACE; }
2390
| IMPORT TABLESPACE { Lex->alter_info.tablespace_op= IMPORT_TABLESPACE; }
1727
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1729
statement->change=0;
1730
statement->alter_info.flags.set(ALTER_ADD_COLUMN);
2419
lex->alter_info.flags|= ALTER_ADD_COLUMN;
1734
2423
alter_list_item:
1735
2424
add_column column_def opt_place { }
1738
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1740
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2427
Lex->alter_info.flags|= ALTER_ADD_INDEX;
1742
2429
| add_column '(' field_list ')'
1744
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1746
statement->alter_info.flags.set(ALTER_ADD_COLUMN);
1747
statement->alter_info.flags.set(ALTER_ADD_INDEX);
2431
Lex->alter_info.flags|= ALTER_ADD_COLUMN | ALTER_ADD_INDEX;
1749
| CHANGE_SYM opt_column field_ident
2433
| CHANGE opt_column field_ident
1751
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1752
statement->change= $3.str;
1753
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
2436
lex->change= $3.str;
2437
lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
1755
2439
field_spec opt_place
1756
2440
| MODIFY_SYM opt_column field_ident
1758
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1759
Lex->length= Lex->dec=0;
1761
statement->default_value= statement->on_update_value= 0;
1762
statement->comment= null_lex_str;
1764
statement->alter_info.flags.set(ALTER_CHANGE_COLUMN);
1765
statement->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
1767
Lex->setField(NULL);
2443
lex->length=lex->dec=0; lex->type=0;
2444
lex->default_value= lex->on_update_value= 0;
2445
lex->comment=null_lex_str;
2447
lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
2448
lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
2449
lex->vcol_info= NULL;
1771
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1773
if (add_field_to_list(Lex->session,&$3,
2454
if (add_field_to_list(lex->session,&$3,
1774
2455
(enum enum_field_types) $5,
1775
Lex->length, Lex->dec, Lex->type,
1776
statement->column_format,
1777
statement->default_value,
1778
statement->on_update_value,
1779
&statement->comment,
1780
$3.str, &Lex->interval_list, Lex->charset))
2456
lex->length,lex->dec,lex->type,
2458
lex->default_value, lex->on_update_value,
2460
$3.str, &lex->interval_list, lex->charset,
1781
2462
DRIZZLE_YYABORT;
1784
2465
| DROP opt_column field_ident
1786
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1788
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::COLUMN, $3.str));
1789
statement->alter_info.flags.set(ALTER_DROP_COLUMN);
2468
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
2470
lex->alter_info.flags|= ALTER_DROP_COLUMN;
1791
2472
| DROP FOREIGN KEY_SYM opt_ident
1793
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1794
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::FOREIGN_KEY,
1796
statement->alter_info.flags.set(ALTER_DROP_INDEX);
1797
statement->alter_info.flags.set(ALTER_FOREIGN_KEY);
2474
Lex->alter_info.flags|= ALTER_DROP_INDEX | ALTER_FOREIGN_KEY;
1799
2476
| DROP PRIMARY_SYM KEY_SYM
1801
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1803
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
2479
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
1805
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2481
lex->alter_info.flags|= ALTER_DROP_INDEX;
1807
2483
| DROP key_or_index field_ident
1809
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1811
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY,
1813
statement->alter_info.flags.set(ALTER_DROP_INDEX);
2486
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
2488
lex->alter_info.flags|= ALTER_DROP_INDEX;
1815
2490
| DISABLE_SYM KEYS
1817
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1819
statement->alter_info.keys_onoff= DISABLE;
1820
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
2493
lex->alter_info.keys_onoff= DISABLE;
2494
lex->alter_info.flags|= ALTER_KEYS_ONOFF;
1822
2496
| ENABLE_SYM KEYS
1824
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1826
statement->alter_info.keys_onoff= ENABLE;
1827
statement->alter_info.flags.set(ALTER_KEYS_ONOFF);
1829
| ALTER_SYM opt_column field_ident SET_SYM DEFAULT signed_literal
1831
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1833
statement->alter_info.alter_list.push_back(new AlterColumn($3.str,$6));
1834
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
1836
| ALTER_SYM opt_column field_ident DROP DEFAULT
1838
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1840
statement->alter_info.alter_list.push_back(new AlterColumn($3.str, (Item*) 0));
1841
statement->alter_info.flags.set(ALTER_COLUMN_DEFAULT);
2499
lex->alter_info.keys_onoff= ENABLE;
2500
lex->alter_info.flags|= ALTER_KEYS_ONOFF;
2502
| ALTER opt_column field_ident SET DEFAULT signed_literal
2505
lex->alter_info.alter_list.push_back(new Alter_column($3.str,$6));
2506
lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
2508
| ALTER opt_column field_ident DROP DEFAULT
2511
lex->alter_info.alter_list.push_back(new Alter_column($3.str,
2513
lex->alter_info.flags|= ALTER_COLUMN_DEFAULT;
1843
2515
| RENAME opt_to table_ident
1845
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1848
Lex->select_lex.db=$3->db.str;
1849
if (Lex->select_lex.db == NULL &&
1850
Lex->copy_db_to(&Lex->select_lex.db, &dummy))
2519
lex->select_lex.db=$3->db.str;
2520
if (lex->select_lex.db == NULL &&
2521
lex->copy_db_to(&lex->select_lex.db, &dummy))
1852
2523
DRIZZLE_YYABORT;
1855
if (check_table_name($3->table.str,$3->table.length))
2525
if (check_table_name($3->table.str,$3->table.length) || ($3->db.str && check_db_name(&$3->db)))
1857
2527
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
1858
2528
DRIZZLE_YYABORT;
1861
Lex->name= $3->table;
1862
statement->alter_info.flags.set(ALTER_RENAME);
2530
lex->name= $3->table;
2531
lex->alter_info.flags|= ALTER_RENAME;
1864
2533
| CONVERT_SYM TO_SYM collation_name_or_default
1866
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1868
statement->create_info().table_charset=
1869
statement->create_info().default_table_charset= $3;
1870
statement->create_info().used_fields|= (HA_CREATE_USED_CHARSET |
2537
Session *session= YYSession;
2538
$3= session->variables.collation_database;
2541
lex->create_info.table_charset=
2542
lex->create_info.default_table_charset= $3;
2543
lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
1871
2544
HA_CREATE_USED_DEFAULT_CHARSET);
1872
statement->alter_info.flags.set(ALTER_CONVERT);
2545
lex->alter_info.flags|= ALTER_CONVERT;
1874
2547
| create_table_options_space_separated
1876
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1878
statement->alter_info.flags.set(ALTER_OPTIONS);
2550
lex->alter_info.flags|= ALTER_OPTIONS;
1882
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1884
statement->alter_info.flags.set(ALTER_FORCE);
2554
Lex->alter_info.flags|= ALTER_FORCE;
1886
2556
| alter_order_clause
1888
statement::AlterTable *statement= (statement::AlterTable *)Lex->statement;
1890
statement->alter_info.flags.set(ALTER_ORDER);
2559
lex->alter_info.flags|= ALTER_ORDER;
2595
SLAVE START and SLAVE STOP are deprecated. We keep them for compatibility.
2599
START_SYM SLAVE slave_thread_opts
2602
lex->sql_command = SQLCOM_SLAVE_START;
2604
/* We'll use mi structure for UNTIL options */
2605
memset(&lex->mi, 0, sizeof(lex->mi));
2606
/* If you change this code don't forget to update SLAVE START too */
2610
| STOP_SYM SLAVE slave_thread_opts
2613
lex->sql_command = SQLCOM_SLAVE_STOP;
2615
/* If you change this code don't forget to update SLAVE STOP too */
2617
| SLAVE START_SYM slave_thread_opts
2620
lex->sql_command = SQLCOM_SLAVE_START;
2622
/* We'll use mi structure for UNTIL options */
2623
memset(&lex->mi, 0, sizeof(lex->mi));
2627
| SLAVE STOP_SYM slave_thread_opts
2630
lex->sql_command = SQLCOM_SLAVE_STOP;
1924
2636
START_SYM TRANSACTION_SYM start_transaction_opts
1926
Lex->statement= new statement::StartTransaction(YYSession, (start_transaction_option_t)$3);
2639
lex->sql_command= SQLCOM_BEGIN;
2640
lex->start_transaction_opt= $3;
1930
2644
start_transaction_opts:
1931
/*empty*/ { $$ = START_TRANS_NO_OPTIONS; }
2645
/*empty*/ { $$ = 0; }
1932
2646
| WITH CONSISTENT_SYM SNAPSHOT_SYM
1934
$$= START_TRANS_OPT_WITH_CONS_SNAPSHOT;
2648
$$= DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT;
2653
{ Lex->slave_session_opt= 0; }
2654
slave_thread_opt_list
2658
slave_thread_opt_list:
2660
| slave_thread_opt_list ',' slave_thread_opt
2665
| SQL_THREAD { Lex->slave_session_opt|=SLAVE_SQL; }
2666
| RELAY_THREAD { Lex->slave_session_opt|=SLAVE_IO; }
2671
| UNTIL_SYM slave_until_opts
2674
if (((lex->mi.log_file_name || lex->mi.pos) && (lex->mi.relay_log_name || lex->mi.relay_log_pos)) ||
2675
!((lex->mi.log_file_name && lex->mi.pos) ||
2676
(lex->mi.relay_log_name && lex->mi.relay_log_pos)))
2678
my_message(ER_BAD_SLAVE_UNTIL_COND,
2679
ER(ER_BAD_SLAVE_UNTIL_COND), MYF(0));
2687
| slave_until_opts ',' master_file_def
2691
CHECKSUM_SYM table_or_tables
2694
lex->sql_command = SQLCOM_CHECKSUM;
2696
table_list opt_checksum_type
2701
/* nothing */ { Lex->check_opt.flags= 0; }
2702
| QUICK { Lex->check_opt.flags= T_QUICK; }
2703
| EXTENDED_SYM { Lex->check_opt.flags= T_EXTEND; }
2707
REPAIR table_or_tables
2710
lex->sql_command = SQLCOM_REPAIR;
2711
lex->check_opt.init();
2713
table_list opt_mi_repair_type
2718
/* empty */ { Lex->check_opt.flags = T_MEDIUM; }
2719
| mi_repair_types {}
2724
| mi_repair_type mi_repair_types {}
2728
QUICK { Lex->check_opt.flags|= T_QUICK; }
2729
| EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; }
2730
| USE_FRM { Lex->check_opt.sql_flags|= TT_USEFRM; }
1939
2734
ANALYZE_SYM table_or_tables
1941
Lex->statement= new statement::Analyze(YYSession);
2737
lex->sql_command = SQLCOM_ANALYZE;
2738
lex->check_opt.init();
2744
binlog_base64_event:
2745
BINLOG_SYM TEXT_STRING_sys
2747
Lex->sql_command = SQLCOM_BINLOG_BASE64_EVENT;
1948
2753
CHECK_SYM table_or_tables
1950
Lex->statement= new statement::Check(YYSession);
2757
lex->sql_command = SQLCOM_CHECK;
2758
lex->check_opt.init();
2760
table_list opt_mi_check_type
2765
/* empty */ { Lex->check_opt.flags = T_MEDIUM; }
2771
| mi_check_type mi_check_types {}
2775
QUICK { Lex->check_opt.flags|= T_QUICK; }
2776
| FAST_SYM { Lex->check_opt.flags|= T_FAST; }
2777
| MEDIUM_SYM { Lex->check_opt.flags|= T_MEDIUM; }
2778
| EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; }
2779
| CHANGED { Lex->check_opt.flags|= T_CHECK_ONLY_CHANGED; }
2780
| FOR_SYM UPGRADE_SYM { Lex->check_opt.sql_flags|= TT_FOR_UPGRADE; }
2784
OPTIMIZE table_or_tables
2787
lex->sql_command = SQLCOM_OPTIMIZE;
2788
lex->check_opt.init();
2078
2970
| select_option
2081
select_option_distinct_or_all:
2084
Lex->current_select->options|= SELECT_DISTINCT;
2086
if (Lex->current_select->options & SELECT_DISTINCT && Lex->current_select->options & SELECT_ALL)
2088
my_error(ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT");
2094
Lex->current_select->options|= SELECT_ALL;
2096
if (Lex->current_select->options & SELECT_DISTINCT && Lex->current_select->options & SELECT_ALL)
2098
my_error(ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT");
2104
select_option_small_or_big:
2107
Lex->current_select->options|= SELECT_SMALL_RESULT;
2109
if (Lex->current_select->options & SELECT_SMALL_RESULT && Lex->current_select->options & SELECT_BIG_RESULT)
2111
my_error(ER_WRONG_USAGE, MYF(0), "SELECT_SMALL_RESULT", "SELECT_SMALL_RESULT");
2117
Lex->current_select->options|= SELECT_BIG_RESULT;
2119
if (Lex->current_select->options & SELECT_SMALL_RESULT && Lex->current_select->options & SELECT_BIG_RESULT)
2121
my_error(ER_WRONG_USAGE, MYF(0), "SELECT_SMALL_RESULT", "SELECT_SMALL_RESULT");
2129
STRAIGHT_JOIN { Lex->current_select->options|= SELECT_STRAIGHT_JOIN; }
2974
STRAIGHT_JOIN { Select->options|= SELECT_STRAIGHT_JOIN; }
2977
if (check_simple_select())
2979
Lex->lock_option= TL_READ_HIGH_PRIORITY;
2981
| DISTINCT { Select->options|= SELECT_DISTINCT; }
2982
| SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
2983
| SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; }
2130
2984
| SQL_BUFFER_RESULT
2132
if (check_simple_select(YYSession))
2986
if (check_simple_select())
2133
2987
DRIZZLE_YYABORT;
2134
Lex->current_select->options|= OPTION_BUFFER_RESULT;
2988
Select->options|= OPTION_BUFFER_RESULT;
2136
| select_option_small_or_big
2138
| select_option_distinct_or_all
2140
2990
| SQL_CALC_FOUND_ROWS
2142
if (check_simple_select(YYSession))
2992
if (check_simple_select())
2143
2993
DRIZZLE_YYABORT;
2144
Lex->current_select->options|= OPTION_FOUND_ROWS;
2994
Select->options|= OPTION_FOUND_ROWS;
2996
| ALL { Select->options|= SELECT_ALL; }
2148
2999
select_lock_type:
2150
3001
| FOR_SYM UPDATE_SYM
2152
Lex->current_select->set_lock_for_tables(TL_WRITE);
3004
lex->current_select->set_lock_for_tables(TL_WRITE);
2154
3006
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
2156
Lex->current_select->
3009
lex->current_select->
2157
3010
set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
2682
3519
| SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')'
2683
3520
{ $$= new (YYSession->mem_root) Item_date_add_interval($3, $6, $7, 1); }
2684
3521
| SUBSTRING '(' expr ',' expr ',' expr ')'
2686
std::string reverse_str("substr");
2687
List<Item> *args= new (YYSession->mem_root) List<Item>;
2688
args->push_back($3);
2689
args->push_back($5);
2690
args->push_back($7);
2691
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
3522
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
2696
3523
| SUBSTRING '(' expr ',' expr ')'
2698
std::string reverse_str("substr");
2699
List<Item> *args= new (YYSession->mem_root) List<Item>;
2700
args->push_back($3);
2701
args->push_back($5);
2702
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
3524
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
2707
3525
| SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
2709
std::string reverse_str("substr");
2710
List<Item> *args= new (YYSession->mem_root) List<Item>;
2711
args->push_back($3);
2712
args->push_back($5);
2713
args->push_back($7);
2714
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
3526
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5,$7); }
2719
3527
| SUBSTRING '(' expr FROM expr ')'
2721
std::string reverse_str("substr");
2722
List<Item> *args= new (YYSession->mem_root) List<Item>;
2723
args->push_back($3);
2724
args->push_back($5);
2725
if (! ($$= parser::reserved_keyword_function(YYSession, reverse_str, args)))
3528
{ $$= new (YYSession->mem_root) Item_func_substr($3,$5); }
2730
3529
| SYSDATE optional_braces
2732
$$= new (YYSession->mem_root) Item_func_sysdate_local();
2733
Lex->setCacheable(false);
3531
if (global_system_variables.sysdate_is_now == 0)
3532
$$= new (YYSession->mem_root) Item_func_sysdate_local();
3534
$$= new (YYSession->mem_root) Item_func_now_local();
2735
3536
| SYSDATE '(' expr ')'
2737
$$= new (YYSession->mem_root) Item_func_sysdate_local($3);
2738
Lex->setCacheable(false);
3538
if (global_system_variables.sysdate_is_now == 0)
3539
$$= new (YYSession->mem_root) Item_func_sysdate_local($3);
3541
$$= new (YYSession->mem_root) Item_func_now_local($3);
2740
3543
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
2741
3544
{ $$= new (YYSession->mem_root) Item_date_add_interval($7,$5,$3,0); }
2759
3564
a dedicated rule is needed here.
2761
3566
function_call_conflict:
2762
COALESCE '(' expr_list ')'
3567
ASCII_SYM '(' expr ')'
3568
{ $$= new (YYSession->mem_root) Item_func_ascii($3); }
3569
| COALESCE '(' expr_list ')'
2763
3570
{ $$= new (YYSession->mem_root) Item_func_coalesce(* $3); }
2764
3571
| COLLATION_SYM '(' expr ')'
2765
3572
{ $$= new (YYSession->mem_root) Item_func_collation($3); }
2766
3573
| DATABASE '(' ')'
2768
if (! ($$= parser::reserved_keyword_function(YYSession, "database", NULL)))
2772
Lex->setCacheable(false);
2774
| CATALOG_SYM '(' ')'
2776
if (! ($$= parser::reserved_keyword_function(YYSession, "catalog", NULL)))
2780
Lex->setCacheable(false);
2782
| EXECUTE_SYM '(' expr ')' opt_wait
2784
List<Item> *args= new (YYSession->mem_root) List<Item>;
2785
args->push_back($3);
2789
args->push_back(new (YYSession->mem_root) Item_int(1));
2792
if (! ($$= parser::reserved_keyword_function(YYSession, "execute", args)))
3575
$$= new (YYSession->mem_root) Item_func_database();
2797
3577
| IF '(' expr ',' expr ',' expr ')'
2798
3578
{ $$= new (YYSession->mem_root) Item_func_if($3,$5,$7); }
2799
| KILL_SYM kill_option '(' expr ')'
2801
std::string kill_str("kill");
2802
List<Item> *args= new (YYSession->mem_root) List<Item>;
2803
args->push_back($4);
2807
args->push_back(new (YYSession->mem_root) Item_uint(1));
2810
if (! ($$= parser::reserved_keyword_function(YYSession, kill_str, args)))
2815
3579
| MICROSECOND_SYM '(' expr ')'
2816
3580
{ $$= new (YYSession->mem_root) Item_func_microsecond($3); }
2817
3581
| MOD_SYM '(' expr ',' expr ')'
2819
3583
| QUARTER_SYM '(' expr ')'
2820
3584
{ $$ = new (YYSession->mem_root) Item_func_quarter($3); }
2821
3585
| REPEAT_SYM '(' expr ',' expr ')'
2822
{ $$= new (YYSession->mem_root) Item_func_repeat(*YYSession, $3, $5); }
3586
{ $$= new (YYSession->mem_root) Item_func_repeat($3,$5); }
2823
3587
| REPLACE '(' expr ',' expr ',' expr ')'
2824
{ $$= new (YYSession->mem_root) Item_func_replace(*YYSession, $3, $5, $7); }
3588
{ $$= new (YYSession->mem_root) Item_func_replace($3,$5,$7); }
3589
| REVERSE_SYM '(' expr ')'
3590
{ $$= new (YYSession->mem_root) Item_func_reverse($3); }
2825
3591
| TRUNCATE_SYM '(' expr ',' expr ')'
2826
3592
{ $$= new (YYSession->mem_root) Item_func_round($3,$5,1); }
2827
| WAIT_SYM '(' expr ')'
2829
std::string wait_str("wait");
2830
List<Item> *args= new (YYSession->mem_root) List<Item>;
2831
args->push_back($3);
2832
if (! ($$= parser::reserved_keyword_function(YYSession, wait_str, args)))
2839
if (! ($$= parser::reserved_keyword_function(YYSession, "uuid", NULL)))
2843
Lex->setCacheable(false);
2845
| WAIT_SYM '(' expr ',' expr ')'
2847
std::string wait_str("wait");
2848
List<Item> *args= new (YYSession->mem_root) List<Item>;
2849
args->push_back($3);
2850
args->push_back($5);
2851
if (! ($$= parser::reserved_keyword_function(YYSession, wait_str, args)))
3593
| WEEK_SYM '(' expr ')'
3595
Session *session= YYSession;
3596
Item *i1= new (session->mem_root) Item_int((char*) "0",
3597
session->variables.default_week_format,
3600
$$= new (session->mem_root) Item_func_week($3, i1);
3602
| WEEK_SYM '(' expr ',' expr ')'
3603
{ $$= new (YYSession->mem_root) Item_func_week($3,$5); }
3604
| WEIGHT_STRING_SYM '(' expr opt_ws_levels ')'
3605
{ $$= new (YYSession->mem_root) Item_func_weight_string($3, 0, $4); }
3606
| WEIGHT_STRING_SYM '(' expr AS CHAR_SYM ws_nweights opt_ws_levels ')'
3608
$$= new (YYSession->mem_root)
3609
Item_func_weight_string($3, $6, $7|MY_STRXFRM_PAD_WITH_SPACE);
3611
| WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')'
3613
$3= create_func_char_cast(YYSession, $3, $6, &my_charset_bin);
3614
$$= new (YYSession->mem_root)
3615
Item_func_weight_string($3, $6, MY_STRXFRM_PAD_WITH_SPACE);
3893
4678
delete_limit_clause:
3896
Lex->current_select->select_limit= 0;
4682
lex->current_select->select_limit= 0;
3898
4684
| LIMIT limit_option
3900
Select_Lex *sel= Lex->current_select;
4686
SELECT_LEX *sel= Select;
3901
4687
sel->select_limit= $2;
3902
4688
sel->explicit_limit= 1;
3907
NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
3908
| HEX_NUM { $$= (unsigned long) strtol($1.str, (char**) 0, 16); }
3909
| LONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
3910
| ULONGLONG_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
3911
| DECIMAL_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
3912
| FLOAT_NUM { int error; $$= (unsigned long) internal::my_strtoll10($1.str, (char**) 0, &error); }
4693
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4694
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4695
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4696
| ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4697
| DECIMAL_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4698
| FLOAT_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4702
NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4703
| HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); }
4704
| LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4705
| ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); }
4706
| dec_num_error { DRIZZLE_YYABORT; }
3916
NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
3917
| ULONGLONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
3918
| LONG_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
3919
| DECIMAL_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
3920
| FLOAT_NUM { int error; $$= (uint64_t) internal::my_strtoll10($1.str, (char**) 0, &error); }
4710
NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4711
| ULONGLONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4712
| LONG_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4713
| DECIMAL_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4714
| FLOAT_NUM { int error; $$= (uint64_t) my_strtoll10($1.str, (char**) 0, &error); }
4719
{ my_parse_error(ER(ER_ONLY_INTEGERS_ALLOWED)); }
4728
ulong_num { $$= $1 != 0 ? HA_CHOICE_YES : HA_CHOICE_NO; }
4729
| DEFAULT { $$= HA_CHOICE_UNDEF; }
3923
4732
select_var_list_init:
3925
if (not Lex->describe && (not (Lex->result= new select_dumpvar())))
4735
if (!lex->describe && (!(lex->result= new select_dumpvar())))
3926
4736
DRIZZLE_YYABORT;
3928
4738
select_var_list
3990
DROP CATALOG_SYM catalog_name
3992
Lex->statement= new statement::catalog::Drop(YYSession, $3);
3994
| DROP opt_temporary table_or_tables if_exists table_list
3996
statement::DropTable *statement= new statement::DropTable(YYSession);
3997
Lex->statement= statement;
3998
statement->drop_temporary= $2;
3999
statement->drop_if_exists= $4;
4797
DROP opt_temporary table_or_tables if_exists table_list
4800
lex->sql_command = SQLCOM_DROP_TABLE;
4801
lex->drop_temporary= $2;
4802
lex->drop_if_exists= $4;
4001
4804
| DROP build_method INDEX_SYM ident ON table_ident {}
4003
statement::DropIndex *statement= new statement::DropIndex(YYSession);
4004
Lex->statement= statement;
4005
statement->alter_info.flags.set(ALTER_DROP_INDEX);
4006
statement->alter_info.build_method= $2;
4007
statement->alter_info.drop_list.push_back(new AlterDrop(AlterDrop::KEY, $4.str));
4008
if (not Lex->current_select->add_table_to_list(Lex->session, $6, NULL,
4009
TL_OPTION_UPDATING))
4807
lex->sql_command= SQLCOM_DROP_INDEX;
4808
lex->alter_info.reset();
4809
lex->alter_info.flags= ALTER_DROP_INDEX;
4810
lex->alter_info.build_method= $2;
4811
lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY,
4813
if (!lex->current_select->add_table_to_list(lex->session, $6, NULL,
4814
TL_OPTION_UPDATING))
4010
4815
DRIZZLE_YYABORT;
4012
| DROP DATABASE if_exists schema_name
4817
| DROP DATABASE if_exists ident
4014
statement::DropSchema *statement= new statement::DropSchema(YYSession);
4015
Lex->statement= statement;
4016
statement->drop_if_exists=$3;
4820
lex->sql_command= SQLCOM_DROP_DB;
4821
lex->drop_if_exists=$3;
4023
4826
| table_list ',' table_name
4346
Lex->lock_option= TL_READ;
4348
Lex->current_select->parsing_place= SELECT_LIST;
5204
lex->lock_option= TL_READ;
5205
mysql_init_select(lex);
5206
lex->current_select->parsing_place= SELECT_LIST;
5207
memset(&lex->create_info, 0, sizeof(lex->create_info));
4356
5214
DATABASES show_wild
4358
if (not show::buildScemas(YYSession))
4362
| TABLES opt_db show_wild
4364
if (not show::buildTables(YYSession, $2))
4367
/* SHOW TEMPORARY TABLES */
4368
| TEMPORARY_SYM TABLES show_wild
4370
if (not show::buildTemporaryTables(YYSession))
4373
/* SHOW TABLE STATUS */
5217
lex->sql_command= SQLCOM_SHOW_DATABASES;
5218
if (prepare_schema_table(YYSession, lex, 0, SCH_SCHEMATA))
5221
| opt_full TABLES opt_db show_wild
5224
lex->sql_command= SQLCOM_SHOW_TABLES;
5225
lex->select_lex.db= $3;
5226
if (prepare_schema_table(YYSession, lex, 0, SCH_TABLE_NAMES))
4374
5229
| TABLE_SYM STATUS_SYM opt_db show_wild
4376
if (not show::buildTableStatus(YYSession, $3))
4379
/* SHOW COLUMNS FROM table_name */
4380
| COLUMNS from_or_in table_ident opt_db show_wild
4382
if (not show::buildColumns(YYSession, $4, $3))
4385
/* SHOW INDEXES from table */
5232
lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
5233
lex->select_lex.db= $3;
5234
if (prepare_schema_table(YYSession, lex, 0, SCH_TABLES))
5237
| OPEN_SYM TABLES opt_db show_wild
5240
lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
5241
lex->select_lex.db= $3;
5242
if (prepare_schema_table(YYSession, lex, 0, SCH_OPEN_TABLES))
5245
| ENGINE_SYM known_storage_engines STATUS_SYM /* This should either go... well it should go */
5247
Lex->create_info.db_type= $2;
5248
Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS;
5250
| opt_full COLUMNS from_or_in table_ident opt_db show_wild
5253
lex->sql_command= SQLCOM_SHOW_FIELDS;
5256
if (prepare_schema_table(YYSession, lex, $4, SCH_COLUMNS))
5259
| master_or_binary LOGS_SYM
5261
Lex->sql_command = SQLCOM_SHOW_BINLOGS;
4386
5263
| keys_or_index from_or_in table_ident opt_db where_clause
4388
if (not show::buildIndex(YYSession, $4, $3))
5266
lex->sql_command= SQLCOM_SHOW_KEYS;
5269
if (prepare_schema_table(YYSession, lex, $3, SCH_STATISTICS))
4391
5272
| COUNT_SYM '(' '*' ')' WARNINGS
4393
show::buildSelectWarning(YYSession);
5273
{ (void) create_select_for_variable("warning_count"); }
4395
5274
| COUNT_SYM '(' '*' ')' ERRORS
4397
show::buildSelectError(YYSession);
5275
{ (void) create_select_for_variable("error_count"); }
4399
5276
| WARNINGS opt_limit_clause_init
4401
show::buildWarnings(YYSession);
5277
{ Lex->sql_command = SQLCOM_SHOW_WARNS;}
4403
5278
| ERRORS opt_limit_clause_init
4405
show::buildErrors(YYSession);
5279
{ Lex->sql_command = SQLCOM_SHOW_ERRORS;}
4407
5280
| opt_var_type STATUS_SYM show_wild
4409
if (not show::buildStatus(YYSession, $1))
4412
| engine_option_value STATUS_SYM
4414
if (not show::buildEngineStatus(YYSession, $1))
5283
lex->sql_command= SQLCOM_SHOW_STATUS;
5284
lex->option_type= $1;
5285
if (prepare_schema_table(YYSession, lex, 0, SCH_STATUS))
5288
| opt_full PROCESSLIST_SYM
5289
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
5290
| opt_var_type VARIABLES show_wild
5293
lex->sql_command= SQLCOM_SHOW_VARIABLES;
5294
lex->option_type= $1;
5295
if (prepare_schema_table(YYSession, lex, 0, SCH_VARIABLES))
5298
| CREATE DATABASE opt_if_not_exists ident
5300
Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
5301
Lex->create_info.options=$3;
4417
5304
| CREATE TABLE_SYM table_ident
4419
if (not show::buildCreateTable(YYSession, $3))
4424
if (not show::buildProcesslist(YYSession))
4427
| opt_var_type VARIABLES show_wild
4429
if (not show::buildVariables(YYSession, $1))
4432
| CREATE DATABASE opt_if_not_exists ident
4434
if (not show::buildCreateSchema(YYSession, $4))
5307
lex->sql_command = SQLCOM_SHOW_CREATE;
5308
if (!lex->select_lex.add_table_to_list(YYSession, $3, NULL,0))
5311
| MASTER_SYM STATUS_SYM
5313
Lex->sql_command = SQLCOM_SHOW_MASTER_STAT;
5317
Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
4439
5326
/* empty */ { $$= 0; }
4440
5327
| from_or_in ident { $$= $2.str; }
5331
/* empty */ { Lex->verbose=0; }
5332
| FULL { Lex->verbose=1; }
4730
simple_ident {$$= $1;}
4731
| '@' user_variable_ident
5672
simple_ident_nospvar {$$= $1;}
4732
5674
{ $$= new Item_user_var_as_out_param($2); }
4735
5677
opt_load_data_set_spec:
4737
| SET_SYM insert_update_list {}
5679
| SET insert_update_list {}
4740
5682
/* Common definitions */
4745
$$ = new Item_string($1.str, $1.length, YYSession->variables.getCollation());
5688
Session *session= YYSession;
5689
const CHARSET_INFO * const cs_con= session->variables.getCollation();
5690
const CHARSET_INFO * const cs_cli= default_charset_info;
5691
uint32_t repertoire= session->lex->text_string_is_7bit &&
5692
my_charset_is_ascii_based(cs_cli) ?
5693
MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
5694
if (session->charset_is_collation_connection ||
5695
(repertoire == MY_REPERTOIRE_ASCII &&
5696
my_charset_is_ascii_based(cs_con)))
5699
session->convert_string(&tmp, cs_con, $1.str, $1.length, cs_cli);
5700
$$= new Item_string(tmp.str, tmp.length, cs_con,
5701
DERIVATION_COERCIBLE, repertoire);
5703
| UNDERSCORE_CHARSET TEXT_STRING
5705
Item_string *str= new Item_string($2.str, $2.length, $1);
5706
str->set_repertoire_from_value();
5707
str->set_cs_specified(true);
4747
5711
| text_literal TEXT_STRING_literal
4749
((Item_string*) $1)->append($2.str, $2.length);
5713
Item_string* item= (Item_string*) $1;
5714
item->append($2.str, $2.length);
5715
if (!(item->collation.repertoire & MY_REPERTOIRE_EXTENDED))
5718
If the string has been pure ASCII so far,
5721
const CHARSET_INFO * const cs= YYSession->variables.getCollation();
5722
item->collation.repertoire|= my_string_repertoire(cs,
4798
5774
$$ = new Item_null();
4799
5775
YYSession->m_lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
4801
| FALSE_SYM { $$= new drizzled::item::False(); }
4802
| TRUE_SYM { $$= new drizzled::item::True(); }
5777
| FALSE_SYM { $$= new Item_int((char*) "FALSE",0,1); }
5778
| TRUE_SYM { $$= new Item_int((char*) "TRUE",1,1); }
4803
5779
| HEX_NUM { $$ = new Item_hex_string($1.str, $1.length);}
4804
5780
| BIN_NUM { $$= new Item_bin_string($1.str, $1.length); }
5781
| UNDERSCORE_CHARSET HEX_NUM
5783
Item *tmp= new Item_hex_string($2.str, $2.length);
5785
it is OK only emulate fix_fieds, because we need only
5789
tmp->quick_fix_field(), tmp->val_str((String*) 0) :
5792
Item_string *item_str=
5793
new Item_string(NULL, /* name will be set in select_item */
5794
str ? str->ptr() : "",
5795
str ? str->length() : 0,
5798
!item_str->check_well_formed_result(&item_str->str_value, true))
5803
item_str->set_repertoire_from_value();
5804
item_str->set_cs_specified(true);
5808
| UNDERSCORE_CHARSET BIN_NUM
5810
Item *tmp= new Item_bin_string($2.str, $2.length);
5812
it is OK only emulate fix_fieds, because we need only
5816
tmp->quick_fix_field(), tmp->val_str((String*) 0) :
5819
Item_string *item_str=
5820
new Item_string(NULL, /* name will be set in select_item */
5821
str ? str->ptr() : "",
5822
str ? str->length() : 0,
5825
!item_str->check_well_formed_result(&item_str->str_value, true))
5830
item_str->set_cs_specified(true);
4805
5834
| DATE_SYM text_literal { $$ = $2; }
4806
| TIMESTAMP_SYM text_literal { $$ = $2; }
5835
| TIME_SYM text_literal { $$ = $2; }
5836
| TIMESTAMP text_literal { $$ = $2; }
4813
$$ = new Item_int($1.str, (int64_t) internal::my_strtoll10($1.str, NULL, &error), $1.length);
5843
$$ = new Item_int($1.str, (int64_t) my_strtoll10($1.str, NULL, &error), $1.length);
4818
$$ = new Item_int($1.str, (int64_t) internal::my_strtoll10($1.str, NULL, &error), $1.length);
5848
$$ = new Item_int($1.str, (int64_t) my_strtoll10($1.str, NULL, &error), $1.length);
4820
5850
| ULONGLONG_NUM
4821
5851
{ $$ = new Item_uint($1.str, $1.length); }
4872
5930
simple_ident_q:
4873
5931
ident '.' ident
4875
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $1, $3);
5933
Session *session= YYSession;
5934
LEX *lex= session->lex;
5937
SELECT_LEX *sel= lex->current_select;
5938
if (sel->no_table_names_allowed)
5940
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5941
MYF(0), $1.str, session->where);
5943
$$= (sel->parsing_place != IN_HAVING ||
5944
sel->get_in_sum_expr() > 0) ?
5945
(Item*) new Item_field(Lex->current_context(),
5946
(const char *)NULL, $1.str, $3.str) :
5947
(Item*) new Item_ref(Lex->current_context(),
5948
(const char *)NULL, $1.str, $3.str);
4877
5951
| '.' ident '.' ident
4879
$$= parser::buildIdent(Lex, NULL_LEX_STRING, $2, $4);
5953
Session *session= YYSession;
5954
LEX *lex= session->lex;
5955
SELECT_LEX *sel= lex->current_select;
5956
if (sel->no_table_names_allowed)
5958
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5959
MYF(0), $2.str, session->where);
5961
$$= (sel->parsing_place != IN_HAVING ||
5962
sel->get_in_sum_expr() > 0) ?
5963
(Item*) new Item_field(Lex->current_context(), NULL, $2.str, $4.str) :
5964
(Item*) new Item_ref(Lex->current_context(),
5965
(const char *)NULL, $2.str, $4.str);
4881
5967
| ident '.' ident '.' ident
4883
$$= parser::buildIdent(Lex, $1, $3, $5);
5969
Session *session= YYSession;
5970
LEX *lex= session->lex;
5971
SELECT_LEX *sel= lex->current_select;
5972
if (sel->no_table_names_allowed)
5974
my_error(ER_TABLENAME_NOT_ALLOWED_HERE,
5975
MYF(0), $3.str, session->where);
5977
$$= (sel->parsing_place != IN_HAVING ||
5978
sel->get_in_sum_expr() > 0) ?
5979
(Item*) new Item_field(Lex->current_context(),
5980
(YYSession->client_capabilities &
5981
CLIENT_NO_SCHEMA ? NULL : $1.str),
5983
(Item*) new Item_ref(Lex->current_context(),
5984
(YYSession->client_capabilities &
5985
CLIENT_NO_SCHEMA ? NULL : $1.str),
4892
5992
| ident '.' ident '.' ident
4894
if (not parser::checkFieldIdent(Lex, $1, $3))
5994
TableList *table= (TableList*) Select->table_list.first;
5995
if (my_strcasecmp(table_alias_charset, $1.str, table->db))
5997
my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
6000
if (my_strcasecmp(table_alias_charset, $3.str,
6003
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str);
4899
6008
| ident '.' ident
4901
if (not parser::checkFieldIdent(Lex, NULL_LEX_STRING, $1))
6010
TableList *table= (TableList*) Select->table_list.first;
6011
if (my_strcasecmp(table_alias_charset, $1.str, table->alias))
6013
my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str);
4902
6014
DRIZZLE_YYABORT;
6018
| '.' ident { $$=$2;} /* For Delphi */
4915
$$= new Table_ident($1);
4917
| schema_name '.' ident
4919
$$=new Table_ident($1,$3);
4923
$$= new Table_ident($2);
6022
ident { $$=new Table_ident($1); }
6023
| ident '.' ident { $$=new Table_ident(YYSession, $1,$3,0);}
6024
| '.' ident { $$=new Table_ident($2);} /* For Delphi */
4942
const CHARSET_INFO * const cs= system_charset_info;
4944
uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
4946
$1.length, &dummy_error);
4947
if (wlen < $1.length)
6031
Session *session= YYSession;
6033
if (session->charset_is_system_charset)
4949
my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
4950
cs->csname, $1.str + wlen);
6035
const CHARSET_INFO * const cs= system_charset_info;
6037
uint32_t wlen= cs->cset->well_formed_len(cs, $1.str,
6039
$1.length, &dummy_error);
6040
if (wlen < $1.length)
6042
my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
6043
cs->csname, $1.str + wlen);
6049
session->convert_string(&$$, system_charset_info,
6050
$1.str, $1.length, session->charset());
4957
6054
TEXT_STRING_sys:
6057
Session *session= YYSession;
6059
if (session->charset_is_system_charset)
6062
session->convert_string(&$$, system_charset_info,
6063
$1.str, $1.length, session->charset());
4964
6067
TEXT_STRING_literal:
6070
Session *session= YYSession;
6072
if (session->charset_is_collation_connection)
6075
session->convert_string(&$$, session->variables.getCollation(),
6076
$1.str, $1.length, session->charset());
4971
6080
TEXT_STRING_filesystem:
6083
Session *session= YYSession;
6085
if (session->charset_is_character_set_filesystem)
6088
session->convert_string(&$$, session->variables.character_set_filesystem,
6089
$1.str, $1.length, session->charset());
5221
6433
sys_option_value:
5222
6434
option_type internal_variable_name equal set_expr_or_default
5225
6439
{ /* System variable */
5228
Lex->option_type= $1;
5230
Lex->var_list.push_back(SetVarPtr(new set_var(Lex->option_type, $2.var, &$2.base_name, $4)));
6441
lex->option_type= $1;
6442
lex->var_list.push_back(new set_var(lex->option_type, $2.var,
6443
&$2.base_name, $4));
5233
6446
| option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
5235
Lex->option_type= $1;
5236
Lex->var_list.push_back(SetVarPtr(new set_var(Lex->option_type,
5237
find_sys_var("tx_isolation"),
5239
new Item_int((int32_t)
6449
lex->option_type= $1;
6450
lex->var_list.push_back(new set_var(lex->option_type,
6451
find_sys_var(YYSession, "tx_isolation"),
6453
new Item_int((int32_t) $5)));
5245
'@' user_variable_ident equal expr
6458
'@' ident_or_text equal expr
5247
Lex->var_list.push_back(SetVarPtr(new set_var_user(new Item_func_set_user_var($2,$4))));
6460
Lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
5249
6462
| '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
5251
Lex->var_list.push_back(SetVarPtr(new set_var($3, $4.var, &$4.base_name, $6)));
5255
user_variable_ident:
5256
internal_variable_ident { $$=$1;}
5257
| TEXT_STRING_sys { $$=$1;}
5258
| LEX_HOSTNAME { $$=$1;}
5261
internal_variable_ident:
5262
keyword_exception_for_variable
5264
$$.str= YYSession->strmake($1.str, $1.length);
5265
$$.length= $1.length;
5267
| IDENT_sys { $$=$1; }
6465
lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
5270
6469
internal_variable_name:
5271
internal_variable_ident
6472
Session *session= YYSession;
5273
6474
/* We have to lookup here since local vars can shadow sysvars */
5275
6476
/* Not an SP local variable */
5276
sys_var *tmp= find_sys_var(std::string($1.str, $1.length));
6477
sys_var *tmp=find_sys_var(session, $1.str, $1.length);
5278
6479
DRIZZLE_YYABORT;
5280
6481
$$.base_name= null_lex_str;
6486
if (check_reserved_words(&$1))
6488
my_parse_error(ER(ER_SYNTAX_ERROR));
6492
sys_var *tmp=find_sys_var(YYSession, $3.str, $3.length);
6495
if (!tmp->is_struct())
6496
my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
6503
sys_var *tmp=find_sys_var(YYSession, $3.str, $3.length);
6506
if (!tmp->is_struct())
6507
my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str);
6509
$$.base_name.str= (char*) "default";
6510
$$.base_name.length= 7;
5285
6514
isolation_types:
5297
6526
| BINARY { $$=new Item_string("binary", 6, system_charset_info); }
6535
Transactional locks can be taken only if all requested locks
6536
are transactional. Initialize lex->lock_transactional as
6537
TRUE. Any non-transactional lock request turns this to FALSE.
6538
Table specific variables keep track of the locking method
6539
requested for the table. This is used to warn about a
6540
changed locking method later.
6542
Lex->lock_transactional= true;
6547
lex->sql_command= SQLCOM_LOCK_TABLES;
5300
6553
table_or_tables:
6560
| table_lock_list ',' table_lock
6564
table_ident opt_table_alias table_lock_info
6567
if (!(tlist= Select->add_table_to_list(YYSession, $1, $2, 0,
6569
DRIZZLE_YYABORT; /* purecov: inspected */
6570
tlist->lock_timeout= $3.lock_timeout;
6571
/* Store the requested lock method for later warning. */
6572
tlist->lock_transactional= $3.lock_transactional;
6573
/* Compute the resulting lock method for all tables. */
6574
if (!$3.lock_transactional)
6575
Lex->lock_transactional= false;
6582
$$.lock_type= TL_READ_NO_INSERT;
6583
$$.lock_timeout= -1;
6584
$$.lock_transactional= false;
6588
$$.lock_type= TL_WRITE_DEFAULT;
6589
$$.lock_timeout= -1;
6590
$$.lock_transactional= false;
6592
| LOW_PRIORITY WRITE_SYM
6594
$$.lock_type= TL_WRITE_DEFAULT;
6595
$$.lock_timeout= -1;
6596
$$.lock_transactional= false;
6598
| READ_SYM LOCAL_SYM
6600
$$.lock_type= TL_READ;
6601
$$.lock_timeout= -1;
6602
$$.lock_transactional= false;
6607
We have a timeout resolution of milliseconds. The WAIT argument is in
6608
seconds with decimal fragments for sub-second resolution. E.g. 22.5, 0.015
6610
/* opt_lock_timeout_value: */
6611
/* empty { $$= -1; } */
6612
/* | NUM { $$= (int) (atof($1.str) * 1000.0 + 0.5); } */
5308
Lex->statement= new statement::UnlockTables(YYSession);
6618
lex->sql_command= SQLCOM_UNLOCK_TABLES;
5310
6620
table_or_tables