Commit d4b5f7a5 authored by Nikita Malyavin's avatar Nikita Malyavin Committed by Oleksandr Byelkin

MDEV-32205 crash in get_schema_key_period_usage_record without InnoDB

Move table open result processing to the caller

* st_schema_table::process_table doesn't have to check whether the table
was opened successfully
* It also doesn't have to check for a thd error and convert it to a warning
* This simplifies adding new tables into information_schema
* A callback still can output some info to a user in case of error. In
order to do this, I_S_EXTENDED_ERROR_HANDLING should be specified in
i_s_requested_object.
parent 62d35a07
......@@ -10,9 +10,21 @@ t CREATE TABLE `t` (
PERIOD FOR `mytime` (`s`, `e`),
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
create view v as select * from t;
select * from information_schema.periods;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PERIOD START_COLUMN_NAME END_COLUMN_NAME
def test t mytime s e
Warnings:
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
select * from information_schema.key_period_usage;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PERIOD_NAME
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
Warnings:
drop view v;
create or replace table t (id int primary key, s timestamp(6), e timestamp(6),
period for mytime(s,e));
show create table t;
......@@ -114,3 +126,40 @@ create table t2 (s date, e date, period for
`abcd123456789012345678901234567890123456789012345678901234567890`
(s,e));
drop table t2;
# MDEV-32205 Server crashes in get_schema_key_period_usage_record on
# server without InnoDB
# Make sure innodb id disabled, but there's at least one innodb table
select "yes" from information_schema.tables where engine="innodb" limit 1;
yes
yes
select plugin_status from information_schema.all_plugins where plugin_name = "innodb";
plugin_status
DISABLED
select * from information_schema.periods;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PERIOD START_COLUMN_NAME END_COLUMN_NAME
select * from information_schema.key_period_usage;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PERIOD_NAME
# [DUPLICATE] MDEV-32204 Server crashes in
# get_schema_key_period_usage_record
create table t (a date) engine=myisam;
create table t1 (a int) engine=merge union = (t) ;
select 1 from information_schema.key_period_usage;
1
Warning 1168 Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
Warnings:
drop table t1;
drop table t;
create view v1 as select 1;
create view v2 as select * from v1;
drop view v1;
select * from information_schema.key_period_usage;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PERIOD_NAME
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
Warnings:
drop view v2;
select * from information_schema.periods;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PERIOD START_COLUMN_NAME END_COLUMN_NAME
Warnings:
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1286 Unknown storage engine 'InnoDB'
create or replace table t1 (id int primary key, s timestamp(6), e timestamp(6),
period for mytime(s,e));
create or replace table t2 (id int primary key, s timestamp(6), e timestamp(6),
......@@ -15,9 +19,9 @@ s timestamp(6) NO NULL
e timestamp(6) NO NULL
select * from information_schema.periods where table_schema = 'test';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PERIOD START_COLUMN_NAME END_COLUMN_NAME
def test t1 mytime s e
def test t2 SYSTEM_TIME vs ve
def test t2 mytime s e
def test t1 mytime s e
create user periods_hidden@localhost;
grant create on test.nonexist to periods_hidden@localhost;
connect chopped,localhost,periods_hidden,,test;
......
......@@ -22,9 +22,9 @@ unique(id2, very_interesting_period without overlaps)
);
select * from information_schema.key_period_usage;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PERIOD_NAME
def test PRIMARY def test t p
def test PRIMARY def test t_multi very_interesting_period
def test id2 def test t_multi very_interesting_period
def test PRIMARY def test t p
drop table t_multi;
insert into t values (1, '2003-01-01', '2003-03-01'),
(1, '2003-05-01', '2003-07-01');
......
......@@ -2,7 +2,11 @@ create table t (id int primary key, s date, e date, period for mytime(s,e));
--echo # CONSTRAINT CHECK (s < e) is added implicitly, and shouldn't be shown
--echo # this is important for correct command-based replication
show create table t;
create view v as select * from t;
select * from information_schema.periods;
--sorted_result
select * from information_schema.key_period_usage;
drop view v;
create or replace table t (id int primary key, s timestamp(6), e timestamp(6),
period for mytime(s,e));
......@@ -101,3 +105,33 @@ create table t2 (s date, e date, period for
`abcd123456789012345678901234567890123456789012345678901234567890`
(s,e));
drop table t2;
--echo # MDEV-32205 Server crashes in get_schema_key_period_usage_record on
--echo # server without InnoDB
--echo # Make sure innodb id disabled, but there's at least one innodb table
--disable_warnings
select "yes" from information_schema.tables where engine="innodb" limit 1;
select plugin_status from information_schema.all_plugins where plugin_name = "innodb";
select * from information_schema.periods;
select * from information_schema.key_period_usage;
--enable_warnings
--echo # [DUPLICATE] MDEV-32204 Server crashes in
--echo # get_schema_key_period_usage_record
create table t (a date) engine=myisam;
create table t1 (a int) engine=merge union = (t) ;
--sorted_result
select 1 from information_schema.key_period_usage;
drop table t1;
drop table t;
create view v1 as select 1;
create view v2 as select * from v1;
drop view v1;
--sorted_result
select * from information_schema.key_period_usage;
drop view v2;
......@@ -14,6 +14,7 @@ create or replace table t2 (id int primary key, s timestamp(6), e timestamp(6),
show columns from t1;
--sorted_result
select * from information_schema.periods where table_schema = 'test';
create user periods_hidden@localhost;
......@@ -21,14 +22,17 @@ create user periods_hidden@localhost;
grant create on test.nonexist to periods_hidden@localhost;
--connect (chopped,localhost,periods_hidden,,test)
--sorted_result
select * from information_schema.periods where table_schema = 'test';
--connection default
grant select(id) on test.t1 to periods_hidden@localhost;
--connection chopped
--sorted_result
select * from information_schema.periods where table_schema = 'test';
--connection default
grant select(s) on test.t1 to periods_hidden@localhost;
--connection chopped
--sorted_result
select * from information_schema.periods where table_schema = 'test';
--connection default
grant select(e) on test.t2 to periods_hidden@localhost;
......
......@@ -13,12 +13,14 @@ create or replace table t(id int, s date, e date,
--replace_result $default_engine DEFAULT_ENGINE
show create table t;
--sorted_result
select * from information_schema.key_period_usage;
create or replace table t_multi(id int, id2 int, s date, e date,
period for very_interesting_period(s,e),
primary key(id, very_interesting_period without overlaps),
unique(id2, very_interesting_period without overlaps)
);
--sorted_result
select * from information_schema.key_period_usage;
drop table t_multi;
......
......@@ -158,17 +158,6 @@ static int get_geometry_column_record(THD *thd, TABLE_LIST *tables,
Field **ptr, *field;
DBUG_ENTER("get_geometry_column_record");
if (res)
{
/*
open_table() failed with an error.
Convert the error to a warning and let the caller
continue with the next table.
*/
convert_error_to_warning(thd);
DBUG_RETURN(0);
}
// Skip INFORMATION_SCHEMA tables. They don't have geometry columns.
if (tables->schema_table)
DBUG_RETURN(0);
......
This diff is collapsed.
......@@ -130,6 +130,13 @@
*/
#define OPEN_TRIGGER_ONLY (1 << 21)
/**
This flag is used in information schema to determine if handling funciton
can treat open result extensively and provide some user output even if
table open fails.
*/
#define I_S_EXTENDED_ERROR_HANDLING (1 << 22)
/*
Minimum length pattern before Turbo Boyer-Moore is used
for SELECT "text" LIKE "%pattern%", excluding the two
......
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