summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/handler.cc9
-rw-r--r--sql/table.cc16
-rw-r--r--storage/test_sql_discovery/mysql-test/sql_discovery/simple.result71
-rw-r--r--storage/test_sql_discovery/mysql-test/sql_discovery/simple.test27
4 files changed, 58 insertions, 65 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 069e1369df3..f59fdddd54a 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4336,8 +4336,13 @@ static my_bool discover_handlerton(THD *thd, plugin_ref plugin,
{
if (error)
{
- DBUG_ASSERT(share->error); // MUST be always set for get_cached_table_share to work
- my_error(ER_GET_ERRNO, MYF(0), error, plugin_name(plugin)->str);
+ DBUG_ASSERT(share->error); // get_cached_table_share needs that
+ /*
+ report an error, unless it is "generic" and a more
+ specific one was already reported
+ */
+ if (error != HA_ERR_GENERIC || !thd->is_error())
+ my_error(ER_GET_ERRNO, MYF(0), error, plugin_name(plugin)->str);
share->db_plugin= 0;
}
else
diff --git a/sql/table.cc b/sql/table.cc
index b5550e090a1..dab76723b4e 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2085,16 +2085,10 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
lex_start(thd);
- if ((error= parse_sql(thd, & parser_state, NULL)))
+ if ((error= parse_sql(thd, & parser_state, NULL) ||
+ sql_unusable_for_discovery(thd, sql_copy)))
goto ret;
- if (sql_unusable_for_discovery(thd, sql_copy))
- {
- my_error(ER_SQL_DISCOVER_ERROR, MYF(0), plugin_name(db_plugin)->str,
- db.str, table_name.str, sql_copy);
- goto ret;
- }
-
thd->lex->create_info.db_type= plugin_hton(db_plugin);
if (tabledef_version.str)
@@ -2125,8 +2119,10 @@ ret:
if (thd->is_error() || error)
{
thd->clear_error();
- my_error(ER_NO_SUCH_TABLE, MYF(0), db.str, table_name.str);
- DBUG_RETURN(HA_ERR_NOT_A_TABLE);
+ my_error(ER_SQL_DISCOVER_ERROR, MYF(0),
+ plugin_name(db_plugin)->str, db.str, table_name.str,
+ sql_copy);
+ DBUG_RETURN(HA_ERR_GENERIC);
}
DBUG_RETURN(0);
}
diff --git a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result
index 4fee0a983ed..94589744ca8 100644
--- a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result
+++ b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result
@@ -11,92 +11,79 @@ set @@test_sql_discovery_statement='t1:foobar bwa-ha-ha';
select * from t0;
ERROR 42S02: Table 'test.t0' doesn't exist
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'foobar bwa-ha-ha'
show warnings;
Level Code Message
Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'foobar bwa-ha-ha' at line 1
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
+Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'foobar bwa-ha-ha'
set @@test_sql_discovery_statement='t1:select 1';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'select 1'
show warnings;
Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'select 1'
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
set @@test_sql_discovery_statement='t1:create table t1 (a int primary key) partition by hash(id) partitions 2';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int primary key) partition by hash(id) partitions 2'
show warnings;
Level Code Message
Error 1290 The MariaDB server is running with the --skip-partition option so it cannot execute this statement
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
+Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int primary key) partition by hash(id) partitions 2'
set @@test_sql_discovery_statement='t1:create table t1 (a int) union=(t3,t4)';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int) union=(t3,t4)'
show warnings;
Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int) union=(t3,t4)'
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
set @@test_sql_discovery_statement='t1:create table t1 like t2';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 like t2'
show warnings;
Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 like t2'
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
set @@test_sql_discovery_statement='t1:create table t1 select * from t2';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 select * from t2'
show warnings;
Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 select * from t2'
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
set @@test_sql_discovery_statement='t1:create table t1 (a int) index directory="/tmp"';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int) index directory="/tmp"'
show warnings;
Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int) index directory="/tmp"'
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
set @@test_sql_discovery_statement='t1:create table t1 (a int) data directory="/tmp"';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int) data directory="/tmp"'
show warnings;
Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int) data directory="/tmp"'
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
set @@test_sql_discovery_statement='t1:create table t1 (a int) engine=myisam';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int) engine=myisam'
show warnings;
Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int) engine=myisam'
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
set @@test_sql_discovery_statement='t1:create temporary table t1 (a int)';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create temporary table t1 (a int)'
show warnings;
Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create temporary table t1 (a int)'
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
set @@test_sql_discovery_statement='t1:create table if not exists t1 (a int)';
select * from t1;
-ERROR 42S02: Table 'test.t1' doesn't exist
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table if not exists t1 (a int)'
show warnings;
Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table if not exists t1 (a int)'
-Error 1146 Table 'test.t1' doesn't exist
-Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
+set @@test_sql_discovery_statement='t1:create table t1 (a uint)';
+select * from t1;
+ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a uint)'
+show warnings;
+Level Code Message
+Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'uint)' at line 1
+Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a uint)'
set @@test_sql_discovery_statement='t1:create table t1 (a int)';
select * from t1;
a
@@ -127,7 +114,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 13
+Handler_discover 14
show create table t1;
Table Create Table
t1 CREATE TABLE t1 (
@@ -145,7 +132,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 14
+Handler_discover 15
----
t1.frm
----
@@ -156,19 +143,19 @@ select * from t1;
a b c d e f
show status like 'handler_discover';
Variable_name Value
-Handler_discover 14
+Handler_discover 15
flush tables;
select * from t1;
a b c d e f
show status like 'handler_discover';
Variable_name Value
-Handler_discover 14
+Handler_discover 15
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 14
+Handler_discover 15
show create table t1;
Table Create Table
t1 CREATE TABLE t1 (
@@ -176,7 +163,7 @@ t1 CREATE TABLE t1 (
) ENGINE=TEST_SQL_DISCOVERY DEFAULT CHARSET=latin1
show status like 'handler_discover';
Variable_name Value
-Handler_discover 15
+Handler_discover 16
----
----
show open tables from test;
@@ -186,14 +173,14 @@ select * from t1;
a
show status like 'handler_discover';
Variable_name Value
-Handler_discover 15
+Handler_discover 16
flush tables;
select * from t1;
a
show status like 'handler_discover';
Variable_name Value
-Handler_discover 16
+Handler_discover 17
drop table t1;
show status like 'handler_discover';
Variable_name Value
-Handler_discover 16
+Handler_discover 17
diff --git a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.test b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.test
index 4aa5ac2864e..b8dea42297a 100644
--- a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.test
+++ b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.test
@@ -13,7 +13,7 @@ select * from t1;
set @@test_sql_discovery_statement='t1:foobar bwa-ha-ha';
--error ER_NO_SUCH_TABLE
select * from t0;
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
@@ -22,52 +22,57 @@ show warnings;
#
set @@test_sql_discovery_statement='t1:select 1';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int primary key) partition by hash(id) partitions 2';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int) union=(t3,t4)';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
set @@test_sql_discovery_statement='t1:create table t1 like t2';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
set @@test_sql_discovery_statement='t1:create table t1 select * from t2';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int) index directory="/tmp"';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int) data directory="/tmp"';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int) engine=myisam';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
set @@test_sql_discovery_statement='t1:create temporary table t1 (a int)';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;
set @@test_sql_discovery_statement='t1:create table if not exists t1 (a int)';
---error ER_NO_SUCH_TABLE
+--error ER_SQL_DISCOVER_ERROR
+select * from t1;
+show warnings;
+
+set @@test_sql_discovery_statement='t1:create table t1 (a uint)';
+--error ER_SQL_DISCOVER_ERROR
select * from t1;
show warnings;