Skip to content

Commit ff750ce

Browse files
committed
Teach nulltestsel() that system columns are never NULL.
While it's perhaps unlikely that users would write an explicit test like "ctid IS NULL", this function is also used in range estimation, and an incorrect answer can throw off the results for tight ranges. Anyway it's not much code so we might as well do it. Edmund Horner Discussion: https://postgr.es/m/CAMyN-kCa3BFUFrCTtQeprxTU1anCd3Pua7zXstGCKq4pXgjukw@mail.gmail.com
1 parent 6119060 commit ff750ce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/backend/utils/adt/selfuncs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,15 @@ nulltestsel(PlannerInfo *root, NullTestType nulltesttype, Node *arg,
17971797
return (Selectivity) 0; /* keep compiler quiet */
17981798
}
17991799
}
1800+
else if (vardata.var && IsA(vardata.var, Var) &&
1801+
((Var *) vardata.var)->varattno < 0)
1802+
{
1803+
/*
1804+
* There are no stats for system columns, but we know they are never
1805+
* NULL.
1806+
*/
1807+
selec = (nulltesttype == IS_NULL) ? 0.0 : 1.0;
1808+
}
18001809
else
18011810
{
18021811
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy