Skip to content

Commit 89ebadc

Browse files
committed
Back-patch fix for erroneous selectivity of not-equals.
1 parent 5a5531a commit 89ebadc

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/backend/utils/adt/selfuncs.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.66 2000/05/26 17:19:15 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.66.2.1 2000/09/23 21:27:05 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -255,9 +255,24 @@ neqsel(Oid opid,
255255
Datum value,
256256
int32 flag)
257257
{
258+
Oid eqopid;
258259
float64 result;
259260

260-
result = eqsel(opid, relid, attno, value, flag);
261+
/*
262+
* We want 1 - eqsel() where the equality operator is the one associated
263+
* with this != operator, that is, its negator.
264+
*/
265+
eqopid = get_negator(opid);
266+
if (eqopid)
267+
{
268+
result = eqsel(eqopid, relid, attno, value, flag);
269+
}
270+
else
271+
{
272+
/* Use default selectivity (should we raise an error instead?) */
273+
result = (float64) palloc(sizeof(float64data));
274+
*result = DEFAULT_EQ_SEL;
275+
}
261276
*result = 1.0 - *result;
262277
return result;
263278
}

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