Skip to content

Commit

Permalink
Fix regression in FOR JSON AUTO with nested queries. (#3125)
Browse files Browse the repository at this point in the history
* Fix regression in FOR JSON AUTO with nested queries.

The previous implementation of nested FOR JSON AUTO relied on the happy
accident that the enum T_JsonArrayQueryConstructor happened to have the
same value as the typid for the json type, 114. In PG17 the enum value
for T_JsonArrayQueryConstructor changed to 130, leading to errors when
trying to evaluate nested FOR JSON AUTO queries. Fix this by properly
using the typid for json.

Task: BABEL-5398

Signed-off-by: Jason Teng <[email protected]>
  • Loading branch information
roshan0708 authored Nov 15, 2024
1 parent 81de5b9 commit e47fa84
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/src/pl_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ static void modifyColumnEntries(List* targetList, forjson_table **tableInfoArr,
if(handleForJsonAuto(castNode(Query, sl->subselect), tableInfoArr, numTables)) {
CoerceViaIO *iocoerce = makeNode(CoerceViaIO);
iocoerce->arg = (Expr*) sl;
iocoerce->resulttype = T_JsonArrayQueryConstructor;
iocoerce->resulttype = TypenameGetTypid("json");
iocoerce->resultcollid = 0;
iocoerce->coerceformat = COERCE_EXPLICIT_CAST;
buildJsonEntry(1, "temp", te);
Expand Down
3 changes: 0 additions & 3 deletions test/JDBC/jdbc_schedule
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,6 @@ ignore#!#pgr_select
ignore#!#pgr_zzz_clean_up

# Ignoring some test temporarily to get clean tests
ignore#!#forjsonauto-vu-prepare
ignore#!#forjsonauto-vu-verify
ignore#!#forjsonauto-vu-cleanup
ignore#!#BABEL-3292
ignore#!#BABEL-3512
ignore#!#BABEL-4046-vu-prepare
Expand Down
2 changes: 1 addition & 1 deletion test/JDBC/upgrade/16_5/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ forjson
forjson-datatypes
forjson-subquery
forjson-nesting
# forjsonauto - TODO JIRA - BABEL-5398
forjsonauto
format
format-dep
forxml
Expand Down
2 changes: 1 addition & 1 deletion test/JDBC/upgrade/latest/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ forjson
forjson-datatypes
forjson-subquery
forjson-nesting
# forjsonauto - TODO JIRA - BABEL-5398
forjsonauto
format
format-dep
forxml
Expand Down

0 comments on commit e47fa84

Please sign in to comment.