Commit a2d795c1 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-4450 misleading error messages from init_from_sql_statement_string()

parent 0973b7a8
...@@ -4336,8 +4336,13 @@ static my_bool discover_handlerton(THD *thd, plugin_ref plugin, ...@@ -4336,8 +4336,13 @@ static my_bool discover_handlerton(THD *thd, plugin_ref plugin,
{ {
if (error) if (error)
{ {
DBUG_ASSERT(share->error); // MUST be always set for get_cached_table_share to work DBUG_ASSERT(share->error); // get_cached_table_share needs that
my_error(ER_GET_ERRNO, MYF(0), error, plugin_name(plugin)->str); /*
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; share->db_plugin= 0;
} }
else else
......
...@@ -2085,16 +2085,10 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, ...@@ -2085,16 +2085,10 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
lex_start(thd); 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; 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); thd->lex->create_info.db_type= plugin_hton(db_plugin);
if (tabledef_version.str) if (tabledef_version.str)
...@@ -2125,8 +2119,10 @@ ret: ...@@ -2125,8 +2119,10 @@ ret:
if (thd->is_error() || error) if (thd->is_error() || error)
{ {
thd->clear_error(); thd->clear_error();
my_error(ER_NO_SUCH_TABLE, MYF(0), db.str, table_name.str); my_error(ER_SQL_DISCOVER_ERROR, MYF(0),
DBUG_RETURN(HA_ERR_NOT_A_TABLE); plugin_name(db_plugin)->str, db.str, table_name.str,
sql_copy);
DBUG_RETURN(HA_ERR_GENERIC);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -11,92 +11,79 @@ set @@test_sql_discovery_statement='t1:foobar bwa-ha-ha'; ...@@ -11,92 +11,79 @@ set @@test_sql_discovery_statement='t1:foobar bwa-ha-ha';
select * from t0; select * from t0;
ERROR 42S02: Table 'test.t0' doesn't exist ERROR 42S02: Table 'test.t0' doesn't exist
select * from t1; 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; show warnings;
Level Code Message 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 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 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'foobar bwa-ha-ha'
Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY
set @@test_sql_discovery_statement='t1:select 1'; set @@test_sql_discovery_statement='t1:select 1';
select * from t1; 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; show warnings;
Level Code Message Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'select 1' 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'; set @@test_sql_discovery_statement='t1:create table t1 (a int primary key) partition by hash(id) partitions 2';
select * from t1; 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; show warnings;
Level Code Message Level Code Message
Error 1290 The MariaDB server is running with the --skip-partition option so it cannot execute this statement 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 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'
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) union=(t3,t4)'; set @@test_sql_discovery_statement='t1:create table t1 (a int) union=(t3,t4)';
select * from t1; 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; show warnings;
Level Code Message 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 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'; set @@test_sql_discovery_statement='t1:create table t1 like t2';
select * from t1; 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; show warnings;
Level Code Message Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 like t2' 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'; set @@test_sql_discovery_statement='t1:create table t1 select * from t2';
select * from t1; 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; show warnings;
Level Code Message Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 select * from t2' 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"'; set @@test_sql_discovery_statement='t1:create table t1 (a int) index directory="/tmp"';
select * from t1; 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; show warnings;
Level Code Message 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 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"'; set @@test_sql_discovery_statement='t1:create table t1 (a int) data directory="/tmp"';
select * from t1; 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; show warnings;
Level Code Message 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 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'; set @@test_sql_discovery_statement='t1:create table t1 (a int) engine=myisam';
select * from t1; 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; show warnings;
Level Code Message Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a int) engine=myisam' 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)'; set @@test_sql_discovery_statement='t1:create temporary table t1 (a int)';
select * from t1; 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; show warnings;
Level Code Message Level Code Message
Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create temporary table t1 (a int)' 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)'; set @@test_sql_discovery_statement='t1:create table if not exists t1 (a int)';
select * from t1; 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; show warnings;
Level Code Message 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 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 set @@test_sql_discovery_statement='t1:create table t1 (a uint)';
Error 1030 Got error 130 "Incorrect file format" from storage engine TEST_SQL_DISCOVERY 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)'; set @@test_sql_discovery_statement='t1:create table t1 (a int)';
select * from t1; select * from t1;
a a
...@@ -127,7 +114,7 @@ create table t1 ( ...@@ -127,7 +114,7 @@ create table t1 (
) comment="abc" default character set utf8 max_rows=100 min_rows=10 checksum=1'; ) comment="abc" default character set utf8 max_rows=100 min_rows=10 checksum=1';
show status like 'handler_discover'; show status like 'handler_discover';
Variable_name Value Variable_name Value
Handler_discover 13 Handler_discover 14
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE t1 ( t1 CREATE TABLE t1 (
...@@ -145,7 +132,7 @@ 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' ) ENGINE=TEST_SQL_DISCOVERY DEFAULT CHARSET=utf8 MIN_ROWS=10 MAX_ROWS=100 CHECKSUM=1 COMMENT='abc'
show status like 'handler_discover'; show status like 'handler_discover';
Variable_name Value Variable_name Value
Handler_discover 14 Handler_discover 15
---- ----
t1.frm t1.frm
---- ----
...@@ -156,19 +143,19 @@ select * from t1; ...@@ -156,19 +143,19 @@ select * from t1;
a b c d e f a b c d e f
show status like 'handler_discover'; show status like 'handler_discover';
Variable_name Value Variable_name Value
Handler_discover 14 Handler_discover 15
flush tables; flush tables;
select * from t1; select * from t1;
a b c d e f a b c d e f
show status like 'handler_discover'; show status like 'handler_discover';
Variable_name Value Variable_name Value
Handler_discover 14 Handler_discover 15
drop table t1; drop table t1;
set @@test_sql_discovery_write_frm=0; set @@test_sql_discovery_write_frm=0;
set @@test_sql_discovery_statement='t1:create table t1 (a int)'; set @@test_sql_discovery_statement='t1:create table t1 (a int)';
show status like 'handler_discover'; show status like 'handler_discover';
Variable_name Value Variable_name Value
Handler_discover 14 Handler_discover 15
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE t1 ( t1 CREATE TABLE t1 (
...@@ -176,7 +163,7 @@ t1 CREATE TABLE t1 ( ...@@ -176,7 +163,7 @@ t1 CREATE TABLE t1 (
) ENGINE=TEST_SQL_DISCOVERY DEFAULT CHARSET=latin1 ) ENGINE=TEST_SQL_DISCOVERY DEFAULT CHARSET=latin1
show status like 'handler_discover'; show status like 'handler_discover';
Variable_name Value Variable_name Value
Handler_discover 15 Handler_discover 16
---- ----
---- ----
show open tables from test; show open tables from test;
...@@ -186,14 +173,14 @@ select * from t1; ...@@ -186,14 +173,14 @@ select * from t1;
a a
show status like 'handler_discover'; show status like 'handler_discover';
Variable_name Value Variable_name Value
Handler_discover 15 Handler_discover 16
flush tables; flush tables;
select * from t1; select * from t1;
a a
show status like 'handler_discover'; show status like 'handler_discover';
Variable_name Value Variable_name Value
Handler_discover 16 Handler_discover 17
drop table t1; drop table t1;
show status like 'handler_discover'; show status like 'handler_discover';
Variable_name Value Variable_name Value
Handler_discover 16 Handler_discover 17
...@@ -13,7 +13,7 @@ select * from t1; ...@@ -13,7 +13,7 @@ select * from t1;
set @@test_sql_discovery_statement='t1:foobar bwa-ha-ha'; set @@test_sql_discovery_statement='t1:foobar bwa-ha-ha';
--error ER_NO_SUCH_TABLE --error ER_NO_SUCH_TABLE
select * from t0; select * from t0;
--error ER_NO_SUCH_TABLE --error ER_SQL_DISCOVER_ERROR
select * from t1; select * from t1;
show warnings; show warnings;
...@@ -22,52 +22,57 @@ show warnings; ...@@ -22,52 +22,57 @@ show warnings;
# #
set @@test_sql_discovery_statement='t1:select 1'; set @@test_sql_discovery_statement='t1:select 1';
--error ER_NO_SUCH_TABLE --error ER_SQL_DISCOVER_ERROR
select * from t1; select * from t1;
show warnings; show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int primary key) partition by hash(id) partitions 2'; 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; select * from t1;
show warnings; show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int) union=(t3,t4)'; 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; select * from t1;
show warnings; show warnings;
set @@test_sql_discovery_statement='t1:create table t1 like t2'; set @@test_sql_discovery_statement='t1:create table t1 like t2';
--error ER_NO_SUCH_TABLE --error ER_SQL_DISCOVER_ERROR
select * from t1; select * from t1;
show warnings; show warnings;
set @@test_sql_discovery_statement='t1:create table t1 select * from t2'; 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; select * from t1;
show warnings; show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int) index directory="/tmp"'; 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; select * from t1;
show warnings; show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int) data directory="/tmp"'; 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; select * from t1;
show warnings; show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int) engine=myisam'; 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; select * from t1;
show warnings; show warnings;
set @@test_sql_discovery_statement='t1:create temporary table t1 (a int)'; 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; select * from t1;
show warnings; show warnings;
set @@test_sql_discovery_statement='t1:create table if not exists t1 (a int)'; 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; select * from t1;
show warnings; show warnings;
......
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