summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-05-17 10:05:07 +0300
committerunknown <bell@sanja.is.com.ua>2003-05-17 10:05:07 +0300
commitacda3d79b6f16441375171dfc58a78b85d313eff (patch)
treec9fa69ab2da8ee1dc3cc3ea759cd3fa02bef9aca /sql/sql_yacc.yy
parentddabd51c5738bf3bd9f0f40d7368bd3eee92e966 (diff)
downloadmariadb-git-acda3d79b6f16441375171dfc58a78b85d313eff.tar.gz
fixed memory overrun (bug 380)
mysql-test/r/func_group.result: new tests mysql-test/t/func_group.test: new tests sql/item.cc: count items in select list sql/item_subselect.cc: use number of item in select list for array creation sql/item_sum.cc: with_sum_func now is boolean sql/sql_derived.cc: use number of item in select list for array creation sql/sql_lex.cc: create_refs changed with parsing_place enum variable sql/sql_lex.h: added items in select list counter create_refs changed with parsing_place enum variable with_sum_func now is boolean sql/sql_select.cc: use number of item in select list for array creation sql/sql_union.cc: use number of item in select list for array creation sql/sql_yacc.yy: create_refs changed with parsing_place enum variable
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy54
1 files changed, 45 insertions, 9 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index ad60270ccb3..12482d98220 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -925,8 +925,13 @@ create3:
LEX *lex=Lex;
lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ;
mysql_init_select(lex);
+ lex->current_select->parsing_place= SELECT_LEX_NODE::SELECT_LIST;
}
- select_options select_item_list opt_select_from union_clause {}
+ select_options select_item_list
+ {
+ Select->parsing_place= SELECT_LEX_NODE::NO_MATTER;
+ }
+ opt_select_from union_clause {}
;
opt_as:
@@ -1883,8 +1888,13 @@ select_part2:
lex->lock_option= TL_READ; /* Only for global SELECT */
if (sel->linkage != UNION_TYPE)
mysql_init_select(lex);
+ lex->current_select->parsing_place= SELECT_LEX_NODE::SELECT_LIST;
+ }
+ select_options select_item_list
+ {
+ Select->parsing_place= SELECT_LEX_NODE::NO_MATTER;
}
- select_options select_item_list select_into select_lock_type;
+ select_into select_lock_type;
select_into:
opt_limit_clause {}
@@ -2917,10 +2927,15 @@ where_clause:
having_clause:
/* empty */
- | HAVING { Select->select_lex()->create_refs= 1; } expr
+ | HAVING
+ {
+ Select->select_lex()->parsing_place= SELECT_LEX_NODE::IN_HAVING;
+ }
+ expr
{
SELECT_LEX *sel= Select->select_lex();
- sel->having= $3; sel->create_refs=0;
+ sel->having= $3;
+ sel->parsing_place= SELECT_LEX_NODE::NO_MATTER;
if ($3)
$3->top_level_item();
}
@@ -3348,8 +3363,13 @@ insert_values:
SQLCOM_INSERT_SELECT : SQLCOM_REPLACE_SELECT);
lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ;
mysql_init_select(lex);
+ lex->current_select->parsing_place= SELECT_LEX_NODE::SELECT_LIST;
+ }
+ select_options select_item_list
+ {
+ Select->parsing_place= SELECT_LEX_NODE::NO_MATTER;
}
- select_options select_item_list opt_select_from select_lock_type
+ opt_select_from select_lock_type
union_clause {}
;
@@ -4030,7 +4050,10 @@ simple_ident:
ident
{
SELECT_LEX_NODE *sel=Select;
- $$ = !sel->create_refs || sel->get_in_sum_expr() > 0 ? (Item*) new Item_field(NullS,NullS,$1.str) : (Item*) new Item_ref(NullS,NullS,$1.str);
+ $$= (sel->parsing_place != SELECT_LEX_NODE::IN_HAVING ||
+ sel->get_in_sum_expr() > 0) ?
+ (Item*) new Item_field(NullS,NullS,$1.str) :
+ (Item*) new Item_ref(NullS,NullS,$1.str);
}
| ident '.' ident
{
@@ -4043,7 +4066,10 @@ simple_ident:
ER(ER_TABLENAME_NOT_ALLOWED_HERE),
MYF(0), $1.str, thd->where);
}
- $$ = !sel->create_refs || sel->get_in_sum_expr() > 0 ? (Item*) new Item_field(NullS,$1.str,$3.str) : (Item*) new Item_ref(NullS,$1.str,$3.str);
+ $$= (sel->parsing_place != SELECT_LEX_NODE::IN_HAVING ||
+ sel->get_in_sum_expr() > 0) ?
+ (Item*) new Item_field(NullS,$1.str,$3.str) :
+ (Item*) new Item_ref(NullS,$1.str,$3.str);
}
| '.' ident '.' ident
{
@@ -4056,7 +4082,10 @@ simple_ident:
ER(ER_TABLENAME_NOT_ALLOWED_HERE),
MYF(0), $2.str, thd->where);
}
- $$ = !sel->create_refs || sel->get_in_sum_expr() > 0 ? (Item*) new Item_field(NullS,$2.str,$4.str) : (Item*) new Item_ref(NullS,$2.str,$4.str);
+ $$= (sel->parsing_place != SELECT_LEX_NODE::IN_HAVING ||
+ sel->get_in_sum_expr() > 0) ?
+ (Item*) new Item_field(NullS,$2.str,$4.str) :
+ (Item*) new Item_ref(NullS,$2.str,$4.str);
}
| ident '.' ident '.' ident
{
@@ -4069,7 +4098,14 @@ simple_ident:
ER(ER_TABLENAME_NOT_ALLOWED_HERE),
MYF(0), $3.str, thd->where);
}
- $$ = !sel->create_refs || sel->get_in_sum_expr() > 0 ? (Item*) new Item_field((YYTHD->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str) : (Item*) new Item_ref((YYTHD->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str);
+ $$= (sel->parsing_place != SELECT_LEX_NODE::IN_HAVING ||
+ sel->get_in_sum_expr() > 0) ?
+ (Item*) new Item_field((YYTHD->client_capabilities &
+ CLIENT_NO_SCHEMA ? NullS : $1.str),
+ $3.str, $5.str) :
+ (Item*) new Item_ref((YYTHD->client_capabilities &
+ CLIENT_NO_SCHEMA ? NullS : $1.str),
+ $3.str, $5.str);
};