]> granicus.if.org Git - postgresql/blobdiff - src/backend/nodes/equalfuncs.c
Add a concept of "placeholder" variables to the planner. These are variables
[postgresql] / src / backend / nodes / equalfuncs.c
index 96eec16ebc1f985be5fd4538e62622b97fcd03c0..e0b8bdcecb1230ad8e75ca870ef10a5df6d1d10f 100644 (file)
@@ -22,7 +22,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.333 2008/10/06 17:39:26 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.334 2008/10/21 20:42:52 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -763,6 +763,27 @@ _equalFlattenedSubLink(FlattenedSubLink *a, FlattenedSubLink *b)
        return true;
 }
 
+static bool
+_equalPlaceHolderVar(PlaceHolderVar *a, PlaceHolderVar *b)
+{
+       /*
+        * We intentionally do not compare phexpr.  Two PlaceHolderVars with the
+        * same ID and levelsup should be considered equal even if the contained
+        * expressions have managed to mutate to different states.  One way in
+        * which that can happen is that initplan sublinks would get replaced by
+        * differently-numbered Params when sublink folding is done.  (The end
+        * result of such a situation would be some unreferenced initplans, which
+        * is annoying but not really a problem.)
+        *
+        * COMPARE_NODE_FIELD(phexpr);
+        */
+       COMPARE_BITMAPSET_FIELD(phrels);
+       COMPARE_SCALAR_FIELD(phid);
+       COMPARE_SCALAR_FIELD(phlevelsup);
+
+       return true;
+}
+
 static bool
 _equalSpecialJoinInfo(SpecialJoinInfo *a, SpecialJoinInfo *b)
 {
@@ -792,6 +813,18 @@ _equalAppendRelInfo(AppendRelInfo *a, AppendRelInfo *b)
        return true;
 }
 
+static bool
+_equalPlaceHolderInfo(PlaceHolderInfo *a, PlaceHolderInfo *b)
+{
+       COMPARE_SCALAR_FIELD(phid);
+       COMPARE_NODE_FIELD(ph_var);
+       COMPARE_BITMAPSET_FIELD(ph_eval_at);
+       COMPARE_BITMAPSET_FIELD(ph_needed);
+       COMPARE_SCALAR_FIELD(ph_width);
+
+       return true;
+}
+
 
 /*
  * Stuff from parsenodes.h
@@ -2289,12 +2322,19 @@ equal(void *a, void *b)
                case T_FlattenedSubLink:
                        retval = _equalFlattenedSubLink(a, b);
                        break;
+               case T_PlaceHolderVar:
+                       retval = _equalPlaceHolderVar(a, b);
+                       break;
                case T_SpecialJoinInfo:
                        retval = _equalSpecialJoinInfo(a, b);
                        break;
                case T_AppendRelInfo:
                        retval = _equalAppendRelInfo(a, b);
                        break;
+               case T_PlaceHolderInfo:
+                       retval = _equalPlaceHolderInfo(a, b);
+                       break;
+
                case T_List:
                case T_IntList:
                case T_OidList: