Skip to content

Commit 72dc054

Browse files
committed
MDEV-36104 Server crashes when reading information_schema.COLUMNS after creating a table with virtual columns using the GIS data type
allow the table to be opened in any sql_mode, so that it can be examined (show create) and alter'ed to correct the error. the type mismatch error will be issued on DMLs and on CREATE, but not on SHOW or ALTER
1 parent 3c98e8c commit 72dc054

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

mysql-test/main/create.result

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,3 +2129,32 @@ EXECUTE stmt USING 4;
21292129
ERROR 22007: Truncated incorrect DECIMAL value: ''
21302130
DROP TABLE t;
21312131
# End of 11.7 Test
2132+
#
2133+
# MDEV-36104 Server crashes when reading information_schema.COLUMNS after creating a table with virtual columns using the GIS data type
2134+
#
2135+
create table t (a point generated always as (1) stored,b int generated always as (1) virtual);
2136+
ERROR HY000: Cannot cast 'int' as 'point' in assignment of `test`.`t`.`a`
2137+
set sql_mode='';
2138+
create table t (a point generated always as (1) stored,b int generated always as (1) virtual);
2139+
Warnings:
2140+
Warning 4078 Cannot cast 'int' as 'point' in assignment of `test`.`t`.`a`
2141+
set sql_mode=default;
2142+
select column_name,column_type from information_schema.columns where table_name='t';
2143+
column_name column_type
2144+
a point
2145+
b int(11)
2146+
Warnings:
2147+
Warning 4078 Cannot cast 'int' as 'point' in assignment of `test`.`t`.`a`
2148+
show create table t;
2149+
Table Create Table
2150+
t CREATE TABLE `t` (
2151+
`a` point GENERATED ALWAYS AS (1) STORED,
2152+
`b` int(11) GENERATED ALWAYS AS (1) VIRTUAL
2153+
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
2154+
Warnings:
2155+
Warning 4078 Cannot cast 'int' as 'point' in assignment of `test`.`t`.`a`
2156+
insert t () values ();
2157+
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
2158+
alter table t add column c int, drop column a, drop column b;
2159+
drop table t;
2160+
# End of 11.8 Test

mysql-test/main/create.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,3 +2002,22 @@ EXECUTE stmt USING 4;
20022002
DROP TABLE t;
20032003

20042004
--echo # End of 11.7 Test
2005+
2006+
--echo #
2007+
--echo # MDEV-36104 Server crashes when reading information_schema.COLUMNS after creating a table with virtual columns using the GIS data type
2008+
--echo #
2009+
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
2010+
create table t (a point generated always as (1) stored,b int generated always as (1) virtual);
2011+
set sql_mode='';
2012+
create table t (a point generated always as (1) stored,b int generated always as (1) virtual);
2013+
set sql_mode=default;
2014+
select column_name,column_type from information_schema.columns where table_name='t';
2015+
--enable_prepare_warnings
2016+
show create table t;
2017+
--disable_prepare_warnings
2018+
--error ER_CANT_CREATE_GEOMETRY_OBJECT
2019+
insert t () values ();
2020+
alter table t add column c int, drop column a, drop column b;
2021+
drop table t;
2022+
2023+
--echo # End of 11.8 Test

sql/table.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,8 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
12601260
table->map= 1;
12611261
if (vcol &&
12621262
(field_ptr[0]->check_vcol_sql_mode_dependency(thd, mode) ||
1263-
vcol->expr->check_assignability_to(field_ptr[0], false)))
1263+
vcol->expr->check_assignability_to(field_ptr[0],
1264+
mode == VCOL_INIT_DEPENDENCY_FAILURE_IS_WARNING)))
12641265
{
12651266
DBUG_ASSERT(thd->is_error());
12661267
*error_reported= true;

0 commit comments

Comments
 (0)