Remove dubious warning message from SQL/JSON functions
authorPeter Eisentraut <[email protected]>
Fri, 18 Aug 2023 05:41:14 +0000 (07:41 +0200)
committerPeter Eisentraut <[email protected]>
Fri, 18 Aug 2023 05:43:52 +0000 (07:43 +0200)
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

src/backend/parser/parse_expr.c
src/test/regress/expected/sqljson.out

index c08c06373a9ad82900c23fba45a189a15ea3b3b2..de5732622fe914e15f181370c5d12488c5e11076 100644 (file)
@@ -3240,12 +3240,7 @@ transformJsonValueExpr(ParseState *pstate, const char *constructName,
                    parser_errposition(pstate, ve->format->location));
 
        if (exprtype == JSONOID || exprtype == JSONBOID)
-       {
            format = JS_FORMAT_DEFAULT; /* do not format json[b] types */
-           ereport(WARNING,
-                   errmsg("FORMAT JSON has no effect for json and jsonb types"),
-                   parser_errposition(pstate, ve->format->location));
-       }
        else
            format = ve->format->format_type;
    }
index 11ebf4403b0687522ddcf082025c024591be021c..fa2abdb4a7f5517c94cbe0965ecbedb772333d6e 100644 (file)
@@ -84,9 +84,6 @@ ERROR:  JSON ENCODING clause is only allowed for bytea input type
 LINE 1: SELECT JSON_OBJECT('foo': NULL::int FORMAT JSON ENCODING UTF...
                                             ^
 SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON);
-WARNING:  FORMAT JSON has no effect for json and jsonb types
-LINE 1: SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON);
-                                             ^
   json_object   
 ----------------
  {"foo" : null}
@@ -97,9 +94,6 @@ ERROR:  JSON ENCODING clause is only allowed for bytea input type
 LINE 1: SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON ENCODING UT...
                                              ^
 SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON);
-WARNING:  FORMAT JSON has no effect for json and jsonb types
-LINE 1: SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON);
-                                              ^
   json_object  
 ---------------
  {"foo": null}