Commit 5e2b5510 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5260 discovery with sql is too restrictive

allow ENGINE=FOOBAR in the discovering create table statement,
as long as the discovering engine is FOOBAR too
parent 09b63917
......@@ -1997,7 +1997,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
}
static bool sql_unusable_for_discovery(THD *thd, const char *sql)
static bool sql_unusable_for_discovery(THD *thd, handlerton *engine,
const char *sql)
{
LEX *lex= thd->lex;
HA_CREATE_INFO *create_info= &lex->create_info;
......@@ -2029,7 +2030,7 @@ static bool sql_unusable_for_discovery(THD *thd, const char *sql)
if (create_info->data_file_name || create_info->index_file_name)
return 1;
// ... engine
if (create_info->used_fields & HA_CREATE_USED_ENGINE)
if (create_info->db_type && create_info->db_type != engine)
return 1;
return 0;
......@@ -2049,6 +2050,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
LEX tmp_lex;
KEY *unused1;
uint unused2;
handlerton *hton= plugin_hton(db_plugin);
LEX_CUSTRING frm= {0,0};
DBUG_ENTER("TABLE_SHARE::init_from_sql_statement_string");
......@@ -2080,10 +2082,10 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
lex_start(thd);
if ((error= parse_sql(thd, & parser_state, NULL) ||
sql_unusable_for_discovery(thd, sql_copy)))
sql_unusable_for_discovery(thd, hton, sql_copy)))
goto ret;
thd->lex->create_info.db_type= plugin_hton(db_plugin);
thd->lex->create_info.db_type= hton;
if (tabledef_version.str)
thd->lex->create_info.tabledef_version= tabledef_version;
......
......@@ -99,6 +99,10 @@ a
select * from t2;
ERROR 42S02: Table 'test.t2' doesn't exist
drop table t1;
set @@test_sql_discovery_statement='t1:create table t1 (a int) engine=test_sql_discovery';
select * from t1;
a
drop table t1;
set @@test_sql_discovery_statement='t1:
create table t1 (
a int not null default 5 primary key,
......@@ -114,7 +118,7 @@ create table t1 (
) comment="abc" default character set utf8 max_rows=100 min_rows=10 checksum=1';
show status like 'handler_discover';
Variable_name Value
Handler_discover 14
Handler_discover 15
show create table t1;
Table Create Table
t1 CREATE TABLE t1 (
......@@ -132,7 +136,7 @@ t1 CREATE TABLE t1 (
) ENGINE=TEST_SQL_DISCOVERY DEFAULT CHARSET=utf8 MIN_ROWS=10 MAX_ROWS=100 CHECKSUM=1 COMMENT='abc'
show status like 'handler_discover';
Variable_name Value
Handler_discover 15
Handler_discover 16
----
t1.frm
----
......@@ -143,19 +147,19 @@ select * from t1;
a b c d e f
show status like 'handler_discover';
Variable_name Value
Handler_discover 15
Handler_discover 16
flush tables;
select * from t1;
a b c d e f
show status like 'handler_discover';
Variable_name Value
Handler_discover 15
Handler_discover 16
drop table t1;
set @@test_sql_discovery_write_frm=0;
set @@test_sql_discovery_statement='t1:create table t1 (a int)';
show status like 'handler_discover';
Variable_name Value
Handler_discover 15
Handler_discover 16
show create table t1;
Table Create Table
t1 CREATE TABLE t1 (
......@@ -163,7 +167,7 @@ t1 CREATE TABLE t1 (
) ENGINE=TEST_SQL_DISCOVERY DEFAULT CHARSET=latin1
show status like 'handler_discover';
Variable_name Value
Handler_discover 16
Handler_discover 17
----
----
show open tables from test;
......@@ -173,14 +177,14 @@ select * from t1;
a
show status like 'handler_discover';
Variable_name Value
Handler_discover 16
Handler_discover 17
flush tables;
select * from t1;
a
show status like 'handler_discover';
Variable_name Value
Handler_discover 17
Handler_discover 18
drop table t1;
show status like 'handler_discover';
Variable_name Value
Handler_discover 17
Handler_discover 18
......@@ -91,6 +91,10 @@ select * from t1;
select * from t2;
drop table t1;
set @@test_sql_discovery_statement='t1:create table t1 (a int) engine=test_sql_discovery';
select * from t1;
drop table t1;
# and something more complex
set @@test_sql_discovery_statement='t1:
create table t1 (
......
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