mariadb/mysql-test/suite/vcol/t
Aleksey Midenkov 076b1186ab MDEV-29155 CREATE OR REPLACE with self-referencing CHECK hangs
forever, cannot be killed

Virtual_column_info::fix_and_check_expr() first does fix_expr() which
finds all fields in query tables and then check_vcol_func_processor()
which prohibits SELECT expression. So before we get the error
prohibiting SELECT in vcol expression we must satisfy fix_expr() with
all the opened tables. The patch achieves this by iterating
query_tables from parsed vcol expression and by assigning opened
tables from the main parser context (as they are already preopened if
the parser sees some SELECT expressions).

But the problem is, we cannot use these TABLE objects fully for vcol
expression, at least the comment about MERGE tables states so:

  /* MERGE tables need to access parent and child TABLE_LISTs. */
  DBUG_ASSERT(tables->table->pos_in_table_list == tables);

Therefore after we have done vcol check we should revert back
TABLE_LISTs to the original TABLE-less state.

As CREATE OR REPLACE first drops the original table (at least prior to
MDEV-25292) we can use the above hack from the currently opening
table. And that is possible only after bitmaps initialized, so we move
their execution to a little earlier stage, before vcol parsing. But
partitioning depends on uninitialized bitmaps, so we temporarily
revert some to make partitioning initialization happy.

Note that plain CREATE TABLE just fails this case in parser with
NO_SUCH_TABLE, CREATE OR REPLACE doesn't fail in parser as the old
table still exists.

Now to the hang, mysql_rm_table_no_locks() does TDC_RT_REMOVE_ALL
which waits while share is closed. The table normally is open only as
OPEN_STUB, this is what parser does for CREATE TABLE. But for SELECT
the table is opened not as a stub. If it is the same table name we
anyway have two TABLE_LIST objects: stub and not stub. So for "not
stub" TDC_RT_REMOVE_ALL sees open count and decides to wait until it
is closed. And of course it hangs, because that was opened in the same
thread. Now we force close such TABLE objects before
mysql_rm_table_no_locks().

And the third, condition for sequences was wrong: we have to check
TABLE_LIST::sequence property to make sure we processing sequence.
2025-05-19 00:09:12 +03:00
..
alter_inplace-9045.test
binlog.test [1/2] MDEV-18166 ASSERT_COLUMN_MARKED_FOR_READ failed on tables with vcols 2021-07-12 22:00:39 +03:00
charsets.test
cross_db.test Updated mtr files to support different compiled in options 2019-09-01 19:17:35 +03:00
delayed.test
func_regexp.test MDEV-21058 CREATE TABLE with generated column and RLIKE results in sigabrt 2024-04-29 11:08:07 +04:00
index.test
innodb_autoinc_vcol.test
innodb_virtual_fk.test MDEV-31853 Assertion failure in Column_definition::check_vcol_for_key upon adding FK 2023-08-06 20:08:51 +02:00
load_data.test MDEV-31005: Make working cursor-protocol 2024-09-18 18:39:26 +07:00
mrr.test
myisam_repair_prefix_varchar.test
not_supported.test MDEV-29155 CREATE OR REPLACE with self-referencing CHECK hangs 2025-05-19 00:09:12 +03:00
partition.test MDEV-28127 EXCHANGE PARTITION with non-matching vcol expression segfault 2023-11-10 15:46:15 +03:00
races.test
range.test
rpl_vcol.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
update.test Merge branch '10.3' into 10.4 2019-09-06 11:53:10 +02:00
update_binlog.test
upgrade.test
vcol_archive.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_blackhole.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_blocked_sql_funcs.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_blocked_sql_funcs_main.inc
vcol_column_def_options_innodb.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_column_def_options_myisam.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_csv.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_handler_aria.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_handler_innodb.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_handler_myisam.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_ins_upd_innodb.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_ins_upd_myisam.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_keys_aria.test
vcol_keys_innodb.opt MDEV-20799 DROP Virtual Column crashes MariaDB 2019-10-28 08:40:48 +01:00
vcol_keys_innodb.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_keys_myisam.test MDEV-31005: Make working cursor-protocol 2024-09-18 18:39:26 +07:00
vcol_memory.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_merge.test
vcol_misc.opt vcols: cannot use CONTEXT_ANALYSIS_ONLY_VCOL_EXPR on fix_fields 2022-04-19 17:10:05 +02:00
vcol_misc.test MDEV-26891 Segfault in Field::register_field_in_read_map upon INSERT 2025-01-14 18:56:13 +03:00
vcol_non_stored_columns_innodb.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_non_stored_columns_myisam.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_partition_innodb.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_partition_myisam.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_select_innodb.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_select_myisam.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_sql_mode.test Merge 10.4 into 10.5 2019-09-17 09:07:52 +03:00
vcol_sql_mode_datetime.test Merge 10.4 into 10.5 2019-09-24 10:07:56 +03:00
vcol_sql_mode_time.test Merge 10.4 into 10.5 2019-09-24 10:07:56 +03:00
vcol_sql_mode_timestamp.test Merge remote-tracking branch 'origin/10.4' into 10.5 2019-10-01 11:44:27 +04:00
vcol_sql_mode_upgrade.test Revert "Part3: MDEV-18156 Assertion 0' failed or btr_validate_index(index, 0, false)' in row_upd_sec_index_entry or error code 126: Index is corrupted upon DELETE with PAD_CHAR_TO_FULL_LENGTH" 2019-09-11 13:52:33 +04:00
vcol_supported_sql_funcs.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_supported_sql_funcs_main.inc
vcol_syntax.test Merge branch '10.4' into 10.5 2023-12-02 01:02:50 +01:00
vcol_trigger_sp_innodb.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_trigger_sp_myisam.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_utf32.test MDEV-27966 Assertion fixed()' failed and Assertion fixed == 1' failed, both in Item_func_concat::val_str on SELECT after INSERT with collation utf32_bin on utf8_bin table 2024-06-19 10:01:30 +04:00
vcol_view_innodb.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
vcol_view_myisam.test MDEV-18650: Options deprecated in previous versions - storage_engine 2020-02-13 13:42:01 +02:00
wrong_arena.test MDEV-31003: Second execution for ps-protocol 2023-07-26 17:15:00 +07:00