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

Fixed bug CORE-5847 : "Malformed string" instead of key value in PK violation error message

This commit is contained in:
hvlad 2018-06-19 11:32:53 +03:00
parent e5dc6ef8e8
commit b9da7ba014

View File

@ -504,9 +504,9 @@ DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, int mLen)
fb_assert(!desc->isBlob());
value = MOV_make_string2(tdbb, desc, ttype_dynamic);
const bool octets = (desc->isText() && desc->getTextType() == ttype_binary);
value = MOV_make_string2(tdbb, desc, octets ? ttype_binary : ttype_dynamic);
const int len = (int) value.length();
const char* const str = value.c_str();
if (desc->isText() || desc->isDateTime())
@ -517,9 +517,15 @@ DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, int mLen)
value.rtrim(pad);
}
if (desc->isText() && desc->getTextType() == ttype_binary)
if (octets)
{
Firebird::string hex;
int len = (int) value.length();
const bool cut = (len > (maxLen - 3) / 2);
if (cut)
len = (maxLen - 5) / 2;
char* s = hex.getBuffer(2 * len);
for (int i = 0; i < len; i++)
@ -527,14 +533,13 @@ DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, int mLen)
sprintf(s, "%02X", (int)(unsigned char) str[i]);
s += 2;
}
value = "x'" + hex + "'";
value = "x'" + hex + (cut ? "..." : "'");
}
else
value = "'" + value + "'";
}
if (value.length() > maxLen)
if (value.length() > (FB_SIZE_T) maxLen)
{
fb_assert(desc->isText());