Commit f1dcbc2d authored by Alexander Barkov's avatar Alexander Barkov

MDEV-20639 ASAN SEGV in get_prefix upon modifying base column type with...

MDEV-20639 ASAN SEGV in get_prefix upon modifying base column type with existing indexed virtual column
parent 9b5cdeeb
......@@ -97,5 +97,22 @@ UPDATE IGNORE t1 SET d = NOW();
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# MDEV-20639 ASAN SEGV in get_prefix upon modifying base column type with existing indexed virtual column
#
CREATE TABLE t1 (
a TIMESTAMP,
b TIMESTAMP AS (a) VIRTUAL,
KEY (b)
);
ALTER TABLE t1 MODIFY a BLOB FIRST;
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `b`
Warning 1105 Expression depends on the @@sql_mode value TIME_ROUND_FRACTIONAL
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `b`
Warning 1105 Expression depends on the @@sql_mode value TIME_ROUND_FRACTIONAL
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `b`
Warning 1105 Expression depends on the @@sql_mode value TIME_ROUND_FRACTIONAL
DROP TABLE t1;
#
# End of 10.4 tests
#
......@@ -106,6 +106,18 @@ UPDATE IGNORE t1 SET d = NOW();
DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo #
--echo # MDEV-20639 ASAN SEGV in get_prefix upon modifying base column type with existing indexed virtual column
--echo #
CREATE TABLE t1 (
a TIMESTAMP,
b TIMESTAMP AS (a) VIRTUAL,
KEY (b)
);
ALTER TABLE t1 MODIFY a BLOB FIRST;
DROP TABLE t1;
--echo #
--echo # End of 10.4 tests
......
......@@ -1152,12 +1152,21 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
vcol= unpack_vcol_info_from_frm(thd, mem_root, table, &expr_str,
&((*field_ptr)->vcol_info), error_reported);
*(vfield_ptr++)= *field_ptr;
DBUG_ASSERT(table->map == 0);
/*
We need Item_field::const_item() to return false, so
datetime_precision() and time_precision() do not try to calculate
field values, e.g. val_str().
Set table->map to non-zero temporarily.
*/
table->map= 1;
if (vcol && field_ptr[0]->check_vcol_sql_mode_dependency(thd, mode))
{
DBUG_ASSERT(thd->is_error());
*error_reported= true;
goto end;
}
table->map= 0;
break;
case VCOL_DEFAULT:
vcol= unpack_vcol_info_from_frm(thd, mem_root, table, &expr_str,
......
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