Commit 88a0bb83 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-15626 Assertion on update virtual column in partitioned table

table.cc:
  virtual columns must be computed for INSERT, if they're part
  of the partitioning expression.

this change broke gcol.gcol_partition_innodb.
fix CHECK TABLE for partitioned tables and vcols.

sql_partition.cc:
  mark prerequisite base columns in full_part_field_set
ha_partition.cc
  initialize vcol_set accordingly
parent 8ba0eea6
......@@ -18,3 +18,13 @@ x
15
22
DROP TABLE t1;
create table t1 (i int, v int as (i) virtual)
partition by range columns (i)
subpartition by hash(v) subpartitions 3 (
partition p1 values less than (3),
partition pn values less than (maxvalue));
insert t1 set i= 0;
set statement sql_mode= '' for update t1 set i= 1, v= 2;
Warnings:
Warning 1906 The value specified for generated column 'v' in table 't1' ignored
drop table t1;
......@@ -18,3 +18,15 @@ INSERT t1 (id, store_id) VALUES(1, 2), (3, 4), (3, 12), (4, 18);
CREATE INDEX idx ON t1(x);
SELECT x FROM t1;
DROP TABLE t1;
#
# MDEV-15626 Assertion on update virtual column in partitioned table
#
create table t1 (i int, v int as (i) virtual)
partition by range columns (i)
subpartition by hash(v) subpartitions 3 (
partition p1 values less than (3),
partition pn values less than (maxvalue));
insert t1 set i= 0;
set statement sql_mode= '' for update t1 set i= 1, v= 2;
drop table t1;
......@@ -8877,6 +8877,8 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
{
/* Only need to read the partitioning fields. */
bitmap_union(table->read_set, &m_part_info->full_part_field_set);
if (table->vcol_set)
bitmap_union(table->vcol_set, &m_part_info->full_part_field_set);
}
if ((result= m_file[read_part_id]->ha_rnd_init(1)))
......
......@@ -614,9 +614,16 @@ static bool create_full_part_field_array(THD *thd, TABLE *table,
full_part_field_array may be NULL if storage engine supports native
partitioning.
*/
table->vcol_set= table->read_set= &part_info->full_part_field_set;
if ((ptr= part_info->full_part_field_array))
for (; *ptr; ptr++)
bitmap_set_bit(&part_info->full_part_field_set, (*ptr)->field_index);
{
if ((*ptr)->vcol_info)
table->mark_virtual_col(*ptr);
else
bitmap_fast_test_and_set(table->read_set, (*ptr)->field_index);
}
table->default_column_bitmaps();
end:
DBUG_RETURN(result);
......
......@@ -6629,7 +6629,7 @@ bool TABLE::mark_virtual_columns_for_write(bool insert_fl)
if (bitmap_is_set(write_set, tmp_vfield->field_index))
bitmap_updated= mark_virtual_col(tmp_vfield);
else if (tmp_vfield->vcol_info->stored_in_db ||
(tmp_vfield->flags & PART_KEY_FLAG))
(tmp_vfield->flags & (PART_KEY_FLAG | FIELD_IN_PART_FUNC_FLAG)))
{
if (insert_fl)
{
......
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