Skip to content

Commit c03852e

Browse files
committed
Merge pull request #8204 from FirebirdSQL/work/gh-8203
Fixed bug #8203 : Function MAKE_DBKEY may produce random errors if used with relation name
1 parent ed60d4d commit c03852e

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

src/dsql/ExprNodes.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12330,7 +12330,9 @@ DmlNode* SysFuncCallNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScrat
1233012330

1233112331
if (literal && literal->litDesc.isText())
1233212332
{
12333-
const MetaName relName = literal->getText();
12333+
MetaName relName;
12334+
CVT2_make_metaname(&literal->litDesc, name, tdbb->getAttachment()->att_dec_status);
12335+
1233412336
const jrd_rel* const relation = MET_lookup_relation(tdbb, relName);
1233512337

1233612338
if (relation)

src/dsql/ExprNodes.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -972,12 +972,6 @@ class LiteralNode final : public TypedNode<ValueExprNode, ExprNode::TYPE_LITERAL
972972
return *reinterpret_cast<SLONG*>(litDesc.dsc_address);
973973
}
974974

975-
const char* getText() const
976-
{
977-
fb_assert(litDesc.dsc_dtype == dtype_text);
978-
return reinterpret_cast<const char*>(litDesc.dsc_address);
979-
}
980-
981975
void fixMinSInt32(MemoryPool& pool);
982976
void fixMinSInt64(MemoryPool& pool);
983977
void fixMinSInt128(MemoryPool& pool);

src/jrd/SysFunction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "../jrd/blb_proto.h"
4545
#include "../jrd/cch_proto.h"
4646
#include "../jrd/cvt_proto.h"
47+
#include "../jrd/cvt2_proto.h"
4748
#include "../common/cvt.h"
4849
#include "../jrd/evl_proto.h"
4950
#include "../jrd/intl_proto.h"
@@ -5381,7 +5382,7 @@ dsc* evlMakeDbkey(Jrd::thread_db* tdbb, const SysFunction* function, const NestV
53815382
if (argDsc->isText())
53825383
{
53835384
MetaName relName;
5384-
MOV_get_metaname(tdbb, argDsc, relName);
5385+
CVT2_make_metaname(argDsc, relName, tdbb->getAttachment()->att_dec_status);
53855386

53865387
const jrd_rel* const relation = MET_lookup_relation(tdbb, relName);
53875388
if (!relation)

src/jrd/cvt2.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,28 @@ int CVT2_blob_compare(const dsc* arg1, const dsc* arg2, DecimalStatus decSt)
914914
}
915915

916916

917+
void CVT2_make_metaname(const dsc* desc, MetaName& name, DecimalStatus decSt)
918+
/**************************************
919+
*
920+
* C V T 2 _ m a k e _ m e t a n a m e
921+
*
922+
**************************************
923+
*
924+
* Functional description
925+
*
926+
* Convert the data from the desc to a string in the metadata charset.
927+
* Then return the string as MetaName object.
928+
*
929+
**************************************/
930+
{
931+
MoveBuffer buff;
932+
UCHAR* ptr = nullptr;
933+
934+
const auto len = CVT2_make_string2(desc, CS_METADATA, &ptr, buff, decSt);
935+
name.assign(reinterpret_cast<const char*>(ptr), len);
936+
}
937+
938+
917939
USHORT CVT2_make_string2(const dsc* desc, USHORT to_interp, UCHAR** address, MoveBuffer& temp, DecimalStatus decSt)
918940
{
919941
/**************************************

src/jrd/cvt2_proto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern const BYTE CVT2_compare_priority[];
3131
bool CVT2_get_binary_comparable_desc(dsc*, const dsc*, const dsc*);
3232
int CVT2_compare(const dsc*, const dsc*, Firebird::DecimalStatus);
3333
int CVT2_blob_compare(const dsc*, const dsc*, Firebird::DecimalStatus);
34+
void CVT2_make_metaname(const dsc* desc, Jrd::MetaName& name, Firebird::DecimalStatus);
3435
USHORT CVT2_make_string2(const dsc*, USHORT, UCHAR**, Jrd::MoveBuffer&, Firebird::DecimalStatus);
3536

3637
#endif // JRD_CVT2_PROTO_H

0 commit comments

Comments
 (0)