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

Commiteef5195

Browse files
committed
Revert recent SQL/JSON related commits
Revertsc88ce38,5067c23, ande4e2797, because a few BFanimals didn't like one or all of them.
1 parente4e2797 commiteef5195

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
@@ -4236,8 +4236,6 @@ ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state,
42364236
ErrorSaveContext*escontext=
42374237
jsexpr->on_error->btype!=JSON_BEHAVIOR_ERROR ?
42384238
&jsestate->escontext :NULL;
4239-
boolreturning_domain=
4240-
get_typtype(jsexpr->returning->typid)==TYPTYPE_DOMAIN;
42414239

42424240
jsestate->jsexpr=jsexpr;
42434241

@@ -4380,27 +4378,20 @@ ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state,
43804378
ExprEvalPushStep(state,scratch);
43814379
}
43824380

4381+
jsestate->jump_empty=jsestate->jump_error=-1;
4382+
43834383
/*
43844384
* Step to check jsestate->error and return the ON ERROR expression if
43854385
* there is one. This handles both the errors that occur during jsonpath
43864386
* evaluation in EEOP_JSONEXPR_PATH and subsequent coercion evaluation.
4387-
*
4388-
* Speed up common cases by avoiding extra steps for a NULL-valued ON
4389-
* ERROR expression unless RETURNING a domain type, where constraints must
4390-
* be checked. ExecEvalJsonExprPath() already returns NULL on error,
4391-
* making additional steps unnecessary in typical scenarios. Note that the
4392-
* default ON ERROR behavior for JSON_VALUE() and JSON_QUERY() is to
4393-
* return NULL.
43944387
*/
4395-
jsestate->jump_error=state->steps_len;
43964388
if (jsexpr->on_error&&
4397-
jsexpr->on_error->btype!=JSON_BEHAVIOR_ERROR&&
4398-
(!(IsA(jsexpr->on_error->expr,Const)&&
4399-
((Const*)jsexpr->on_error->expr)->constisnull)||
4400-
returning_domain))
4389+
jsexpr->on_error->btype!=JSON_BEHAVIOR_ERROR)
44014390
{
44024391
ErrorSaveContext*saved_escontext;
44034392

4393+
jsestate->jump_error=state->steps_len;
4394+
44044395
/* JUMP to end if false, that is, skip the ON ERROR expression. */
44054396
jumps_to_end=lappend_int(jumps_to_end,state->steps_len);
44064397
scratch->opcode=EEOP_JUMP_IF_NOT_TRUE;
@@ -4450,19 +4441,14 @@ ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state,
44504441
/*
44514442
* Step to check jsestate->empty and return the ON EMPTY expression if
44524443
* there is one.
4453-
*
4454-
* See the comment above for details on the optimization for NULL-valued
4455-
* expressions.
44564444
*/
4457-
jsestate->jump_empty=state->steps_len;
44584445
if (jsexpr->on_empty!=NULL&&
4459-
jsexpr->on_empty->btype!=JSON_BEHAVIOR_ERROR&&
4460-
(!(IsA(jsexpr->on_empty->expr,Const)&&
4461-
((Const*)jsexpr->on_empty->expr)->constisnull)||
4462-
returning_domain))
4446+
jsexpr->on_empty->btype!=JSON_BEHAVIOR_ERROR)
44634447
{
44644448
ErrorSaveContext*saved_escontext;
44654449

4450+
jsestate->jump_empty=state->steps_len;
4451+
44664452
/* JUMP to end if false, that is, skip the ON EMPTY expression. */
44674453
jumps_to_end=lappend_int(jumps_to_end,state->steps_len);
44684454
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