You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] ORCA: QD segfault in CExtendedStatsProcessor when extended statistics (dependencies) do not cover all filtered columns #1949
With ORCA enabled, the backend crashes when a query filters on a set of columns that is only partially covered by an extended statistics object (CREATE STATISTICS ... (dependencies)). In the reproducer below the statistics object covers c0, c1 and the outer WHERE also references c2, which is not covered.
The crash is a null-pointer dereference in the QD backend inside ORCA's statistics derivation:
colid_to_attno_mapping->Find(&colid) returns nullptr for the column that is not part of the statistics object, and the result is dereferenced without a check.
With optimizer = off the query runs fine and returns 0 rows.
Found by SQLancer.
What you think should happen instead
The query should run and return 0 rows (no row has c1 = ''). Cardinality estimation must not assume every filtered column is present in the extended statistics object.
How to reproduce
CREATETABLEt3 (c0 boolean, c1 text, c2 int) DISTRIBUTED BY (c0);
INSERT INTO t3 SELECT (g%2=0), 'x'||g, g FROM generate_series(1,100) g;
CREATE STATISTICS s0 (dependencies) ON c0, c1 FROM t3; -- covers c0, c1 only
ANALYZE t3;
SET optimizer =on;
SELECT*FROM (SELECT ALL t3.c0AS t3c0, t3.c1AS t3c1, t3.c2AS t3c2
FROM t3
WHERE (t3.c0) IS TRUE
GROUP BYt3.c0, t3.c1, t3.c2ORDER BYt3.c1) AS result
WHEREresult.t3c0= TRUE ANDresult.t3c1=''ANDresult.t3c2>0; -- c2 not covered by s0-- QD backend SIGSEGV
Operating System
Linux
Anything else
Found while running SQLancer against Cloudberry main (3-segment demo cluster, --enable-cassert). See the proposal to run SQLancer continuously: #1952
changed the title [-][Bug] ORCA: backend crash when extended statistics (dependencies) do not cover all filtered columns[/-][+][Bug] ORCA: QD segfault in CExtendedStatsProcessor when extended statistics (dependencies) do not cover all filtered columns[/+]on Sep 3, 2026
Activity
[-][Bug] ORCA: backend crash when extended statistics (dependencies) do not cover all filtered columns[/-][+][Bug] ORCA: QD segfault in CExtendedStatsProcessor when extended statistics (dependencies) do not cover all filtered columns[/+]