Skip to content

Commit

Permalink
MDEV-32205 crash in get_schema_key_period_usage_record without InnoDB
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
FooBarrior authored and sanja-byelkin committed Feb 12, 2024
1 parent 62d35a0 commit d4b5f7a
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 127 deletions.
49 changes: 49 additions & 0 deletions mysql-test/suite/period/r/create.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
6 changes: 5 additions & 1 deletion mysql-test/suite/period/r/i_s_notembedded.result
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
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),
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/period/r/overlaps.result
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
34 changes: 34 additions & 0 deletions mysql-test/suite/period/t/create.test
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
4 changes: 4 additions & 0 deletions mysql-test/suite/period/t/i_s_notembedded.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,25 @@ 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;
# Give it a privilege to connect
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;
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/period/t/overlaps.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 0 additions & 11 deletions plugin/type_geom/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d4b5f7a

Please sign in to comment.