Commit 08a1ac9d authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-4449 SEQUENCE depends on TEST_SQL_DISCOVERY for discovering tables upon DDL

implement a non-dummy discover_table_existence() method
parent a2d795c1
......@@ -268,3 +268,4 @@ 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;
......@@ -91,3 +91,7 @@ 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;
......@@ -255,16 +255,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 +285,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 +314,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=
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment