From a6bc3301925e1a8ad1f58da629b9dd55bc4b8d9c Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 24 Sep 2022 18:18:33 -0400 Subject: Add read support for some missing raw parse nodes The node types A_Const, Constraint, and A_Expr had custom output functions, but no read functions were implemented so far. The A_Expr output format had to be tweaked a bit to make it easier to parse. Be a bit more cautious about applying strncmp to unterminated strings. Also error out if an unrecognized enum value is found in each case, instead of just printing a placeholder value. That was maybe ok for debugging but won't work if we want to have robust round-tripping. Reviewed-by: Tom Lane Discussion: https://www.postgresql.org/message-id/flat/4159834.1657405226@sss.pgh.pa.us --- src/backend/nodes/outfuncs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/backend/nodes/outfuncs.c') diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 60610e3a4bd..24ea0487e7f 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -548,12 +548,12 @@ _outA_Expr(StringInfo str, const A_Expr *node) WRITE_NODE_FIELD(name); break; case AEXPR_OP_ANY: - WRITE_NODE_FIELD(name); appendStringInfoString(str, " ANY"); + WRITE_NODE_FIELD(name); break; case AEXPR_OP_ALL: - WRITE_NODE_FIELD(name); appendStringInfoString(str, " ALL"); + WRITE_NODE_FIELD(name); break; case AEXPR_DISTINCT: appendStringInfoString(str, " DISTINCT"); @@ -600,7 +600,7 @@ _outA_Expr(StringInfo str, const A_Expr *node) WRITE_NODE_FIELD(name); break; default: - appendStringInfoString(str, " ??"); + elog(ERROR, "unrecognized A_Expr_Kind: %d", (int) node->kind); break; } @@ -782,8 +782,7 @@ _outConstraint(StringInfo str, const Constraint *node) break; default: - appendStringInfo(str, "", - (int) node->contype); + elog(ERROR, "unrecognized ConstrType: %d", (int) node->contype); break; } } -- cgit v1.2.3