Reword recent error messages: "should" -> "must"
authorÁlvaro Herrera <[email protected]>
Tue, 21 Jan 2025 14:24:49 +0000 (15:24 +0100)
committerÁlvaro Herrera <[email protected]>
Tue, 21 Jan 2025 14:24:49 +0000 (15:24 +0100)
Most were introduced in the 17 timeframe.  The ones in wparser_def.c are
very old.

I also changed "JSON path expression for column \"%s\" should return
single item without wrapper" to "JSON path expression for column \"%s\"
must return single item when no wrapper is requested" to avoid
ambiguity.

Back to 17.

Crickets: https://postgr.es/m/202501131819[email protected]

src/backend/tsearch/wparser_def.c
src/backend/utils/adt/jsonpath_exec.c
src/test/regress/expected/sqljson_jsontable.out
src/test/regress/expected/sqljson_queryfuncs.out

index f26923d044b6dbc89720f408a4a6f3ba43d6ee6d..79bcd32a0639e768adb11c5ed97252b7e4485844 100644 (file)
@@ -2671,19 +2671,19 @@ prsd_headline(PG_FUNCTION_ARGS)
        if (min_words >= max_words)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                    errmsg("MinWords should be less than MaxWords")));
+                    errmsg("%s must be less than %s", "MinWords", "MaxWords")));
        if (min_words <= 0)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                    errmsg("MinWords should be positive")));
+                    errmsg("%s must be positive", "MinWords")));
        if (shortword < 0)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                    errmsg("ShortWord should be >= 0")));
+                    errmsg("%s must be >= 0", "ShortWord")));
        if (max_fragments < 0)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                    errmsg("MaxFragments should be >= 0")));
+                    errmsg("%s must be >= 0", "MaxFragments")));
    }
 
    /* Locate words and phrases matching the query */
index f6dfcb11a62aa184d1b127a750ee66868c892f01..960fdec3dbac8f0610fa7f4e9317ea3db760ee24 100644 (file)
@@ -3977,13 +3977,13 @@ JsonPathQuery(Datum jb, JsonPath *jp, JsonWrapper wrapper, bool *empty,
        if (column_name)
            ereport(ERROR,
                    (errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
-                    errmsg("JSON path expression for column \"%s\" should return single item without wrapper",
+                    errmsg("JSON path expression for column \"%s\" must return single item when no wrapper is requested",
                            column_name),
                     errhint("Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.")));
        else
            ereport(ERROR,
                    (errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
-                    errmsg("JSON path expression in JSON_QUERY should return single item without wrapper"),
+                    errmsg("JSON path expression in JSON_QUERY must return single item when no wrapper is requested"),
                     errhint("Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.")));
    }
 
@@ -4041,12 +4041,12 @@ JsonPathValue(Datum jb, JsonPath *jp, bool *empty, bool *error, List *vars,
        if (column_name)
            ereport(ERROR,
                    (errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
-                    errmsg("JSON path expression for column \"%s\" should return single scalar item",
+                    errmsg("JSON path expression for column \"%s\" must return single scalar item",
                            column_name)));
        else
            ereport(ERROR,
                    (errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
-                    errmsg("JSON path expression in JSON_VALUE should return single scalar item")));
+                    errmsg("JSON path expression in JSON_VALUE must return single scalar item")));
    }
 
    res = JsonValueListHead(&found);
@@ -4065,12 +4065,12 @@ JsonPathValue(Datum jb, JsonPath *jp, bool *empty, bool *error, List *vars,
        if (column_name)
            ereport(ERROR,
                    (errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
-                    errmsg("JSON path expression for column \"%s\" should return single scalar item",
+                    errmsg("JSON path expression for column \"%s\" must return single scalar item",
                            column_name)));
        else
            ereport(ERROR,
                    (errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
-                    errmsg("JSON path expression in JSON_VALUE should return single scalar item")));
+                    errmsg("JSON path expression in JSON_VALUE must return single scalar item")));
    }
 
    if (res->type == jbvNull)
index d62d32241d3a3c2c2a0b71e5bc9d94d07fd084f6..458c5aaa5b0683a1854acf6d6eedcd9b2f237426 100644 (file)
@@ -710,7 +710,7 @@ LINE 1: SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || '...
                                                      ^
 -- JsonPathQuery() error message mentioning column name
 SELECT * FROM JSON_TABLE('{"a": [{"b": "1"}, {"b": "2"}]}', '$' COLUMNS (b json path '$.a[*].b' ERROR ON ERROR));
-ERROR:  JSON path expression for column "b" should return single item without wrapper
+ERROR:  JSON path expression for column "b" must return single item when no wrapper is requested
 HINT:  Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.
 -- JSON_TABLE: nested paths
 -- Duplicate path names
index 329ef674961b93629fc54e5e4ae8f6e46f434ed1..5a35aeb7bba3afd01a70c728481712299856e483 100644 (file)
@@ -344,7 +344,7 @@ SELECT JSON_VALUE(jsonb '[]', '$');
 (1 row)
 
 SELECT JSON_VALUE(jsonb '[]', '$' ERROR ON ERROR);
-ERROR:  JSON path expression in JSON_VALUE should return single scalar item
+ERROR:  JSON path expression in JSON_VALUE must return single scalar item
 SELECT JSON_VALUE(jsonb '{}', '$');
  json_value 
 ------------
@@ -352,7 +352,7 @@ SELECT JSON_VALUE(jsonb '{}', '$');
 (1 row)
 
 SELECT JSON_VALUE(jsonb '{}', '$' ERROR ON ERROR);
-ERROR:  JSON path expression in JSON_VALUE should return single scalar item
+ERROR:  JSON path expression in JSON_VALUE must return single scalar item
 SELECT JSON_VALUE(jsonb '1', '$.a');
  json_value 
 ------------
@@ -408,7 +408,7 @@ SELECT JSON_VALUE(jsonb '1', 'lax $.a' DEFAULT '2' ON EMPTY DEFAULT '3' ON ERROR
 SELECT JSON_VALUE(jsonb '1', 'lax $.a' ERROR ON EMPTY DEFAULT '3' ON ERROR);
 ERROR:  no SQL/JSON item found for specified path
 SELECT JSON_VALUE(jsonb '[1,2]', '$[*]' ERROR ON ERROR);
-ERROR:  JSON path expression in JSON_VALUE should return single scalar item
+ERROR:  JSON path expression in JSON_VALUE must return single scalar item
 SELECT JSON_VALUE(jsonb '[1,2]', '$[*]' DEFAULT '0' ON ERROR);
  json_value 
 ------------
@@ -806,7 +806,7 @@ SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON ERROR);   -- NULL ON EMPTY
 (1 row)
 
 SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' ERROR ON ERROR);
-ERROR:  JSON path expression in JSON_QUERY should return single item without wrapper
+ERROR:  JSON path expression in JSON_QUERY must return single item when no wrapper is requested
 HINT:  Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.
 SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' DEFAULT '"empty"' ON ERROR);
  json_query