Skip to content

RDB$GET_CONTEXT/RDB$SET_CONTEXT parameters incorrectly described as CHAR NOT NULL instead of VARCHAR NULLABLE. [CORE4156] #4483

Closed
@firebird-automations

Description

@firebird-automations

Submitted by: @mrotteveel

Attachments:
trace_set_context.txt

The value returned by a query with RDB$GET_CONTEXT inside an XSQLVAR is padded with spaces upto the declared length (255), even though the value itself is declared as a VARCHAR(sqltype=449).

Eg setting the context using
SELECT RDB$SET_CONTEXT('USER_SESSION', ?, ?) FROM RDB$DATABASE
with parameter 1 "TestProperty" and parameter 2 "testValue"

And then retrieving the value using
SELECT RDB$GET_CONTEXT('USER_SESSION', ?) FROM RDB$DATABASE
with parameter 1 "TestProperty"

Will return "testValue<+246 spaces>" (or [116, 101, 115, 116, 86, 97, 108, 117, 101, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]

Firebird 2.5 and earlier exhibit the expected behavior (the returned value is "testValue" without any spaces). Strangely enough when I use flamerobin then the returned value is not padded, not even when I try with '|' || RDB$GET_CONTEXT('USER_SESSION', 'TestProperty') || '|', doing this with Jaybird does return the value padded (as "|testValue<+246 spaces>|").

The only reason I can think of is that the current version of Jaybird when sending the parameter value for the set context, it will send the varchar padded with spaces upto the declared length, but it does send the actual length (9). Testing with other varchars does not display this behavior (eg insert parametrized and select the value), so it seems to be specific to RDB$SET_CONTEXT with parameters.

EDIT:
See my comment at 04/Aug/13 01:56 PM: the cause seems to be the parameter description of the query with RDB$SET_CONTEXT: they are described as CHAR instead of VARCHAR.

Commits: 8a19e7a FirebirdSQL/fbt-repository@3a88585

====== Test Details ======

See comments inside .fbt related to sqltype for nullable args (differ in 2.5 vs 3.0).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions