Skip to content

Commit dcfc49c

Browse files
committed
Remove dubious warning message from SQL/JSON functions
There was a warning that FORMAT JSON has no effect on json/jsonb types, which is true, but it's not clear why we should issue a warning about it. The SQL standard does not say anything about this, which should generally govern the behavior here. So remove it. Discussion: https://www.postgresql.org/message-id/flat/dfec2cae-d17e-c508-6d16-c2dba82db486%40eisentraut.org
1 parent 6337e99 commit dcfc49c

File tree

2 files changed

+0
-11
lines changed

2 files changed

+0
-11
lines changed

src/backend/parser/parse_expr.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,12 +3240,7 @@ transformJsonValueExpr(ParseState *pstate, const char *constructName,
32403240
parser_errposition(pstate, ve->format->location));
32413241

32423242
if (exprtype == JSONOID || exprtype == JSONBOID)
3243-
{
32443243
format = JS_FORMAT_DEFAULT; /* do not format json[b] types */
3245-
ereport(WARNING,
3246-
errmsg("FORMAT JSON has no effect for json and jsonb types"),
3247-
parser_errposition(pstate, ve->format->location));
3248-
}
32493244
else
32503245
format = ve->format->format_type;
32513246
}

src/test/regress/expected/sqljson.out

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ ERROR: JSON ENCODING clause is only allowed for bytea input type
8484
LINE 1: SELECT JSON_OBJECT('foo': NULL::int FORMAT JSON ENCODING UTF...
8585
^
8686
SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON);
87-
WARNING: FORMAT JSON has no effect for json and jsonb types
88-
LINE 1: SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON);
89-
^
9087
json_object
9188
----------------
9289
{"foo" : null}
@@ -97,9 +94,6 @@ ERROR: JSON ENCODING clause is only allowed for bytea input type
9794
LINE 1: SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON ENCODING UT...
9895
^
9996
SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON);
100-
WARNING: FORMAT JSON has no effect for json and jsonb types
101-
LINE 1: SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON);
102-
^
10397
json_object
10498
---------------
10599
{"foo": null}

0 commit comments

Comments
 (0)