Antony T Curtis wrote:
>
> Allows grammar such as
>
> SELECT tote_seq_no INTO @seq
> FROM toteq WHERE tote_no=@tote AND zone=@zone AND status="O"
> ORDER BY tote_seq_no
> LIMIT 1;
>
This diff should work.
--
ANTONY T CURTIS Tel: +44 (1635) 36222
Abacus Polar Holdings Ltd Fax: +44 (1635) 38670
> The world is coming to an end! Repent and return those library books!
diff -dC 4 -X diff.exclude /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_class.cc
mysql-3.23.38-10/sql/sql_class.cc
*** /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_class.cc Fri Jun 8 13:41:37 2001
--- mysql-3.23.38-10/sql/sql_class.cc Fri Jun 8 10:43:34 2001
***************
*** 308,376 ****
}
/***************************************************************************
- ** Export of select to local user variables
- ***************************************************************************/
-
-
- int select_into::prepare(List<Item> &list)
- {
- if (list.elements != lex->into_var_list.elements)
- {
- my_error(ER_TOO_MANY_FIELDS,MYF(0));
- return 1;
- }
- return 0;
- }
-
-
- bool select_into::send_data(List<Item> &items)
- {
- List_iterator<Item> li1(items);
- List_iterator<String> li2(lex->into_var_list);
- String *res, *var;
- Item *item;
- DBUG_ENTER("send_data");
-
- if (thd->offset_limit)
- { // using limit offset,count
- thd->offset_limit--;
- DBUG_RETURN(0);
- }
- if (row_count++ > 1)
- {
- my_error(ER_TOO_MANY_ROWS,MYF(0));
- goto err;
- }
- while ((item=li1++))
- {
- String *var_name = li2++;
- LEX_STRING str;
- str.str = (char *)var_name->ptr();
- str.length = var_name->length();
-
- Item_func_set_user_var *target = new Item_func_set_user_var(str, item);
- target->fix_fields(thd, (TABLE_LIST*)lex->table_list.first);
- target->update();
- }
- DBUG_RETURN(0);
- err:
- DBUG_RETURN(1);
- }
-
- void select_into::send_error(uint errcode,const char *err)
- {
- ::send_error(&thd->net,errcode,err);
- }
-
- bool select_into::send_eof()
- {
- ::send_ok(&thd->net,row_count);
- return 0;
- }
-
- /***************************************************************************
** Export of select to textfile
***************************************************************************/
--- 308,315 ----
diff -dC 4 -X diff.exclude /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_class.h
mysql-3.23.38-10/sql/sql_class.h
*** /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_class.h Fri Jun 8 12:32:37 2001
--- mysql-3.23.38-10/sql/sql_class.h Fri Jun 8 10:43:37 2001
***************
*** 380,387 ****
--- 380,388 ----
inline char *memdup(const char *str, unsigned int size)
{ return memdup_root(&mem_root,str,size); }
};
+
class sql_exchange :public Sql_alloc
{
public:
char *file_name;
***************
*** 422,441 ****
void send_error(uint errcode,const char *err);
bool send_eof();
};
- class select_into :public select_result {
- LEX *lex;
- ha_rows row_count;
- public:
- select_into(LEX *src) :lex(src),row_count(0L) {}
- int prepare(List<Item> &list);
- bool send_fields(List<Item> &list,
- uint flag) { return 0; }
- bool send_data(List<Item> &items);
- void send_error(uint errcode,const char *err);
- bool send_eof();
- };
class select_export :public select_result {
sql_exchange *exchange;
File file;
--- 423,430 ----
diff -dC 4 -X diff.exclude /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_lex.h
mysql-3.23.38-10/sql/sql_lex.h
*** /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_lex.h Fri Jun 8 12:49:48 2001
--- mysql-3.23.38-10/sql/sql_lex.h Fri Jun 8 10:43:37 2001
***************
*** 113,121 ****
List<key_part_spec> col_list;
List<Alter_drop> drop_list;
List<Alter_column> alter_list;
List<String> interval_list,use_index,*use_index_ptr,
! ignore_index, *ignore_index_ptr, into_var_list;
List<st_lex_user> users_list;
List<LEX_COLUMN> columns;
List<Key> key_list;
List<create_field> create_list;
--- 113,121 ----
List<key_part_spec> col_list;
List<Alter_drop> drop_list;
List<Alter_column> alter_list;
List<String> interval_list,use_index,*use_index_ptr,
! ignore_index, *ignore_index_ptr;
List<st_lex_user> users_list;
List<LEX_COLUMN> columns;
List<Key> key_list;
List<create_field> create_list;
diff -dC 4 -X diff.exclude /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_parse.cc
mysql-3.23.38-10/sql/sql_parse.cc
*** /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_parse.cc Fri Jun 8 13:14:41 2001
--- mysql-3.23.38-10/sql/sql_parse.cc Fri Jun 8 10:43:34 2001
***************
*** 1101,1116 ****
break;
}
}
}
- else if (lex->into_var_list.elements)
- {
- if (!(result=new select_into(lex)))
- {
- res= -1;
- break;
- }
- }
else if (!(result=new select_send()))
{
res= -1;
#ifdef DELETE_ITEMS
--- 1101,1108 ----
***************
*** 2285,2293 ****
lex->select_limit=current_thd->default_select_limit;
lex->offset_limit=0L;
lex->options=0;
lex->exchange = 0;
- lex->into_var_list.empty();
lex->proc_list.first=0;
lex->order_list.elements=lex->group_list.elements=0;
lex->order_list.first=0;
lex->order_list.next= (byte**) &lex->order_list.first;
--- 2277,2284 ----
diff -dC 4 -X diff.exclude /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_yacc.yy
mysql-3.23.38-10/sql/sql_yacc.yy
*** /uwk/wwwcode/sql/mysql-3.23.38-10/sql/sql_yacc.yy Fri Jun 8 12:59:05 2001
--- mysql-3.23.38-10/sql/sql_yacc.yy Fri Jun 8 10:43:34 2001
***************
*** 455,463 ****
remember_name remember_end opt_len opt_ident opt_db text_or_password
opt_escape
%type <string>
! text_string into_var_item
%type <num>
type int_type real_type order_dir opt_field_spec set_option lock_option
udf_type if_exists opt_local opt_table_options table_options
--- 455,463 ----
remember_name remember_end opt_len opt_ident opt_db text_or_password
opt_escape
%type <string>
! text_string
%type <num>
type int_type real_type order_dir opt_field_spec set_option lock_option
udf_type if_exists opt_local opt_table_options table_options
***************
*** 1970,1989 ****
{
if (!(Lex->exchange= new sql_exchange($3.str,1)))
YYABORT;
}
- | INTO
- {
- Lex->into_var_list.empty();
- }
- into_var_list
-
- into_var_list:
- into_var_item { Lex->into_var_list.push_back($1); }
- | into_var_list ',' into_var_item { Lex->into_var_list.push_back($3); }
- into_var_item:
- '@' ident_or_text { $$ = new String((const char*) $2.str,$2.length); }
/*
** Drop : delete tables or index
*/
--- 1970,1978 ----