firebird 5.0.0.1306 engine crashes
chedek opened this issue · 3 comments
Source table:
CREATE TABLE LISTVALUES (
IND D_COD NOT NULL,
CODROOT D_COD_S NOT NULL,
CODLIST D_COD_S,
ORD D_COD NOT NULL,
VCOD D_COD,
UDL D_CHAR COLLATE PXW_CYRL,
VTIP D_COD_S,
SORTORDER D_COD
);
ALTER TABLE LISTVALUES ADD CONSTRAINT PK_LISTVALUES PRIMARY KEY (IND);
CREATE INDEX LISTVALUES_FIND ON LISTVALUES (VTIP, VCOD);
CREATE INDEX LISTVALUES_IDX1 ON LISTVALUES (CODLIST, ORD);
CREATE INDEX LISTVALUES_IDX2 ON LISTVALUES (CODLIST, VCOD);
CREATE UNIQUE INDEX LISTVALUES_MAIN ON LISTVALUES (CODROOT, ORD);
This query causes to crash server:
execute block
returns (cod int)
as
declare variable sqltext varchar(1000);
begin
sqltext='select lv.ord from listvalues lv
where lv.codlist=479 and lv.ord in (2,3,20,21,5,8,9,10,11,12) order by lv.ord';
for execute statement sqltext
into :cod
do
suspend;
end
This happens due using ordering by index in plan for subquery
"select lv.codlist from listvalues lv where lv.codlist=479 and lv.ord in (2,3,20,21,5,8,9,10,11,12) order by lv.ord"
PLAN (LV ORDER LISTVALUES_IDX1)
If I'm changing the subquery to except using it, all is working correct:
execute block
returns (cod int)
as
declare variable sqltext varchar(1000);
begin
sqltext='select lv.ord from listvalues lv
where lv.codlist=479 and lv.ord in (2,3,20,21,5,8,9,10,11,12) order by lv.ord+0';
for execute statement sqltext
into :cod
do
suspend;
end
Please re-test using any recent snapshot build:
https://github.com/FirebirdSQL/snapshots/releases/tag/snapshot-v5.0-release
with snapshot all is OK!
Domains DDL (d_code, d_cod_s, d_char) and example of data for table 'listvalues' will be gratefully appreciated :-)
Following script does NOT cause crash of WI-V5.0.0.1306 (using default firebird.conf):
set bail on;
set echo on;
shell if exist e:\temp\tmp4test.fdb del /q /f e:\temp\tmp4test.fdb;
create database 'localhost:e:\temp\tmp4test.fdb';
show version;
create domain d_cod int;
create domain d_cod_s smallint;
create domain d_char varchar(50) character set win1251;
create table listvalues (
ind d_cod not null,
codroot d_cod_s not null,
codlist d_cod_s,
ord d_cod not null,
vcod d_cod,
udl d_char collate pxw_cyrl,
vtip d_cod_s,
sortorder d_cod
);
alter table listvalues add constraint pk_listvalues primary key (ind);
create index listvalues_find on listvalues (vtip, vcod);
create index listvalues_idx1 on listvalues (codlist, ord);
create index listvalues_idx2 on listvalues (codlist, vcod);
create unique index listvalues_main on listvalues (codroot, ord);
commit;
------------------------------------------------------------------
insert into listvalues(
ind --d_cod not null,
,codroot -- d_cod_s not null,
,codlist -- d_cod_s,
,ord -- d_cod not null,
,vcod -- d_cod,
,udl -- d_char collate pxw_cyrl,
,vtip -- d_cod_s,
,sortorder -- d_cod
)
select
row_number()over()
,row_number()over()
,479 + mod(row_number()over(),2)
,3 + mod(row_number()over(),15)
,row_number()over()
,row_number()over()
,row_number()over()
,row_number()over()
from rdb$types;
commit;
------------------------------------------------------------------
set count on;
set term ^;
execute block returns (cod int) as
declare sqltext varchar(1000);
begin
sqltext =
'select lv.ord from listvalues lv '
|| 'where lv.codlist=479 and lv.ord in (2,3,20,21,5,8,9,10,11,12) '
|| 'order by lv.ord'
;
for
execute statement sqltext
into :cod
do
suspend;
end
^
set term ;^
set planonly;
set explain on;
select lv.ord
from listvalues lv
where lv.codlist=479 and lv.ord in (2,3,20,21,5,8,9,10,11,12)
order by lv.ord;
(69 records will be displayed)