RDB$GET_CONTEXT value is padded with spaces upto the declared length (255) --------------------------------------------------------------------------
Key: CORE-4156 URL: http://tracker.firebirdsql.org/browse/CORE-4156 Project: Firebird Core Issue Type: Bug Components: API / Client Library, Engine Affects Versions: 3.0 Alpha 1 Environment: Windows 8 64 bit WI-T3.0.0.30566 Firebird 3.0 Alpha 1 (64 bit) Jaybird trunk on Java 7 Reporter: Mark Rotteveel 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', 'TestProperty', 'testValue') FROM RDB$DATABASE with parameter 1 "TestProperty" and parameter 2 "testValue" And then retrieving the value using SELECT RDB$GET_CONTEXT('USER_SESSION', 'TestProperty') FROM RDB$DATABASE 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 upto the declared length, padded with spaces, but it will prefix the right length (9). Testing with other varchars does not display this behavior. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://tracker.firebirdsql.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------------ Get your SQL database under version control now! Version control is standard for application code, but databases havent caught up. So what steps can you take to put your SQL databases under version control? Why should you start doing it? Read more to find out. http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel