From b9da7ba0144cf95a2169007923a1464c313f9818 Mon Sep 17 00:00:00 2001 From: hvlad Date: Tue, 19 Jun 2018 11:32:53 +0300 Subject: [PATCH] Fixed bug CORE-5847 : "Malformed string" instead of key value in PK violation error message --- src/jrd/mov.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/jrd/mov.cpp b/src/jrd/mov.cpp index 5f600083c5..5a07090575 100644 --- a/src/jrd/mov.cpp +++ b/src/jrd/mov.cpp @@ -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());