From ef4c35a8aa6e6e855814629545cacc97fbcb9066 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 11 Mar 2024 09:15:33 +0100 Subject: [PATCH v3 8/8] WIP: Remove custom RangeTblEntry node read/write implementations This is part of an effort to reduce the number of special cases in the automatically generated node support functions. This patch removes the custom read/write functions for RangeTblEntry. Discussion: https://www.postgresql.org/message-id/flat/4b27fc50-8cd6-46f5-ab20-88dbaadca645@eisentraut.org TODO: check how much this bloats stored rules TODO: catversion --- src/backend/nodes/outfuncs.c | 81 ----------------------------- src/backend/nodes/readfuncs.c | 93 ---------------------------------- src/include/nodes/parsenodes.h | 2 - 3 files changed, 176 deletions(-) diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 5e34584c55..dbc316ed32 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -490,87 +490,6 @@ _outExtensibleNode(StringInfo str, const ExtensibleNode *node) methods->nodeOut(str, node); } -static void -_outRangeTblEntry(StringInfo str, const RangeTblEntry *node) -{ - AssertRangeTblEntryIsValid(node); - WRITE_NODE_TYPE("RANGETBLENTRY"); - - WRITE_NODE_FIELD(alias); - WRITE_NODE_FIELD(eref); - WRITE_ENUM_FIELD(rtekind, RTEKind); - - switch (node->rtekind) - { - case RTE_RELATION: - WRITE_OID_FIELD(relid); - WRITE_BOOL_FIELD(inh); - WRITE_CHAR_FIELD(relkind); - WRITE_INT_FIELD(rellockmode); - WRITE_UINT_FIELD(perminfoindex); - WRITE_NODE_FIELD(tablesample); - break; - case RTE_SUBQUERY: - WRITE_NODE_FIELD(subquery); - WRITE_BOOL_FIELD(security_barrier); - /* we re-use these RELATION fields, too: */ - WRITE_OID_FIELD(relid); - WRITE_BOOL_FIELD(inh); - WRITE_CHAR_FIELD(relkind); - WRITE_INT_FIELD(rellockmode); - WRITE_UINT_FIELD(perminfoindex); - break; - case RTE_JOIN: - WRITE_ENUM_FIELD(jointype, JoinType); - WRITE_INT_FIELD(joinmergedcols); - WRITE_NODE_FIELD(joinaliasvars); - WRITE_NODE_FIELD(joinleftcols); - WRITE_NODE_FIELD(joinrightcols); - WRITE_NODE_FIELD(join_using_alias); - break; - case RTE_FUNCTION: - WRITE_NODE_FIELD(functions); - WRITE_BOOL_FIELD(funcordinality); - break; - case RTE_TABLEFUNC: - WRITE_NODE_FIELD(tablefunc); - break; - case RTE_VALUES: - WRITE_NODE_FIELD(values_lists); - WRITE_NODE_FIELD(coltypes); - WRITE_NODE_FIELD(coltypmods); - WRITE_NODE_FIELD(colcollations); - break; - case RTE_CTE: - WRITE_STRING_FIELD(ctename); - WRITE_UINT_FIELD(ctelevelsup); - WRITE_BOOL_FIELD(self_reference); - WRITE_NODE_FIELD(coltypes); - WRITE_NODE_FIELD(coltypmods); - WRITE_NODE_FIELD(colcollations); - break; - case RTE_NAMEDTUPLESTORE: - WRITE_STRING_FIELD(enrname); - WRITE_FLOAT_FIELD(enrtuples); - WRITE_NODE_FIELD(coltypes); - WRITE_NODE_FIELD(coltypmods); - WRITE_NODE_FIELD(colcollations); - /* we re-use these RELATION fields, too: */ - WRITE_OID_FIELD(relid); - break; - case RTE_RESULT: - /* no extra fields */ - break; - default: - elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind); - break; - } - - WRITE_BOOL_FIELD(lateral); - WRITE_BOOL_FIELD(inFromCl); - WRITE_NODE_FIELD(securityQuals); -} - static void _outA_Expr(StringInfo str, const A_Expr *node) { diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 217d81041a..1a322659be 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -344,99 +344,6 @@ _readA_Const(void) READ_DONE(); } -static RangeTblEntry * -_readRangeTblEntry(void) -{ - READ_LOCALS(RangeTblEntry); - - READ_NODE_FIELD(alias); - READ_NODE_FIELD(eref); - READ_ENUM_FIELD(rtekind, RTEKind); - - switch (local_node->rtekind) - { - case RTE_RELATION: - READ_OID_FIELD(relid); - READ_BOOL_FIELD(inh); - READ_CHAR_FIELD(relkind); - READ_INT_FIELD(rellockmode); - READ_UINT_FIELD(perminfoindex); - READ_NODE_FIELD(tablesample); - break; - case RTE_SUBQUERY: - READ_NODE_FIELD(subquery); - READ_BOOL_FIELD(security_barrier); - /* we re-use these RELATION fields, too: */ - READ_OID_FIELD(relid); - READ_BOOL_FIELD(inh); - READ_CHAR_FIELD(relkind); - READ_INT_FIELD(rellockmode); - READ_UINT_FIELD(perminfoindex); - break; - case RTE_JOIN: - READ_ENUM_FIELD(jointype, JoinType); - READ_INT_FIELD(joinmergedcols); - READ_NODE_FIELD(joinaliasvars); - READ_NODE_FIELD(joinleftcols); - READ_NODE_FIELD(joinrightcols); - READ_NODE_FIELD(join_using_alias); - break; - case RTE_FUNCTION: - READ_NODE_FIELD(functions); - READ_BOOL_FIELD(funcordinality); - break; - case RTE_TABLEFUNC: - READ_NODE_FIELD(tablefunc); - /* The RTE must have a copy of the column type info, if any */ - if (local_node->tablefunc) - { - TableFunc *tf = local_node->tablefunc; - - local_node->coltypes = tf->coltypes; - local_node->coltypmods = tf->coltypmods; - local_node->colcollations = tf->colcollations; - } - break; - case RTE_VALUES: - READ_NODE_FIELD(values_lists); - READ_NODE_FIELD(coltypes); - READ_NODE_FIELD(coltypmods); - READ_NODE_FIELD(colcollations); - break; - case RTE_CTE: - READ_STRING_FIELD(ctename); - READ_UINT_FIELD(ctelevelsup); - READ_BOOL_FIELD(self_reference); - READ_NODE_FIELD(coltypes); - READ_NODE_FIELD(coltypmods); - READ_NODE_FIELD(colcollations); - break; - case RTE_NAMEDTUPLESTORE: - READ_STRING_FIELD(enrname); - READ_FLOAT_FIELD(enrtuples); - READ_NODE_FIELD(coltypes); - READ_NODE_FIELD(coltypmods); - READ_NODE_FIELD(colcollations); - /* we re-use these RELATION fields, too: */ - READ_OID_FIELD(relid); - break; - case RTE_RESULT: - /* no extra fields */ - break; - default: - elog(ERROR, "unrecognized RTE kind: %d", - (int) local_node->rtekind); - break; - } - - READ_BOOL_FIELD(lateral); - READ_BOOL_FIELD(inFromCl); - READ_NODE_FIELD(securityQuals); - - AssertRangeTblEntryIsValid(local_node); - READ_DONE(); -} - static A_Expr * _readA_Expr(void) { diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 6192492df8..b3b5a6cdf1 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -1022,8 +1022,6 @@ typedef enum RTEKind typedef struct RangeTblEntry { - pg_node_attr(custom_read_write) - NodeTag type; /* -- 2.44.0