Issue Details (XML | Word | Printable)

Key: CORE-4566
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Alexander Peshkov
Reporter: Simonov Denis
Votes: 0
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Incorrect size of the output parameter/argument when execute block, procedure or function use system field in metadata charset

Created: 01/Oct/14 08:59 AM   Updated: 25/Sep/15 01:14 PM
Component/s: Charsets/Collation
Affects Version/s: 2.1.5, 2.5.2, 2.1.5 Update 1, 2.5.2 Update 1, 3.0 Alpha 1, 3.0 Alpha 2, 2.1.6, 2.5.3
Fix Version/s: 3.0 Beta 1, 2.1.7, 2.5.4

Issue Links:
Relate
 

QA Status: Done successfully


 Description  « Hide
Incorrect size of the output argument when connection character set does not match the character set of the return argument.

Database created with character set win1251.

CREATE OR ALTER FUNCTION GET_MNEMONIC (
    AFIELD_NAME TYPE OF COLUMN RDB$TYPES.RDB$FIELD_NAME,
    ATYPE TYPE OF COLUMN RDB$TYPES.RDB$TYPE)
RETURNS TYPE OF COLUMN RDB$TYPES.RDB$TYPE_NAME
AS
begin
  RETURN (SELECT RDB$TYPE_NAME
          FROM RDB$TYPES
          WHERE RDB$FIELD_NAME = :AFIELD_NAME
            AND RDB$TYPE = :ATYPE);
end

Use CONNECT or CREATE DATABASE to specify a database
SQL> set names win1251;
SQL> connect 'localhost:test' user 'sysdba' password 'masterkey';
Database: 'localhost:horses', User: sysdba
SQL> select GET_MNEMONIC('MON$SHUTDOWN_MODE', 1) AS MNEMONIC
CON> from rdb$database;

MNEMONIC
==========
Statement failed, SQLSTATE = 22001
arithmetic exception, numeric overflow, or string truncation
-string right truncation
-expected length 10, actual 19

SQL> select cast(GET_MNEMONIC('MON$SHUTDOWN_MODE', 1) as varchar(100)) AS MNEMONIC
CON> from rdb$database;

MNEMONIC

===============================================================================
MULTI_USER_SHUTDOWN


SQL> SELECT
CON> RDB$TYPE_NAME
CON> FROM
CON> RDB$TYPES
CON> WHERE RDB$FIELD_NAME = 'MON$SHUTDOWN_MODE'
CON> AND RDB$TYPE = 1;

RDB$TYPE_NAME
===============================
MULTI_USER_SHUTDOWN



 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Simonov Denis added a comment - 02/Oct/14 05:31 PM
In Firebird 2.5.3 also reproduced

execute block
returns (
  FIELD_NAME RDB$FIELD_NAME
)
as
begin
  for select rdb$type_name
      from rdb$types
      into FIELD_NAME
  do
    suspend;
end

Alexander Peshkov added a comment - 05/Oct/14 01:12 PM
This bug seems to affect all firebird versions, but in later versions shows itself more active due to more ablities to use type of system objects in procedures and functions.

Alexander Peshkov added a comment - 05/Oct/14 01:19 PM
Also fixed in B2_1, but there is no appropriate version in "Fix Version/s" list.