Description:
Hi guys
We have been getting great convenience from MySQL open source project, thanks for all your guys's great work.
I also faced some diffculty when we want to generate unique ID, so I developed a new storage engine named Sequence Engine, I also want to contribute to MySQL project.
Detailed information about it:
[Feature] SEQUENCE ENGINE
Description:
------------
SEQUENCE engine as an embedded logical engine, it mainly used to generate unique number,
it is the middle layer engine that use InnoDB or other storage engine as the based table engine,
All query on sequence table will be changed into the operation on based table.
the cache or other sequence value management is decided by SEQUENCE engine handler.
According to the setting which is defined by 'CREATE SEQUENCE ... ' or 'CREATE TABLE...Engine=Sequence + INSERT VALUES'.
user can query the nextval or currval from sequence object.
In order to distinguish the normal SELECT statement, we supply two functions;
'SELECT NEXTVAL FROM SEQUENCE' will return the based table record directly.
'SELECT NEXTVAL(), CURRVAL()' will return the iterated record.
Syntax:
-------
CREATE SEQUENCE SYNTAX:
CREATE SEQUENCE [IF NOT EXISTS] schema.sequence_name
[START WITH <constant>]
[MINVALUE <constant>]
[MAXVALUE <constant>]
[INCREMENT BY <constant>]
[CACHE <constant> | NOCACHE]
[CYCLE | NOCYCLE]
;
OR:
CREATE TABLE schema.sequence_name (
`currval` bigint(21) NOT NULL COMMENT 'current value',
`nextval` bigint(21) NOT NULL COMMENT 'next value',
`minvalue` bigint(21) NOT NULL COMMENT 'min value',
`maxvalue` bigint(21) NOT NULL COMMENT 'max value',
`start` bigint(21) NOT NULL COMMENT 'start value',
`increment` bigint(21) NOT NULL COMMENT 'increment value',
`cache` bigint(21) NOT NULL COMMENT 'cache size',
`cycle` bigint(21) NOT NULL COMMENT 'cycle state',
`round` bigint(21) NOT NULL COMMENT 'already how many round'
) ENGINE=Sequence DEFAULT CHARSET=latin1
INSERT INTO schema.sequence_name VALUES(0,0,1,9223372036854775807,1,1,10000,1,0);
COMMIT;
Strongly recommend the first CREATE SEQUENCE syntax.
SHOW SYNTAX:
SHOW CREATE TABLE schema.sequence_name;
QUERY SYNTAX:
SELECT [nextval | currval | *] FROM schema.sequence_name;
SELECT nextval(schema.sequence_name);
SELECT currval(schema.sequence_name);
Usage:
------
FOR EXAMPLE:
CREATE SEQUENCE s;
INSERT INTO t VALUES(NEXTVAL(s));
How to repeat:
see Description;
Description: Hi guys We have been getting great convenience from MySQL open source project, thanks for all your guys's great work. I also faced some diffculty when we want to generate unique ID, so I developed a new storage engine named Sequence Engine, I also want to contribute to MySQL project. Detailed information about it: [Feature] SEQUENCE ENGINE Description: ------------ SEQUENCE engine as an embedded logical engine, it mainly used to generate unique number, it is the middle layer engine that use InnoDB or other storage engine as the based table engine, All query on sequence table will be changed into the operation on based table. the cache or other sequence value management is decided by SEQUENCE engine handler. According to the setting which is defined by 'CREATE SEQUENCE ... ' or 'CREATE TABLE...Engine=Sequence + INSERT VALUES'. user can query the nextval or currval from sequence object. In order to distinguish the normal SELECT statement, we supply two functions; 'SELECT NEXTVAL FROM SEQUENCE' will return the based table record directly. 'SELECT NEXTVAL(), CURRVAL()' will return the iterated record. Syntax: ------- CREATE SEQUENCE SYNTAX: CREATE SEQUENCE [IF NOT EXISTS] schema.sequence_name [START WITH <constant>] [MINVALUE <constant>] [MAXVALUE <constant>] [INCREMENT BY <constant>] [CACHE <constant> | NOCACHE] [CYCLE | NOCYCLE] ; OR: CREATE TABLE schema.sequence_name ( `currval` bigint(21) NOT NULL COMMENT 'current value', `nextval` bigint(21) NOT NULL COMMENT 'next value', `minvalue` bigint(21) NOT NULL COMMENT 'min value', `maxvalue` bigint(21) NOT NULL COMMENT 'max value', `start` bigint(21) NOT NULL COMMENT 'start value', `increment` bigint(21) NOT NULL COMMENT 'increment value', `cache` bigint(21) NOT NULL COMMENT 'cache size', `cycle` bigint(21) NOT NULL COMMENT 'cycle state', `round` bigint(21) NOT NULL COMMENT 'already how many round' ) ENGINE=Sequence DEFAULT CHARSET=latin1 INSERT INTO schema.sequence_name VALUES(0,0,1,9223372036854775807,1,1,10000,1,0); COMMIT; Strongly recommend the first CREATE SEQUENCE syntax. SHOW SYNTAX: SHOW CREATE TABLE schema.sequence_name; QUERY SYNTAX: SELECT [nextval | currval | *] FROM schema.sequence_name; SELECT nextval(schema.sequence_name); SELECT currval(schema.sequence_name); Usage: ------ FOR EXAMPLE: CREATE SEQUENCE s; INSERT INTO t VALUES(NEXTVAL(s)); How to repeat: see Description;