contraints_exclusion fails to refute simple condition - Mailing list pgsql-hackers

From Sandro Santilli
Subject contraints_exclusion fails to refute simple condition
Date
Msg-id 20150305122020.GA30797@localhost
Whole thread Raw
Responses Re: contraints_exclusion fails to refute simple condition
List pgsql-hackers
PostGIS installs standard constraints of this kind:
 CHECK (geometrytype(g) = 'POINT'::text OR g IS NULL)

The constraint is used by constraint_exclusion if using this condition:
 WHERE g IS NOT NULL AND geometrytype(g) = 'LINESTRING'

But it is _NOT_ used if the NOT NULL condition is removed:
 WHERE geometrytype(g) = 'LINESTRING'

As the "geometrytype" is defined as STRICT and IMMUTABLE, there's
no way for geometrytype(g) = 'LINESTRING' to hold true, so why
is the "IS NOT NULL" condition also needed by the planner ?

Andres Freund on IRC suggested that predicate_refuted_by_simple_clause()
looks like trying to handle such cases, but if that's the case it seems
to fail here.

--strk; 



pgsql-hackers by date:

Previous
From: "Syed, Rahila"
Date:
Subject: Re: [REVIEW] Re: Compression of full-page-writes
Next
From: Pavel Stehule
Date:
Subject: Re: Providing catalog view to pg_hba.conf file - Patch submission