Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] SEQUENCE ENGINE #238

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion include/my_base.h
Expand Up @@ -921,7 +921,15 @@ is the global server default. */
#define HA_ERR_NO_WAIT_LOCK 203 /* Don't wait for record lock */
#define HA_ERR_DISK_FULL_NOWAIT 204 /* No more room in disk */
#define HA_ERR_NO_SESSION_TEMP 205 /* No session temporary space available */
#define HA_ERR_LAST 205 /* Copy of last error nr */

/* These errors are only for Sequence Engine. */
#define HA_ERR_SEQUENCE_RUN_OUT 206 /* Sequence has run out */
#define HA_ERR_SEQUENCE_INVALID 207 /* Structure or number is invalid */
#define HA_ERR_SEQUENCE_NOT_DEFINED 208 /* Sequence is not yet defined */
#define HA_ERR_SEQUENCE_ACCESS_FAILURE 209 /* Sequence access failure*/
/* Sequence Engine errors end */

#define HA_ERR_LAST 209 /* Copy of last error nr */

/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
Expand Down
8 changes: 8 additions & 0 deletions mysql-test/r/information_schema_keywords.result
Expand Up @@ -102,8 +102,10 @@ CURRENT_DATE 1
CURRENT_TIME 1
CURRENT_TIMESTAMP 1
CURRENT_USER 1
CURRVAL 0
CURSOR 1
CURSOR_NAME 0
CYCLE 0
DATA 0
DATABASE 1
DATABASES 1
Expand Down Expand Up @@ -237,6 +239,7 @@ IGNORE 1
IGNORE_SERVER_IDS 0
IMPORT 0
IN 1
INCREMENT 0
INDEX 1
INDEXES 0
INFILE 1
Expand Down Expand Up @@ -352,6 +355,7 @@ MIGRATE 0
MINUTE 0
MINUTE_MICROSECOND 1
MINUTE_SECOND 1
MINVALUE 0
MIN_ROWS 0
MOD 1
MODE 0
Expand All @@ -374,7 +378,10 @@ NESTED 0
NEVER 0
NEW 0
NEXT 0
NEXTVAL 0
NO 0
NOCACHE 0
NOCYCLE 0
NODEGROUP 0
NONE 0
NOT 1
Expand Down Expand Up @@ -527,6 +534,7 @@ SECURITY 0
SELECT 1
SENSITIVE 1
SEPARATOR 1
SEQUENCE 0
SERIAL 0
SERIALIZABLE 0
SERVER 0
Expand Down
18 changes: 9 additions & 9 deletions mysql-test/r/udf.result
Expand Up @@ -4,7 +4,7 @@ CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
ERROR HY000: Can't find symbol 'myfunc_nonexist' in library
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION sequence RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION sequence_alias RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION lookup RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION reverse_lookup
RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
Expand All @@ -21,7 +21,7 @@ metaphon char function UDF_EXAMPLE_LIB 1
myfunc_double double function UDF_EXAMPLE_LIB 1
myfunc_int integer function UDF_EXAMPLE_LIB 1
reverse_lookup char function UDF_EXAMPLE_LIB 1
sequence integer function UDF_EXAMPLE_LIB 1
sequence_alias integer function UDF_EXAMPLE_LIB 1
# Should get an index lookup
EXPLAIN
SELECT udf_type FROM performance_schema.user_defined_functions
Expand Down Expand Up @@ -253,7 +253,7 @@ DROP FUNCTION myfunc_double;
DROP FUNCTION myfunc_nonexist;
ERROR 42000: FUNCTION test.myfunc_nonexist does not exist
DROP FUNCTION myfunc_int;
DROP FUNCTION sequence;
DROP FUNCTION sequence_alias;
DROP FUNCTION lookup;
DROP FUNCTION reverse_lookup;
DROP FUNCTION avgcost;
Expand Down Expand Up @@ -367,32 +367,32 @@ DROP FUNCTION check_const_len;
DROP PROCEDURE check_const_len_sp;
DROP TRIGGER check_const_len_trigger;
DROP TABLE const_len_bug;
CREATE FUNCTION sequence RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION sequence_alias RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (4),(3),(2),(1);
INSERT INTO t2 SELECT * FROM t1;
SELECT sequence() AS seq, a FROM t1 ORDER BY seq ASC;
SELECT sequence_alias() AS seq, a FROM t1 ORDER BY seq ASC;
seq a
1 4
2 3
3 2
4 1
SELECT sequence() AS seq, a FROM t1 ORDER BY seq DESC;
SELECT sequence_alias() AS seq, a FROM t1 ORDER BY seq DESC;
seq a
4 1
3 2
2 3
1 4
SELECT * FROM t1 WHERE a = sequence();
SELECT * FROM t1 WHERE a = sequence_alias();
a
SELECT * FROM t2 WHERE a = sequence();
SELECT * FROM t2 WHERE a = sequence_alias();
a
1
2
3
4
DROP FUNCTION sequence;
DROP FUNCTION sequence_alias;
DROP TABLE t1,t2;
drop function if exists test.metaphon;
drop function if exists metaphon;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/r/variables.result
Expand Up @@ -2019,6 +2019,7 @@ SET SESSION pseudo_thread_id = @@session.pseudo_thread_id;
SET SESSION rand_seed1 = @@session.rand_seed1;
SET SESSION rand_seed2 = @@session.rand_seed2;
SET SESSION resultset_metadata = @@session.resultset_metadata;
SET SESSION sequence_read_skip_cache = @@session.sequence_read_skip_cache;
SET SESSION sql_log_bin = @@session.sql_log_bin;
SET SESSION timestamp = @@session.timestamp;
SET SESSION transaction_allow_batching = @@session.transaction_allow_batching;
Expand Down