]> granicus.if.org Git - postgresql/commitdiff
Fix problems related to RangeTblEntry members enrname and enrtuples.
authorRobert Haas <rhaas@postgresql.org>
Wed, 14 Jun 2017 20:19:46 +0000 (16:19 -0400)
committerRobert Haas <rhaas@postgresql.org>
Wed, 14 Jun 2017 20:19:46 +0000 (16:19 -0400)
Commit 18ce3a4ab22d2984f8540ab480979c851dae5338 failed to update
the comments in parsenodes.h for the new members, and made only
incomplete updates to src/backend/nodes

Thomas Munro, per a report from Noah Misch.

Discussion: http://postgr.es/m/20170611062525.GA1628882@rfd.leadboat.com

src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/include/nodes/parsenodes.h

index 36bf1dc92bbe3c90de58741c1a1d9c6c69d3c884..02451c2a7130077ea72e5096a811dbd582c21abf 100644 (file)
@@ -2303,10 +2303,11 @@ _copyRangeTblEntry(const RangeTblEntry *from)
        COPY_STRING_FIELD(ctename);
        COPY_SCALAR_FIELD(ctelevelsup);
        COPY_SCALAR_FIELD(self_reference);
-       COPY_STRING_FIELD(enrname);
        COPY_NODE_FIELD(coltypes);
        COPY_NODE_FIELD(coltypmods);
        COPY_NODE_FIELD(colcollations);
+       COPY_STRING_FIELD(enrname);
+       COPY_SCALAR_FIELD(enrtuples);
        COPY_NODE_FIELD(alias);
        COPY_NODE_FIELD(eref);
        COPY_SCALAR_FIELD(lateral);
index 5bcf0317dc8fb01000634d2dbf9e56f669df3b9d..c88d09f7c65661e19262129c7acaaf9e312d69f8 100644 (file)
@@ -2631,6 +2631,8 @@ _equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b)
        COMPARE_NODE_FIELD(coltypes);
        COMPARE_NODE_FIELD(coltypmods);
        COMPARE_NODE_FIELD(colcollations);
+       COMPARE_STRING_FIELD(enrname);
+       COMPARE_SCALAR_FIELD(enrtuples);
        COMPARE_NODE_FIELD(alias);
        COMPARE_NODE_FIELD(eref);
        COMPARE_SCALAR_FIELD(lateral);
index c348bdcde39e37edabc625900af3767c7ddbe4ed..4fd2ca50c02183b675b56ed7e9a44350d8964370 100644 (file)
@@ -3047,6 +3047,7 @@ _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
                        break;
                case RTE_NAMEDTUPLESTORE:
                        WRITE_STRING_FIELD(enrname);
+                       WRITE_FLOAT_FIELD(enrtuples, "%.0f");
                        WRITE_OID_FIELD(relid);
                        WRITE_NODE_FIELD(coltypes);
                        WRITE_NODE_FIELD(coltypmods);
index 81ddfc32712e51237e3d2beed0b0e1e255397d9d..039910e1f7003da568b8b841424590d9874c525e 100644 (file)
@@ -1358,6 +1358,7 @@ _readRangeTblEntry(void)
                        break;
                case RTE_NAMEDTUPLESTORE:
                        READ_STRING_FIELD(enrname);
+                       READ_FLOAT_FIELD(enrtuples);
                        READ_OID_FIELD(relid);
                        READ_NODE_FIELD(coltypes);
                        READ_NODE_FIELD(coltypmods);
index 2d2e2c0fbc1e9998c591ec8704a6f5431df8b6ad..271564fd23b735fee0306aea915ab587daa82d93 100644 (file)
@@ -944,6 +944,11 @@ typedef struct RangeTblEntry
 
        /*
         * Fields valid for a plain relation RTE (else zero):
+        *
+        * As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
+        * that the tuple format of the tuplestore is the same as the referenced
+        * relation.  This allows plans referencing AFTER trigger transition
+        * tables to be invalidated if the underlying table is altered.
         */
        Oid                     relid;                  /* OID of the relation */
        char            relkind;                /* relation kind (see pg_class.relkind) */
@@ -1004,16 +1009,23 @@ typedef struct RangeTblEntry
        bool            self_reference; /* is this a recursive self-reference? */
 
        /*
-        * Fields valid for values and CTE RTEs (else NIL):
+        * Fields valid for table functions, values, CTE and ENR RTEs (else NIL):
         *
         * We need these for CTE RTEs so that the types of self-referential
         * columns are well-defined.  For VALUES RTEs, storing these explicitly
         * saves having to re-determine the info by scanning the values_lists.
+        * For ENRs, we store the types explicitly here (we could get the
+        * information from the catalogs if 'relid' was supplied, but we'd still
+        * need these for TupleDesc-based ENRs, so we might as well always store
+        * the type info here).
         */
        List       *coltypes;           /* OID list of column type OIDs */
        List       *coltypmods;         /* integer list of column typmods */
        List       *colcollations;      /* OID list of column collation OIDs */
 
+       /*
+        * Fields valid for ENR RTEs (else NULL/zero):
+        */
        char       *enrname;            /* name of ephemeral named relation */
        double          enrtuples;              /* estimated or actual from caller */