8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-02-02 10:00:38 +01:00

This should fix #7727: Index for integer column cannot be used when INT128/DECFLOAT value is being searched

This commit is contained in:
Dmitry Yemanov 2023-08-31 19:51:21 +03:00
parent 983025977a
commit b70067fe8d
2 changed files with 23 additions and 12 deletions

View File

@ -138,6 +138,11 @@ typedef struct dsc
return dsc_dtype == dtype_blob || dsc_dtype == dtype_quad;
}
bool isBoolean() const
{
return dsc_dtype == dtype_boolean;
}
bool isExact() const
{
return dsc_dtype == dtype_int128 || dsc_dtype == dtype_int64 ||

View File

@ -2413,26 +2413,32 @@ bool BTR_types_comparable(const dsc& target, const dsc& source)
if (source.isNull() || DSC_EQUIV(&source, &target, true))
return true;
if (DTYPE_IS_TEXT(target.dsc_dtype))
if (target.isText())
{
// should we also check for the INTL stuff here?
return (DTYPE_IS_TEXT(source.dsc_dtype) || source.dsc_dtype == dtype_dbkey);
return source.isText() || source.isDbKey();
}
if (target.dsc_dtype == dtype_int64)
return (source.dsc_dtype <= dtype_long || source.dsc_dtype == dtype_int64);
if (target.isNumeric())
return source.isText() || source.isNumeric();
if (DTYPE_IS_NUMERIC(target.dsc_dtype))
return (source.dsc_dtype <= dtype_double || source.dsc_dtype == dtype_int64);
if (target.isDate())
{
// source.isDate() is already covered above in DSC_EQUIV
return source.isText() || source.isTimeStamp();
}
if (target.dsc_dtype == dtype_sql_date)
return (source.dsc_dtype <= dtype_sql_date || source.dsc_dtype == dtype_timestamp);
if (target.isTime())
{
// source.isTime() below covers both TZ and non-TZ time
return source.isText() || source.isTime() || source.isTimeStamp();
}
if (DTYPE_IS_DATE(target.dsc_dtype))
return (source.dsc_dtype <= dtype_timestamp);
if (target.isTimeStamp())
return source.isText() || source.isDateTime();
if (target.dsc_dtype == dtype_boolean)
return DTYPE_IS_TEXT(source.dsc_dtype) || source.dsc_dtype == dtype_boolean;
if (target.isBoolean())
return source.isText() || source.isBoolean();
return false;
}