~ubuntu-branches/ubuntu/raring/mysql-5.5/raring-proposed

« back to all changes in this revision

Viewing changes to mysql-test/t/sp.test

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
8755
8755
call p1(1, 5);
8756
8756
call p1(3, 2);
8757
8757
 
 
8758
delimiter |;
 
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)
 
8763
  returns int
 
8764
begin
 
8765
  declare a int;
 
8766
  set a = (select count(*) from t1 limit a, b);
 
8767
  return a;
 
8768
end|
 
8769
 
 
8770
create function f1()
 
8771
  returns int
 
8772
begin
 
8773
  declare a, b, c int;
 
8774
  set a = (select count(*) from t1 limit b, c);
 
8775
  return a;
 
8776
end|
 
8777
 
 
8778
delimiter ;|
 
8779
--echo # How do we handle NULL limit values?
 
8780
select f1();
 
8781
 
 
8782
drop function f1;
 
8783
 
 
8784
delimiter |;
 
8785
--echo #
 
8786
--echo # Try to use data types not allowed in LIMIT 
 
8787
--echo #
 
8788
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
 
8789
create function f1(p1 date, p2 date)
 
8790
  returns int
 
8791
begin
 
8792
  declare a int;
 
8793
  set a = (select count(*) from t1 limit p1, p2);
 
8794
  return a;
 
8795
end|
 
8796
 
 
8797
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
 
8798
create function f1(p1 integer, p2 float)
 
8799
  returns int
 
8800
begin
 
8801
  declare a int;
 
8802
  set a = (select count(*) from t1 limit p1, p2);
 
8803
  return a;
 
8804
end|
 
8805
 
 
8806
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
 
8807
create function f1(p1 integer, p2 char(1))
 
8808
  returns int
 
8809
begin
 
8810
  declare a int;
 
8811
  set a = (select count(*) from t1 limit p1, p2);
 
8812
  return a;
 
8813
end|
 
8814
 
 
8815
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
 
8816
create function f1(p1 varchar(5), p2 char(1))
 
8817
  returns int
 
8818
begin
 
8819
  declare a int;
 
8820
  set a = (select count(*) from t1 limit p1, p2);
 
8821
  return a;
 
8822
end|
 
8823
 
 
8824
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
 
8825
create function f1(p1 decimal, p2 decimal)
 
8826
  returns int
 
8827
begin
 
8828
  declare a int;
 
8829
  set a = (select count(*) from t1 limit p1, p2);
 
8830
  return a;
 
8831
end|
 
8832
 
 
8833
--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
 
8834
create function f1(p1 double, p2 double)
 
8835
  returns int
 
8836
begin
 
8837
  declare a int;
 
8838
  set a = (select count(*) from t1 limit p1, p2);
 
8839
  return a;
 
8840
end|
 
8841
 
 
8842
--echo #
 
8843
--echo # Finally, test the valid case.
 
8844
--echo #
 
8845
 
 
8846
create function f1(p1 integer, p2 integer)
 
8847
returns int
 
8848
begin
 
8849
  declare count int;
 
8850
  set count= (select count(*) from (select * from t1 limit p1, p2) t_1);
 
8851
  return count;
 
8852
end|
 
8853
 
 
8854
delimiter ;|
 
8855
 
 
8856
select f1(0, 0);
 
8857
select f1(0, -1);
 
8858
select f1(-1, 0);
 
8859
select f1(-1, -1);
 
8860
select f1(0, 1);
 
8861
select f1(1, 0);
 
8862
select f1(1, 5);
 
8863
select f1(3, 2);
8758
8864
 
8759
8865
--echo # Cleanup
8760
8866
drop table t1;
8761
8867
drop procedure p1;
8762
 
 
 
8868
drop function f1;
8763
8869
 
8764
8870
--echo # 
8765
8871
--echo # BUG#11766234: 59299: ASSERT (TABLE_REF->TABLE || TABLE_REF->VIEW) 
8881
8987
DROP PROCEDURE p1;
8882
8988
--echo
8883
8989
 
 
8990
--echo #
 
8991
--echo # Bug#12621017 - Crash if a sp variable is used in the
 
8992
--echo #                limit clause of a set statement
 
8993
--echo #
 
8994
 
 
8995
--disable_warnings
 
8996
DROP TABLE IF EXISTS t1;
 
8997
DROP PROCEDURE IF EXISTS p1; 
 
8998
DROP PROCEDURE IF EXISTS p2;
 
8999
--enable_warnings
 
9000
 
 
9001
CREATE TABLE t1 (c1 INT); 
 
9002
INSERT INTO t1 VALUES (1);
 
9003
 
 
9004
delimiter |;
 
9005
 
 
9006
CREATE PROCEDURE p1() 
 
9007
BEGIN 
 
9008
  DECLARE foo, cnt INT UNSIGNED DEFAULT 1; 
 
9009
  SET foo = (SELECT MIN(c1) FROM t1 LIMIT cnt); 
 
9010
END| 
 
9011
 
 
9012
CREATE PROCEDURE p2()
 
9013
BEGIN
 
9014
 
 
9015
DECLARE iLimit INT;
 
9016
DECLARE iVal INT;
 
9017
 
 
9018
DECLARE cur1 CURSOR FOR
 
9019
  SELECT c1 FROM t1
 
9020
  LIMIT iLimit;
 
9021
 
 
9022
SET iLimit=1;
 
9023
 
 
9024
OPEN cur1;
 
9025
FETCH cur1 INTO iVal;
 
9026
 
 
9027
END|
 
9028
 
 
9029
delimiter ;|
 
9030
 
 
9031
CALL p1();
 
9032
CALL p2();
 
9033
 
 
9034
DROP PROCEDURE p1;
 
9035
DROP PROCEDURE p2;
 
9036
DROP TABLE t1;
 
9037
 
8884
9038
--echo # End of 5.5 test