mariadb/libmysqld
Sergei Petrunia 4941ac9192 MDEV-32113: utf8mb3_key_col=utf8mb4_value cannot be used for ref
(Variant#3: Allow cross-charset comparisons, use a special
CHARSET_INFO to create lookup keys. Review input addressed.)

Equalities that compare utf8mb{3,4}_general_ci strings, like:

  WHERE ... utf8mb3_key_col=utf8mb4_value    (MB3-4-CMP)

can now be used to construct ref[const] access and also participate
in multiple-equalities.
This means that utf8mb3_key_col can be used for key-lookups when
compared with an utf8mb4 constant, field or expression using '=' or
'<=>' comparison operators.

This is controlled by optimizer_switch='cset_narrowing=on', which is
OFF by default.

IMPLEMENTATION
Item value comparison in (MB3-4-CMP) is done using utf8mb4_general_ci.
This is valid as any utf8mb3 value is also an utf8mb4 value.

When making index lookup value for utf8mb3_key_col, we do "Charset
Narrowing": characters that are in the Basic Multilingual Plane (=BMP) are
copied as-is, as they can be represented in utf8mb3. Characters that are
outside the BMP cannot be represented in utf8mb3 and are replaced
with U+FFFD, the "Replacement Character".

In utf8mb4_general_ci, the Replacement Character compares as equal to any
character that's not in BMP. Because of this, the constructed lookup value
will find all index records that would be considered equal by the original
condition (MB3-4-CMP).

Approved-by: Monty <monty@mariadb.org>
2023-10-19 17:24:30 +03:00
..
examples MDEV-21303 Make executables MariaDB named 2020-03-21 20:20:29 +01:00
client_settings.h Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
CMakeLists.txt MDEV-32113: utf8mb3_key_col=utf8mb4_value cannot be used for ref 2023-10-19 17:24:30 +03:00
emb_qcache.cc MDEV-19275 Provide SQL service to plugins. 2020-08-14 21:04:25 +04:00
emb_qcache.h MDEV-19275 Provide SQL service to plugins. 2020-08-14 21:04:25 +04:00
embedded_priv.h fix query cache in embedded 2022-01-30 13:56:22 +01:00
lib_sql.cc Merge 10.5 into 10.6 2023-09-20 08:32:04 +03:00
libmysql.c Merge 10.5 into 10.6 2023-04-11 16:15:19 +03:00
libmysqld.c Merge branch '10.5' into 10.6 2023-08-01 15:08:52 +02:00
libmysqld.def
libmysqld.rc
resource.h