From fbb39ebed9916876522cf43323162557e81d25ce Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Thu, 7 Apr 2022 14:33:23 -0300 Subject: [PATCH] Fix #7167 - Incorrect transliteration of field names in constraint violation errors. --- src/jrd/btr.cpp | 4 ++-- src/jrd/filters.cpp | 2 +- src/jrd/mov.cpp | 10 +++++----- src/jrd/mov_proto.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 86fab23bdb..77345d02a2 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -6145,7 +6145,7 @@ string print_key(thread_db* tdbb, jrd_rel* relation, index_desc* idx, Record* re { bool notNull = false; const dsc* const desc = BTR_eval_expression(tdbb, idx, record, notNull); - value = DescPrinter(tdbb, notNull ? desc : NULL, MAX_KEY_STRING_LEN).get(); + value = DescPrinter(tdbb, notNull ? desc : NULL, MAX_KEY_STRING_LEN, CS_METADATA).get(); key += " = " + value; } else @@ -6164,7 +6164,7 @@ string print_key(thread_db* tdbb, jrd_rel* relation, index_desc* idx, Record* re dsc desc; const bool notNull = EVL_field(relation, record, field_id, &desc); - value = DescPrinter(tdbb, notNull ? &desc : NULL, MAX_KEY_STRING_LEN).get(); + value = DescPrinter(tdbb, notNull ? &desc : NULL, MAX_KEY_STRING_LEN, CS_METADATA).get(); key += " = " + value; if (i < idx->idx_count - 1) diff --git a/src/jrd/filters.cpp b/src/jrd/filters.cpp index 1738af2cf5..83f98b4750 100644 --- a/src/jrd/filters.cpp +++ b/src/jrd/filters.cpp @@ -407,7 +407,7 @@ ISC_STATUS filter_format(USHORT action, BlobControl* control) d = desc; d.dsc_address = pBuff; - DescPrinter val(JRD_get_thread_data(), &d, 32); + DescPrinter val(JRD_get_thread_data(), &d, 32, CS_dynamic); str.printf(fmt2, fieldId, diff --git a/src/jrd/mov.cpp b/src/jrd/mov.cpp index 8b2323d5aa..1e8a618171 100644 --- a/src/jrd/mov.cpp +++ b/src/jrd/mov.cpp @@ -488,7 +488,7 @@ Int128 MOV_get_int128(Jrd::thread_db* tdbb, const dsc* desc, SSHORT scale) namespace Jrd { -DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen) +DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen, USHORT charSetId) : maxLen(mLen) { const char* const NULL_KEY_STRING = "NULL"; @@ -501,8 +501,8 @@ DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen) fb_assert(!desc->isBlob()); - const bool isBinary = (desc->isText() && desc->getTextType() == ttype_binary); - value = MOV_make_string2(tdbb, desc, isBinary ? ttype_binary : ttype_dynamic); + const bool isBinary = (desc->isText() && desc->getCharSet() == CS_BINARY); + value = MOV_make_string2(tdbb, desc, isBinary ? CS_BINARY : charSetId); const char* const str = value.c_str(); @@ -510,7 +510,7 @@ DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen) { if (desc->dsc_dtype == dtype_text) { - const char* const pad = (desc->dsc_sub_type == ttype_binary) ? "\0" : " "; + const char* const pad = (desc->getCharSet() == CS_BINARY) ? "\0" : " "; value.rtrim(pad); } @@ -542,7 +542,7 @@ DescPrinter::DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen) value.resize(maxLen); - const CharSet* const cs = INTL_charset_lookup(tdbb, desc->getCharSet()); + const CharSet* const cs = INTL_charset_lookup(tdbb, charSetId); while (value.hasData() && !cs->wellFormed(value.length(), (const UCHAR*) value.c_str())) value.resize(value.length() - 1); diff --git a/src/jrd/mov_proto.h b/src/jrd/mov_proto.h index 816842a4b2..8edfd15923 100644 --- a/src/jrd/mov_proto.h +++ b/src/jrd/mov_proto.h @@ -62,7 +62,7 @@ namespace Jrd class DescPrinter { public: - DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen); + DescPrinter(thread_db* tdbb, const dsc* desc, FB_SIZE_T mLen, USHORT charSetId); const Firebird::string& get() const {