Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit db19a50

Browse files
committed
Reword recent error messages: "should" -> "must"
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. Backpatch to 17. Crickets: https://postgr.es/m/202501131819.26ors7oouafu@alvherre.pgsql
1 parent 9b21f20 commit db19a50

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/backend/tsearch/wparser_def.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,19 +2671,19 @@ prsd_headline(PG_FUNCTION_ARGS)
26712671
if (min_words >= max_words)
26722672
ereport(ERROR,
26732673
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2674-
errmsg("MinWords should be less than MaxWords")));
2674+
errmsg("%s must be less than %s", "MinWords", "MaxWords")));
26752675
if (min_words <= 0)
26762676
ereport(ERROR,
26772677
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2678-
errmsg("MinWords should be positive")));
2678+
errmsg("%s must be positive", "MinWords")));
26792679
if (shortword < 0)
26802680
ereport(ERROR,
26812681
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2682-
errmsg("ShortWord should be >= 0")));
2682+
errmsg("%s must be >= 0", "ShortWord")));
26832683
if (max_fragments < 0)
26842684
ereport(ERROR,
26852685
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2686-
errmsg("MaxFragments should be >= 0")));
2686+
errmsg("%s must be >= 0", "MaxFragments")));
26872687
}
26882688

26892689
/* Locate words and phrases matching the query */

src/backend/utils/adt/jsonpath_exec.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3977,13 +3977,13 @@ JsonPathQuery(Datum jb, JsonPath *jp, JsonWrapper wrapper, bool *empty,
39773977
if (column_name)
39783978
ereport(ERROR,
39793979
(errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
3980-
errmsg("JSON path expression for column \"%s\" should return single item without wrapper",
3980+
errmsg("JSON path expression for column \"%s\" must return single item when no wrapper is requested",
39813981
column_name),
39823982
errhint("Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.")));
39833983
else
39843984
ereport(ERROR,
39853985
(errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
3986-
errmsg("JSON path expression in JSON_QUERY should return single item without wrapper"),
3986+
errmsg("JSON path expression in JSON_QUERY must return single item when no wrapper is requested"),
39873987
errhint("Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.")));
39883988
}
39893989

@@ -4041,12 +4041,12 @@ JsonPathValue(Datum jb, JsonPath *jp, bool *empty, bool *error, List *vars,
40414041
if (column_name)
40424042
ereport(ERROR,
40434043
(errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
4044-
errmsg("JSON path expression for column \"%s\" should return single scalar item",
4044+
errmsg("JSON path expression for column \"%s\" must return single scalar item",
40454045
column_name)));
40464046
else
40474047
ereport(ERROR,
40484048
(errcode(ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM),
4049-
errmsg("JSON path expression in JSON_VALUE should return single scalar item")));
4049+
errmsg("JSON path expression in JSON_VALUE must return single scalar item")));
40504050
}
40514051

40524052
res = JsonValueListHead(&found);
@@ -4065,12 +4065,12 @@ JsonPathValue(Datum jb, JsonPath *jp, bool *empty, bool *error, List *vars,
40654065
if (column_name)
40664066
ereport(ERROR,
40674067
(errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
4068-
errmsg("JSON path expression for column \"%s\" should return single scalar item",
4068+
errmsg("JSON path expression for column \"%s\" must return single scalar item",
40694069
column_name)));
40704070
else
40714071
ereport(ERROR,
40724072
(errcode(ERRCODE_SQL_JSON_SCALAR_REQUIRED),
4073-
errmsg("JSON path expression in JSON_VALUE should return single scalar item")));
4073+
errmsg("JSON path expression in JSON_VALUE must return single scalar item")));
40744074
}
40754075

40764076
if (res->type == jbvNull)

src/test/regress/expected/sqljson_jsontable.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ LINE 1: SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || '...
710710
^
711711
-- JsonPathQuery() error message mentioning column name
712712
SELECT * FROM JSON_TABLE('{"a": [{"b": "1"}, {"b": "2"}]}', '$' COLUMNS (b json path '$.a[*].b' ERROR ON ERROR));
713-
ERROR: JSON path expression for column "b" should return single item without wrapper
713+
ERROR: JSON path expression for column "b" must return single item when no wrapper is requested
714714
HINT: Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.
715715
-- JSON_TABLE: nested paths
716716
-- Duplicate path names

src/test/regress/expected/sqljson_queryfuncs.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,15 @@ SELECT JSON_VALUE(jsonb '[]', '$');
344344
(1 row)
345345

346346
SELECT JSON_VALUE(jsonb '[]', '$' ERROR ON ERROR);
347-
ERROR: JSON path expression in JSON_VALUE should return single scalar item
347+
ERROR: JSON path expression in JSON_VALUE must return single scalar item
348348
SELECT JSON_VALUE(jsonb '{}', '$');
349349
json_value
350350
------------
351351

352352
(1 row)
353353

354354
SELECT JSON_VALUE(jsonb '{}', '$' ERROR ON ERROR);
355-
ERROR: JSON path expression in JSON_VALUE should return single scalar item
355+
ERROR: JSON path expression in JSON_VALUE must return single scalar item
356356
SELECT JSON_VALUE(jsonb '1', '$.a');
357357
json_value
358358
------------
@@ -408,7 +408,7 @@ SELECT JSON_VALUE(jsonb '1', 'lax $.a' DEFAULT '2' ON EMPTY DEFAULT '3' ON ERROR
408408
SELECT JSON_VALUE(jsonb '1', 'lax $.a' ERROR ON EMPTY DEFAULT '3' ON ERROR);
409409
ERROR: no SQL/JSON item found for specified path
410410
SELECT JSON_VALUE(jsonb '[1,2]', '$[*]' ERROR ON ERROR);
411-
ERROR: JSON path expression in JSON_VALUE should return single scalar item
411+
ERROR: JSON path expression in JSON_VALUE must return single scalar item
412412
SELECT JSON_VALUE(jsonb '[1,2]', '$[*]' DEFAULT '0' ON ERROR);
413413
json_value
414414
------------
@@ -806,7 +806,7 @@ SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON ERROR); -- NULL ON EMPTY
806806
(1 row)
807807

808808
SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' ERROR ON ERROR);
809-
ERROR: JSON path expression in JSON_QUERY should return single item without wrapper
809+
ERROR: JSON path expression in JSON_QUERY must return single item when no wrapper is requested
810810
HINT: Use the WITH WRAPPER clause to wrap SQL/JSON items into an array.
811811
SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' DEFAULT '"empty"' ON ERROR);
812812
json_query

0 commit comments

Comments
 (0)