Skip to content

Commit 8d9f963

Browse files
committed
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
1 parent 054325c commit 8d9f963

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,8 @@ _copyJsonTable(const JsonTable *from)
27032703
COPY_NODE_FIELD(plan);
27042704
COPY_NODE_FIELD(on_error);
27052705
COPY_NODE_FIELD(alias);
2706-
COPY_SCALAR_FIELD(location);
2706+
COPY_SCALAR_FIELD(lateral);
2707+
COPY_LOCATION_FIELD(location);
27072708

27082709
return newnode;
27092710
}
@@ -2721,13 +2722,13 @@ _copyJsonTableColumn(const JsonTableColumn *from)
27212722
COPY_NODE_FIELD(typeName);
27222723
COPY_STRING_FIELD(pathspec);
27232724
COPY_STRING_FIELD(pathname);
2724-
COPY_SCALAR_FIELD(format);
2725+
COPY_NODE_FIELD(format);
27252726
COPY_SCALAR_FIELD(wrapper);
27262727
COPY_SCALAR_FIELD(omit_quotes);
27272728
COPY_NODE_FIELD(columns);
27282729
COPY_NODE_FIELD(on_empty);
27292730
COPY_NODE_FIELD(on_error);
2730-
COPY_SCALAR_FIELD(location);
2731+
COPY_LOCATION_FIELD(location);
27312732

27322733
return newnode;
27332734
}
@@ -2742,10 +2743,10 @@ _copyJsonTablePlan(const JsonTablePlan *from)
27422743

27432744
COPY_SCALAR_FIELD(plan_type);
27442745
COPY_SCALAR_FIELD(join_type);
2745-
COPY_STRING_FIELD(pathname);
27462746
COPY_NODE_FIELD(plan1);
27472747
COPY_NODE_FIELD(plan2);
2748-
COPY_SCALAR_FIELD(location);
2748+
COPY_STRING_FIELD(pathname);
2749+
COPY_LOCATION_FIELD(location);
27492750

27502751
return newnode;
27512752
}

src/backend/nodes/equalfuncs.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,29 @@ _equalTableFunc(const TableFunc *a, const TableFunc *b)
147147
return true;
148148
}
149149

150+
static bool
151+
_equalJsonTablePlan(const JsonTablePlan *a, const JsonTablePlan *b)
152+
{
153+
COMPARE_SCALAR_FIELD(plan_type);
154+
COMPARE_SCALAR_FIELD(join_type);
155+
COMPARE_NODE_FIELD(plan1);
156+
COMPARE_NODE_FIELD(plan2);
157+
COMPARE_STRING_FIELD(pathname);
158+
COMPARE_LOCATION_FIELD(location);
159+
160+
return true;
161+
}
162+
150163
static bool
151164
_equalJsonTable(const JsonTable *a, const JsonTable *b)
152165
{
153166
COMPARE_NODE_FIELD(common);
154167
COMPARE_NODE_FIELD(columns);
168+
COMPARE_NODE_FIELD(plan);
155169
COMPARE_NODE_FIELD(on_error);
156170
COMPARE_NODE_FIELD(alias);
157-
COMPARE_SCALAR_FIELD(location);
171+
COMPARE_SCALAR_FIELD(lateral);
172+
COMPARE_LOCATION_FIELD(location);
158173

159174
return true;
160175
}
@@ -166,13 +181,14 @@ _equalJsonTableColumn(const JsonTableColumn *a, const JsonTableColumn *b)
166181
COMPARE_STRING_FIELD(name);
167182
COMPARE_NODE_FIELD(typeName);
168183
COMPARE_STRING_FIELD(pathspec);
169-
COMPARE_SCALAR_FIELD(format);
184+
COMPARE_STRING_FIELD(pathname);
185+
COMPARE_NODE_FIELD(format);
170186
COMPARE_SCALAR_FIELD(wrapper);
171187
COMPARE_SCALAR_FIELD(omit_quotes);
172188
COMPARE_NODE_FIELD(columns);
173189
COMPARE_NODE_FIELD(on_empty);
174190
COMPARE_NODE_FIELD(on_error);
175-
COMPARE_SCALAR_FIELD(location);
191+
COMPARE_LOCATION_FIELD(location);
176192

177193
return true;
178194
}
@@ -4405,6 +4421,9 @@ equal(const void *a, const void *b)
44054421
case T_JsonArgument:
44064422
retval = _equalJsonArgument(a, b);
44074423
break;
4424+
case T_JsonTablePlan:
4425+
retval = _equalJsonTablePlan(a, b);
4426+
break;
44084427
case T_JsonTable:
44094428
retval = _equalJsonTable(a, b);
44104429
break;

0 commit comments

Comments
 (0)