Skip to content

Commit b2f60ae

Browse files
AliSQLAliSQL
authored andcommitted
[Feature] Issue alibaba#41 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 SEQUENCE TABLE... + INSERT VALUES'. user can query the nextval or currval from sequence. In order to distinguish the normal SELECT statement, we supply new Syntax 'SELECT NEXTVAL FOR SEQUENCE'; 1. 'SELECT NEXTVAL FROM SEQUENCE' will return the based table record directly. 2. 'SELECT NEXTVAL FOR SEQUENCE' will return the iteratored 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 SEQUENCE 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=InnoDB 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 SEQUENCE schema.sequence_name; SHOW CREATE TABLE schema.sequence_name; QUERY SYNTAX: SELECT [nextval | currval | *] FOR schema.sequence_name; SELECT [nextval | currval | *] FROM schema.sequence_name; Usage: ------ FOR EXAMPLE: create sequence s; create table t(id int); select nextval for s; insert into t select nextval for s;
1 parent 02a5207 commit b2f60ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+6597
-17
lines changed

include/my_base.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,10 @@ is the global server default. */
488488
#define HA_ERR_TEMP_FILE_WRITE_FAILURE 189 /* Temporary file write failure */
489489
#define HA_ERR_INNODB_FORCED_RECOVERY 190 /* Innodb is in force recovery mode */
490490
#define HA_ERR_FTS_TOO_MANY_WORDS_IN_PHRASE 191 /* Too many words in a phrase */
491-
#define HA_ERR_LAST 191 /* Copy of last error nr */
491+
#define HA_ERR_SEQUENCE_RUN_OUT 192 /* Sequence has been run out */
492+
#define HA_ERR_SEQUENCE_INVALID 193 /* Sequence structure or number is invalid.*/
493+
#define HA_ERR_SEQUENCE_ACCESS_ERROR 194 /* Sequence access error */
494+
#define HA_ERR_LAST 194 /* Copy of last error nr */
492495

493496
/* Number of different errors */
494497
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)

include/mysql/plugin.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,10 @@ void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
673673
*/
674674
void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton,
675675
const void *ha_data);
676+
void *thd_get_atm_ha_data(const MYSQL_THD thd);
677+
void thd_set_atm_ha_data(MYSQL_THD thd, const void *ha_data);
678+
unsigned long thd_get_atm_lock_type(const MYSQL_THD thd);
679+
void thd_set_atm_lock_type(MYSQL_THD thd, unsigned long lock_type);
676680
#ifdef __cplusplus
677681
}
678682
#endif

include/mysql/plugin_audit.h.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@
252252
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
253253
void thd_set_ha_data(void* thd, const struct handlerton *hton,
254254
const void *ha_data);
255+
void *thd_get_atm_ha_data(const void* thd);
256+
void thd_set_atm_ha_data(void* thd, const void *ha_data);
257+
unsigned long thd_get_atm_lock_type(const void *thd);
258+
void thd_set_atm_lock_type(void *thd, unsigned long lock_type);
255259
struct mysql_event_general
256260
{
257261
unsigned int event_subclass;

include/mysql/plugin_auth.h.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@
252252
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
253253
void thd_set_ha_data(void* thd, const struct handlerton *hton,
254254
const void *ha_data);
255+
void *thd_get_atm_ha_data(const void* thd);
256+
void thd_set_atm_ha_data(void* thd, const void *ha_data);
257+
unsigned long thd_get_atm_lock_type(const void *thd);
258+
void thd_set_atm_lock_type(void *thd, unsigned long lock_type);
255259
#include <mysql/plugin_auth_common.h>
256260
typedef struct st_plugin_vio_info
257261
{

include/mysql/plugin_ftparser.h.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@
205205
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
206206
void thd_set_ha_data(void* thd, const struct handlerton *hton,
207207
const void *ha_data);
208+
void *thd_get_atm_ha_data(const void* thd);
209+
void thd_set_atm_ha_data(void* thd, const void *ha_data);
210+
unsigned long thd_get_atm_lock_type(const void *thd);
211+
void thd_set_atm_lock_type(void *thd, unsigned long lock_type);
208212
enum enum_ftparser_mode
209213
{
210214
MYSQL_FTPARSER_SIMPLE_MODE= 0,

0 commit comments

Comments
 (0)