Re: User-defined Operator Pushdown and Collations - Mailing list pgsql-hackers

From Paul Ramsey
Subject Re: User-defined Operator Pushdown and Collations
Date
Msg-id CACowWR1F1oM9WEEjXRZ9z=dREwH36UBjW32g+JJr=+TywwJXGQ@mail.gmail.com
Whole thread Raw
In response to User-defined Operator Pushdown and Collations  (Paul Ramsey <pramsey@cleverelephant.ca>)
Responses Re: User-defined Operator Pushdown and Collations
List pgsql-hackers


On Fri, Nov 25, 2016 at 11:30 AM, Paul Ramsey <pramsey@cleverelephant.ca> wrote:
I've been trying to figure out an issue with operators not being pushed down for user defined types, in this case "hstore". TL;DR:

hstore=# explain (verbose) select * from hs_fdw where h -> 'a' = '1';
                              QUERY PLAN                              
----------------------------------------------------------------------
 Foreign Scan on public.hs_fdw  (cost=100.00..157.78 rows=7 width=36)
   Output: id, h
   Filter: ((hs_fdw.h -> 'a'::text) = '1'::text)
   Remote SQL: SELECT id, h FROM public.hs
(4 rows)

In terms of "shippability" the "->" operator passes fine. It ends up not being shipped because its collation bubbles up as FDW_COLLATE_NONE, and gets kicked back as not deparseable around here:



I'm finding this piece of code a little suspect, but that may just be my not fully understanding why/what determines when a collation is shippable. 

In the case of my example above, the OpExpr '->' has an input collation of 100 (DEFAULT_COLLATION_ID). The Var below has a collation of 0 (InvalidOid) and state of FDW_COLLATE_NONE, and the Const has collation of 100 (DEFAULT_COLLATION_ID ) and state of FDW_COLLATE_NONE.  In other parts of the code, the default collation and collection 0 are treated as both leading to a state of FDW_COLLATE_NONE. But the OpExpr instead of bubbling FDW_COLLATE_NONE up the chain, returns false and ends the shippability of the Node.

What are the issues around shipping nodes of different collations to the remote? All the nodes in my example are foreign Var, or local Const, and all either are collation 0 or DEFAULT_COLLATION_ID. Surely it should be shippable?

P

 
I'm still working at wrapping my head around why this is good or not, but if there's an obvious explanation and/or workaround, I'd love to know.

Thanks!

P


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: References to arbitrary database objects that are suitable for pg_dump
Next
From: Amos Bird
Date:
Subject: Re: make default TABLESPACE belong to target table.