Skip to content

Fix #9222: Use oldFormat text type for ttype_dynamic text items in DsqlDmlRequest::metadataToFormat - #9223

Open
mariuz wants to merge 2 commits into
FirebirdSQL:masterfrom
mariuz:fix-9222-blr-text-dynamic-charset
Open

mariuz wants to merge 2 commits into
FirebirdSQL:masterfrom
mariuz:fix-9222-blr-text-dynamic-charset

Conversation

@mariuz

@mariuz mariuz commented Oct 20, 2026

Copy link
Copy Markdown
Member

Fixes #9222

Summary

In Firebird 2.5 through 5.0, DsqlRequest::parseMetadata reset ttype_dynamic (CS_dynamic) to ttype_none (CS_NONE) for text items in DSQL message metadata so that clients encoding SQL_TEXT/SQL_VARYING using plain blr_text/blr_varying (which MetadataFromBlr maps to CS_dynamic) would not fail with string truncation or validation errors on NONE/OCTETS columns over multi-byte connection charsets.

When parseMetadata and mapInOut were replaced by DsqlDmlRequest::metadataToFormat in #8145 (11d5d59), that reset was dropped, causing wire-protocol clients that send plain blr_text/blr_varying to fail on Firebird 6.0 with:

  • string right truncation (expected length N/4, actual M) when fetching CHARACTER SET NONE / OCTETS / ASCII columns (including system columns like RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE) over UTF8.
  • Malformed string when fetching or binding OCTETS or non-UTF8 NONE data over UTF8.

This PR restores the ttype_dynamic → ttype_none reset in DsqlDmlRequest::metadataToFormat.

…uest::metadataToFormat

Restore the ttype_dynamic -> ttype_none reset for text items in DSQL message
metadata (originally in DsqlRequest::parseMetadata before FirebirdSQL#8145) so clients
that encode SQL_TEXT/SQL_VARYING with plain blr_text/blr_varying do not fail
with string right truncation or malformed string on NONE/OCTETS columns over
multi-byte connection charsets.
@aafemt

aafemt commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

I would move this code a couple lines up in order not to call setTextType twice. Besides, reset text type not to NONE unconditionally but to the text type from oldFormat (which should be the real charset of the column).

@mariuz mariuz changed the title Fix #9222: Reset ttype_dynamic to ttype_none in DsqlDmlRequest::metadataToFormat Fix #9222: Use oldFormat text type for ttype_dynamic text items in DsqlDmlRequest::metadataToFormat Oct 20, 2026
@mariuz

mariuz commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

@aafemt Updated in d5b7692 to resolve textType == ttype_dynamic to oldFormat->fmt_desc[param->par_parameter].getTextType() before calling desc.setTextType(textType).

@aafemt

aafemt commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

I wonder if my suggestion did break the case when non-text field is requested as text. May be it worth check that old format is also text and otherwise fallback to ttype_none...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants