On 29/04/2016 13:20, Michael Paquier wrote:
> On Fri, Apr 29, 2016 at 7:25 PM, Stefan Huehner <ste...@huehner.org> wrote:
>> If you need any more info or testing done just let me know.
> 
> The information you are providing is sufficient to reproduce the
> problem, thanks! I have added this bug to the list of open items for
> 9.6.
> 

The segfault is caused by quals_match_foreign_key() calling get_leftop()
and get_rightop() on a ScalarArrayOpExpr node.

Reordering the common fields of OpExpr and ScalarArrayOpExpr at the
beginning of the struct so the get_*op() work with either (as in
attached patch) fixes the issue.

I'm not sure that assuming this compatibility is the right way to fix
this though.

-- 
Julien Rouhaud
http://dalibo.com - http://dalibo.org
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 1ffc0a1..dffe129 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -468,12 +468,12 @@ typedef struct OpExpr
        Expr            xpr;
        Oid                     opno;                   /* PG_OPERATOR OID of 
the operator */
        Oid                     opfuncid;               /* PG_PROC OID of 
underlying function */
-       Oid                     opresulttype;   /* PG_TYPE OID of result value 
*/
-       bool            opretset;               /* true if operator returns set 
*/
-       Oid                     opcollid;               /* OID of collation of 
result */
        Oid                     inputcollid;    /* OID of collation that 
operator should use */
        List       *args;                       /* arguments to the operator (1 
or 2) */
        int                     location;               /* token location, or 
-1 if unknown */
+       Oid                     opresulttype;   /* PG_TYPE OID of result value 
*/
+       bool            opretset;               /* true if operator returns set 
*/
+       Oid                     opcollid;               /* OID of collation of 
result */
 } OpExpr;
 
 /*
@@ -511,10 +511,10 @@ typedef struct ScalarArrayOpExpr
        Expr            xpr;
        Oid                     opno;                   /* PG_OPERATOR OID of 
the operator */
        Oid                     opfuncid;               /* PG_PROC OID of 
underlying function */
-       bool            useOr;                  /* true for ANY, false for ALL 
*/
        Oid                     inputcollid;    /* OID of collation that 
operator should use */
        List       *args;                       /* the scalar and array 
operands */
        int                     location;               /* token location, or 
-1 if unknown */
+       bool            useOr;                  /* true for ANY, false for ALL 
*/
 } ScalarArrayOpExpr;
 
 /*
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to