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
wrong negative XSQLVAR.sqllen returned when using fb25 isql with fb30 [CORE5595] #5861
Comments
Modified by: Holger Klemt (klemmo)description: just tried to use a udf replacement using the stored function and received very strange out of memory errors from firebird 3.0.2 CREATE OR ALTER FUNCTION RTRIM ( when executing the following statement, the error "out of memory" is shown workaround: change return declaration to VARCHAR(10888) or any other length smaller than 10888 and all works fine. I think this is an error in the handling of expressions in stored functions params, since when doing the same statement with trim insted of rtrim, all works fine => just tried to use a udf replacement using the stored function and received very strange out of memory errors from firebird 3.0.2 CREATE OR ALTER FUNCTION RTRIM ( when executing the following statement, the error "out of memory" is shown SELECT (R.RDB$RELATION_NAME || ' (' || TRIM(CASE WHEN (R.RDB$VIEW_SOURCE IS NULL) workaround: change return declaration to VARCHAR(10888) or any other length smaller than 10888 and all works fine. I think this is an error in the handling of expressions in stored functions params, since when doing the same statement with trim insted of rtrim, all works fine |
Modified by: Holger Klemt (klemmo)description: just tried to use a udf replacement using the stored function and received very strange out of memory errors from firebird 3.0.2 CREATE OR ALTER FUNCTION RTRIM ( when executing the following statement, the error "out of memory" is shown SELECT (R.RDB$RELATION_NAME || ' (' || TRIM(CASE WHEN (R.RDB$VIEW_SOURCE IS NULL) workaround: change return declaration to VARCHAR(10888) or any other length smaller than 10888 and all works fine. I think this is an error in the handling of expressions in stored functions params, since when doing the same statement with trim insted of rtrim, all works fine => just tried to use a udf replacement using the stored function and received very strange out of memory errors from firebird 3.0.2 CREATE OR ALTER FUNCTION RTRIM ( when executing the following statement, the error "out of memory" is shown SELECT (R.RDB$RELATION_NAME || ' (' || TRIM(CASE WHEN (R.RDB$VIEW_SOURCE IS NULL) workaround: change return declaration to VARCHAR(10888) or any other length smaller than 10888 and all works fine. I think this is an error in the handling of expressions in stored functions params, since when doing the same statement with trim instead of rtrim, all works fine |
Commented by: @asfernandes Cannot reproduce in Linux. |
Commented by: Holger Klemt (klemmo) changed original tracker entry to a more detailed version |
Modified by: Holger Klemt (klemmo)description: just tried to use a udf replacement using the stored function and received very strange out of memory errors from firebird 3.0.2 CREATE OR ALTER FUNCTION RTRIM ( when executing the following statement, the error "out of memory" is shown SELECT (R.RDB$RELATION_NAME || ' (' || TRIM(CASE WHEN (R.RDB$VIEW_SOURCE IS NULL) workaround: change return declaration to VARCHAR(10888) or any other length smaller than 10888 and all works fine. I think this is an error in the handling of expressions in stored functions params, since when doing the same statement with trim instead of rtrim, all works fine => just tried to use a udf replacement using the stored function and received very strange out of memory errors from firebird 3.0.2 CREATE OR ALTER FUNCTION RTRIM ( when executing the following statement, the error "out of memory" is shown SELECT (R.RDB$RELATION_NAME || ' (' || RTRIM(CASE WHEN (R.RDB$VIEW_SOURCE IS NULL) workaround: change return declaration to VARCHAR(10888) or any other length smaller than 10888 and all works fine. I think this is an error in the handling of expressions in stored functions params, since when doing the same statement with trim instead of rtrim, all works fine |
Commented by: @asfernandes I saw it and still cannot reproduce even in 3.02 in w64 as you reported. |
Commented by: Holger Klemt (klemmo) changed original tracker entry to a more detailed version |
Commented by: Holger Klemt (klemmo) at least now we know the problem, but not the reason, when doing a prepare for the statement, we get a value for XSQLVAR.sqllen of -32765 which is in fact a stupid value to allocate memory. Anyone have any idea why this can happen with a stored function used and not when a udf is used? |
Commented by: Holger Klemt (klemmo) Easy way to reproduce (except in isql, which still does not create this error, but almost any other app will): SELECT cast('any text' as varchar(32765)) || 'abcd' FROM rdb$database Firebird returns value of lenght which is greater than max value of sqllen defined as shortint in ibase.pas SELECT cast('any text' as varchar(32766)) || 'abcd' Maybe in the new API (AFAIK, isql uses new API) something is different and therefore isql doesn't |
Commented by: Holger Klemt (klemmo) one easy way to reproduce the error with firebirds own tools: create the database on fb3 and use a isql version from firebird 2.5 with fb3 client lib SELECT cast('any text' as varchar(32765)) || 'abcd' FROM rdb$database Result: Statement failed, SQLSTATE = HY001 |
Modified by: Holger Klemt (klemmo)description: just tried to use a udf replacement using the stored function and received very strange out of memory errors from firebird 3.0.2 CREATE OR ALTER FUNCTION RTRIM ( when executing the following statement, the error "out of memory" is shown SELECT (R.RDB$RELATION_NAME || ' (' || RTRIM(CASE WHEN (R.RDB$VIEW_SOURCE IS NULL) workaround: change return declaration to VARCHAR(10888) or any other length smaller than 10888 and all works fine. I think this is an error in the handling of expressions in stored functions params, since when doing the same statement with trim instead of rtrim, all works fine => create the database on fb3 and use a isql version from firebird 2.5 with fb3 client lib SELECT cast('any text' as varchar(32765)) || 'abcd' FROM rdb$database Result: Statement failed, SQLSTATE = HY001 environment: Test on FB302w64 => Test on FB302w64 and FB302lx64 summary: very strange limit in stored function return param => wrong negative XSQLVAR.sqllen returned when using fb25 isql with fb30 |
Commented by: @asfernandes Maybe we should change sqllen to USHORT? |
Commented by: @dyemanov MAX_COLUMN_SIZE is 32767, so SSHORT should be enough. No string value should exceed this limit during concatenation, so there should be a bug somewhere. |
Commented by: @dyemanov FB 2.5 operates with MAX_COLUMN_SIZE = 32767 as string length limit, while FB 3.0 defines MAX_STR_SIZE = 65535 for the same goal. This explains the issue. |
Commented by: @asfernandes It's CORE4881 and there is discussion about it in devel. Main reason to extend it was 32K / 4 was too limited for UTF-8 AFAIR. |
Submitted by: Holger Klemt (klemmo)
create the database on fb3 and use a isql version from firebird 2.5 with fb3 client lib
and execute
SELECT cast('any text' as varchar(32765)) || 'abcd' FROM rdb$database
Result:
Statement failed, SQLSTATE = HY001
unable to allocate memory from operating system
The text was updated successfully, but these errors were encountered: