8759
--echo # Try to create a function that
8760
--echo # refers to non-existing variables.
8761
--error ER_SP_UNDECLARED_VAR
8762
create function f1(p1 integer, p2 integer)
8766
set a = (select count(*) from t1 limit a, b);
8770
create function f1()
8773
declare a, b, c int;
8774
set a = (select count(*) from t1 limit b, c);
8779
--echo # How do we handle NULL limit values?
8786
--echo # Try to use data types not allowed in LIMIT
8788
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
8789
create function f1(p1 date, p2 date)
8793
set a = (select count(*) from t1 limit p1, p2);
8797
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
8798
create function f1(p1 integer, p2 float)
8802
set a = (select count(*) from t1 limit p1, p2);
8806
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
8807
create function f1(p1 integer, p2 char(1))
8811
set a = (select count(*) from t1 limit p1, p2);
8815
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
8816
create function f1(p1 varchar(5), p2 char(1))
8820
set a = (select count(*) from t1 limit p1, p2);
8824
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
8825
create function f1(p1 decimal, p2 decimal)
8829
set a = (select count(*) from t1 limit p1, p2);
8833
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
8834
create function f1(p1 double, p2 double)
8838
set a = (select count(*) from t1 limit p1, p2);
8843
--echo # Finally, test the valid case.
8846
create function f1(p1 integer, p2 integer)
8850
set count= (select count(*) from (select * from t1 limit p1, p2) t_1);
8759
8865
--echo # Cleanup
8761
8867
drop procedure p1;
8765
8871
--echo # BUG#11766234: 59299: ASSERT (TABLE_REF->TABLE || TABLE_REF->VIEW)
8881
8987
DROP PROCEDURE p1;
8991
--echo # Bug#12621017 - Crash if a sp variable is used in the
8992
--echo # limit clause of a set statement
8996
DROP TABLE IF EXISTS t1;
8997
DROP PROCEDURE IF EXISTS p1;
8998
DROP PROCEDURE IF EXISTS p2;
9001
CREATE TABLE t1 (c1 INT);
9002
INSERT INTO t1 VALUES (1);
9006
CREATE PROCEDURE p1()
9008
DECLARE foo, cnt INT UNSIGNED DEFAULT 1;
9009
SET foo = (SELECT MIN(c1) FROM t1 LIMIT cnt);
9012
CREATE PROCEDURE p2()
9018
DECLARE cur1 CURSOR FOR
9025
FETCH cur1 INTO iVal;
8884
9038
--echo # End of 5.5 test