Closed pramsey closed 3 years ago
This is looking pretty intractable. The argument coming in on the right side of && is
(FuncExpr) $3 = {
xpr = (type = T_FuncExpr)
funcid = 639820
funcresulttype = 639459
funcretset = false
funcvariadic = false
funcformat = COERCE_IMPLICIT_CAST
funccollid = 0
inputcollid = 100
args = 0x00007fdd468134b8
location = -1
}
And the function being called is
oid | 639820
proname | geometry
pronamespace | 2200
...
prorettype | 639459
proargtypes | 25
prosrc | parse_WKT_lwgeom
probin | $libdir/postgis-3.1
Basically, geometry(text)
. So something about this query is falling into our implicit PostGIS geometry(text)
cast (what?) which means we don't have access to the constant anymore.
Really for all cases where plan caching happens, but is most visible with a test using prepared statements.
Set up an FDW.
Then set up a prepared statement and run it 6 times.
On the 6th run the plan will change and the geometry will not be materialized as a Const anymore, so the FDW will not attempt to push it down. This might be because the generic plan wraps the prepared parameter in a CAST, hiding the fact that it's a constant.
Here's the 6th plan.
If there's some way to figure out if the right hand side of the operator is constant, other than just looking for Const nodes, that would get us out of this bind.