summaryrefslogtreecommitdiff
path: root/storage/sequence
diff options
context:
space:
mode:
Diffstat (limited to 'storage/sequence')
-rw-r--r--storage/sequence/mysql-test/sequence/simple.result5
-rw-r--r--storage/sequence/mysql-test/sequence/simple.test13
-rw-r--r--storage/sequence/sequence.cc46
3 files changed, 50 insertions, 14 deletions
diff --git a/storage/sequence/mysql-test/sequence/simple.result b/storage/sequence/mysql-test/sequence/simple.result
index 2d56e57d199..a1dbd33ec19 100644
--- a/storage/sequence/mysql-test/sequence/simple.result
+++ b/storage/sequence/mysql-test/sequence/simple.result
@@ -268,3 +268,8 @@ master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use test; insert t1 select * from seq_1_to_10
master-bin.000001 # Xid # # COMMIT /* XID */
drop table t1;
+drop table seq_1_to_1;
+set binlog_format=statement;
+lock table seq_1_to_2 write;
+set binlog_format=row;
+lock table seq_1_to_2 write;
diff --git a/storage/sequence/mysql-test/sequence/simple.test b/storage/sequence/mysql-test/sequence/simple.test
index b16c954176e..7c76997dddf 100644
--- a/storage/sequence/mysql-test/sequence/simple.test
+++ b/storage/sequence/mysql-test/sequence/simple.test
@@ -91,3 +91,16 @@ let $binlog_limit= 10;
--source include/show_binlog_events.inc
drop table t1;
+#
+# MDEV-4449 SEQUENCE depends on TEST_SQL_DISCOVERY for discovering tables upon DDL
+#
+drop table seq_1_to_1;
+
+#
+# MDEV-4451 Attempt to write-lock a SEQUENCE table with log-bin enabled causes ER_BINLOG_ROW_ENGINE_AND_STMT_ENGINE
+#
+set binlog_format=statement;
+lock table seq_1_to_2 write;
+set binlog_format=row;
+lock table seq_1_to_2 write;
+
diff --git a/storage/sequence/sequence.cc b/storage/sequence/sequence.cc
index 2349f7aae63..60b360592ce 100644
--- a/storage/sequence/sequence.cc
+++ b/storage/sequence/sequence.cc
@@ -45,7 +45,8 @@ private:
public:
ha_seq(handlerton *hton, TABLE_SHARE *table_arg)
: handler(hton, table_arg), seqs(0) { }
- ulonglong table_flags() const { return 0; }
+ ulonglong table_flags() const
+ { return HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE; }
/* open/close/locking */
int create(const char *name, TABLE *table_arg,
@@ -255,16 +256,26 @@ static handler *create_handler(handlerton *hton, TABLE_SHARE *table,
return new (mem_root) ha_seq(hton, table);
}
-static int discover_table(handlerton *hton, THD *thd, TABLE_SHARE *share)
+
+static bool parse_table_name(const char *name, size_t name_length,
+ ulonglong *from, ulonglong *to, ulonglong *step)
{
- // the table is discovered if it has the pattern of seq_1_to_10 or
- // seq_1_to_10_step_3
- ulonglong from, to, step= 1;
uint n1= 0, n2= 0;
- bool reverse;
- sscanf(share->table_name.str, "seq_%llu_to_%llu%n_step_%llu%n",
- &from, &to, &n1, &step, &n2);
- if (n1 != share->table_name.length && n2 != share->table_name.length)
+ *step= 1;
+
+ // the table is discovered if its name matches the pattern of seq_1_to_10 or
+ // seq_1_to_10_step_3
+ sscanf(name, "seq_%llu_to_%llu%n_step_%llu%n",
+ from, to, &n1, step, &n2);
+ return n1 != name_length && n2 != name_length;
+}
+
+
+static int discover_table(handlerton *hton, THD *thd, TABLE_SHARE *share)
+{
+ ulonglong from, to, step;
+ if (parse_table_name(share->table_name.str, share->table_name.length,
+ &from, &to, &step))
return HA_ERR_NO_SUCH_TABLE;
if (step == 0)
@@ -275,6 +286,7 @@ static int discover_table(handlerton *hton, THD *thd, TABLE_SHARE *share)
if (res)
return res;
+ bool reverse;
if ((reverse = from > to))
{
if (step > from - to)
@@ -303,15 +315,21 @@ static int discover_table(handlerton *hton, THD *thd, TABLE_SHARE *share)
}
+static int discover_table_existence(handlerton *hton, const char *db,
+ const char *table_name)
+{
+ ulonglong from, to, step;
+ return !parse_table_name(table_name, strlen(table_name), &from, &to, &step);
+}
+
static int dummy_ret_int() { return 0; }
static int init(void *p)
{
- handlerton *hton = (handlerton *)p;
- hton->create = create_handler;
- hton->discover_table = discover_table;
- hton->discover_table_existence =
- (int (*)(handlerton *, const char *, const char *)) &dummy_ret_int;
+ handlerton *hton= (handlerton *)p;
+ hton->create= create_handler;
+ hton->discover_table= discover_table;
+ hton->discover_table_existence= discover_table_existence;
hton->commit= hton->rollback= hton->prepare=
(int (*)(handlerton *, THD *, bool)) &dummy_ret_int;
hton->savepoint_set= hton->savepoint_rollback= hton->savepoint_release=