Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4d7e24e

Browse files
committed
Revert recent SQL/JSON related commits
Reverts6822285,565caaa, and3a97460, because a fewBF animals didn't like one or all of them.
1 parent3a97460 commit4d7e24e

File tree

5 files changed

+15
-82
lines changed

5 files changed

+15
-82
lines changed

‎src/backend/executor/execExpr.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4414,8 +4414,6 @@ ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state,
44144414
ErrorSaveContext*escontext=
44154415
jsexpr->on_error->btype!=JSON_BEHAVIOR_ERROR ?
44164416
&jsestate->escontext :NULL;
4417-
boolreturning_domain=
4418-
get_typtype(jsexpr->returning->typid)==TYPTYPE_DOMAIN;
44194417

44204418
jsestate->jsexpr=jsexpr;
44214419

@@ -4558,27 +4556,20 @@ ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state,
45584556
ExprEvalPushStep(state,scratch);
45594557
}
45604558

4559+
jsestate->jump_empty=jsestate->jump_error=-1;
4560+
45614561
/*
45624562
* Step to check jsestate->error and return the ON ERROR expression if
45634563
* there is one. This handles both the errors that occur during jsonpath
45644564
* evaluation in EEOP_JSONEXPR_PATH and subsequent coercion evaluation.
4565-
*
4566-
* Speed up common cases by avoiding extra steps for a NULL-valued ON
4567-
* ERROR expression unless RETURNING a domain type, where constraints must
4568-
* be checked. ExecEvalJsonExprPath() already returns NULL on error,
4569-
* making additional steps unnecessary in typical scenarios. Note that the
4570-
* default ON ERROR behavior for JSON_VALUE() and JSON_QUERY() is to
4571-
* return NULL.
45724565
*/
4573-
jsestate->jump_error=state->steps_len;
45744566
if (jsexpr->on_error&&
4575-
jsexpr->on_error->btype!=JSON_BEHAVIOR_ERROR&&
4576-
(!(IsA(jsexpr->on_error->expr,Const)&&
4577-
((Const*)jsexpr->on_error->expr)->constisnull)||
4578-
returning_domain))
4567+
jsexpr->on_error->btype!=JSON_BEHAVIOR_ERROR)
45794568
{
45804569
ErrorSaveContext*saved_escontext;
45814570

4571+
jsestate->jump_error=state->steps_len;
4572+
45824573
/* JUMP to end if false, that is, skip the ON ERROR expression. */
45834574
jumps_to_end=lappend_int(jumps_to_end,state->steps_len);
45844575
scratch->opcode=EEOP_JUMP_IF_NOT_TRUE;
@@ -4628,19 +4619,14 @@ ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state,
46284619
/*
46294620
* Step to check jsestate->empty and return the ON EMPTY expression if
46304621
* there is one.
4631-
*
4632-
* See the comment above for details on the optimization for NULL-valued
4633-
* expressions.
46344622
*/
4635-
jsestate->jump_empty=state->steps_len;
46364623
if (jsexpr->on_empty!=NULL&&
4637-
jsexpr->on_empty->btype!=JSON_BEHAVIOR_ERROR&&
4638-
(!(IsA(jsexpr->on_empty->expr,Const)&&
4639-
((Const*)jsexpr->on_empty->expr)->constisnull)||
4640-
returning_domain))
4624+
jsexpr->on_empty->btype!=JSON_BEHAVIOR_ERROR)
46414625
{
46424626
ErrorSaveContext*saved_escontext;
46434627

4628+
jsestate->jump_empty=state->steps_len;
4629+
46444630
/* JUMP to end if false, that is, skip the ON EMPTY expression. */
46454631
jumps_to_end=lappend_int(jumps_to_end,state->steps_len);
46464632
scratch->opcode=EEOP_JUMP_IF_NOT_TRUE;

‎src/backend/parser/parse_expr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4603,13 +4603,13 @@ transformJsonFuncExpr(ParseState *pstate, JsonFuncExpr *func)
46034603
}
46044604

46054605
/*
4606-
* Assume EMPTYARRAYON ERROR when ON ERROR is not specified.
4606+
* Assume EMPTY ON ERROR when ON ERROR is not specified.
46074607
*
46084608
* ON EMPTY cannot be specified at the top level but it can be for
46094609
* the individual columns.
46104610
*/
46114611
jsexpr->on_error=transformJsonBehavior(pstate,func->on_error,
4612-
JSON_BEHAVIOR_EMPTY_ARRAY,
4612+
JSON_BEHAVIOR_EMPTY,
46134613
jsexpr->returning);
46144614
break;
46154615

‎src/backend/utils/adt/ruleutils.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11719,6 +11719,7 @@ get_json_table_columns(TableFunc *tf, JsonTablePathScan *scan,
1171911719
boolshowimplicit)
1172011720
{
1172111721
StringInfobuf=context->buf;
11722+
JsonExpr*jexpr=castNode(JsonExpr,tf->docexpr);
1172211723
ListCell*lc_colname;
1172311724
ListCell*lc_coltype;
1172411725
ListCell*lc_coltypmod;
@@ -11771,10 +11772,6 @@ get_json_table_columns(TableFunc *tf, JsonTablePathScan *scan,
1177111772
if (ordinality)
1177211773
continue;
1177311774

11774-
/*
11775-
* Set default_behavior to guide get_json_expr_options() on whether to
11776-
* to emit the ON ERROR / EMPTY clauses.
11777-
*/
1177811775
if (colexpr->op==JSON_EXISTS_OP)
1177911776
{
1178011777
appendStringInfoString(buf," EXISTS");
@@ -11798,6 +11795,9 @@ get_json_table_columns(TableFunc *tf, JsonTablePathScan *scan,
1179811795
default_behavior=JSON_BEHAVIOR_NULL;
1179911796
}
1180011797

11798+
if (jexpr->on_error->btype==JSON_BEHAVIOR_ERROR)
11799+
default_behavior=JSON_BEHAVIOR_ERROR;
11800+
1180111801
appendStringInfoString(buf," PATH ");
1180211802

1180311803
get_json_path_spec(colexpr->path_spec,context,showimplicit);
@@ -11875,7 +11875,7 @@ get_json_table(TableFunc *tf, deparse_context *context, bool showimplicit)
1187511875
get_json_table_columns(tf,castNode(JsonTablePathScan,tf->plan),context,
1187611876
showimplicit);
1187711877

11878-
if (jexpr->on_error->btype!=JSON_BEHAVIOR_EMPTY_ARRAY)
11878+
if (jexpr->on_error->btype!=JSON_BEHAVIOR_EMPTY)
1187911879
get_json_behavior(jexpr->on_error,context,"ERROR");
1188011880

1188111881
if (PRETTY_INDENT(context))

‎src/test/regress/expected/sqljson_jsontable.out

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,46 +1132,3 @@ ERROR: invalid ON ERROR behavior for column "a"
11321132
LINE 1: ...M JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty obje...
11331133
^
11341134
DETAIL: Only ERROR, TRUE, FALSE, or UNKNOWN is allowed in ON ERROR for EXISTS columns.
1135-
-- Test JSON_TABLE() column deparsing -- don't emit default ON ERROR / EMPTY
1136-
-- behavior
1137-
EXPLAIN VERBOSE SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$'));
1138-
QUERY PLAN
1139-
-----------------------------------------------------------------------------------------------------
1140-
Table Function Scan on "json_table" (cost=0.01..1.00 rows=100 width=32)
1141-
Output: a
1142-
Table Function Call: JSON_TABLE('"a"'::jsonb, '$' AS json_table_path_0 COLUMNS (a text PATH '$'))
1143-
(3 rows)
1144-
1145-
EXPLAIN VERBOSE SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$') ERROR ON ERROR);
1146-
QUERY PLAN
1147-
--------------------------------------------------------------------------------------------------------------------
1148-
Table Function Scan on "json_table" (cost=0.01..1.00 rows=100 width=32)
1149-
Output: a
1150-
Table Function Call: JSON_TABLE('"a"'::jsonb, '$' AS json_table_path_0 COLUMNS (a text PATH '$') ERROR ON ERROR)
1151-
(3 rows)
1152-
1153-
-- Test JSON_TABLE() deparsing -- don't emit default ON ERROR behavior
1154-
EXPLAIN VERBOSE SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$'));
1155-
QUERY PLAN
1156-
-----------------------------------------------------------------------------------------------------
1157-
Table Function Scan on "json_table" (cost=0.01..1.00 rows=100 width=32)
1158-
Output: a
1159-
Table Function Call: JSON_TABLE('"a"'::jsonb, '$' AS json_table_path_0 COLUMNS (a text PATH '$'))
1160-
(3 rows)
1161-
1162-
EXPLAIN VERBOSE SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$') EMPTY ON ERROR);
1163-
QUERY PLAN
1164-
-----------------------------------------------------------------------------------------------------
1165-
Table Function Scan on "json_table" (cost=0.01..1.00 rows=100 width=32)
1166-
Output: a
1167-
Table Function Call: JSON_TABLE('"a"'::jsonb, '$' AS json_table_path_0 COLUMNS (a text PATH '$'))
1168-
(3 rows)
1169-
1170-
EXPLAIN VERBOSE SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$') EMPTY ARRAY ON ERROR);
1171-
QUERY PLAN
1172-
-----------------------------------------------------------------------------------------------------
1173-
Table Function Scan on "json_table" (cost=0.01..1.00 rows=100 width=32)
1174-
Output: a
1175-
Table Function Call: JSON_TABLE('"a"'::jsonb, '$' AS json_table_path_0 COLUMNS (a text PATH '$'))
1176-
(3 rows)
1177-

‎src/test/regress/sql/sqljson_jsontable.sql

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,3 @@ SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int) NULL ON ERROR);
542542
SELECT*FROM JSON_TABLE(jsonb'1','$' COLUMNS (aint trueon empty));
543543
SELECT*FROM JSON_TABLE(jsonb'1','$' COLUMNS (aint omit quotes trueon error));
544544
SELECT*FROM JSON_TABLE(jsonb'1','$' COLUMNS (aint exists empty objecton error));
545-
546-
-- Test JSON_TABLE() column deparsing -- don't emit default ON ERROR / EMPTY
547-
-- behavior
548-
EXPLAIN VERBOSESELECT*from JSON_TABLE('"a"','$' COLUMNS (atextPATH'$'));
549-
EXPLAIN VERBOSESELECT*from JSON_TABLE('"a"','$' COLUMNS (atextPATH'$') ERRORON ERROR);
550-
551-
-- Test JSON_TABLE() deparsing -- don't emit default ON ERROR behavior
552-
EXPLAIN VERBOSESELECT*from JSON_TABLE('"a"','$' COLUMNS (atextPATH'$'));
553-
EXPLAIN VERBOSESELECT*from JSON_TABLE('"a"','$' COLUMNS (atextPATH'$') EMPTYON ERROR);
554-
EXPLAIN VERBOSESELECT*from JSON_TABLE('"a"','$' COLUMNS (atextPATH'$') EMPTY ARRAYON ERROR);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp