Skip to content

Fixed bug #8203 : Function MAKE_DBKEY may produce random errors if used with relation name #8204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/dsql/ExprNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12306,7 +12306,9 @@ DmlNode* SysFuncCallNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScrat

if (literal && literal->litDesc.isText())
{
const MetaName relName = literal->getText();
MetaName relName;
CVT2_make_metaname(&literal->litDesc, name, tdbb->getAttachment()->att_dec_status);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be relName, not name here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I was sure I checked it :(


const jrd_rel* const relation = MET_lookup_relation(tdbb, relName);

if (relation)
Expand Down
6 changes: 0 additions & 6 deletions src/dsql/ExprNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -965,12 +965,6 @@ class LiteralNode final : public TypedNode<ValueExprNode, ExprNode::TYPE_LITERAL
return *reinterpret_cast<SLONG*>(litDesc.dsc_address);
}

const char* getText() const
{
fb_assert(litDesc.dsc_dtype == dtype_text);
return reinterpret_cast<const char*>(litDesc.dsc_address);
}

void fixMinSInt32(MemoryPool& pool);
void fixMinSInt64(MemoryPool& pool);
void fixMinSInt128(MemoryPool& pool);
Expand Down
3 changes: 2 additions & 1 deletion src/jrd/SysFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "../jrd/blb_proto.h"
#include "../jrd/cch_proto.h"
#include "../jrd/cvt_proto.h"
#include "../jrd/cvt2_proto.h"
#include "../common/cvt.h"
#include "../jrd/evl_proto.h"
#include "../jrd/intl_proto.h"
Expand Down Expand Up @@ -5365,7 +5366,7 @@ dsc* evlMakeDbkey(Jrd::thread_db* tdbb, const SysFunction* function, const NestV
if (argDsc->isText())
{
MetaName relName;
MOV_get_metaname(tdbb, argDsc, relName);
CVT2_make_metaname(argDsc, relName, tdbb->getAttachment()->att_dec_status);

const jrd_rel* const relation = MET_lookup_relation(tdbb, relName);
if (!relation)
Expand Down
22 changes: 22 additions & 0 deletions src/jrd/cvt2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,28 @@ int CVT2_blob_compare(const dsc* arg1, const dsc* arg2, DecimalStatus decSt)
}


void CVT2_make_metaname(const dsc* desc, MetaName& name, DecimalStatus decSt)
/**************************************
*
* C V T 2 _ m a k e _ m e t a n a m e
*
**************************************
*
* Functional description
*
* Convert the data from the desc to a string in the metadata charset.
* Then return the string as MetaName object.
*
**************************************/
{
MoveBuffer buff;
UCHAR* ptr = nullptr;

const auto len = CVT2_make_string2(desc, CS_METADATA, &ptr, buff, decSt);
name.assign(reinterpret_cast<const char*>(ptr), len);
}


USHORT CVT2_make_string2(const dsc* desc, USHORT to_interp, UCHAR** address, MoveBuffer& temp, DecimalStatus decSt)
{
/**************************************
Expand Down
1 change: 1 addition & 0 deletions src/jrd/cvt2_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern const BYTE CVT2_compare_priority[];
bool CVT2_get_binary_comparable_desc(dsc*, const dsc*, const dsc*);
int CVT2_compare(const dsc*, const dsc*, Firebird::DecimalStatus);
int CVT2_blob_compare(const dsc*, const dsc*, Firebird::DecimalStatus);
void CVT2_make_metaname(const dsc* desc, Jrd::MetaName& name, Firebird::DecimalStatus);
USHORT CVT2_make_string2(const dsc*, USHORT, UCHAR**, Jrd::MoveBuffer&, Firebird::DecimalStatus);

#endif // JRD_CVT2_PROTO_H
Loading