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

Frontport fix for CORE-2875 - String right truncation error when char column longer than 4096 bytes is compared with string constant

This commit is contained in:
asfernandes 2010-02-19 10:19:22 +00:00
parent 7ed350a3e9
commit 1db35d473b

View File

@ -642,17 +642,17 @@ int INTL_compare(thread_db* tdbb, const dsc* pText1, const dsc* pText2, ErrorFun
UCHAR* p1; UCHAR* p1;
USHORT t1; USHORT t1;
USHORT length1 = CVT_get_string_ptr(pText1, &t1, &p1, NULL, 0, err); ULONG length1 = CVT_get_string_ptr(pText1, &t1, &p1, NULL, 0, err);
UCHAR* p2; UCHAR* p2;
USHORT t2; USHORT t2;
USHORT length2 = CVT_get_string_ptr(pText2, &t2, &p2, NULL, 0, err); ULONG length2 = CVT_get_string_ptr(pText2, &t2, &p2, NULL, 0, err);
// YYY - by SQL II compare_type must be explicit in the // YYY - by SQL II compare_type must be explicit in the
// SQL statement if there is any doubt // SQL statement if there is any doubt
USHORT compare_type = MAX(t1, t2); // YYY USHORT compare_type = MAX(t1, t2); // YYY
UCHAR buffer[MAX_KEY]; HalfStaticArray<UCHAR, BUFFER_XLARGE> buffer;
if (t1 != t2) if (t1 != t2)
{ {
@ -672,15 +672,21 @@ int INTL_compare(thread_db* tdbb, const dsc* pText1, const dsc* pText2, ErrorFun
sense if the string cannot be expressed... sense if the string cannot be expressed...
*/ */
length2 = INTL_convert_bytes(tdbb, cs1, buffer, sizeof(buffer), cs2, p2, length2, err); UCHAR* p = buffer.getBuffer(INTL_convert_bytes(tdbb, cs1, NULL, 0,
p2 = buffer; cs2, p2, length2, err));
length2 = INTL_convert_bytes(tdbb, cs1, p, (ULONG) buffer.getCount(),
cs2, p2, length2, err);
p2 = p;
} }
else else
{ {
// convert pText1 to pText2's type, if possible // convert pText1 to pText2's type, if possible
length1 = INTL_convert_bytes(tdbb, cs2, buffer, sizeof(buffer), cs1, p1, length1, err); UCHAR* p = buffer.getBuffer(INTL_convert_bytes(tdbb, cs2, NULL, 0,
p1 = buffer; cs1, p1, length1, err));
length1 = INTL_convert_bytes(tdbb, cs2, p, (ULONG) buffer.getCount(),
cs1, p1, length1, err);
p1 = p;
} }
} }
} }