Extending varchar domain leaves old smaller size in PSQL BLR ------------------------------------------------------------
Key: CORE-5812 URL: http://tracker.firebirdsql.org/browse/CORE-5812 Project: Firebird Core Issue Type: Bug Affects Versions: 2.5.8 Environment: First detected on this env: WI-V2.5.7.27050 Firebird 2.5 classic windows 10 Reporter: Pavel Cisar Consistently reproducible test case: create domain dmn varchar(1); commit; create table tbl(fld dmn); commit; set term ^; create procedure sp returns (fld dmn) as begin for select case when 1=1 then fld else 'x' end from tbl into :fld do begin suspend; end end ^ set term ;^ commit; alter domain dmn type varchar(2); commit; insert into tbl (fld) values ('12'); commit; set term ^; alter procedure sp returns (fld dmn) as begin select fld from tbl into :fld; /* select field uses new domain type varchar(2) */ suspend; end ^ set term ;^ commit; select * from sp; /*no exception*/ commit; set term ^; alter procedure sp returns (fld dmn) as begin select case when 1=1 then fld else 'x' end from tbl into :fld; /* case when fld still uses old domain type varchar(1) in BLR */ suspend; end ^ set term ;^ commit; select * from sp; /*string truncation*/ commit; /*reconnect*/ select * from sp; /*still string truncation*/ commit; set term ^; alter procedure sp returns (fld dmn) as begin select case when 1=1 then fld else 'x' end from tbl into :fld; /* after reconnect 'case when fld' starts to use new domain type varchar(2) in BLR */ suspend; end ^ set term ;^ commit; select * from sp; /*no more exception*/ commit; drop procedure sp; drop table tbl; drop domain dmn; commit; --- Initial comment from Vlad Khorsun: The issue is related with metadata caching (it was obvious). There is no cache of domains, but there is cache of relations and cached relations (of course) have fields with data types. When domain definition changed, relations in cache are not invalidated. Thus, SQL parser uses old data type (not domain based, just raw data type) when handle procedure text. In particular, it CAST result of CASE expression to the VARCHAR(1) data type. You may see in generated BLR something like ... blr_cast, blr_varying2, 0,0, 1,0, blr_value_if, ... Later, when engine executed query, it knows real data type for the relation field (VARCHAR(2)) but should CAST it to the VARCHAR(1) - here it raised "string right truncation" error. So far i see no quick way to fix it, sorry -- 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 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel