Skip to content
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

Fix #7548 - SET BIND OF TIMESTAMP WITH TIME ZONE TO CHAR is not working with UTF8 connection charset. #7549

Merged
merged 1 commit into from
Apr 18, 2023
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
6 changes: 3 additions & 3 deletions src/dsql/dsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2415,14 +2415,14 @@ static UCHAR* var_info(const dsql_msg* message,

// Scan sources of coercion rules in reverse order to observe
// 'last entered in use' rule. Start with dynamic binding rules ...
if (!attachment->att_bindings.coerce(&desc))
if (!attachment->att_bindings.coerce(tdbb, &desc))
{
// next - given in DPB ...
if (!attachment->getInitialBindings()->coerce(&desc))
if (!attachment->getInitialBindings()->coerce(tdbb, &desc))
{
Database* dbb = tdbb->getDatabase();
// and finally - rules from .conf files.
dbb->getBindings()->coerce(&desc, dbb->dbb_compatibility_index);
dbb->getBindings()->coerce(tdbb, &desc, dbb->dbb_compatibility_index);
}
}

Expand Down
20 changes: 13 additions & 7 deletions src/jrd/Coercion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "../dsql/dsql.h"
#include "../dsql/make_proto.h"
#include "../jrd/align.h"
#include "../jrd/DataTypeUtil.h"

using namespace Jrd;
using namespace Firebird;
Expand All @@ -41,12 +42,12 @@ static const USHORT FROM_MASK = FLD_has_len | FLD_has_chset | FLD_has_scale |
static const USHORT TO_MASK = FLD_has_len | FLD_has_chset | FLD_has_scale |
FLD_legacy | FLD_native | FLD_has_sub | FLD_has_prec | FLD_extended;

bool CoercionArray::coerce(dsc* d, unsigned startItem) const
bool CoercionArray::coerce(thread_db* tdbb, dsc* d, unsigned startItem) const
{
// move down through array to ensure correct order: newer rule overrides older one
for (unsigned n = getCount(); n-- > startItem; )
{
if (getElement(n).coerce(d))
if (getElement(n).coerce(tdbb, d))
return true;
}

Expand Down Expand Up @@ -224,7 +225,7 @@ static const USHORT subTypeCompatibility[DTYPE_TYPE_MAX] =
};


bool CoercionRule::coerce(dsc* d) const
bool CoercionRule::coerce(thread_db* tdbb, dsc* d) const
{
// check does descriptor match FROM clause
if (! match(d))
Expand Down Expand Up @@ -295,6 +296,8 @@ bool CoercionRule::coerce(dsc* d) const

// final pass - order is important

const auto srcCharSet = d->getCharSet();

// scale
if (toMask & FLD_has_scale)
d->dsc_scale = toDsc.dsc_scale;
Expand Down Expand Up @@ -330,14 +333,17 @@ bool CoercionRule::coerce(dsc* d) const
d->dsc_dtype = toDsc.dsc_dtype;
}

// varchar length
if (d->dsc_dtype == dtype_varying)
d->dsc_length += sizeof(USHORT);

// charset
if (toMask & FLD_has_chset)
d->setTextType(toDsc.getTextType());

if (d->isText())
d->dsc_length = DataTypeUtil(tdbb).convertLength(d->dsc_length, srcCharSet, toDsc.getCharSet());

// varchar length
if (d->dsc_dtype == dtype_varying)
d->dsc_length += sizeof(USHORT);

// subtype - special processing for BLOBs
if (toMask & FLD_has_sub)
d->setBlobSubType(toDsc.getBlobSubType());
Expand Down
4 changes: 2 additions & 2 deletions src/jrd/Coercion.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CoercionRule

void setRule(const TypeClause* from, const TypeClause *to);
dsc* makeLegacy(USHORT mask = 0);
bool coerce(dsc* d) const;
bool coerce(thread_db* tdbb, dsc* d) const;
bool match(const dsc* d) const;
bool operator==(const CoercionRule& rule) const;

Expand All @@ -68,7 +68,7 @@ class CoercionArray : public Firebird::HalfStaticArray<CoercionRule, 4>
{
}

bool coerce(dsc* d, unsigned startItem = 0) const;
bool coerce(thread_db* tdbb, dsc* d, unsigned startItem = 0) const;
void setRule(const TypeClause* from, const TypeClause *to);
};

Expand Down