summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-10-29 19:26:52 +0300
committerunknown <monty@mysql.com>2004-10-29 19:26:52 +0300
commitf095274fe8c3d3394d6c0ce0a68f4bea04311999 (patch)
tree23bcc9a71fe7237887a111b158e30f5a6bb665d3 /sql/sql_yacc.yy
parentf41bba8c6156a7adf4c67dfa75e16112767a5d3c (diff)
parent5be6c328f5a9f78f37176bbbd88a538fa3b65fe9 (diff)
downloadmariadb-git-f095274fe8c3d3394d6c0ce0a68f4bea04311999.tar.gz
merge with 4.1
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/triggers/post-commit: Auto merged Docs/Support/texi2html: Auto merged Makefile.am: Auto merged client/Makefile.am: Auto merged client/mysql.cc: Auto merged client/mysqldump.c: Auto merged include/my_base.h: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/my_time.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/buf/buf0buf.c: Auto merged innobase/include/row0mysql.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/examples/Makefile.am: Auto merged myisam/mi_check.c: Auto merged mysql-test/include/ps_modify.inc: Auto merged mysql-test/install_test_db.sh: Auto merged mysql-test/r/alter_table.result: Auto merged mysql-test/r/auto_increment.result: Auto merged mysql-test/r/bdb.result: Auto merged mysql-test/r/ctype_latin1_de.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_if.result: Auto merged mysql-test/t/derived.test: Auto merged mysql-test/t/insert.test: merge with 4.1 Fixed test case to not use 'if exists' when it shouldn't mysql-test/t/range.test: merge with 4.1 Added missing drop table sql/ha_ndbcluster.cc: merge with 4.1 Simple optimization: use max() instead of ? : sql/item_func.cc: merge with 4.1 (Added back old variable names for easier merges) sql/opt_range.cc: merge with 4.1 Removed argument 'parent_alloc' from QUICK_RANGE_SELECT as this was not used Added assert if using QUICK_GROUP_MIN_MAX_SELECT with parent_alloc as the init() function can't handle this Changed back get_quick_select_for_ref() to use it's own alloc root becasue this function may be called several times for one query sql/sql_handler.cc: merge with 4.1 change variable 'err' to 'error' as same function had a label named 'err' sql/sql_update.cc: Use multi-update code from 5.0 instead of 4.1 We will fix the locking code shortly in 5.0 to be faster than in 4.1
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy149
1 files changed, 100 insertions, 49 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index d792d144545..bdda1f6fa07 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -917,14 +917,14 @@ prepare_src:
THD *thd=YYTHD;
LEX *lex= thd->lex;
lex->prepared_stmt_code= $1;
- lex->prepared_stmt_code_is_varref= false;
+ lex->prepared_stmt_code_is_varref= FALSE;
}
| '@' ident_or_text
{
THD *thd=YYTHD;
LEX *lex= thd->lex;
lex->prepared_stmt_code= $2;
- lex->prepared_stmt_code_is_varref= true;
+ lex->prepared_stmt_code_is_varref= TRUE;
};
execute:
@@ -2388,20 +2388,20 @@ trg_event:
;
create2:
- '(' create2a {}
- | opt_create_table_options create3 {}
- | LIKE table_ident
- {
- LEX *lex=Lex;
- if (!(lex->name= (char *)$2))
+ '(' create2a {}
+ | opt_create_table_options create3 {}
+ | LIKE table_ident
+ {
+ LEX *lex=Lex;
+ if (!(lex->name= (char *)$2))
YYABORT;
- }
- | '(' LIKE table_ident ')'
- {
- LEX *lex=Lex;
- if (!(lex->name= (char *)$3))
+ }
+ | '(' LIKE table_ident ')'
+ {
+ LEX *lex=Lex;
+ if (!(lex->name= (char *)$3))
YYABORT;
- }
+ }
;
create2a:
@@ -2739,10 +2739,21 @@ type:
if (YYTHD->variables.sql_mode & MODE_MAXDB)
$$=FIELD_TYPE_DATETIME;
else
+ {
+ /*
+ Unlike other types TIMESTAMP fields are NOT NULL by default.
+ */
+ Lex->type|= NOT_NULL_FLAG;
$$=FIELD_TYPE_TIMESTAMP;
+ }
}
- | TIMESTAMP '(' NUM ')' { Lex->length=$3.str;
- $$=FIELD_TYPE_TIMESTAMP; }
+ | TIMESTAMP '(' NUM ')'
+ {
+ LEX *lex= Lex;
+ lex->length= $3.str;
+ lex->type|= NOT_NULL_FLAG;
+ $$= FIELD_TYPE_TIMESTAMP;
+ }
| DATETIME { $$=FIELD_TYPE_DATETIME; }
| TINYBLOB { Lex->charset=&my_charset_bin;
$$=FIELD_TYPE_TINY_BLOB; }
@@ -3130,7 +3141,17 @@ key_list:
key_part:
ident { $$=new key_part_spec($1.str); }
- | ident '(' NUM ')' { $$=new key_part_spec($1.str,(uint) atoi($3.str)); };
+ | ident '(' NUM ')'
+ {
+ int key_part_len= atoi($3.str);
+ if (!key_part_len)
+ {
+ my_printf_error(ER_UNKNOWN_ERROR,
+ "Key part '%s' length cannot be 0",
+ MYF(0), $1.str);
+ }
+ $$=new key_part_spec($1.str,(uint) key_part_len);
+ };
opt_ident:
/* empty */ { $$=(char*) 0; } /* Defaultlength */
@@ -4242,7 +4263,7 @@ simple_expr:
| CONCAT '(' expr_list ')'
{ $$= new Item_func_concat(* $3); }
| CONCAT_WS '(' expr ',' expr_list ')'
- { $$= new Item_func_concat_ws($3, *$5); }
+ { $5->push_front($3); $$= new Item_func_concat_ws(*$5); }
| CONTAINS_SYM '(' expr ',' expr ')'
{ $$= create_func_contains($3, $5); }
| CONVERT_TZ_SYM '(' expr ',' expr ',' expr ')'
@@ -5395,15 +5416,11 @@ select_var_ident:
into:
INTO OUTFILE TEXT_STRING_sys
{
- LEX *lex=Lex;
- if (!lex->describe)
- {
- lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
- if (!(lex->exchange= new sql_exchange($3.str,0)))
- YYABORT;
- if (!(lex->result= new select_export(lex->exchange)))
- YYABORT;
- }
+ LEX *lex= Lex;
+ lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
+ if (!(lex->exchange= new sql_exchange($3.str, 0)) ||
+ !(lex->result= new select_export(lex->exchange)))
+ YYABORT;
}
opt_field_term opt_line_term
| INTO DUMPFILE TEXT_STRING_sys
@@ -5702,14 +5719,18 @@ expr_or_default:
opt_insert_update:
/* empty */
| ON DUPLICATE_SYM
- { /* for simplisity, let's forget about
- INSERT ... SELECT ... UPDATE
- for a moment */
- if (Lex->sql_command != SQLCOM_INSERT)
+ {
+ LEX *lex= Lex;
+ /*
+ For simplicity, let's forget about INSERT ... SELECT ... UPDATE
+ for a moment.
+ */
+ if (lex->sql_command != SQLCOM_INSERT)
{
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
}
+ lex->duplicates= DUP_UPDATE;
}
KEY_SYM UPDATE_SYM update_list
;
@@ -5725,12 +5746,14 @@ update:
lex->lock_option= TL_UNLOCK; /* Will be set later */
}
opt_low_priority opt_ignore join_table_list
- SET update_list where_clause opt_order_clause delete_limit_clause
+ SET update_list
{
LEX *lex= Lex;
- Select->set_lock_for_tables($3);
if (lex->select_lex.table_list.elements > 1)
+ {
lex->sql_command= SQLCOM_UPDATE_MULTI;
+ lex->multi_lock_option= $3;
+ }
else if (lex->select_lex.get_table_list()->derived)
{
/* it is single table update and it is update of derived table */
@@ -5738,7 +5761,10 @@ update:
lex->select_lex.get_table_list()->alias, "UPDATE");
YYABORT;
}
+ else
+ Select->set_lock_for_tables($3);
}
+ where_clause opt_order_clause delete_limit_clause {}
;
update_list:
@@ -6319,15 +6345,28 @@ field_term_list:
| field_term;
field_term:
- TERMINATED BY text_string { Lex->exchange->field_term= $3;}
+ TERMINATED BY text_string
+ {
+ DBUG_ASSERT(Lex->exchange);
+ Lex->exchange->field_term= $3;
+ }
| OPTIONALLY ENCLOSED BY text_string
{
- LEX *lex=Lex;
- lex->exchange->enclosed= $4;
- lex->exchange->opt_enclosed=1;
+ LEX *lex= Lex;
+ DBUG_ASSERT(lex->exchange);
+ lex->exchange->enclosed= $4;
+ lex->exchange->opt_enclosed= 1;
}
- | ENCLOSED BY text_string { Lex->exchange->enclosed= $3;}
- | ESCAPED BY text_string { Lex->exchange->escaped= $3;};
+ | ENCLOSED BY text_string
+ {
+ DBUG_ASSERT(Lex->exchange);
+ Lex->exchange->enclosed= $3;
+ }
+ | ESCAPED BY text_string
+ {
+ DBUG_ASSERT(Lex->exchange);
+ Lex->exchange->escaped= $3;
+ };
opt_line_term:
/* empty */
@@ -6338,13 +6377,24 @@ line_term_list:
| line_term;
line_term:
- TERMINATED BY text_string { Lex->exchange->line_term= $3;}
- | STARTING BY text_string { Lex->exchange->line_start= $3;};
+ TERMINATED BY text_string
+ {
+ DBUG_ASSERT(Lex->exchange);
+ Lex->exchange->line_term= $3;
+ }
+ | STARTING BY text_string
+ {
+ DBUG_ASSERT(Lex->exchange);
+ Lex->exchange->line_start= $3;
+ };
opt_ignore_lines:
/* empty */
- | IGNORE_SYM NUM LINES
- { Lex->exchange->skip_lines=atol($2.str); };
+ | IGNORE_SYM NUM LINES
+ {
+ DBUG_ASSERT(Lex->exchange);
+ Lex->exchange->skip_lines= atol($2.str);
+ };
/* Common definitions */
@@ -6505,7 +6555,7 @@ simple_ident:
$$= (sel->parsing_place != IN_HAVING ||
sel->get_in_sum_expr() > 0) ?
(Item*) new Item_field(NullS,NullS,$1.str) :
- (Item*) new Item_ref(0,0, NullS,NullS,$1.str);
+ (Item*) new Item_ref(NullS,NullS,$1.str);
}
}
| simple_ident_q { $$= $1; }
@@ -6518,7 +6568,7 @@ simple_ident_nospvar:
$$= (sel->parsing_place != IN_HAVING ||
sel->get_in_sum_expr() > 0) ?
(Item*) new Item_field(NullS,NullS,$1.str) :
- (Item*) new Item_ref(0,0,NullS,NullS,$1.str);
+ (Item*) new Item_ref(NullS,NullS,$1.str);
}
| simple_ident_q { $$= $1; }
;
@@ -6588,7 +6638,7 @@ simple_ident_q:
$$= (sel->parsing_place != IN_HAVING ||
sel->get_in_sum_expr() > 0) ?
(Item*) new Item_field(NullS,$1.str,$3.str) :
- (Item*) new Item_ref(0,0,NullS,$1.str,$3.str);
+ (Item*) new Item_ref(NullS,$1.str,$3.str);
}
}
| '.' ident '.' ident
@@ -6605,7 +6655,7 @@ simple_ident_q:
$$= (sel->parsing_place != IN_HAVING ||
sel->get_in_sum_expr() > 0) ?
(Item*) new Item_field(NullS,$2.str,$4.str) :
- (Item*) new Item_ref(0,0,NullS,$2.str,$4.str);
+ (Item*) new Item_ref(NullS, $2.str, $4.str);
}
| ident '.' ident '.' ident
{
@@ -6623,8 +6673,8 @@ simple_ident_q:
(Item*) new Item_field((YYTHD->client_capabilities &
CLIENT_NO_SCHEMA ? NullS : $1.str),
$3.str, $5.str) :
- (Item*) new Item_ref(0,0,(YYTHD->client_capabilities &
- CLIENT_NO_SCHEMA ? NullS : $1.str),
+ (Item*) new Item_ref((YYTHD->client_capabilities &
+ CLIENT_NO_SCHEMA ? NullS : $1.str),
$3.str, $5.str);
};
@@ -6958,6 +7008,7 @@ keyword:
| TIME_SYM {}
| TYPE_SYM {}
| TYPES_SYM {}
+ | UDF_RETURNS_SYM {}
| FUNCTION_SYM {}
| UNCOMMITTED_SYM {}
| UNDEFINED_SYM {}