mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed sequences based on comments from Peter Gulutzan and Andrii Nikitin
- Changed names of SEQUENCE table columns to be more close to ANSI - Fixed error message for SHOW SEQUENCE non_existing_sequence - Allow syntax CACHE +1 - Fixed ALTER TABLE for TEMPORARY sequences.
This commit is contained in:
@ -5,26 +5,26 @@ Note 1051 Unknown table 'test.t1'
|
||||
# Test setval function
|
||||
#
|
||||
CREATE SEQUENCE t1 cache 10 engine=myisam;
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
1 0
|
||||
do setval(t1,10);
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
11 0
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
11
|
||||
do setval(t1,12,1);
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
21 0
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
13
|
||||
do setval(t1,15,0);
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
21 0
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
@ -39,15 +39,15 @@ do setval(t1,1000,0);
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
1000
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
1010 0
|
||||
do setval(t1,2000,0);
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
2000
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
2010 0
|
||||
select setval(t1,1000,0);
|
||||
setval(t1,1000,0)
|
||||
@ -61,8 +61,8 @@ NULL
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
2002
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
2010 0
|
||||
select setval(t1,2002,0);
|
||||
setval(t1,2002,0)
|
||||
@ -76,40 +76,40 @@ setval(t1,2010,0)
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
2010
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
2020 0
|
||||
drop sequence t1;
|
||||
#
|
||||
# Testing with cycle
|
||||
#
|
||||
CREATE SEQUENCE t1 cache=10 maxvalue=100 cycle engine=innodb;
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
1 0
|
||||
select setval(t1,100,0);
|
||||
setval(t1,100,0)
|
||||
100
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
100 0
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
100
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
101 0
|
||||
select setval(t1,100,0);
|
||||
setval(t1,100,0)
|
||||
NULL
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
101 0
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
1
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
11 1
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
@ -117,8 +117,8 @@ next value for t1
|
||||
select setval(t1,100,0,1);
|
||||
setval(t1,100,0,1)
|
||||
100
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
100 1
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
@ -126,8 +126,8 @@ next value for t1
|
||||
select setval(t1,100,1,2);
|
||||
setval(t1,100,1,2)
|
||||
100
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
101 2
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
@ -135,8 +135,8 @@ next value for t1
|
||||
select setval(t1,100,0,3);
|
||||
setval(t1,100,0,3)
|
||||
100
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
100 3
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
@ -146,27 +146,27 @@ drop sequence t1;
|
||||
# Testing extreme values
|
||||
#
|
||||
CREATE SEQUENCE t1 cache=10 maxvalue=100 engine=innodb;
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
1 0
|
||||
select setval(t1,200);
|
||||
setval(t1,200)
|
||||
200
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
101 0
|
||||
select next value for t1;
|
||||
ERROR HY000: Sequence 'test.t1' has run out
|
||||
drop sequence t1;
|
||||
CREATE SEQUENCE t1 cache=10 maxvalue=100 cycle engine=innodb;
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
1 0
|
||||
select setval(t1,200);
|
||||
setval(t1,200)
|
||||
200
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
101 0
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
@ -176,8 +176,8 @@ CREATE SEQUENCE t1 cache=10 maxvalue=0 increment=-10;
|
||||
select setval(t1,-10);
|
||||
setval(t1,-10)
|
||||
-10
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
-20 0
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
@ -185,8 +185,8 @@ next value for t1
|
||||
select setval(t1,-15);
|
||||
setval(t1,-15)
|
||||
NULL
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
-120 0
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
@ -214,8 +214,8 @@ CREATE SEQUENCE t1 cache=10 maxvalue=0 increment=-10;
|
||||
select setval(t1,-10,0);
|
||||
setval(t1,-10,0)
|
||||
-10
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
-10 0
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
@ -231,8 +231,8 @@ setval(t1,10,0) setval(t1,15,1) setval(t1,5,1)
|
||||
select next value for t1;
|
||||
next value for t1
|
||||
16
|
||||
select next_value,round from t1;
|
||||
next_value round
|
||||
select next_not_cached_value,cycle_count from t1;
|
||||
next_not_cached_value cycle_count
|
||||
1016 0
|
||||
explain extended select setval(t1,100),setval(t1,100,TRUE),setval(t1,100,FALSE,50);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
|
Reference in New Issue
Block a user