1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

MDEV-31800 Problem with open ranges on prefix blobs keys

don't construct open ranges from prefix blob keys for < (less than)
just as it's already done for > (greater than)

because prefix KEY_PART doesn't create prefix Field for blobs
(see open_table_from_share() near "Create a new field for the key part"),
so stored_field_cmp_to_item() will compare the original field to the
value not taking the prefix length into account.
This commit is contained in:
Sergei Golubchik
2023-07-31 20:36:19 +02:00
parent 4da80a41f6
commit 4dd38f9f39
3 changed files with 36 additions and 6 deletions

View File

@@ -1947,18 +1947,25 @@ public:
Use this constructor if value->save_in_field() went precisely,
without any data rounding or truncation.
*/
SEL_ARG_LT(const uchar *key, Field *field)
SEL_ARG_LT(const uchar *key, const KEY_PART *key_part, Field *field)
:SEL_ARG_LE(key, field)
{ max_flag= NEAR_MAX; }
{
// Don't use open ranges for partial key_segments
if (!(key_part->flag & HA_PART_KEY_SEG))
max_flag= NEAR_MAX;
}
/*
Use this constructor if value->save_in_field() returned success,
but we don't know if rounding or truncation happened
(as some Field::store() do not report minor data changes).
*/
SEL_ARG_LT(THD *thd, const uchar *key, Field *field, Item *value)
SEL_ARG_LT(THD *thd, const uchar *key,
const KEY_PART *key_part, Field *field, Item *value)
:SEL_ARG_LE(key, field)
{
if (stored_field_cmp_to_item(thd, field, value) == 0)
// Don't use open ranges for partial key_segments
if (!(key_part->flag & HA_PART_KEY_SEG) &&
stored_field_cmp_to_item(thd, field, value) == 0)
max_flag= NEAR_MAX;
}
};
@@ -9032,7 +9039,7 @@ SEL_ARG *Field::stored_field_make_mm_leaf(RANGE_OPT_PARAM *param,
case SCALAR_CMP_LE:
DBUG_RETURN(new (mem_root) SEL_ARG_LE(str, this));
case SCALAR_CMP_LT:
DBUG_RETURN(new (mem_root) SEL_ARG_LT(thd, str, this, value));
DBUG_RETURN(new (mem_root) SEL_ARG_LT(thd, str, key_part, this, value));
case SCALAR_CMP_GT:
DBUG_RETURN(new (mem_root) SEL_ARG_GT(thd, str, key_part, this, value));
case SCALAR_CMP_GE:
@@ -9061,7 +9068,7 @@ SEL_ARG *Field::stored_field_make_mm_leaf_exact(RANGE_OPT_PARAM *param,
case SCALAR_CMP_LE:
DBUG_RETURN(new (param->mem_root) SEL_ARG_LE(str, this));
case SCALAR_CMP_LT:
DBUG_RETURN(new (param->mem_root) SEL_ARG_LT(str, this));
DBUG_RETURN(new (param->mem_root) SEL_ARG_LT(str, key_part, this));
case SCALAR_CMP_GT:
DBUG_RETURN(new (param->mem_root) SEL_ARG_GT(str, key_part, this));
case SCALAR_CMP_GE: