Hi Tom,
I can.
And I reduced the SQL to:
CREATE temp TABLE tid ( i integer not null , d date);
create index tid_i on tid (d,i);
SELECT * FROM tid
WHERE d < TODAY - 1 UNITS DAY
AND ( d < TODAY - 1 UNITS MONTH OR i = 1);
As you said, the index is required and must be used by the query, or at least considered (since this occurs in the optimizer, it would not even have settled for and you'd not get a query plan if the error occurs).
Per my further testing all these need to be true too:
- index must be defined on (d,i), not (i,d)
- those two DAY and MONTH units need to be different (can't both be DAY)
- the WHERE ... AND ( ... OR ...) needs to exist
I'm going to log a defect. Please approach tech support if you require this fixed.
BR,
Andreas
------------------------------
Andreas Legner
------------------------------
Original Message:
Sent: Tue September 06, 2022 09:47 PM
From: TOM GIRSCH
Subject: Odd -1266 error with combined conditions and fragmented index
Hey, everyone. Hitting a weird issue which I can replicate on 12.10.FC14, 14.10.FC7 and 14.10.FC8 (all on CentOS). Run the script below (change the dbspace names in the index creation statement to ones that exist on your system). All of the statements work except for the final one, which gives error -1266. Without the index there (or if you avoid the index by directive) it runs fine. Something clearly haywire with the indexed scan.
Can anyone else here reproduce this?
Thanks,
- TJG
CREATE TEMP TABLE tjvouch (
vcnumb integer not null ,
vopdate2 date,
enc_vccrcard char(40)
) WITH NO LOG;
create index "informix".ix03
on "informix".tjvouch (vopdate2,enc_vccrcard,vcnumb) using btree
fragment by expression
partition vouch_enc_crcard_null (enc_vccrcard IS NULL ) IN chaos_tmp1,
partition vouch_enc_crcard_blank (enc_vccrcard <= ' ' ) IN chaos_tmp2,
partition vouch_enc_crcard_realvalue (enc_vccrcard > ' ' ) IN chaos_tmp3;
CREATE TEMP TABLE tjcsfiles (
cs_res integer not null ,
cs_filestat char(2)
) WITH NO LOG;
SELECT COUNT(*)
FROM tjvouch
WHERE vopdate2 < TODAY - 60 UNITS DAY
AND vcnumb NOT IN (
SELECT cs_res
FROM tjcsfiles
WHERE cs_filestat <> "C"
);
SELECT COUNT(*)
FROM tjvouch
WHERE vopdate2 < TODAY - 60 UNITS DAY
AND vopdate2 < TODAY - 13 UNITS MONTH;
SELECT COUNT(*)
FROM tjvouch
WHERE vopdate2 < TODAY - 60 UNITS DAY
AND ( vopdate2 < TODAY - 13 UNITS MONTH OR
vcnumb NOT IN ( SELECT cs_res FROM tjcsfiles WHERE cs_filestat <> "C" ) );
------------------------------
TOM GIRSCH
------------------------------
#Informix