]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
process_implied_equality must copy the substructure of the clauses it
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 27 Feb 2004 21:42:10 +0000 (21:42 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 27 Feb 2004 21:42:10 +0000 (21:42 +0000)
is generating, to avoid problems when subselects are involved.  Per
report from Damon Hart.

src/backend/optimizer/plan/initsplan.c

index bff9b11df2f68e5b87de2080a4992f5d554eae57..859280686c2af0d7c84033a2e7ee469607140a58 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.91.2.1 2003/11/05 22:00:52 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.91.2.2 2004/02/27 21:42:10 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -768,11 +768,16 @@ process_implied_equality(Query *root,
                                 errmsg("equality operator for types %s and %s should be merge-joinable, but isn't",
                                                format_type_be(ltype), format_type_be(rtype))));
 
+       /*
+        * Now we can build the new clause.  Copy to ensure it shares no
+        * substructure with original (this is necessary in case there are
+        * subselects in there...)
+        */
        clause = make_opclause(oprid(eq_operator),      /* opno */
                                                   BOOLOID,             /* opresulttype */
                                                   false,               /* opretset */
-                                                  (Expr *) item1,
-                                                  (Expr *) item2);
+                                                  (Expr *) copyObject(item1),
+                                                  (Expr *) copyObject(item2));
 
        ReleaseSysCache(eq_operator);