diff options
author | Sergei Petrunia <sergey@mariadb.com> | 2023-05-03 15:15:37 +0300 |
---|---|---|
committer | Sergei Petrunia <sergey@mariadb.com> | 2023-05-05 12:45:30 +0300 |
commit | 822dfad630221e1bbb5686b9d95c72e9b50f6b36 (patch) | |
tree | c3602955c04863f81014f0e745e9522f08014c99 /sql/opt_subselect.cc | |
parent | 9c287c0a90fcb6637417bd118f62c78de78f75ee (diff) | |
download | mariadb-git-bb-11.0-MDEV-31022-variant3.tar.gz |
MDEV-31022: SIGSEGV in maria_create from create_internal_tmp_tablebb-11.0-MDEV-31022-variant3
The code in create_internal_tmp_table() didn't take into account that
now temporary (derived) tables may have multiple indexes:
- one index due to duplicate removal
= In this example created by conversion of big-IN(...) into subquery
= this index might be converted into a "unique constraint" if the field(s)
length is too large.
- one index added by derived_with_keys optimization.
Make it handle multiple indexes.
As a consequence of this, remove TABLE_SHARE::uniques and replace it with
per-index HA_UNIQUE_HASH flag.
- TABLE_SHARE::uniques made sense when it referred to the only index in the
table.
- Now, we need to know which of table indexes should be a unique constraint,
so we indicate that as an index flag.
This patch is based on Monty's patch:
Co-Author: Monty <monty@mariadb.org>
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r-- | sql/opt_subselect.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 1d0b1ff1874..94adae02a17 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -4903,11 +4903,13 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd) { DBUG_PRINT("info",("Creating group key in temporary table")); share->keys=1; - share->uniques= MY_TEST(using_unique_constraint); table->key_info= share->key_info= keyinfo; keyinfo->key_part=key_part_info; - keyinfo->flags=HA_NOSAME; + keyinfo->flags= HA_NOSAME | (using_unique_constraint ? HA_UNIQUE_HASH : 0); + keyinfo->ext_key_flags= keyinfo->flags; keyinfo->usable_key_parts= keyinfo->user_defined_key_parts= 1; + keyinfo->ext_key_parts= 1; + share->key_parts= 1; keyinfo->key_length=0; keyinfo->rec_per_key=0; keyinfo->algorithm= HA_KEY_ALG_UNDEF; |