Skip to content

Commit f5d8f0b

Browse files
committed
process_implied_equality must copy the substructure of the clauses it
is generating, to avoid problems when subselects are involved. Per report from Damon Hart.
1 parent f46a80c commit f5d8f0b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/backend/optimizer/plan/initsplan.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.97 2004/01/05 05:07:35 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.98 2004/02/27 21:42:00 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -756,11 +756,16 @@ process_implied_equality(Query *root,
756756
errmsg("equality operator for types %s and %s should be merge-joinable, but isn't",
757757
format_type_be(ltype), format_type_be(rtype))));
758758

759+
/*
760+
* Now we can build the new clause. Copy to ensure it shares no
761+
* substructure with original (this is necessary in case there are
762+
* subselects in there...)
763+
*/
759764
clause = make_opclause(oprid(eq_operator), /* opno */
760765
BOOLOID, /* opresulttype */
761766
false, /* opretset */
762-
(Expr *) item1,
763-
(Expr *) item2);
767+
(Expr *) copyObject(item1),
768+
(Expr *) copyObject(item2));
764769

765770
ReleaseSysCache(eq_operator);
766771

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy