diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-07-05 11:12:33 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-07-05 11:12:33 -0400 |
commit | 8d9f9634ef21ab0023e2bd98e799f5ad2eec4539 (patch) | |
tree | b4345ec308dd9197047f189514e129b08da95951 | |
parent | 054325c5eeb3140a067ba66735c3d811163ecd6a (diff) | |
download | postgresql-8d9f9634ef21ab0023e2bd98e799f5ad2eec4539.tar.gz postgresql-8d9f9634ef21ab0023e2bd98e799f5ad2eec4539.zip |
Fix errors in copyfuncs/equalfuncs support for JSON node types.
Noted while comparing existing code to the output of the proposed
patch to automate creation of these functions. Some of the changes
are just cosmetic, but others represent real bugs. I've not
attempted to analyze the user-visible impact.
Back-patch to v15 where this code came in.
Discussion: https://postgr.es/m/1794155.1656984188@sss.pgh.pa.us
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 11 | ||||
-rw-r--r-- | src/backend/nodes/equalfuncs.c | 25 |
2 files changed, 28 insertions, 8 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 51d630fa892..706d283a925 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -2703,7 +2703,8 @@ _copyJsonTable(const JsonTable *from) COPY_NODE_FIELD(plan); COPY_NODE_FIELD(on_error); COPY_NODE_FIELD(alias); - COPY_SCALAR_FIELD(location); + COPY_SCALAR_FIELD(lateral); + COPY_LOCATION_FIELD(location); return newnode; } @@ -2721,13 +2722,13 @@ _copyJsonTableColumn(const JsonTableColumn *from) COPY_NODE_FIELD(typeName); COPY_STRING_FIELD(pathspec); COPY_STRING_FIELD(pathname); - COPY_SCALAR_FIELD(format); + COPY_NODE_FIELD(format); COPY_SCALAR_FIELD(wrapper); COPY_SCALAR_FIELD(omit_quotes); COPY_NODE_FIELD(columns); COPY_NODE_FIELD(on_empty); COPY_NODE_FIELD(on_error); - COPY_SCALAR_FIELD(location); + COPY_LOCATION_FIELD(location); return newnode; } @@ -2742,10 +2743,10 @@ _copyJsonTablePlan(const JsonTablePlan *from) COPY_SCALAR_FIELD(plan_type); COPY_SCALAR_FIELD(join_type); - COPY_STRING_FIELD(pathname); COPY_NODE_FIELD(plan1); COPY_NODE_FIELD(plan2); - COPY_SCALAR_FIELD(location); + COPY_STRING_FIELD(pathname); + COPY_LOCATION_FIELD(location); return newnode; } diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index e747e1667d0..fccc0b4a18d 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -148,13 +148,28 @@ _equalTableFunc(const TableFunc *a, const TableFunc *b) } static bool +_equalJsonTablePlan(const JsonTablePlan *a, const JsonTablePlan *b) +{ + COMPARE_SCALAR_FIELD(plan_type); + COMPARE_SCALAR_FIELD(join_type); + COMPARE_NODE_FIELD(plan1); + COMPARE_NODE_FIELD(plan2); + COMPARE_STRING_FIELD(pathname); + COMPARE_LOCATION_FIELD(location); + + return true; +} + +static bool _equalJsonTable(const JsonTable *a, const JsonTable *b) { COMPARE_NODE_FIELD(common); COMPARE_NODE_FIELD(columns); + COMPARE_NODE_FIELD(plan); COMPARE_NODE_FIELD(on_error); COMPARE_NODE_FIELD(alias); - COMPARE_SCALAR_FIELD(location); + COMPARE_SCALAR_FIELD(lateral); + COMPARE_LOCATION_FIELD(location); return true; } @@ -166,13 +181,14 @@ _equalJsonTableColumn(const JsonTableColumn *a, const JsonTableColumn *b) COMPARE_STRING_FIELD(name); COMPARE_NODE_FIELD(typeName); COMPARE_STRING_FIELD(pathspec); - COMPARE_SCALAR_FIELD(format); + COMPARE_STRING_FIELD(pathname); + COMPARE_NODE_FIELD(format); COMPARE_SCALAR_FIELD(wrapper); COMPARE_SCALAR_FIELD(omit_quotes); COMPARE_NODE_FIELD(columns); COMPARE_NODE_FIELD(on_empty); COMPARE_NODE_FIELD(on_error); - COMPARE_SCALAR_FIELD(location); + COMPARE_LOCATION_FIELD(location); return true; } @@ -4405,6 +4421,9 @@ equal(const void *a, const void *b) case T_JsonArgument: retval = _equalJsonArgument(a, b); break; + case T_JsonTablePlan: + retval = _equalJsonTablePlan(a, b); + break; case T_JsonTable: retval = _equalJsonTable(a, b); break; |