Commit 4df2e3bf authored by Sinisa@sinisa.nasamreza.org's avatar Sinisa@sinisa.nasamreza.org

Merge sinisa@work.mysql.com:/home/bk/mysql-4.1

into sinisa.nasamreza.org:/mnt/work/mysql-4.1
parents b79a4c01 97990887
...@@ -3266,3 +3266,13 @@ select wss_type from t1 where wss_type =102935229216544093; ...@@ -3266,3 +3266,13 @@ select wss_type from t1 where wss_type =102935229216544093;
wss_type wss_type
102935229216544093 102935229216544093
drop table t1; drop table t1;
select 1+2,"aaaa",3.13*2.0 into @a,@b,@c;
select @a;
@a
3
select @b;
@b
aaaa
select @c;
@c
6.26
...@@ -1751,3 +1751,7 @@ select wss_type from t1 where wss_type ='102935229216544104'; ...@@ -1751,3 +1751,7 @@ select wss_type from t1 where wss_type ='102935229216544104';
select wss_type from t1 where wss_type ='102935229216544093'; select wss_type from t1 where wss_type ='102935229216544093';
select wss_type from t1 where wss_type =102935229216544093; select wss_type from t1 where wss_type =102935229216544093;
drop table t1; drop table t1;
select 1+2,"aaaa",3.13*2.0 into @a,@b,@c;
select @a;
select @b;
select @c;
...@@ -912,3 +912,47 @@ bool select_exists_subselect::send_data(List<Item> &items) ...@@ -912,3 +912,47 @@ bool select_exists_subselect::send_data(List<Item> &items)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/***************************************************************************
** Dump of select to variables
***************************************************************************/
bool select_dumpvar::send_data(List<Item> &items)
{
List_iterator_fast<Item> li(items);
List_iterator_fast<LEX_STRING> gl(current_thd->lex.select_into_var_list);
Item *item;
LEX_STRING *ls;
DBUG_ENTER("send_data");
if (row_count++ > 1)
{
my_error(ER_TOO_MANY_ROWS, MYF(0));
goto err;
}
while ((item=li++) && (ls=gl++))
{
Item_func_set_user_var *xx = new Item_func_set_user_var(*ls,item);
xx->fix_fields(current_thd,(TABLE_LIST*) current_thd->lex.select_lex.table_list.first,&item);
xx->fix_length_and_dec();
xx->update();
}
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
}
bool select_dumpvar::send_eof()
{
if (row_count)
{
::send_ok(thd,row_count);
return 0;
}
else
{
my_error(ER_EMPTY_QUERY,MYF(0));
return 1;
}
}
...@@ -966,3 +966,25 @@ public: ...@@ -966,3 +966,25 @@ public:
bool send_eof(); bool send_eof();
}; };
class select_dumpvar :public select_result {
ha_rows row_count;
public:
select_dumpvar(void) { row_count=0;}
~select_dumpvar() {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u) { return 0;}
bool send_fields(List<Item> &list, uint flag)
{
if (current_thd->lex.select_into_var_list.elements != list.elements)
{
my_error(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, MYF(0));
return 1;
}
return 0;
}
bool send_data(List<Item> &items);
void send_error(uint errcode,const char *err)
{
my_message(errcode, err, MYF(0));
}
bool send_eof();
};
...@@ -347,6 +347,7 @@ typedef struct st_lex ...@@ -347,6 +347,7 @@ typedef struct st_lex
List<List_item> many_values; List<List_item> many_values;
List<set_var_base> var_list; List<set_var_base> var_list;
List<Item> param_list; List<Item> param_list;
List<LEX_STRING> select_into_var_list;
SQL_LIST proc_list, auxilliary_table_list; SQL_LIST proc_list, auxilliary_table_list;
TYPELIB *interval; TYPELIB *interval;
create_field *last_field; create_field *last_field;
......
...@@ -1449,7 +1449,17 @@ mysql_execute_command(THD *thd) ...@@ -1449,7 +1449,17 @@ mysql_execute_command(THD *thd)
} }
} }
} }
else if (!(result=new select_send())) else if (lex->select_into_var_list.elements)
{
if (!(result=new select_dumpvar()))
{
res= -1;
break;
}
}
else
{
if (!(result=new select_send()))
{ {
res= -1; res= -1;
#ifdef DELETE_ITEMS #ifdef DELETE_ITEMS
...@@ -1469,6 +1479,7 @@ mysql_execute_command(THD *thd) ...@@ -1469,6 +1479,7 @@ mysql_execute_command(THD *thd)
for (table = tables ; table ; table=table->next) for (table = tables ; table ; table=table->next)
table->lock_type= lex->lock_option; table->lock_type= lex->lock_option;
} }
}
if (!(res=open_and_lock_tables(thd,tables))) if (!(res=open_and_lock_tables(thd,tables)))
{ {
...@@ -2966,6 +2977,7 @@ mysql_init_select(LEX *lex) ...@@ -2966,6 +2977,7 @@ mysql_init_select(LEX *lex)
select_lex->olap= UNSPECIFIED_OLAP_TYPE; select_lex->olap= UNSPECIFIED_OLAP_TYPE;
lex->exchange= 0; lex->exchange= 0;
lex->proc_list.first= 0; lex->proc_list.first= 0;
lex->select_into_var_list.empty();
} }
......
...@@ -632,7 +632,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -632,7 +632,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
handler_rkey_function handler_read_or_scan handler_rkey_function handler_read_or_scan
single_multi table_wild_list table_wild_one opt_wild union union_list single_multi table_wild_list table_wild_one opt_wild union union_list
precision union_option opt_on_delete_item subselect_start opt_and precision union_option opt_on_delete_item subselect_start opt_and
subselect_end subselect_end select_var_list
END_OF_INPUT END_OF_INPUT
%type <NONE> %type <NONE>
...@@ -1544,6 +1544,7 @@ select_part2: ...@@ -1544,6 +1544,7 @@ select_part2:
select_into: select_into:
limit_clause {} limit_clause {}
| select_from | select_from
| opt_into
| opt_into select_from | opt_into select_from
| select_from opt_into; | select_from opt_into;
...@@ -2287,11 +2288,11 @@ select_part3: ...@@ -2287,11 +2288,11 @@ select_part3:
mysql_init_select(lex); mysql_init_select(lex);
lex->select->linkage= DERIVED_TABLE_TYPE; lex->select->linkage= DERIVED_TABLE_TYPE;
} }
select_options select_item_list select_intoto select_options select_item_list select_intoto;
select_intoto: select_intoto:
limit_clause {} limit_clause {}
| select_from | select_from;
opt_outer: opt_outer:
/* empty */ {} /* empty */ {}
...@@ -2544,6 +2545,18 @@ procedure_item: ...@@ -2544,6 +2545,18 @@ procedure_item:
$2->set_name($1,(uint) ((char*) Lex->tok_end - $1)); $2->set_name($1,(uint) ((char*) Lex->tok_end - $1));
}; };
select_var_list:
select_var_list ',' '@' ident_or_text
{
if (Lex->select_into_var_list.push_back((LEX_STRING*) sql_memdup(&$4,sizeof(LEX_STRING))))
YYABORT;
}
| '@' ident_or_text
{
if (Lex->select_into_var_list.push_back((LEX_STRING*) sql_memdup(&$2,sizeof(LEX_STRING))))
YYABORT;
};
opt_into: opt_into:
INTO OUTFILE TEXT_STRING INTO OUTFILE TEXT_STRING
{ {
...@@ -2555,6 +2568,10 @@ opt_into: ...@@ -2555,6 +2568,10 @@ opt_into:
{ {
if (!(Lex->exchange= new sql_exchange($3.str,1))) if (!(Lex->exchange= new sql_exchange($3.str,1)))
YYABORT; YYABORT;
}
| INTO select_var_list
{
current_thd->safe_to_cache_query=0;
}; };
/* /*
...@@ -3225,7 +3242,7 @@ param_marker: ...@@ -3225,7 +3242,7 @@ param_marker:
yyerror("You have an error in your SQL syntax"); yyerror("You have an error in your SQL syntax");
YYABORT; YYABORT;
} }
} };
literal: literal:
text_literal { $$ = $1; } text_literal { $$ = $1; }
| NUM { $$ = new Item_int($1.str, (longlong) atol($1.str),$1.length); } | NUM { $$ = new Item_int($1.str, (longlong) atol($1.str),$1.length); }
...@@ -3565,7 +3582,7 @@ option_value: ...@@ -3565,7 +3582,7 @@ option_value:
| PASSWORD FOR_SYM user equal text_or_password | PASSWORD FOR_SYM user equal text_or_password
{ {
Lex->var_list.push_back(new set_var_password($3,$5)); Lex->var_list.push_back(new set_var_password($3,$5));
} };
internal_variable_name: internal_variable_name:
ident ident
...@@ -3574,7 +3591,7 @@ internal_variable_name: ...@@ -3574,7 +3591,7 @@ internal_variable_name:
if (!tmp) if (!tmp)
YYABORT; YYABORT;
$$=tmp; $$=tmp;
} };
isolation_types: isolation_types:
READ_SYM UNCOMMITTED_SYM { $$= ISO_READ_UNCOMMITTED; } READ_SYM UNCOMMITTED_SYM { $$= ISO_READ_UNCOMMITTED; }
...@@ -3933,7 +3950,7 @@ require_clause: /* empty */ ...@@ -3933,7 +3950,7 @@ require_clause: /* empty */
| REQUIRE_SYM NONE_SYM | REQUIRE_SYM NONE_SYM
{ {
Lex->ssl_type=SSL_TYPE_NONE; Lex->ssl_type=SSL_TYPE_NONE;
} };
grant_options: grant_options:
/* empty */ {} /* empty */ {}
...@@ -4076,4 +4093,4 @@ subselect_end: ...@@ -4076,4 +4093,4 @@ subselect_end:
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->select = lex->select->outer_select(); lex->select = lex->select->outer_select();
} };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment