From e0412cdbd0d84b39a40355042b3c99fd88273b8d Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 11 Mar 2024 09:15:33 +0100 Subject: [PATCH v3 5/8] Make RangeTblEntry dump order consistent Put the fields alias and eref earlier in the struct, so that it matches the order in _outRangeTblEntry()/_readRangeTblEntry(). This helps if we ever want to fully automate out/read of RangeTblEntry. Also, it makes dumps in the debugger easier to read in the same way. Internally, this makes no difference. Discussion: https://www.postgresql.org/message-id/flat/4b27fc50-8cd6-46f5-ab20-88dbaadca645@eisentraut.org TODO: catversion --- src/backend/nodes/outfuncs.c | 1 - src/backend/nodes/readfuncs.c | 1 - src/include/nodes/parsenodes.h | 14 ++++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 29cbc83bd9..c55375e7f9 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -494,7 +494,6 @@ _outRangeTblEntry(StringInfo str, const RangeTblEntry *node) { WRITE_NODE_TYPE("RANGETBLENTRY"); - /* put alias + eref first to make dump more legible */ WRITE_NODE_FIELD(alias); WRITE_NODE_FIELD(eref); WRITE_ENUM_FIELD(rtekind, RTEKind); diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index a122407c88..c4d01a441a 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -348,7 +348,6 @@ _readRangeTblEntry(void) { READ_LOCALS(RangeTblEntry); - /* put alias + eref first to make dump more legible */ READ_NODE_FIELD(alias); READ_NODE_FIELD(eref); READ_ENUM_FIELD(rtekind, RTEKind); diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index aae50abdb0..6192492df8 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -1026,6 +1026,16 @@ typedef struct RangeTblEntry NodeTag type; + /* + * Fields valid in all RTEs: + * + * put alias + eref first to make dump more legible + */ + /* user-written alias clause, if any */ + Alias *alias pg_node_attr(query_jumble_ignore); + /* expanded reference names */ + Alias *eref pg_node_attr(query_jumble_ignore); + RTEKind rtekind; /* see above */ /* @@ -1217,10 +1227,6 @@ typedef struct RangeTblEntry /* * Fields valid in all RTEs: */ - /* user-written alias clause, if any */ - Alias *alias pg_node_attr(query_jumble_ignore); - /* expanded reference names */ - Alias *eref pg_node_attr(query_jumble_ignore); /* was LATERAL specified? */ bool lateral pg_node_attr(query_jumble_ignore); /* present in FROM clause? */ -- 2.44.0