1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; either version 2 of the License, or
6
(at your option) any later version.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21
#define YYINITDEPTH 100
22
#define YYMAXDEPTH 3200 /* Because of 64K stack */
23
#define Lex current_lex
24
#include "mysql_priv.h"
26
#include "lex_symbol.h"
29
extern void yyerror(const char*);
30
int yylex(void *yylval);
32
#define yyoverflow(A,B,C,D,E,F) if (my_yyoverflow((B),(D),(F))) { yyerror((char*) (A)); return 2; }
34
inline Item *or_or_concat(Item* A, Item* B)
36
return (current_thd->options & OPTION_ANSI_MODE ?
37
(Item*) new Item_func_concat(A,B) : (Item*) new Item_cond_or(A,B));
44
ulonglong ulonglong_num;
46
LEX_STRING *lex_str_ptr;
51
List<Item> *item_list;
52
List<String> *string_list;
53
Key::Keytype key_type;
55
enum row_type row_type;
57
key_part_spec *key_part;
58
TABLE_LIST *table_list;
60
interval_type interval;
62
enum Item_udftype udf_type;
66
bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
69
%pure_parser /* We have threads */
129
%token AVG_ROW_LENGTH
130
%token BERKELEY_DB_SYM
148
%token DELAY_KEY_WRITE_SYM
195
%token MASTER_HOST_SYM
196
%token MASTER_USER_SYM
197
%token MASTER_LOG_FILE_SYM
198
%token MASTER_LOG_POS_SYM
199
%token MASTER_PASSWORD_SYM
200
%token MASTER_PORT_SYM
201
%token MASTER_CONNECT_RETRY_SYM
228
%token PROCESSLIST_SYM
230
%token RAID_STRIPED_SYM
233
%token RAID_CHUNKSIZE
243
%token ROW_FORMAT_SYM
262
%token UDF_RETURNS_SYM
263
%token UDF_SONAME_SYM
274
%token COMPRESSED_SYM
322
%token DATE_ADD_INTERVAL
323
%token DATE_SUB_INTERVAL
325
%token DAY_MINUTE_SYM
328
%token DAY_SECOND_SYM
341
%token GROUP_UNIQUE_USERS
342
%token HOUR_MINUTE_SYM
343
%token HOUR_SECOND_SYM
345
%token IDENTIFIED_SYM
349
%token LAST_INSERT_ID
353
%token MINUTE_SECOND_SYM
368
%token SUBSTRING_INDEX
374
%token UDF_FLOAT_FUNC
377
%token UNIX_TIMESTAMP
384
%token YEAR_MONTH_SYM
391
%token SQL_BIG_TABLES
392
%token SQL_BIG_SELECTS
393
%token SQL_SELECT_LIMIT
394
%token SQL_MAX_JOIN_SIZE
397
%token SQL_LOG_UPDATE
398
%token SQL_LOW_PRIORITY_UPDATES
399
%token SQL_SMALL_RESULT
400
%token SQL_BIG_RESULT
401
%token SQL_BUFFER_RESULT
403
%token SQL_AUTO_IS_NULL
404
%token SQL_SAFE_UPDATES
407
%left OR_OR_CONCAT OR
409
%left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
410
%left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP IN_SYM
413
%left SHIFT_LEFT SHIFT_RIGHT
421
IDENT TEXT_STRING REAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM LEX_HOSTNAME
422
field_ident select_alias ident ident_or_text
430
%type <simple_string>
431
remember_name remember_end opt_len opt_ident opt_db text_or_password
438
type int_type real_type order_dir opt_field_spec set_option lock_option
439
udf_type if_exists opt_local opt_table_options table_options
440
table_option opt_if_not_exists
445
%type <ulonglong_num>
449
literal text_literal insert_ident group_ident order_ident
450
simple_ident select_item2 expr opt_expr opt_else sum_expr in_sum_expr
451
table_wild opt_pad no_in_expr expr_expr simple_expr no_and_expr
455
expr_list udf_expr_list when_list ident_list
467
join_table_list join_table
470
UDF_CHAR_FUNC UDF_FLOAT_FUNC UDF_INT_FUNC
471
UDA_CHAR_SUM UDA_FLOAT_SUM UDA_INT_SUM
473
%type <interval> interval
475
%type <db_type> table_types
477
%type <row_type> row_types
479
%type <udf_type> udf_func_type
481
%type <symbol> FUNC_ARG0 FUNC_ARG1 FUNC_ARG2 FUNC_ARG3 keyword
483
%type <lex_user> user grant_user
486
query verb_clause create change select drop insert replace insert2
487
insert_values update delete show describe load alter optimize flush
488
begin commit rollback slave master_def master_defs
489
repair analyze check field_list field_list_item field_spec kill
490
select_item_list select_item values_list no_braces
491
limit_clause delete_limit_clause fields opt_values values
492
procedure_list procedure_list2 procedure_item
493
when_list2 expr_list2
494
opt_precision opt_ignore opt_column opt_restrict
495
grant revoke set lock unlock string_list field_options field_option
496
field_opt_list opt_binary table_lock_list table_lock varchar
497
references opt_on_delete opt_on_delete_list opt_on_delete_item use
498
opt_outer table_list table opt_option opt_place opt_low_priority
499
opt_attribute opt_attribute_list attribute column_list column_list_id
500
opt_column_list grant_privileges opt_table user_list grant_option
501
grant_privilege grant_privilege_list
502
flush_options flush_option insert_lock_option replace_lock_option
503
equal optional_braces opt_key_definition key_usage_list2
504
opt_mi_check_type opt_to mi_check_types normal_join
508
'-' '+' '*' '/' '%' '(' ')'
509
',' '!' '{' '}' '&' '|' AND OR OR_OR_CONCAT BETWEEN_SYM CASE_SYM THEN_SYM WHEN_SYM
516
if (!current_thd->bootstrap)
517
send_error(¤t_thd->net,ER_EMPTY_QUERY);
520
| verb_clause END_OF_INPUT {}
555
CHANGE MASTER_SYM TO_SYM
558
lex->sql_command = SQLCOM_CHANGE_MASTER;
559
memset(&lex->mi, 0, sizeof(lex->mi));
565
master_defs ',' master_def
568
MASTER_HOST_SYM EQ TEXT_STRING
570
Lex->mi.host = $3.str;
573
MASTER_USER_SYM EQ TEXT_STRING
575
Lex->mi.user = $3.str;
578
MASTER_PASSWORD_SYM EQ TEXT_STRING
580
Lex->mi.password = $3.str;
583
MASTER_LOG_FILE_SYM EQ TEXT_STRING
585
Lex->mi.log_file_name = $3.str;
588
MASTER_PORT_SYM EQ ULONGLONG_NUM
593
MASTER_LOG_POS_SYM EQ ULONGLONG_NUM
598
MASTER_CONNECT_RETRY_SYM EQ ULONGLONG_NUM
600
Lex->mi.connect_retry = $3;
608
CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident
611
lex->sql_command= SQLCOM_CREATE_TABLE;
612
if (!add_table_to_list($5,
613
($2 & HA_LEX_CREATE_TMP_TABLE ?
614
&tmp_table_alias : (LEX_STRING*) 0)))
616
lex->create_list.empty();
617
lex->key_list.empty();
618
lex->col_list.empty();
620
bzero((char*) &lex->create_info,sizeof(lex->create_info));
621
lex->create_info.options=$2 | $4;
622
lex->create_info.db_type= default_table_type;
626
| CREATE opt_unique INDEX ident ON table_ident
628
Lex->sql_command= SQLCOM_CREATE_INDEX;
629
if (!add_table_to_list($6,NULL))
631
Lex->create_list.empty();
632
Lex->key_list.empty();
633
Lex->col_list.empty();
638
Lex->key_list.push_back(new Key($2,$4.str,Lex->col_list));
639
Lex->col_list.empty();
641
| CREATE COLLECTION ident ON table_ident
643
Lex->sql_command= SQLCOM_CREATE_INDEX;
644
if (!add_table_to_list($5,NULL))
646
Lex->create_list.empty();
647
Lex->key_list.empty();
648
Lex->col_list.empty();
653
Lex->key_list.push_back(new Key(Key::FULLTEXT,$3.str,Lex->col_list));
654
Lex->col_list.empty();
656
| CREATE DATABASE opt_if_not_exists ident
658
Lex->sql_command=SQLCOM_CREATE_DB;
660
Lex->create_info.options=$3;
662
| CREATE udf_func_type UDF_SYM ident
664
Lex->sql_command = SQLCOM_CREATE_FUNCTION;
665
Lex->udf.name=$4.str;
666
Lex->udf.name_length=$4.length;
669
UDF_RETURNS_SYM udf_type UDF_SONAME_SYM TEXT_STRING
671
Lex->udf.returns=(Item_result) $7;
676
'(' field_list ')' opt_create_table_options create3 {}
677
| opt_create_table_options create3 {}
681
| opt_duplicate SELECT_SYM
684
lex->where=lex->having=0;
685
lex->select_limit=current_thd->default_select_limit;
686
lex->offset_limit=0L;
689
lex->order_list.elements=lex->group_list.elements=0;
690
lex->order_list.first=0;
691
lex->order_list.next= (byte**) &lex->order_list.first;
692
lex->group_list.first=0;
693
lex->group_list.next= (byte**) &lex->group_list.first;
695
select_options select_item_list opt_select_from {}
698
/* empty */ { $$= 0; }
699
| table_options { $$= $1;}
702
table_option { $$=$1; }
703
| table_option table_options { $$= $1 | $2 }
706
TEMPORARY { $$=HA_LEX_CREATE_TMP_TABLE; }
709
/* empty */ { $$= 0; }
710
| IF NOT EXISTS { $$=HA_LEX_CREATE_IF_NOT_EXISTS; }
712
opt_create_table_options:
714
| create_table_options
716
create_table_options:
718
| create_table_option create_table_options
721
TYPE_SYM EQ table_types { Lex->create_info.db_type= $3; }
722
| MAX_ROWS EQ ULONGLONG_NUM { Lex->create_info.max_rows= $3; }
723
| MIN_ROWS EQ ULONGLONG_NUM { Lex->create_info.min_rows= $3; }
724
| AVG_ROW_LENGTH EQ ULONG_NUM { Lex->create_info.avg_row_length=$3; }
725
| PASSWORD EQ TEXT_STRING { Lex->create_info.password=$3.str; }
726
| COMMENT_SYM EQ TEXT_STRING { Lex->create_info.comment=$3.str; }
727
| AUTO_INC EQ ULONGLONG_NUM { Lex->create_info.auto_increment_value=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;}
728
| PACK_KEYS_SYM EQ ULONG_NUM { Lex->create_info.table_options|= $3 ? HA_OPTION_PACK_KEYS : HA_OPTION_NO_PACK_KEYS; }
729
| CHECKSUM_SYM EQ ULONG_NUM { Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM; }
730
| DELAY_KEY_WRITE_SYM EQ ULONG_NUM { Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE; }
731
| ROW_FORMAT_SYM EQ row_types { Lex->create_info.row_type= $3; }
732
| RAID_TYPE EQ raid_types { Lex->create_info.raid_type= $3; Lex->create_info.used_fields|= HA_CREATE_USED_RAID;}
733
| RAID_CHUNKS EQ ULONG_NUM { Lex->create_info.raid_chunks= $3; Lex->create_info.used_fields|= HA_CREATE_USED_RAID;}
734
| RAID_CHUNKSIZE EQ ULONG_NUM { Lex->create_info.raid_chunksize= $3*RAID_BLOCK_SIZE; Lex->create_info.used_fields|= HA_CREATE_USED_RAID;}
737
ISAM_SYM { $$= DB_TYPE_ISAM; }
738
| MYISAM_SYM { $$= DB_TYPE_MYISAM; }
739
| MERGE_SYM { $$= DB_TYPE_MRG_MYISAM; }
740
| HEAP_SYM { $$= DB_TYPE_HEAP; }
741
| BERKELEY_DB_SYM { $$= DB_TYPE_BERKELEY_DB; }
744
DEFAULT { $$= ROW_TYPE_DEFAULT; }
745
| FIXED_SYM { $$= ROW_TYPE_FIXED; }
746
| DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; }
747
| COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; }
750
RAID_STRIPED_SYM { $$= RAID_TYPE_0; }
751
| RAID_0_SYM { $$= RAID_TYPE_0; }
752
| ULONG_NUM { $$=$1;}
759
/* empty */ { $$ = UDFTYPE_FUNCTION; }
760
| AGGREGATE_SYM { $$ = UDFTYPE_AGGREGATE; }
763
STRING_SYM {$$ = (int) STRING_RESULT; }
764
| REAL {$$ = (int) REAL_RESULT; }
765
| INT_SYM {$$ = (int) INT_RESULT; }
769
| field_list ',' field_list_item
774
| field_spec references
776
Lex->col_list.empty(); /* Alloced by sql_alloc */
778
| key_type opt_ident '(' key_list ')'
780
Lex->key_list.push_back(new Key($1,$2,Lex->col_list));
781
Lex->col_list.empty(); /* Alloced by sql_alloc */
783
| opt_constraint FOREIGN KEY_SYM '(' key_list ')' references
785
Lex->col_list.empty(); /* Alloced by sql_alloc */
787
| opt_constraint CHECK_SYM '(' expr ')'
789
Lex->col_list.empty(); /* Alloced by sql_alloc */
794
| CONSTRAINT opt_ident
799
Lex->length=Lex->dec=0; Lex->type=0; Lex->interval=0;
800
Lex->default_value=0;
804
if (add_field_to_list($1.str,
805
(enum enum_field_types) $3,
806
Lex->length,Lex->dec,Lex->type,
807
Lex->default_value,Lex->change,
813
int_type opt_len field_options { Lex->length=$2; $$=$1; }
814
| real_type opt_precision field_options { $$=$1; }
815
| FLOAT_SYM float_options field_options { $$=FIELD_TYPE_FLOAT; }
816
| BIT_SYM opt_len { Lex->length=(char*) "1";
817
$$=FIELD_TYPE_TINY; }
818
| BOOL_SYM { Lex->length=(char*) "1";
819
$$=FIELD_TYPE_TINY; }
820
| char '(' NUM ')' opt_binary { Lex->length=$3.str;
821
$$=FIELD_TYPE_STRING; }
822
| char opt_binary { Lex->length=(char*) "1";
823
$$=FIELD_TYPE_STRING; }
824
| BINARY '(' NUM ')' { Lex->length=$3.str;
825
Lex->type|=BINARY_FLAG;
826
$$=FIELD_TYPE_STRING; }
827
| varchar '(' NUM ')' opt_binary { Lex->length=$3.str;
828
$$=FIELD_TYPE_VAR_STRING; }
829
| VARBINARY '(' NUM ')' { Lex->length=$3.str;
830
Lex->type|=BINARY_FLAG;
831
$$=FIELD_TYPE_VAR_STRING; }
832
| YEAR_SYM opt_len field_options { $$=FIELD_TYPE_YEAR; Lex->length=$2; }
833
| DATE_SYM { $$=FIELD_TYPE_DATE; }
834
| TIME_SYM { $$=FIELD_TYPE_TIME; }
835
| TIMESTAMP { $$=FIELD_TYPE_TIMESTAMP; }
836
| TIMESTAMP '(' NUM ')' { Lex->length=$3.str;
837
$$=FIELD_TYPE_TIMESTAMP; }
838
| DATETIME { $$=FIELD_TYPE_DATETIME; }
839
| TINYBLOB { Lex->type|=BINARY_FLAG;
840
$$=FIELD_TYPE_TINY_BLOB; }
841
| BLOB_SYM { Lex->type|=BINARY_FLAG;
842
$$=FIELD_TYPE_BLOB; }
843
| MEDIUMBLOB { Lex->type|=BINARY_FLAG;
844
$$=FIELD_TYPE_MEDIUM_BLOB; }
845
| LONGBLOB { Lex->type|=BINARY_FLAG;
846
$$=FIELD_TYPE_LONG_BLOB; }
847
| LONG_SYM VARBINARY { Lex->type|=BINARY_FLAG;
848
$$=FIELD_TYPE_MEDIUM_BLOB; }
849
| LONG_SYM varchar { $$=FIELD_TYPE_MEDIUM_BLOB; }
850
| TINYTEXT { $$=FIELD_TYPE_TINY_BLOB; }
851
| TEXT_SYM { $$=FIELD_TYPE_BLOB; }
852
| MEDIUMTEXT { $$=FIELD_TYPE_MEDIUM_BLOB; }
853
| LONGTEXT { $$=FIELD_TYPE_LONG_BLOB; }
854
| DECIMAL_SYM float_options field_options
855
{ $$=FIELD_TYPE_DECIMAL;}
856
| NUMERIC_SYM float_options field_options
857
{ $$=FIELD_TYPE_DECIMAL;}
858
| ENUM {Lex->interval_list.empty();} '(' string_list ')'
860
Lex->interval=typelib(Lex->interval_list);
863
| SET { Lex->interval_list.empty();} '(' string_list ')'
865
Lex->interval=typelib(Lex->interval_list);
872
| NATIONAL_SYM CHAR_SYM {}
877
| NATIONAL_SYM VARCHAR {}
878
| NCHAR_SYM VARCHAR {}
881
INT_SYM { $$=FIELD_TYPE_LONG; }
882
| TINYINT { $$=FIELD_TYPE_TINY; }
883
| SMALLINT { $$=FIELD_TYPE_SHORT; }
884
| MEDIUMINT { $$=FIELD_TYPE_INT24; }
885
| BIGINT { $$=FIELD_TYPE_LONGLONG; }
888
REAL { $$= current_thd->options & OPTION_ANSI_MODE ?
889
FIELD_TYPE_FLOAT : FIELD_TYPE_DOUBLE; }
890
| DOUBLE_SYM { $$=FIELD_TYPE_DOUBLE; }
891
| DOUBLE_SYM PRECISION { $$=FIELD_TYPE_DOUBLE; }
896
| '(' NUM ')' { Lex->length=$2.str; }
897
| '(' NUM ',' NUM ')' { Lex->length=$2.str; Lex->dec=$4.str; }
904
field_opt_list field_option {}
908
UNSIGNED { Lex->type|= UNSIGNED_FLAG;}
909
| ZEROFILL { Lex->type|= UNSIGNED_FLAG | ZEROFILL_FLAG; }
912
/* empty */ { $$=(char*) 0; } /* use default length */
913
| '(' NUM ')' { $$=$2.str; }
917
| '(' NUM ',' NUM ')' { Lex->length=$2.str; Lex->dec=$4.str; }
921
| opt_attribute_list {}
924
opt_attribute_list attribute {}
928
NULL_SYM { Lex->type&= ~ NOT_NULL_FLAG; }
929
| NOT NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
930
| DEFAULT literal { Lex->default_value=$2; }
931
| AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
932
| PRIMARY_SYM KEY_SYM { Lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG; }
933
| UNIQUE_SYM { Lex->type|= UNIQUE_FLAG; }
934
| UNIQUE_SYM KEY_SYM { Lex->type|= UNIQUE_KEY_FLAG; }
938
| BINARY { Lex->type|=BINARY_FLAG; }
941
REFERENCES table_ident opt_on_delete {}
942
| REFERENCES table_ident '(' key_list ')' opt_on_delete
944
Lex->col_list.empty(); /* Alloced by sql_alloc */
949
| opt_on_delete_list {}
952
opt_on_delete_list opt_on_delete_item {}
953
| opt_on_delete_item {}
957
ON DELETE_SYM delete_option {}
958
| ON UPDATE_SYM delete_option {}
970
opt_constraint PRIMARY_SYM KEY_SYM { $$= Key::PRIMARY; }
971
| key_or_index { $$= Key::MULTIPLE; }
972
| opt_constraint UNIQUE_SYM { $$= Key::UNIQUE; }
973
| opt_constraint UNIQUE_SYM key_or_index { $$= Key::UNIQUE; }
984
/* empty */ { $$= Key::MULTIPLE; }
985
| UNIQUE_SYM { $$= Key::UNIQUE; }
988
key_list ',' key_part order_dir { Lex->col_list.push_back($3); }
989
| key_part order_dir { Lex->col_list.push_back($1); }
992
ident { $$=new key_part_spec($1.str); }
993
| ident '(' NUM ')' { $$=new key_part_spec($1.str,(uint) atoi($3.str)); }
996
/* empty */ { $$=(char*) 0; } /* Defaultlength */
997
| field_ident { $$=$1.str; }
1000
text_string { Lex->interval_list.push_back($1); }
1001
| string_list ',' text_string { Lex->interval_list.push_back($3); }
1008
ALTER opt_ignore TABLE_SYM table_ident
1011
lex->sql_command = SQLCOM_ALTER_TABLE;
1013
if (!add_table_to_list($4, NULL))
1015
lex->drop_primary=0;
1016
lex->create_list.empty();
1017
lex->key_list.empty();
1018
lex->col_list.empty();
1019
lex->drop_list.empty();
1020
lex->alter_list.empty();
1021
lex->db=lex->name=0;
1022
bzero((char*) &lex->create_info,sizeof(lex->create_info));
1023
lex->create_info.db_type= DB_TYPE_DEFAULT;
1025
alter_list opt_create_table_options
1029
| alter_list ',' alter_list_item
1032
ADD opt_column { Lex->change=0;}
1035
add_column field_list_item opt_place
1036
| add_column '(' field_list ')'
1037
| CHANGE opt_column field_ident { Lex->change= $3.str; } field_spec
1038
| MODIFY_SYM opt_column field_ident
1040
Lex->length=Lex->dec=0; Lex->type=0; Lex->interval=0;
1041
Lex->default_value=0;
1045
if (add_field_to_list($3.str,
1046
(enum enum_field_types) $5,
1047
Lex->length,Lex->dec,Lex->type,
1048
Lex->default_value, $3.str,
1052
| DROP opt_column field_ident opt_restrict
1053
{ Lex->drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
1055
| DROP PRIMARY_SYM KEY_SYM { Lex->drop_primary=1; }
1056
| DROP FOREIGN KEY_SYM opt_ident {}
1057
| DROP key_or_index field_ident
1058
{ Lex->drop_list.push_back(new Alter_drop(Alter_drop::KEY,
1060
| ALTER opt_column field_ident SET DEFAULT literal
1061
{ Lex->alter_list.push_back(new Alter_column($3.str,$6)); }
1062
| ALTER opt_column field_ident DROP DEFAULT
1063
{ Lex->alter_list.push_back(new Alter_column($3.str,(Item*) 0)); }
1064
| RENAME opt_to table_alias table_ident
1065
{ Lex->db=$4->db.str ; Lex->name= $4->table.str; }
1066
| create_table_option
1073
/* empty */ { Lex->duplicates=DUP_ERROR; }
1074
| IGNORE_SYM { Lex->duplicates=DUP_IGNORE; }
1083
| AFTER_SYM ident { store_position_for_column($2.str); }
1084
| FIRST_SYM { store_position_for_column(first_keyword); }
1093
Lex->sql_command = SQLCOM_SLAVE_START;
1099
Lex->sql_command = SQLCOM_SLAVE_STOP;
1104
REPAIR table_or_tables
1106
Lex->sql_command = SQLCOM_REPAIR;
1107
Lex->check_opt.init();
1109
table_list opt_mi_check_type
1113
/* empty */ { Lex->check_opt.flags = T_MEDIUM; }
1114
| TYPE_SYM EQ mi_check_types {}
1117
QUICK { Lex->check_opt.quick = 1; }
1118
| EXTENDED_SYM { Lex->check_opt.flags = T_EXTEND; }
1121
ANALYZE_SYM table_or_tables table_list
1123
Lex->sql_command = SQLCOM_ANALYZE;
1124
Lex->check_opt.init();
1128
CHECK_SYM table_or_tables
1130
Lex->sql_command = SQLCOM_CHECK;
1131
Lex->check_opt.init();
1133
table_list opt_mi_check_type
1136
OPTIMIZE table_or_tables table_ident
1138
Lex->sql_command = SQLCOM_OPTIMIZE;
1139
if (!add_table_to_list($3, NULL))
1144
** Select : retrieve data from table
1152
lex->where=lex->having=0;
1153
lex->select_limit=current_thd->default_select_limit;
1154
lex->offset_limit=0L;
1156
lex->sql_command= SQLCOM_SELECT;
1158
lex->order_list.elements=lex->group_list.elements=0;
1159
lex->order_list.first=0;
1160
lex->order_list.next= (byte**) &lex->order_list.first;
1161
lex->group_list.first=0;
1162
lex->group_list.next= (byte**) &lex->group_list.first;
1164
select_options select_item_list select_into
1169
| opt_into select_from
1170
| select_from opt_into
1173
FROM join_table_list where_clause group_clause having_clause order_clause limit_clause procedure_clause
1178
| select_option_list
1181
select_option_list select_option
1185
STRAIGHT_JOIN { Lex->options|= SELECT_STRAIGHT_JOIN; }
1186
| HIGH_PRIORITY { Lex->options|= SELECT_HIGH_PRIORITY; }
1187
| DISTINCT { Lex->options|= SELECT_DISTINCT; }
1188
| SQL_SMALL_RESULT { Lex->options|= SELECT_SMALL_RESULT; }
1189
| SQL_BIG_RESULT { Lex->options|= SELECT_BIG_RESULT; }
1190
| SQL_BUFFER_RESULT { Lex->options|= OPTION_BUFFER_RESULT; }
1194
select_item_list ',' select_item
1198
if (add_item_to_list(new Item_field(NULL,NULL,"*")))
1204
remember_name select_item2 remember_end select_alias
1206
if (add_item_to_list($2))
1209
$2->set_name($4.str);
1211
$2->set_name($1,(uint) ($3 - $1));
1215
{ $$=(char*) Lex->tok_start; }
1218
{ $$=(char*) Lex->tok_end; }
1221
table_wild { $$=$1; } /* table.* */
1226
| AS ident { $$=$2; }
1227
| AS TEXT_STRING { $$=$2; }
1229
| TEXT_STRING { $$=$1; }
1235
/* all possible expressions */
1236
expr: expr_expr {$$ = $1; }
1237
| simple_expr {$$ = $1; }
1239
/* expressions that begin with 'expr' */
1241
expr IN_SYM '(' expr_list ')'
1242
{ $$= new Item_func_in($1,*$4); }
1243
| expr NOT IN_SYM '(' expr_list ')'
1244
{ $$= new Item_func_not(new Item_func_in($1,*$5)); }
1245
| expr BETWEEN_SYM no_and_expr AND expr
1246
{ $$= new Item_func_between($1,$3,$5); }
1247
| expr NOT BETWEEN_SYM no_and_expr AND expr
1248
{ $$= new Item_func_not(new Item_func_between($1,$4,$6)); }
1249
| expr OR_OR_CONCAT expr { $$= or_or_concat($1,$3); }
1250
| expr OR expr { $$= new Item_cond_or($1,$3); }
1251
| expr AND expr { $$= new Item_cond_and($1,$3); }
1252
| expr LIKE simple_expr opt_escape { $$= new Item_func_like($1,$3,$4); }
1253
| expr NOT LIKE simple_expr opt_escape { $$= new Item_func_not(new Item_func_like($1,$4,$5));}
1254
| expr REGEXP expr { $$= new Item_func_regex($1,$3); }
1255
| expr NOT REGEXP expr { $$= new Item_func_not(new Item_func_regex($1,$4)); }
1256
| expr IS NULL_SYM { $$= new Item_func_isnull($1); }
1257
| expr IS NOT NULL_SYM { $$= new Item_func_isnotnull($1); }
1258
| expr EQ expr { $$= new Item_func_eq($1,$3); }
1259
| expr EQUAL_SYM expr { $$= new Item_func_equal($1,$3); }
1260
| expr GE expr { $$= new Item_func_ge($1,$3); }
1261
| expr GT_SYM expr { $$= new Item_func_gt($1,$3); }
1262
| expr LE expr { $$= new Item_func_le($1,$3); }
1263
| expr LT expr { $$= new Item_func_lt($1,$3); }
1264
| expr NE expr { $$= new Item_func_ne($1,$3); }
1265
| expr SHIFT_LEFT expr { $$= new Item_func_shift_left($1,$3); }
1266
| expr SHIFT_RIGHT expr { $$= new Item_func_shift_right($1,$3); }
1267
| expr '+' expr { $$= new Item_func_plus($1,$3); }
1268
| expr '-' expr { $$= new Item_func_minus($1,$3); }
1269
| expr '*' expr { $$= new Item_func_mul($1,$3); }
1270
| expr '/' expr { $$= new Item_func_div($1,$3); }
1271
| expr '|' expr { $$= new Item_func_bit_or($1,$3); }
1272
| expr '&' expr { $$= new Item_func_bit_and($1,$3); }
1273
| expr '%' expr { $$= new Item_func_mod($1,$3); }
1274
| expr '+' INTERVAL_SYM expr interval
1275
{ $$= new Item_date_add_interval($1,$4,$5,0); }
1276
| expr '-' INTERVAL_SYM expr interval
1277
{ $$= new Item_date_add_interval($1,$4,$5,1); }
1279
/* expressions that begin with 'expr' that do NOT follow IN_SYM */
1281
no_in_expr BETWEEN_SYM no_and_expr AND expr
1282
{ $$= new Item_func_between($1,$3,$5); }
1283
| no_in_expr NOT BETWEEN_SYM no_and_expr AND expr
1284
{ $$= new Item_func_not(new Item_func_between($1,$4,$6)); }
1285
| no_in_expr OR_OR_CONCAT expr { $$= or_or_concat($1,$3); }
1286
| no_in_expr OR expr { $$= new Item_cond_or($1,$3); }
1287
| no_in_expr AND expr { $$= new Item_cond_and($1,$3); }
1288
| no_in_expr LIKE simple_expr opt_escape { $$= new Item_func_like($1,$3,$4); }
1289
| no_in_expr NOT LIKE simple_expr opt_escape { $$= new Item_func_not(new Item_func_like($1,$4,$5)); }
1290
| no_in_expr REGEXP expr { $$= new Item_func_regex($1,$3); }
1291
| no_in_expr NOT REGEXP expr { $$= new Item_func_not(new Item_func_regex($1,$4)); }
1292
| no_in_expr IS NULL_SYM { $$= new Item_func_isnull($1); }
1293
| no_in_expr IS NOT NULL_SYM { $$= new Item_func_isnotnull($1); }
1294
| no_in_expr EQ expr { $$= new Item_func_eq($1,$3); }
1295
| no_in_expr EQUAL_SYM expr { $$= new Item_func_equal($1,$3); }
1296
| no_in_expr GE expr { $$= new Item_func_ge($1,$3); }
1297
| no_in_expr GT_SYM expr { $$= new Item_func_gt($1,$3); }
1298
| no_in_expr LE expr { $$= new Item_func_le($1,$3); }
1299
| no_in_expr LT expr { $$= new Item_func_lt($1,$3); }
1300
| no_in_expr NE expr { $$= new Item_func_ne($1,$3); }
1301
| no_in_expr SHIFT_LEFT expr { $$= new Item_func_shift_left($1,$3); }
1302
| no_in_expr SHIFT_RIGHT expr { $$= new Item_func_shift_right($1,$3); }
1303
| no_in_expr '+' expr { $$= new Item_func_plus($1,$3); }
1304
| no_in_expr '-' expr { $$= new Item_func_minus($1,$3); }
1305
| no_in_expr '*' expr { $$= new Item_func_mul($1,$3); }
1306
| no_in_expr '/' expr { $$= new Item_func_div($1,$3); }
1307
| no_in_expr '|' expr { $$= new Item_func_bit_or($1,$3); }
1308
| no_in_expr '&' expr { $$= new Item_func_bit_and($1,$3); }
1309
| no_in_expr '%' expr { $$= new Item_func_mod($1,$3); }
1310
| no_in_expr '+' INTERVAL_SYM expr interval
1311
{ $$= new Item_date_add_interval($1,$4,$5,0); }
1312
| no_in_expr '-' INTERVAL_SYM expr interval
1313
{ $$= new Item_date_add_interval($1,$4,$5,1); }
1316
/* expressions that begin with 'expr' that does NOT follow AND */
1318
no_and_expr IN_SYM '(' expr_list ')'
1319
{ $$= new Item_func_in($1,*$4); }
1320
| no_and_expr NOT IN_SYM '(' expr_list ')'
1321
{ $$= new Item_func_not(new Item_func_in($1,*$5)); }
1322
| no_and_expr BETWEEN_SYM no_and_expr AND expr
1323
{ $$= new Item_func_between($1,$3,$5); }
1324
| no_and_expr NOT BETWEEN_SYM no_and_expr AND expr
1325
{ $$= new Item_func_not(new Item_func_between($1,$4,$6)); }
1326
| no_and_expr OR_OR_CONCAT expr { $$= or_or_concat($1,$3); }
1327
| no_and_expr OR expr { $$= new Item_cond_or($1,$3); }
1328
| no_and_expr LIKE simple_expr opt_escape { $$= new Item_func_like($1,$3,$4); }
1329
| no_and_expr NOT LIKE simple_expr opt_escape { $$= new Item_func_not(new Item_func_like($1,$4,$5)); }
1330
| no_and_expr REGEXP expr { $$= new Item_func_regex($1,$3); }
1331
| no_and_expr NOT REGEXP expr { $$= new Item_func_not(new Item_func_regex($1,$4)); }
1332
| no_and_expr IS NULL_SYM { $$= new Item_func_isnull($1); }
1333
| no_and_expr IS NOT NULL_SYM { $$= new Item_func_isnotnull($1); }
1334
| no_and_expr EQ expr { $$= new Item_func_eq($1,$3); }
1335
| no_and_expr EQUAL_SYM expr { $$= new Item_func_equal($1,$3); }
1336
| no_and_expr GE expr { $$= new Item_func_ge($1,$3); }
1337
| no_and_expr GT_SYM expr { $$= new Item_func_gt($1,$3); }
1338
| no_and_expr LE expr { $$= new Item_func_le($1,$3); }
1339
| no_and_expr LT expr { $$= new Item_func_lt($1,$3); }
1340
| no_and_expr NE expr { $$= new Item_func_ne($1,$3); }
1341
| no_and_expr SHIFT_LEFT expr { $$= new Item_func_shift_left($1,$3); }
1342
| no_and_expr SHIFT_RIGHT expr { $$= new Item_func_shift_right($1,$3); }
1343
| no_and_expr '+' expr { $$= new Item_func_plus($1,$3); }
1344
| no_and_expr '-' expr { $$= new Item_func_minus($1,$3); }
1345
| no_and_expr '*' expr { $$= new Item_func_mul($1,$3); }
1346
| no_and_expr '/' expr { $$= new Item_func_div($1,$3); }
1347
| no_and_expr '|' expr { $$= new Item_func_bit_or($1,$3); }
1348
| no_and_expr '&' expr { $$= new Item_func_bit_and($1,$3); }
1349
| no_and_expr '%' expr { $$= new Item_func_mod($1,$3); }
1350
| no_and_expr '+' INTERVAL_SYM expr interval
1351
{ $$= new Item_date_add_interval($1,$4,$5,0); }
1352
| no_and_expr '-' INTERVAL_SYM expr interval
1353
{ $$= new Item_date_add_interval($1,$4,$5,1); }
1359
| '@' ident_or_text SET_VAR expr { $$= new Item_func_set_user_var($2,$4); }
1360
| '@' ident_or_text { $$= new Item_func_get_user_var($2); }
1362
| '-' expr %prec NEG { $$= new Item_func_neg($2); }
1363
| '~' expr %prec NEG { $$= new Item_func_bit_neg($2); }
1364
| NOT expr %prec NEG { $$= new Item_func_not($2); }
1365
| '!' expr %prec NEG { $$= new Item_func_not($2); }
1366
| '(' expr ')' { $$= $2; }
1367
| '{' ident expr '}' { $$= $3; }
1368
| MATCH '(' ident_list ')' AGAINST '(' expr ')'
1369
{ Lex->ftfunc_list.push_back(
1370
(Item_func_match *)($$=new Item_func_match(*$3,$7))); }
1371
| MATCH ident_list AGAINST '(' expr ')'
1372
{ Lex->ftfunc_list.push_back(
1373
(Item_func_match *)($$=new Item_func_match(*$2,$5))); }
1374
| BINARY expr %prec NEG { $$= new Item_func_binary($2); }
1375
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
1376
{ $$= new Item_func_case(* $4, $2, $5 ) }
1378
{ $$= ((Item*(*)(void))($1.symbol->create_func))();}
1379
| FUNC_ARG1 '(' expr ')'
1380
{ $$= ((Item*(*)(Item*))($1.symbol->create_func))($3);}
1381
| FUNC_ARG2 '(' expr ',' expr ')'
1382
{ $$= ((Item*(*)(Item*,Item*))($1.symbol->create_func))($3,$5);}
1383
| FUNC_ARG3 '(' expr ',' expr ',' expr ')'
1384
{ $$= ((Item*(*)(Item*,Item*,Item*))($1.symbol->create_func))($3,$5,$7);}
1386
{ $$= new Item_func_atan($3); }
1387
| ATAN '(' expr ',' expr ')'
1388
{ $$= new Item_func_atan($3,$5); }
1389
| CHAR_SYM '(' expr_list ')'
1390
{ $$= new Item_func_char(*$3); }
1391
| COALESCE '(' expr_list ')'
1392
{ $$= new Item_func_coalesce(* $3); }
1393
| CONCAT '(' expr_list ')'
1394
{ $$= new Item_func_concat(* $3); }
1395
| CONCAT_WS '(' expr ',' expr_list ')'
1396
{ $$= new Item_func_concat_ws($3, *$5); }
1397
| CURDATE optional_braces
1398
{ $$= new Item_func_curdate(); }
1399
| CURTIME optional_braces
1400
{ $$= new Item_func_curtime(); }
1401
| CURTIME '(' expr ')'
1402
{ $$= new Item_func_curtime($3); }
1403
| DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')'
1404
{ $$= new Item_date_add_interval($3,$6,$7,0); }
1405
| DATE_SUB_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')'
1406
{ $$= new Item_date_add_interval($3,$6,$7,1); }
1408
{ $$= new Item_func_database(); }
1409
| ELT_FUNC '(' expr ',' expr_list ')'
1410
{ $$= new Item_func_elt($3, *$5); }
1411
| MAKE_SET_SYM '(' expr ',' expr_list ')'
1412
{ $$= new Item_func_make_set($3, *$5); }
1413
| ENCRYPT '(' expr ')' { $$= new Item_func_encrypt($3); }
1414
| ENCRYPT '(' expr ',' expr ')' { $$= new Item_func_encrypt($3,$5); }
1415
| DECODE_SYM '(' expr ',' TEXT_STRING ')'
1416
{ $$= new Item_func_decode($3,$5.str); }
1417
| ENCODE_SYM '(' expr ',' TEXT_STRING ')'
1418
{ $$= new Item_func_encode($3,$5.str); }
1419
| EXPORT_SET '(' expr ',' expr ',' expr ')'
1420
{ $$= new Item_func_export_set($3, $5, $7); }
1421
| EXPORT_SET '(' expr ',' expr ',' expr ',' expr ')'
1422
{ $$= new Item_func_export_set($3, $5, $7, $9); }
1423
| EXPORT_SET '(' expr ',' expr ',' expr ',' expr ',' expr ')'
1424
{ $$= new Item_func_export_set($3, $5, $7, $9, $11); }
1425
| FORMAT_SYM '(' expr ',' NUM ')'
1426
{ $$= new Item_func_format($3,atoi($5.str)); }
1427
| FROM_UNIXTIME '(' expr ')'
1428
{ $$= new Item_func_from_unixtime($3); }
1429
| FROM_UNIXTIME '(' expr ',' expr ')'
1431
$$= new Item_func_date_format(new Item_func_from_unixtime($3),$5,0);
1433
| FIELD_FUNC '(' expr ',' expr_list ')'
1434
{ $$= new Item_func_field($3, *$5); }
1435
| HOUR_SYM '(' expr ')'
1436
{ $$= new Item_func_hour($3); }
1437
| IF '(' expr ',' expr ',' expr ')'
1438
{ $$= new Item_func_if($3,$5,$7); }
1439
| INSERT '(' expr ',' expr ',' expr ',' expr ')'
1440
{ $$= new Item_func_insert($3,$5,$7,$9); }
1441
| INTERVAL_SYM expr interval '+' expr
1442
/* we cannot put interval before - */
1443
{ $$= new Item_date_add_interval($5,$2,$3,0); }
1444
| INTERVAL_SYM '(' expr ',' expr_list ')'
1445
{ $$= new Item_func_interval($3,* $5); }
1446
| LAST_INSERT_ID '(' ')'
1448
$$= new Item_int((char*) "last_insert_id()",
1449
current_thd->insert_id(),21);
1451
| LAST_INSERT_ID '(' expr ')'
1453
$$= new Item_func_set_last_insert_id($3);
1455
| LEFT '(' expr ',' expr ')'
1456
{ $$= new Item_func_left($3,$5); }
1457
| LOCATE '(' expr ',' expr ')'
1458
{ $$= new Item_func_locate($5,$3); }
1459
| LOCATE '(' expr ',' expr ',' expr ')'
1460
{ $$= new Item_func_locate($5,$3,$7); }
1461
| GREATEST_SYM '(' expr ',' expr_list ')'
1462
{ $5->push_front($3); $$= new Item_func_max(*$5); }
1463
| LEAST_SYM '(' expr ',' expr_list ')'
1464
{ $5->push_front($3); $$= new Item_func_min(*$5); }
1465
| MINUTE_SYM '(' expr ')'
1466
{ $$= new Item_func_minute($3); }
1467
| MONTH_SYM '(' expr ')'
1468
{ $$= new Item_func_month($3); }
1469
| NOW_SYM optional_braces
1470
{ $$= new Item_func_now(); }
1471
| NOW_SYM '(' expr ')'
1472
{ $$= new Item_func_now($3); }
1473
| PASSWORD '(' expr ')' { $$= new Item_func_password($3); }
1474
| POSITION_SYM '(' no_in_expr IN_SYM expr ')'
1475
{ $$ = new Item_func_locate($5,$3); }
1476
| RAND '(' expr ')' { $$= new Item_func_rand($3); }
1477
| RAND '(' ')' { $$= new Item_func_rand(); }
1478
| REPLACE '(' expr ',' expr ',' expr ')'
1479
{ $$= new Item_func_replace($3,$5,$7); }
1480
| RIGHT '(' expr ',' expr ')'
1481
{ $$= new Item_func_right($3,$5); }
1482
| ROUND '(' expr ')'
1483
{ $$= new Item_func_round($3, new Item_int((char*)"0",0,1),0); }
1484
| ROUND '(' expr ',' expr ')' { $$= new Item_func_round($3,$5,0); }
1485
| SECOND_SYM '(' expr ')'
1486
{ $$= new Item_func_second($3); }
1487
| SUBSTRING '(' expr ',' expr ',' expr ')'
1488
{ $$= new Item_func_substr($3,$5,$7); }
1489
| SUBSTRING '(' expr ',' expr ')'
1490
{ $$= new Item_func_substr($3,$5); }
1491
| SUBSTRING '(' expr FROM expr FOR_SYM expr ')'
1492
{ $$= new Item_func_substr($3,$5,$7); }
1493
| SUBSTRING '(' expr FROM expr ')'
1494
{ $$= new Item_func_substr($3,$5); }
1495
| SUBSTRING_INDEX '(' expr ',' expr ',' expr ')'
1496
{ $$= new Item_func_substr_index($3,$5,$7); }
1498
{ $$= new Item_func_trim($3,new Item_string(" ",1)); }
1499
| TRIM '(' LEADING opt_pad FROM expr ')'
1500
{ $$= new Item_func_ltrim($6,$4); }
1501
| TRIM '(' TRAILING opt_pad FROM expr ')'
1502
{ $$= new Item_func_rtrim($6,$4); }
1503
| TRIM '(' BOTH opt_pad FROM expr ')'
1504
{ $$= new Item_func_trim($6,$4); }
1505
| TRIM '(' expr FROM expr ')'
1506
{ $$= new Item_func_trim($5,$3); }
1508
| UDA_CHAR_SUM '(' udf_expr_list ')'
1511
$$ = new Item_sum_udf_str($1, *$3);
1513
$$ = new Item_sum_udf_str($1);
1515
| UDA_FLOAT_SUM '(' udf_expr_list ')'
1518
$$ = new Item_sum_udf_float($1, *$3);
1520
$$ = new Item_sum_udf_float($1);
1522
| UDA_INT_SUM '(' udf_expr_list ')'
1525
$$ = new Item_sum_udf_int($1, *$3);
1527
$$ = new Item_sum_udf_int($1);
1529
| UDF_CHAR_FUNC '(' udf_expr_list ')'
1532
$$ = new Item_func_udf_str($1, *$3);
1534
$$ = new Item_func_udf_str($1);
1536
| UDF_FLOAT_FUNC '(' udf_expr_list ')'
1539
$$ = new Item_func_udf_float($1, *$3);
1541
$$ = new Item_func_udf_float($1);
1543
| UDF_INT_FUNC '(' udf_expr_list ')'
1546
$$ = new Item_func_udf_int($1, *$3);
1548
$$ = new Item_func_udf_int($1);
1550
| UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' expr_list ')'
1551
{ $$= new Item_func_unique_users($3,atoi($5.str),atoi($7.str), * $9); }
1552
| UNIX_TIMESTAMP '(' ')'
1553
{ $$= new Item_func_unix_timestamp(); }
1554
| UNIX_TIMESTAMP '(' expr ')'
1555
{ $$= new Item_func_unix_timestamp($3); }
1557
{ $$= new Item_func_user(); }
1558
| WEEK_SYM '(' expr ')'
1559
{ $$= new Item_func_week($3,new Item_int((char*) "0",0,1)); }
1560
| WEEK_SYM '(' expr ',' expr ')'
1561
{ $$= new Item_func_week($3,$5); }
1562
| YEAR_SYM '(' expr ')'
1563
{ $$= new Item_func_year($3); }
1564
| YEARWEEK '(' expr ')'
1565
{ $$= new Item_func_yearweek($3,new Item_int((char*) "0",0,1)); }
1566
| YEARWEEK '(' expr ',' expr ')'
1567
{ $$= new Item_func_yearweek($3, $5); }
1568
| BENCHMARK_SYM '(' ULONG_NUM ',' expr ')'
1569
{ $$=new Item_func_benchmark($3,$5); }
1570
| EXTRACT_SYM '(' interval FROM expr ')'
1571
{ $$=new Item_extract( $3, $5); }
1574
/* empty */ { $$= NULL; }
1575
| expr_list { $$= $1;}
1578
AVG_SYM '(' in_sum_expr ')'
1579
{ $$=new Item_sum_avg($3); }
1580
| BIT_AND '(' in_sum_expr ')'
1581
{ $$=new Item_sum_and($3); }
1582
| BIT_OR '(' in_sum_expr ')'
1583
{ $$=new Item_sum_or($3); }
1584
| COUNT_SYM '(' '*' ')'
1585
{ $$=new Item_sum_count(new Item_int((int32) 0L,1)); }
1586
| COUNT_SYM '(' in_sum_expr ')'
1587
{ $$=new Item_sum_count($3); }
1588
| COUNT_SYM '(' DISTINCT expr_list ')'
1589
{ $$=new Item_sum_count_distinct(* $4); }
1590
| GROUP_UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' in_sum_expr ')'
1591
{ $$= new Item_sum_unique_users($3,atoi($5.str),atoi($7.str),$9); }
1592
| MIN_SYM '(' in_sum_expr ')'
1593
{ $$=new Item_sum_min($3); }
1594
| MAX_SYM '(' in_sum_expr ')'
1595
{ $$=new Item_sum_max($3); }
1596
| STD_SYM '(' in_sum_expr ')'
1597
{ $$=new Item_sum_std($3); }
1598
| SUM_SYM '(' in_sum_expr ')'
1599
{ $$=new Item_sum_sum($3); }
1602
{ Lex->in_sum_expr++ }
1610
{ Lex->expr_list.push_front(new List<Item>); }
1612
{ $$= Lex->expr_list.pop(); }
1615
expr { Lex->expr_list.head()->push_back($1); }
1616
| expr_list2 ',' expr { Lex->expr_list.head()->push_back($3); }
1619
{ Lex->expr_list.push_front(new List<Item>); }
1621
{ $$= Lex->expr_list.pop(); }
1624
simple_ident { Lex->expr_list.head()->push_back($1); }
1625
| ident_list2 ',' simple_ident { Lex->expr_list.head()->push_back($3); }
1628
/* empty */ { $$= NULL; }
1632
/* empty */ { $$= NULL; }
1633
| ELSE expr { $$= $2; }
1636
{ Lex->when_list.push_front(new List<Item>) }
1638
{ $$= Lex->when_list.pop(); }
1643
Lex->when_list.head()->push_back($1);
1644
Lex->when_list.head()->push_back($3);
1646
| when_list2 WHEN_SYM expr THEN_SYM expr
1648
Lex->when_list.head()->push_back($3);
1649
Lex->when_list.head()->push_back($5);
1653
/* empty */ { $$=new Item_string(" ",1); }
1657
'(' join_table_list ')' { $$=$2; }
1658
| join_table { $$=$1; }
1659
| join_table_list normal_join join_table { $$=$3 }
1660
| join_table_list STRAIGHT_JOIN join_table { $$=$3 ; $$->straight=1; }
1661
| join_table_list INNER_SYM JOIN_SYM join_table ON expr
1662
{ add_join_on($4,$6); $$=$4; }
1663
| join_table_list INNER_SYM JOIN_SYM join_table
1664
{ Lex->db1=$1->db; Lex->table1=$1->name;
1665
Lex->db2=$4->db; Lex->table2=$4->name; }
1666
USING '(' using_list ')'
1667
{ add_join_on($4,$8); $$=$4; }
1668
| join_table_list LEFT opt_outer JOIN_SYM join_table ON expr
1669
{ add_join_on($5,$7); $5->outer_join=1; $$=$5; }
1670
| join_table_list LEFT opt_outer JOIN_SYM join_table
1671
{ Lex->db1=$1->db; Lex->table1=$1->name;
1672
Lex->db2=$5->db; Lex->table2=$5->name; }
1673
USING '(' using_list ')'
1674
{ add_join_on($5,$9); $5->outer_join=1; $$=$5; }
1675
| join_table_list NATURAL LEFT opt_outer JOIN_SYM join_table
1676
{ add_join_natural($1,$6); $6->outer_join=1; $$=$6; }
1677
| join_table_list NATURAL JOIN_SYM join_table
1678
{ add_join_natural($1,$4); $$=$4; }
1686
{ Lex->use_index_ptr=Lex->ignore_index_ptr=0; }
1687
table_ident opt_table_alias opt_key_definition
1688
{ if (!($$=add_table_to_list($2,$3,TL_UNLOCK, Lex->use_index_ptr,
1689
Lex->ignore_index_ptr))) YYABORT; }
1690
| '{' ident join_table LEFT OUTER JOIN_SYM join_table ON expr '}'
1691
{ add_join_on($7,$9); $7->outer_join=1; $$=$7; }
1699
| USE_SYM key_usage_list
1700
{ Lex->use_index= *$2; Lex->use_index_ptr= &Lex->use_index; }
1701
| IGNORE_SYM key_usage_list
1702
{ Lex->ignore_index= *$2; Lex->ignore_index_ptr= &Lex->ignore_index;}
1705
key_or_index { Lex->interval_list.empty() } '(' key_usage_list2 ')'
1706
{ $$= &Lex->interval_list; }
1709
key_usage_list2 ',' ident
1710
{ Lex->interval_list.push_back(new String((const char*) $3.str,$3.length)); }
1712
{ Lex->interval_list.push_back(new String((const char*) $1.str,$1.length)); }
1714
{ Lex->interval_list.push_back(new String("PRIMARY",7)); }
1718
{ if (!($$= new Item_func_eq(new Item_field(Lex->db1,Lex->table1, $1.str), new Item_field(Lex->db2,Lex->table2,$1.str))))
1721
| using_list ',' ident
1723
if (!($$= new Item_cond_and(new Item_func_eq(new Item_field(Lex->db1,Lex->table1,$3.str), new Item_field(Lex->db2,Lex->table2,$3.str)), $1)))
1728
DAY_HOUR_SYM { $$=INTERVAL_DAY_HOUR; }
1729
| DAY_MINUTE_SYM { $$=INTERVAL_DAY_MINUTE; }
1730
| DAY_SECOND_SYM { $$=INTERVAL_DAY_SECOND; }
1731
| DAY_SYM { $$=INTERVAL_DAY; }
1732
| HOUR_MINUTE_SYM { $$=INTERVAL_HOUR_MINUTE; }
1733
| HOUR_SECOND_SYM { $$=INTERVAL_HOUR_SECOND; }
1734
| HOUR_SYM { $$=INTERVAL_HOUR; }
1735
| MINUTE_SECOND_SYM { $$=INTERVAL_MINUTE_SECOND; }
1736
| MINUTE_SYM { $$=INTERVAL_MINUTE; }
1737
| MONTH_SYM { $$=INTERVAL_MONTH; }
1738
| SECOND_SYM { $$=INTERVAL_SECOND; }
1739
| YEAR_MONTH_SYM { $$=INTERVAL_YEAR_MONTH; }
1740
| YEAR_SYM { $$=INTERVAL_YEAR; }
1748
/* empty */ { $$=0; }
1750
{ $$= (LEX_STRING*) sql_memdup(&$2,sizeof(LEX_STRING)); }
1754
/* empty */ { Lex->where= 0; }
1755
| WHERE expr { Lex->where= $2; }
1759
| HAVING { Lex->create_refs=1; } expr
1760
{ Lex->having= $3; Lex->create_refs=0; }
1763
ESCAPE_SYM TEXT_STRING { $$= $2.str; }
1764
| /* empty */ { $$= (char*) "\\"; }
1768
** group by statement in select
1773
| GROUP BY group_list
1776
group_list ',' group_ident
1777
{ if (add_group_to_list($3,(bool) 1)) YYABORT; }
1778
| group_ident order_dir
1779
{ if (add_group_to_list($1,(bool) 1)) YYABORT; }
1782
** Order by statement in select
1787
| ORDER_SYM BY { Lex->sort_default=1; } order_list
1790
order_list ',' order_ident order_dir
1791
{ if (add_order_to_list($3,(bool) $4)) YYABORT; }
1792
| order_ident order_dir
1793
{ if (add_order_to_list($1,(bool) $2)) YYABORT; }
1796
/* empty */ { $$ = 1; }
1797
| ASC { $$ = Lex->sort_default=1; }
1798
| DESC { $$ = Lex->sort_default=0; }
1804
Lex->select_limit= current_thd->default_select_limit;
1805
Lex->offset_limit= 0L;
1808
{ Lex->select_limit= $2; Lex->offset_limit=0L; }
1809
| LIMIT ULONG_NUM ',' ULONG_NUM
1810
{ Lex->select_limit= $4; Lex->offset_limit=$2; }
1812
delete_limit_clause:
1815
Lex->select_limit= HA_POS_ERROR;
1817
| LIMIT ULONGLONG_NUM
1818
{ Lex->select_limit= (ha_rows) $2; }
1821
NUM { $$= strtoul($1.str,NULL,10); }
1822
| REAL_NUM { $$= strtoul($1.str,NULL,10); }
1823
| FLOAT_NUM { $$= strtoul($1.str,NULL,10); }
1826
NUM { $$= (ulonglong) strtoul($1.str,NULL,10); }
1827
| LONG_NUM { $$= strtoull($1.str,NULL,10); }
1828
| REAL_NUM { $$= strtoull($1.str,NULL,10); }
1829
| FLOAT_NUM { $$= strtoull($1.str,NULL,10); }
1833
| PROCEDURE ident /* Procedure name */
1836
lex->proc_list.elements=0;
1837
lex->proc_list.first=0;
1838
lex->proc_list.next= (byte**) &lex->proc_list.first;
1839
if (add_proc_to_list(new Item_field(NULL,NULL,$2.str)))
1842
'(' procedure_list ')'
1847
| procedure_list2 {}
1850
procedure_list2 ',' procedure_item
1856
if (add_proc_to_list($2))
1859
$2->set_name($1,(uint) ((char*) Lex->tok_end - $1));
1863
INTO OUTFILE TEXT_STRING
1865
if (!(Lex->exchange= new sql_exchange($3.str,0)))
1868
opt_field_term opt_line_term
1869
| INTO DUMPFILE TEXT_STRING
1871
if (!(Lex->exchange= new sql_exchange($3.str,1)))
1877
** Drop : delete tables or index
1881
DROP TABLE_SYM if_exists table_list
1883
Lex->sql_command = SQLCOM_DROP_TABLE;
1884
Lex->drop_if_exists = $3;
1886
| DROP INDEX ident ON table_ident {}
1888
Lex->sql_command= SQLCOM_DROP_INDEX;
1889
Lex->drop_list.empty();
1890
Lex->drop_list.push_back(new Alter_drop(Alter_drop::KEY,
1892
if (!add_table_to_list($5,NULL))
1895
| DROP DATABASE if_exists ident
1897
Lex->sql_command= SQLCOM_DROP_DB;
1898
Lex->drop_if_exists=$3;
1901
| DROP UDF_SYM ident
1903
Lex->sql_command = SQLCOM_DROP_FUNCTION;
1904
Lex->udf.name=$3.str;
1910
| table_list ',' table
1914
{ if (!add_table_to_list($1,NULL)) YYABORT; }
1917
/* empty */ { $$=0; }
1918
| IF EXISTS { $$= 1; }
1921
** Insert : add new data to table
1925
INSERT { Lex->sql_command = SQLCOM_INSERT; } insert_lock_option opt_ignore insert2 insert_field_spec
1928
REPLACE { Lex->sql_command = SQLCOM_REPLACE; } replace_lock_option insert2 insert_field_spec
1931
/* empty */ { Lex->lock_option= TL_WRITE_CONCURRENT_INSERT; }
1932
| LOW_PRIORITY { Lex->lock_option= TL_WRITE_LOW_PRIORITY; }
1933
| DELAYED_SYM { Lex->lock_option= TL_WRITE_DELAYED; }
1934
| HIGH_PRIORITY { Lex->lock_option= TL_WRITE; }
1936
replace_lock_option:
1938
| DELAYED_SYM { Lex->lock_option= TL_WRITE_DELAYED; }
1941
INTO insert_table {}
1947
Lex->field_list.empty();
1948
Lex->many_values.empty();
1953
opt_field_spec insert_values {}
1956
if (!(Lex->insert_list = new List_item) ||
1957
Lex->many_values.push_back(Lex->insert_list))
1964
| '(' fields ')' { }
1968
fields ',' insert_ident { Lex->field_list.push_back($3); }
1969
| insert_ident { Lex->field_list.push_back($1); }
1972
VALUES values_list {}
1976
lex->where=lex->having=0;
1977
lex->select_limit=current_thd->default_select_limit;
1978
lex->offset_limit=0L;
1980
lex->order_list.elements=lex->group_list.elements=0;
1981
lex->order_list.first=0;
1982
lex->order_list.next= (byte**) &lex->order_list.first;
1983
lex->group_list.first=0;
1984
lex->group_list.next= (byte**) &lex->group_list.first;
1985
lex->sql_command = (lex->sql_command == SQLCOM_INSERT ?
1986
SQLCOM_INSERT_SELECT : SQLCOM_REPLACE_SELECT);
1988
select_options select_item_list select_from {}
1991
values_list ',' no_braces
1995
ident_eq_list ',' ident_eq_value
2000
simple_ident equal expr
2002
if (Lex->field_list.push_back($1) ||
2003
Lex->insert_list->push_back($3))
2013
if (!(Lex->insert_list = new List_item))
2018
if (Lex->many_values.push_back(Lex->insert_list))
2029
if (Lex->insert_list->push_back($3))
2034
if (Lex->insert_list->push_back($1))
2038
/* Update rows in a table */
2041
UPDATE_SYM opt_low_priority opt_ignore table SET update_list where_clause delete_limit_clause
2042
{ Lex->sql_command = SQLCOM_UPDATE; }
2045
update_list ',' simple_ident equal expr
2047
if (add_item_to_list($3) || add_value_to_list($5))
2050
| simple_ident equal expr
2052
if (add_item_to_list($1) || add_value_to_list($3))
2057
/* empty */ { Lex->lock_option= current_thd->update_lock_default; }
2058
| LOW_PRIORITY { Lex->lock_option= TL_WRITE_LOW_PRIORITY; }
2060
/* Delete rows from a table */
2063
DELETE_SYM opt_low_priority FROM table where_clause delete_limit_clause
2064
{ Lex->sql_command= SQLCOM_DELETE; }
2069
show: SHOW { Lex->wild=0;} show_param
2073
{ Lex->sql_command= SQLCOM_SHOW_DATABASES; }
2074
| TABLES opt_db wild
2075
{ Lex->sql_command= SQLCOM_SHOW_TABLES; Lex->db= $2; Lex->options=0;}
2076
| TABLE_SYM STATUS_SYM opt_db wild
2077
{ Lex->sql_command= SQLCOM_SHOW_TABLES;
2078
Lex->options|= SELECT_DESCRIBE;
2081
| COLUMNS FROM table_ident opt_db wild
2083
Lex->sql_command= SQLCOM_SHOW_FIELDS;
2086
if (!add_table_to_list($3,NULL))
2089
| keys_or_index FROM table_ident opt_db
2091
Lex->sql_command= SQLCOM_SHOW_KEYS;
2094
if (!add_table_to_list($3,NULL))
2098
{ Lex->sql_command= SQLCOM_SHOW_STATUS; }
2100
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST; Lex->verbose=0; }
2101
| FULL PROCESSLIST_SYM
2102
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST; Lex->verbose=1; }
2104
{ Lex->sql_command= SQLCOM_SHOW_VARIABLES; }
2105
| GRANTS FOR_SYM user
2106
{ Lex->sql_command= SQLCOM_SHOW_GRANTS;
2107
Lex->grant_user=$3; Lex->grant_user->password.str=NullS; }
2108
| CREATE TABLE_SYM table_ident
2110
Lex->sql_command = SQLCOM_SHOW_CREATE;
2111
if(!add_table_to_list($3, NULL))
2114
| MASTER_SYM STATUS_SYM
2116
Lex->sql_command = SQLCOM_SHOW_MASTER_STAT;
2120
Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
2124
/* empty */ { $$= 0; }
2125
| FROM ident { $$= $2.str; }
2129
| LIKE text_string { Lex->wild= $2; }
2131
/* A Oracle compatible synonym for show */
2133
describe_command table_ident
2136
Lex->sql_command=SQLCOM_SHOW_FIELDS;
2137
if (!add_table_to_list($2, NULL))
2141
| describe_command select { Lex->options|= SELECT_DESCRIBE };
2148
opt_describe_column:
2150
| text_string { Lex->wild= $1; }
2151
| ident { Lex->wild= new String((const char*) $1.str,$1.length); }
2157
FLUSH_SYM {Lex->sql_command= SQLCOM_FLUSH; Lex->type=0; } flush_options
2160
flush_options ',' flush_option
2164
TABLES { Lex->type|= REFRESH_TABLES; }
2165
| TABLES WITH READ_SYM LOCK_SYM { Lex->type|= REFRESH_TABLES | REFRESH_READ_LOCK; }
2166
| HOSTS_SYM { Lex->type|= REFRESH_HOSTS; }
2167
| PRIVILEGES { Lex->type|= REFRESH_GRANT; }
2168
| LOGS_SYM { Lex->type|= REFRESH_LOG; }
2169
| STATUS_SYM { Lex->type|= REFRESH_STATUS; }
2170
| SLAVE { Lex->type|= REFRESH_SLAVE; }
2171
| MASTER_SYM { Lex->type|= REFRESH_MASTER; }
2178
Lex->sql_command=SQLCOM_KILL;
2179
Lex->thread_id= (ulong) strtoul($2.str,NULL,10);
2182
/* change database */
2185
{ Lex->sql_command=SQLCOM_CHANGE_DB; Lex->db= $2.str; }
2187
/* import, export of files */
2189
load: LOAD DATA_SYM opt_low_priority opt_local INFILE TEXT_STRING
2191
Lex->sql_command= SQLCOM_LOAD;
2192
Lex->local_file= $4;
2193
if (!(Lex->exchange= new sql_exchange($6.str,0)))
2195
Lex->field_list.empty();
2197
opt_duplicate INTO TABLE_SYM table_ident opt_field_term opt_line_term
2198
opt_ignore_lines opt_field_spec
2200
if (!add_table_to_list($11,NULL))
2204
LOAD TABLE_SYM table_ident FROM MASTER_SYM
2206
Lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
2207
if (!add_table_to_list($3,NULL))
2213
/* empty */ { $$=0;}
2214
| LOCAL_SYM { $$=1;}
2217
/* empty */ { Lex->duplicates=DUP_ERROR; }
2218
| REPLACE { Lex->duplicates=DUP_REPLACE; }
2219
| IGNORE_SYM { Lex->duplicates=DUP_IGNORE; }
2223
| COLUMNS field_term_list
2226
field_term_list field_term
2230
TERMINATED BY text_string { Lex->exchange->field_term= $3;}
2231
| OPTIONALLY ENCLOSED BY text_string
2232
{ Lex->exchange->enclosed= $4; Lex->exchange->opt_enclosed=1;}
2233
| ENCLOSED BY text_string { Lex->exchange->enclosed= $3;}
2234
| ESCAPED BY text_string { Lex->exchange->escaped= $3;}
2238
| LINES line_term_list
2241
line_term_list line_term
2245
TERMINATED BY text_string { Lex->exchange->line_term= $3;}
2246
| STARTING BY text_string { Lex->exchange->line_start= $3;}
2250
| IGNORE_SYM NUM LINES
2251
{ Lex->exchange->skip_lines=atol($2.str); }
2253
/* Common definitions */
2256
TEXT_STRING { $$ = new Item_string($1.str,$1.length); }
2257
| text_literal TEXT_STRING
2258
{ ((Item_string*) $1)->append($2.str,$2.length); }
2261
TEXT_STRING { $$= new String($1.str,$1.length); }
2264
Item *tmp = new Item_varbinary($1.str,$1.length);
2265
$$= tmp ? tmp->val_str((String*) 0) : (String*) 0;
2269
text_literal { $$ = $1; }
2270
| NUM { $$ = new Item_int($1.str, (longlong) atol($1.str),$1.length); }
2271
| LONG_NUM { $$ = new Item_int($1.str); }
2272
| REAL_NUM { $$ = new Item_real($1.str, $1.length); }
2273
| FLOAT_NUM { $$ = new Item_float($1.str, $1.length); }
2274
| NULL_SYM { $$ = new Item_null();
2275
Lex->next_state=STATE_OPERATOR_OR_IDENT;}
2276
| HEX_NUM { $$ = new Item_varbinary($1.str,$1.length)};
2277
| DATE_SYM text_literal { $$ = $2; }
2278
| TIME_SYM text_literal { $$ = $2; }
2279
| TIMESTAMP text_literal { $$ = $2; }
2281
/**********************************************************************
2282
** Createing different items.
2283
**********************************************************************/
2286
simple_ident { $$=$1; }
2287
| table_wild { $$=$1; }
2290
ident '.' '*' { $$ = new Item_field(NullS,$1.str,"*"); }
2291
| ident '.' ident '.' '*'
2292
{ $$ = new Item_field((current_thd->client_capabilities & CLIENT_NO_SCHEMA ? NullS : $1.str),$3.str,"*"); }
2302
{ $$ = !Lex->create_refs || Lex->in_sum_expr > 0 ? (Item*) new Item_field(NullS,NullS,$1.str) : (Item*) new Item_ref(NullS,NullS,$1.str); }
2304
{ $$ = !Lex->create_refs || Lex->in_sum_expr > 0 ? (Item*) new Item_field(NullS,$1.str,$3.str) : (Item*) new Item_ref(NullS,$1.str,$3.str); }
2305
| '.' ident '.' ident
2306
{ $$ = !Lex->create_refs || Lex->in_sum_expr > 0 ? (Item*) new Item_field(NullS,$2.str,$4.str) : (Item*) new Item_ref(NullS,$2.str,$4.str); }
2307
| ident '.' ident '.' ident
2308
{ $$ = !Lex->create_refs || Lex->in_sum_expr > 0 ? (Item*) new Item_field((current_thd->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str) : (Item*) new Item_ref((current_thd->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str); }
2313
| ident '.' ident { $$=$3;} /* Skipp schema name in create*/
2314
| '.' ident { $$=$2;} /* For Delphi */
2317
ident { $$=new Table_ident($1); }
2318
| ident '.' ident { $$=new Table_ident($1,$3,0);}
2319
| '.' ident { $$=new Table_ident($2);} /* For Delphi */
2325
$$.str=sql_strmake($1.str,$1.length);
2326
$$.length=$1.length;
2327
if (Lex->next_state != STATE_END)
2328
Lex->next_state=STATE_OPERATOR_OR_IDENT;
2333
| TEXT_STRING { $$=$1;}
2334
| LEX_HOSTNAME { $$=$1;}
2339
if (!($$=(LEX_USER*) sql_alloc(sizeof(st_lex_user))))
2341
$$->user = $1; $$->host.str=NullS;
2343
| ident_or_text '@' ident_or_text
2345
if (!($$=(LEX_USER*) sql_alloc(sizeof(st_lex_user))))
2347
$$->user = $1; $$->host=$3;
2350
/* Keyword that we allow for identifiers */
2371
| DELAY_KEY_WRITE_SYM {}
2393
| MASTER_HOST_SYM {}
2394
| MASTER_PORT_SYM {}
2395
| MASTER_LOG_FILE_SYM {}
2396
| MASTER_LOG_POS_SYM {}
2397
| MASTER_USER_SYM {}
2398
| MASTER_PASSWORD_SYM {}
2399
| MASTER_CONNECT_RETRY_SYM {}
2412
| PROCESSLIST_SYM {}
2416
| RAID_STRIPED_SYM {}
2442
/* Option functions */
2447
Lex->sql_command= SQLCOM_SET_OPTION;
2448
Lex->options=current_thd->options;
2449
Lex->select_limit=current_thd->default_select_limit;
2459
| option_value_list ',' option_value
2462
set_option equal NUM
2464
if (atoi($3.str) == 0)
2469
| SQL_SELECT_LIMIT equal ULONG_NUM
2471
Lex->select_limit= $3;
2473
| SQL_SELECT_LIMIT equal DEFAULT
2475
Lex->select_limit= HA_POS_ERROR;
2477
| SQL_MAX_JOIN_SIZE equal ULONG_NUM
2479
current_thd->max_join_size= $3;
2480
Lex->options&= ~OPTION_BIG_SELECTS;
2482
| SQL_MAX_JOIN_SIZE equal DEFAULT
2484
current_thd->max_join_size= HA_POS_ERROR;
2486
| TIMESTAMP equal ULONG_NUM
2488
current_thd->set_time((time_t) $3);
2490
| TIMESTAMP equal DEFAULT
2492
current_thd->user_time=0;
2494
| LAST_INSERT_ID equal ULONGLONG_NUM
2496
current_thd->insert_id($3);
2498
| INSERT_ID equal ULONGLONG_NUM
2500
current_thd->next_insert_id=$3;
2502
| CHAR_SYM SET IDENT
2505
if (!(tmp=get_convert_set($3.str)))
2507
net_printf(¤t_thd->net,ER_UNKNOWN_CHARACTER_SET,$3);
2510
current_thd->convert_set=tmp;
2512
| CHAR_SYM SET DEFAULT
2514
current_thd->convert_set=0;
2516
| PASSWORD equal text_or_password
2518
if (change_password(current_thd,current_thd->host,
2519
current_thd->priv_user,$3))
2522
| PASSWORD FOR_SYM user equal text_or_password
2524
if (change_password(current_thd,
2525
$3->host.str ? $3->host.str : current_thd->host,
2529
| '@' ident_or_text equal expr
2531
Item_func_set_user_var *item = new Item_func_set_user_var($2,$4);
2532
if (item->fix_fields(current_thd,0) || item->update())
2537
TEXT_STRING { $$=$1.str;}
2538
| PASSWORD '(' TEXT_STRING ')'
2544
char *buff=(char*) sql_alloc(HASH_PASSWORD_LENGTH+1);
2545
make_scrambled_password(buff,$3.str);
2551
SQL_BIG_TABLES { $$= OPTION_BIG_TABLES; }
2552
| AUTOCOMMIT { $$= OPTION_AUTO_COMMIT; }
2553
| SQL_BIG_SELECTS { $$= OPTION_BIG_SELECTS; }
2554
| SQL_LOG_OFF { $$= OPTION_LOG_OFF; }
2557
$$= (opt_sql_bin_update)? OPTION_UPDATE_LOG|OPTION_BIN_LOG: OPTION_UPDATE_LOG ;
2561
$$= (opt_sql_bin_update)? OPTION_UPDATE_LOG|OPTION_BIN_LOG: OPTION_BIN_LOG ;
2563
| SQL_WARNINGS { $$= OPTION_WARNINGS; }
2564
| SQL_LOW_PRIORITY_UPDATES { $$= OPTION_LOW_PRIORITY_UPDATES; }
2565
| SQL_AUTO_IS_NULL { $$= OPTION_AUTO_IS_NULL; }
2566
| SQL_SAFE_UPDATES { $$= OPTION_SAFE_UPDATES; }
2567
| SQL_BUFFER_RESULT { $$= OPTION_BUFFER_RESULT; }
2572
LOCK_SYM table_or_tables
2574
Lex->sql_command=SQLCOM_LOCK_TABLES;
2584
| table_lock_list ',' table_lock
2587
table_ident opt_table_alias lock_option
2588
{ if (!add_table_to_list($1,$2,(thr_lock_type) $3)) YYABORT; }
2591
READ_SYM { $$=TL_READ_NO_INSERT; }
2592
| WRITE_SYM { $$=current_thd->update_lock_default; }
2593
| LOW_PRIORITY WRITE_SYM { $$=TL_WRITE_LOW_PRIORITY; }
2594
| READ_SYM LOCAL_SYM { $$= TL_READ; }
2597
UNLOCK_SYM table_or_tables { Lex->sql_command=SQLCOM_UNLOCK_TABLES; }
2600
/* GRANT / REVOKE */
2605
Lex->sql_command = SQLCOM_REVOKE;
2606
Lex->users_list.empty();
2607
Lex->columns.empty();
2608
Lex->grant= Lex->grant_tot_col=0;
2611
grant_privileges ON opt_table FROM user_list
2616
Lex->sql_command = SQLCOM_GRANT;
2617
Lex->users_list.empty();
2618
Lex->columns.empty();
2619
Lex->grant= Lex->grant_tot_col=0;
2622
grant_privileges ON opt_table TO_SYM user_list
2626
grant_privilege_list {}
2627
| ALL PRIVILEGES { Lex->grant = UINT_MAX;}
2628
| ALL { Lex->grant = UINT_MAX;}
2630
grant_privilege_list:
2632
| grant_privilege_list ',' grant_privilege
2636
{ Lex->which_columns = SELECT_ACL;}
2639
{ Lex->which_columns = INSERT_ACL; }
2642
{ Lex->which_columns = UPDATE_ACL; }
2644
| DELETE_SYM { Lex->grant |= DELETE_ACL;}
2645
| REFERENCES { Lex->which_columns = REFERENCES_ACL;} opt_column_list
2647
| INDEX { Lex->grant |= INDEX_ACL;}
2648
| ALTER { Lex->grant |= ALTER_ACL;}
2649
| CREATE { Lex->grant |= CREATE_ACL;}
2650
| DROP { Lex->grant |= DROP_ACL;}
2651
| RELOAD { Lex->grant |= RELOAD_ACL;}
2652
| SHUTDOWN { Lex->grant |= SHUTDOWN_ACL;}
2653
| PROCESS { Lex->grant |= PROCESS_ACL;}
2654
| FILE_SYM { Lex->grant |= FILE_ACL;}
2655
| GRANT OPTION { Lex->grant |= GRANT_ACL;}
2660
Lex->db=current_thd->db;
2661
if (Lex->grant == UINT_MAX)
2662
Lex->grant = DB_ACLS & ~GRANT_ACL;
2663
else if (Lex->columns.elements)
2665
net_printf(¤t_thd->net,ER_ILLEGAL_GRANT_FOR_TABLE);
2672
if (Lex->grant == UINT_MAX)
2673
Lex->grant = DB_ACLS & ~GRANT_ACL;
2674
else if (Lex->columns.elements)
2676
net_printf(¤t_thd->net,ER_ILLEGAL_GRANT_FOR_TABLE);
2683
if (Lex->grant == UINT_MAX)
2684
Lex->grant = GLOBAL_ACLS & ~GRANT_ACL;
2685
else if (Lex->columns.elements)
2687
net_printf(¤t_thd->net,ER_ILLEGAL_GRANT_FOR_TABLE);
2693
if (!add_table_to_list($1,NULL))
2695
if (Lex->grant == UINT_MAX)
2696
Lex->grant = TABLE_ACLS & ~GRANT_ACL;
2701
grant_user { if (Lex->users_list.push_back($1)) YYABORT;}
2702
| user_list ',' grant_user { if (Lex->users_list.push_back($3)) YYABORT;}
2706
user IDENTIFIED_SYM BY TEXT_STRING
2708
$$=$1; $1->password=$4;
2711
char *buff=(char*) sql_alloc(HASH_PASSWORD_LENGTH+1);
2714
make_scrambled_password(buff,$4.str);
2715
$1->password.str=buff;
2716
$1->password.length=HASH_PASSWORD_LENGTH;
2720
| user IDENTIFIED_SYM BY PASSWORD TEXT_STRING
2721
{ $$=$1; $1->password=$5 ; }
2723
{ $$=$1; $1->password.str=NullS; }
2727
/* empty */ { Lex->grant |= Lex->which_columns; }
2728
| '(' column_list ')'
2731
column_list ',' column_list_id
2737
String *new_str = new String((const char*) $1.str,$1.length);
2738
List_iterator <LEX_COLUMN> iter(Lex->columns);
2739
class LEX_COLUMN *point;
2740
while ((point=iter++))
2742
if (!my_strcasecmp(point->column.ptr(),new_str->ptr()))
2745
Lex->grant_tot_col|= Lex->which_columns;
2747
point->rights |= Lex->which_columns;
2749
Lex->columns.push_back(new LEX_COLUMN (*new_str,Lex->which_columns));
2754
| WITH GRANT OPTION { Lex->grant |= GRANT_ACL;}
2757
BEGIN_SYM { Lex->sql_command = SQLCOM_COMMIT;} opt_work
2764
COMMIT_SYM { Lex->sql_command = SQLCOM_COMMIT;}
2767
ROLLBACK_SYM { Lex->sql_command = SQLCOM_ROLLBACK;}