Skip to content

Commit dbc3499

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 2f30847 commit dbc3499

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/backend/tsearch/wparser_def.c

+4-4
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

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

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

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

40774077
if (res->type == jbvNull)

src/test/regress/expected/sqljson_jsontable.out

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

src/test/regress/expected/sqljson_queryfuncs.out

+4-4
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)