mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
subselect in procedure argument list (Bug #302)
This commit is contained in:
@ -605,3 +605,6 @@ vio/viotest-ssl
|
|||||||
myisam/ftbench/var/*
|
myisam/ftbench/var/*
|
||||||
myisam/ftbench/data
|
myisam/ftbench/data
|
||||||
myisam/ftbench/t
|
myisam/ftbench/t
|
||||||
|
libmysqld/sp_pcontext.cc
|
||||||
|
libmysqld/sp.cc
|
||||||
|
libmysqld/sp_head.cc
|
||||||
|
@ -887,6 +887,23 @@ do (SELECT a from t1);
|
|||||||
Table 'test.t1' doesn't exist
|
Table 'test.t1' doesn't exist
|
||||||
set @a:=(SELECT a from t1);
|
set @a:=(SELECT a from t1);
|
||||||
Table 'test.t1' doesn't exist
|
Table 'test.t1' doesn't exist
|
||||||
|
create table t1 (a int);
|
||||||
|
create table t2 (a int);
|
||||||
|
insert into t2 values (1), (2), (3);
|
||||||
|
create procedure foo1(x int)
|
||||||
|
insert into test.t1 values (x);
|
||||||
|
create function foo2(i int) returns int
|
||||||
|
return i+1;
|
||||||
|
call foo1((select max(a) from t2));
|
||||||
|
select * from t1;
|
||||||
|
a
|
||||||
|
3
|
||||||
|
select foo2((select max(a) from t2));
|
||||||
|
foo2((select max(a) from t2))
|
||||||
|
4
|
||||||
|
drop table t1, t2;
|
||||||
|
drop procedure foo1;
|
||||||
|
drop function foo2;
|
||||||
CREATE TABLE t1 (a int, KEY(a));
|
CREATE TABLE t1 (a int, KEY(a));
|
||||||
HANDLER t1 OPEN;
|
HANDLER t1 OPEN;
|
||||||
HANDLER t1 READ a=((SELECT 1));
|
HANDLER t1 READ a=((SELECT 1));
|
||||||
|
@ -486,6 +486,9 @@ select ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a');
|
|||||||
select ROW(1, 1, 'a') IN (select b,a,c from t1 limit 2);
|
select ROW(1, 1, 'a') IN (select b,a,c from t1 limit 2);
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# DO & SET
|
||||||
|
#
|
||||||
create table t1 (a int);
|
create table t1 (a int);
|
||||||
insert into t1 values (1);
|
insert into t1 values (1);
|
||||||
do @a:=(SELECT a from t1);
|
do @a:=(SELECT a from t1);
|
||||||
@ -499,6 +502,23 @@ do (SELECT a from t1);
|
|||||||
-- error 1146
|
-- error 1146
|
||||||
set @a:=(SELECT a from t1);
|
set @a:=(SELECT a from t1);
|
||||||
|
|
||||||
|
#
|
||||||
|
# CALL
|
||||||
|
#
|
||||||
|
create table t1 (a int);
|
||||||
|
create table t2 (a int);
|
||||||
|
insert into t2 values (1), (2), (3);
|
||||||
|
create procedure foo1(x int)
|
||||||
|
insert into test.t1 values (x);
|
||||||
|
create function foo2(i int) returns int
|
||||||
|
return i+1;
|
||||||
|
call foo1((select max(a) from t2));
|
||||||
|
select * from t1;
|
||||||
|
select foo2((select max(a) from t2));
|
||||||
|
drop table t1, t2;
|
||||||
|
drop procedure foo1;
|
||||||
|
drop function foo2;
|
||||||
|
|
||||||
CREATE TABLE t1 (a int, KEY(a));
|
CREATE TABLE t1 (a int, KEY(a));
|
||||||
HANDLER t1 OPEN;
|
HANDLER t1 OPEN;
|
||||||
-- error 1149
|
-- error 1149
|
||||||
|
@ -216,6 +216,9 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
|
|||||||
|
|
||||||
nctx->push_item(eval_func_item(thd, *argp++, pvar->type));
|
nctx->push_item(eval_func_item(thd, *argp++, pvar->type));
|
||||||
}
|
}
|
||||||
|
// Close tables opened for subselect in argument list
|
||||||
|
close_thread_tables(thd);
|
||||||
|
|
||||||
// The rest of the frame are local variables which are all IN.
|
// The rest of the frame are local variables which are all IN.
|
||||||
// QQ See comment in execute_procedure below.
|
// QQ See comment in execute_procedure below.
|
||||||
for (; i < csize ; i++)
|
for (; i < csize ; i++)
|
||||||
@ -283,6 +286,9 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
|
|||||||
nctx->set_oindex(i, static_cast<Item_splocal *>(it)->get_offset());
|
nctx->set_oindex(i, static_cast<Item_splocal *>(it)->get_offset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Close tables opened for subselect in argument list
|
||||||
|
close_thread_tables(thd);
|
||||||
|
|
||||||
// The rest of the frame are local variables which are all IN.
|
// The rest of the frame are local variables which are all IN.
|
||||||
// QQ We haven't found any hint of what the value is when unassigned,
|
// QQ We haven't found any hint of what the value is when unassigned,
|
||||||
// so we set it to NULL for now. It's an error to refer to an
|
// so we set it to NULL for now. It's an error to refer to an
|
||||||
|
@ -3060,6 +3060,11 @@ mysql_execute_command(THD *thd)
|
|||||||
uint smrx;
|
uint smrx;
|
||||||
LINT_INIT(smrx);
|
LINT_INIT(smrx);
|
||||||
|
|
||||||
|
if (tables && ((res= check_table_access(thd, SELECT_ACL, tables)) ||
|
||||||
|
(res= open_and_lock_tables(thd,tables))))
|
||||||
|
break;
|
||||||
|
fix_tables_pointers(lex->all_selects_list);
|
||||||
|
|
||||||
#ifndef EMBEDDED_LIBRARY
|
#ifndef EMBEDDED_LIBRARY
|
||||||
// When executing substatements, they're assumed to send_error when
|
// When executing substatements, they're assumed to send_error when
|
||||||
// it happens, but not to send_ok.
|
// it happens, but not to send_ok.
|
||||||
|
Reference in New Issue
Block a user