Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f32d57f

Browse files
committed
Fix problems related to RangeTblEntry members enrname and enrtuples.
Commit 18ce3a4 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
1 parent 6c2003f commit f32d57f

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,10 +2303,11 @@ _copyRangeTblEntry(const RangeTblEntry *from)
23032303
COPY_STRING_FIELD(ctename);
23042304
COPY_SCALAR_FIELD(ctelevelsup);
23052305
COPY_SCALAR_FIELD(self_reference);
2306-
COPY_STRING_FIELD(enrname);
23072306
COPY_NODE_FIELD(coltypes);
23082307
COPY_NODE_FIELD(coltypmods);
23092308
COPY_NODE_FIELD(colcollations);
2309+
COPY_STRING_FIELD(enrname);
2310+
COPY_SCALAR_FIELD(enrtuples);
23102311
COPY_NODE_FIELD(alias);
23112312
COPY_NODE_FIELD(eref);
23122313
COPY_SCALAR_FIELD(lateral);

src/backend/nodes/equalfuncs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,6 +2631,8 @@ _equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b)
26312631
COMPARE_NODE_FIELD(coltypes);
26322632
COMPARE_NODE_FIELD(coltypmods);
26332633
COMPARE_NODE_FIELD(colcollations);
2634+
COMPARE_STRING_FIELD(enrname);
2635+
COMPARE_SCALAR_FIELD(enrtuples);
26342636
COMPARE_NODE_FIELD(alias);
26352637
COMPARE_NODE_FIELD(eref);
26362638
COMPARE_SCALAR_FIELD(lateral);

src/backend/nodes/outfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,6 +3047,7 @@ _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
30473047
break;
30483048
case RTE_NAMEDTUPLESTORE:
30493049
WRITE_STRING_FIELD(enrname);
3050+
WRITE_FLOAT_FIELD(enrtuples, "%.0f");
30503051
WRITE_OID_FIELD(relid);
30513052
WRITE_NODE_FIELD(coltypes);
30523053
WRITE_NODE_FIELD(coltypmods);

src/backend/nodes/readfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,7 @@ _readRangeTblEntry(void)
13581358
break;
13591359
case RTE_NAMEDTUPLESTORE:
13601360
READ_STRING_FIELD(enrname);
1361+
READ_FLOAT_FIELD(enrtuples);
13611362
READ_OID_FIELD(relid);
13621363
READ_NODE_FIELD(coltypes);
13631364
READ_NODE_FIELD(coltypmods);

src/include/nodes/parsenodes.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,11 @@ typedef struct RangeTblEntry
944944

945945
/*
946946
* Fields valid for a plain relation RTE (else zero):
947+
*
948+
* As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
949+
* that the tuple format of the tuplestore is the same as the referenced
950+
* relation. This allows plans referencing AFTER trigger transition
951+
* tables to be invalidated if the underlying table is altered.
947952
*/
948953
Oid relid; /* OID of the relation */
949954
char relkind; /* relation kind (see pg_class.relkind) */
@@ -1004,16 +1009,23 @@ typedef struct RangeTblEntry
10041009
bool self_reference; /* is this a recursive self-reference? */
10051010

10061011
/*
1007-
* Fields valid for values and CTE RTEs (else NIL):
1012+
* Fields valid for table functions, values, CTE and ENR RTEs (else NIL):
10081013
*
10091014
* We need these for CTE RTEs so that the types of self-referential
10101015
* columns are well-defined. For VALUES RTEs, storing these explicitly
10111016
* saves having to re-determine the info by scanning the values_lists.
1017+
* For ENRs, we store the types explicitly here (we could get the
1018+
* information from the catalogs if 'relid' was supplied, but we'd still
1019+
* need these for TupleDesc-based ENRs, so we might as well always store
1020+
* the type info here).
10121021
*/
10131022
List *coltypes; /* OID list of column type OIDs */
10141023
List *coltypmods; /* integer list of column typmods */
10151024
List *colcollations; /* OID list of column collation OIDs */
10161025

1026+
/*
1027+
* Fields valid for ENR RTEs (else NULL/zero):
1028+
*/
10171029
char *enrname; /* name of ephemeral named relation */
10181030
double enrtuples; /* estimated or actual from caller */
10191031

0 commit comments

Comments
 (0)