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

Commit 9a34123

Browse files
committed
Make messages mentioning type names more uniform
This avoids additional translatable strings for each distinct type, as well as making our quoting style around type names more consistent (namely, that we don't quote type names). This continues what started as f402b99. Discussion: https://postgr.es/m/20160401170642.GA57509@alvherre.pgsql
1 parent 716c7d4 commit 9a34123

26 files changed

+155
-129
lines changed

contrib/hstore_plperl/expected/create_transform.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ ERROR: type "foo" does not exist
1818
CREATE TRANSFORM FOR hstore LANGUAGE foo (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail
1919
ERROR: language "foo" does not exist
2020
CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_out(hstore), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail
21-
ERROR: return data type of FROM SQL function must be "internal"
21+
ERROR: return data type of FROM SQL function must be internal
2222
CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION internal_in(cstring), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail
23-
ERROR: first argument of transform function must be type "internal"
23+
ERROR: first argument of transform function must be type internal
2424
CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok
2525
CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail
2626
ERROR: transform for type hstore language "plperl" already exists

src/backend/catalog/aclchk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,8 @@ ExecGrant_Relation(InternalGrant *istmt)
18191819
*/
18201820
ereport(ERROR,
18211821
(errcode(ERRCODE_INVALID_GRANT_OPERATION),
1822-
errmsg("invalid privilege type USAGE for table")));
1822+
errmsg("invalid privilege type %s for table",
1823+
"USAGE")));
18231824
}
18241825
}
18251826
}

src/backend/catalog/dependency.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,8 @@ find_expr_references_walker(Node *node,
15981598
case REGROLEOID:
15991599
ereport(ERROR,
16001600
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1601-
errmsg("constant of the type \"regrole\" cannot be used here")));
1601+
errmsg("constant of the type %s cannot be used here",
1602+
"regrole")));
16021603
break;
16031604
}
16041605
}

src/backend/catalog/heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ CheckAttributeType(const char *attname,
498498
*/
499499
ereport(WARNING,
500500
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
501-
errmsg("column \"%s\" has type \"unknown\"", attname),
501+
errmsg("column \"%s\" has type %s", attname, "unknown"),
502502
errdetail("Proceeding with relation creation anyway.")));
503503
}
504504
else if (att_typtype == TYPTYPE_PSEUDO)

src/backend/commands/functioncmds.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,11 +1482,13 @@ CreateCast(CreateCastStmt *stmt)
14821482
if (nargs > 1 && procstruct->proargtypes.values[1] != INT4OID)
14831483
ereport(ERROR,
14841484
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1485-
errmsg("second argument of cast function must be type integer")));
1485+
errmsg("second argument of cast function must be type %s",
1486+
"integer")));
14861487
if (nargs > 2 && procstruct->proargtypes.values[2] != BOOLOID)
14871488
ereport(ERROR,
14881489
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1489-
errmsg("third argument of cast function must be type boolean")));
1490+
errmsg("third argument of cast function must be type %s",
1491+
"boolean")));
14901492
if (!IsBinaryCoercible(procstruct->prorettype, targettypeid))
14911493
ereport(ERROR,
14921494
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -1776,7 +1778,8 @@ check_transform_function(Form_pg_proc procstruct)
17761778
if (procstruct->proargtypes.values[0] != INTERNALOID)
17771779
ereport(ERROR,
17781780
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1779-
errmsg("first argument of transform function must be type \"internal\"")));
1781+
errmsg("first argument of transform function must be type %s",
1782+
"internal")));
17801783
}
17811784

17821785

@@ -1859,7 +1862,8 @@ CreateTransform(CreateTransformStmt *stmt)
18591862
if (procstruct->prorettype != INTERNALOID)
18601863
ereport(ERROR,
18611864
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1862-
errmsg("return data type of FROM SQL function must be \"internal\"")));
1865+
errmsg("return data type of FROM SQL function must be %s",
1866+
"internal")));
18631867
check_transform_function(procstruct);
18641868
ReleaseSysCache(tuple);
18651869
}

src/backend/commands/proclang.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
278278
{
279279
ereport(WARNING,
280280
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
281-
errmsg("changing return type of function %s from \"opaque\" to \"language_handler\"",
282-
NameListToString(stmt->plhandler))));
281+
errmsg("changing return type of function %s from %s to %s",
282+
NameListToString(stmt->plhandler),
283+
"opaque", "language_handler")));
283284
SetFunctionReturnType(handlerOid, LANGUAGE_HANDLEROID);
284285
}
285286
else

src/backend/commands/trigger.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,9 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
522522
if (funcrettype == OPAQUEOID)
523523
{
524524
ereport(WARNING,
525-
(errmsg("changing return type of function %s from \"opaque\" to \"trigger\"",
526-
NameListToString(stmt->funcname))));
525+
(errmsg("changing return type of function %s from %s to %s",
526+
NameListToString(stmt->funcname),
527+
"opaque", "trigger")));
527528
SetFunctionReturnType(funcoid, TRIGGEROID);
528529
}
529530
else

src/backend/parser/parse_coerce.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,8 +1077,9 @@ coerce_to_boolean(ParseState *pstate, Node *node,
10771077
ereport(ERROR,
10781078
(errcode(ERRCODE_DATATYPE_MISMATCH),
10791079
/* translator: first %s is name of a SQL construct, eg WHERE */
1080-
errmsg("argument of %s must be type boolean, not type %s",
1081-
constructName, format_type_be(inputTypeId)),
1080+
errmsg("argument of %s must be type %s, not type %s",
1081+
constructName, "boolean",
1082+
format_type_be(inputTypeId)),
10821083
parser_errposition(pstate, exprLocation(node))));
10831084
node = newnode;
10841085
}
@@ -1695,8 +1696,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
16951696
if (!OidIsValid(array_typelem))
16961697
ereport(ERROR,
16971698
(errcode(ERRCODE_DATATYPE_MISMATCH),
1698-
errmsg("argument declared \"anyarray\" is not an array but type %s",
1699-
format_type_be(array_typeid))));
1699+
errmsg("argument declared %s is not an array but type %s",
1700+
"anyarray", format_type_be(array_typeid))));
17001701
}
17011702

17021703
if (!OidIsValid(elem_typeid))
@@ -1711,7 +1712,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
17111712
/* otherwise, they better match */
17121713
ereport(ERROR,
17131714
(errcode(ERRCODE_DATATYPE_MISMATCH),
1714-
errmsg("argument declared \"anyarray\" is not consistent with argument declared \"anyelement\""),
1715+
errmsg("argument declared %s is not consistent with argument declared %s",
1716+
"anyarray", "anyelement"),
17151717
errdetail("%s versus %s",
17161718
format_type_be(array_typeid),
17171719
format_type_be(elem_typeid))));
@@ -1732,8 +1734,9 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
17321734
if (!OidIsValid(range_typelem))
17331735
ereport(ERROR,
17341736
(errcode(ERRCODE_DATATYPE_MISMATCH),
1735-
errmsg("argument declared \"anyrange\" is not a range type but type %s",
1736-
format_type_be(range_typeid))));
1737+
errmsg("argument declared %s is not a range type but type %s",
1738+
"anyrange",
1739+
format_type_be(range_typeid))));
17371740
}
17381741

17391742
if (!OidIsValid(elem_typeid))
@@ -1748,7 +1751,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
17481751
/* otherwise, they better match */
17491752
ereport(ERROR,
17501753
(errcode(ERRCODE_DATATYPE_MISMATCH),
1751-
errmsg("argument declared \"anyrange\" is not consistent with argument declared \"anyelement\""),
1754+
errmsg("argument declared %s is not consistent with argument declared %s",
1755+
"anyrange", "anyelement"),
17521756
errdetail("%s versus %s",
17531757
format_type_be(range_typeid),
17541758
format_type_be(elem_typeid))));
@@ -1768,7 +1772,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
17681772
/* Only way to get here is if all the generic args are UNKNOWN */
17691773
ereport(ERROR,
17701774
(errcode(ERRCODE_DATATYPE_MISMATCH),
1771-
errmsg("could not determine polymorphic type because input has type \"unknown\"")));
1775+
errmsg("could not determine polymorphic type because input has type %s",
1776+
"unknown")));
17721777
}
17731778
}
17741779

@@ -1906,8 +1911,8 @@ resolve_generic_type(Oid declared_type,
19061911
if (!OidIsValid(array_typelem))
19071912
ereport(ERROR,
19081913
(errcode(ERRCODE_DATATYPE_MISMATCH),
1909-
errmsg("argument declared \"anyarray\" is not an array but type %s",
1910-
format_type_be(context_base_type))));
1914+
errmsg("argument declared %s is not an array but type %s",
1915+
"anyarray", format_type_be(context_base_type))));
19111916
return context_base_type;
19121917
}
19131918
else if (context_declared_type == ANYELEMENTOID ||
@@ -1940,8 +1945,8 @@ resolve_generic_type(Oid declared_type,
19401945
if (!OidIsValid(array_typelem))
19411946
ereport(ERROR,
19421947
(errcode(ERRCODE_DATATYPE_MISMATCH),
1943-
errmsg("argument declared \"anyarray\" is not an array but type %s",
1944-
format_type_be(context_base_type))));
1948+
errmsg("argument declared %s is not an array but type %s",
1949+
"anyarray", format_type_be(context_base_type))));
19451950
return array_typelem;
19461951
}
19471952
else if (context_declared_type == ANYRANGEOID)
@@ -1953,8 +1958,8 @@ resolve_generic_type(Oid declared_type,
19531958
if (!OidIsValid(range_typelem))
19541959
ereport(ERROR,
19551960
(errcode(ERRCODE_DATATYPE_MISMATCH),
1956-
errmsg("argument declared \"anyrange\" is not a range type but type %s",
1957-
format_type_be(context_base_type))));
1961+
errmsg("argument declared %s is not a range type but type %s",
1962+
"anyrange", format_type_be(context_base_type))));
19581963
return range_typelem;
19591964
}
19601965
else if (context_declared_type == ANYELEMENTOID ||

src/backend/utils/adt/bool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ boolin(PG_FUNCTION_ARGS)
150150

151151
ereport(ERROR,
152152
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
153-
errmsg("invalid input syntax for type boolean: \"%s\"", in_str)));
153+
errmsg("invalid input syntax for type %s: \"%s\"",
154+
"boolean", in_str)));
154155

155156
/* not reached */
156157
PG_RETURN_BOOL(false);

src/backend/utils/adt/cash.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ cash_in(PG_FUNCTION_ARGS)
209209
if (newvalue / 10 != value)
210210
ereport(ERROR,
211211
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
212-
errmsg("value \"%s\" is out of range for type money",
213-
str)));
212+
errmsg("value \"%s\" is out of range for type %s",
213+
str, "money")));
214214

215215
value = newvalue;
216216

@@ -236,8 +236,8 @@ cash_in(PG_FUNCTION_ARGS)
236236
if (value > 0)
237237
ereport(ERROR,
238238
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
239-
errmsg("value \"%s\" is out of range for type money",
240-
str)));
239+
errmsg("value \"%s\" is out of range for type %s",
240+
str, "money")));
241241

242242
/* adjust for less than required decimal places */
243243
for (; dec < fpoint; dec++)
@@ -247,8 +247,8 @@ cash_in(PG_FUNCTION_ARGS)
247247
if (newvalue / 10 != value)
248248
ereport(ERROR,
249249
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
250-
errmsg("value \"%s\" is out of range for type money",
251-
str)));
250+
errmsg("value \"%s\" is out of range for type %s",
251+
str, "money")));
252252

253253
value = newvalue;
254254
}
@@ -276,8 +276,8 @@ cash_in(PG_FUNCTION_ARGS)
276276
else
277277
ereport(ERROR,
278278
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
279-
errmsg("invalid input syntax for type money: \"%s\"",
280-
str)));
279+
errmsg("invalid input syntax for type %s: \"%s\"",
280+
"money", str)));
281281
}
282282

283283
/* If the value is supposed to be positive, flip the sign, but check for
@@ -288,8 +288,8 @@ cash_in(PG_FUNCTION_ARGS)
288288
if (result < 0)
289289
ereport(ERROR,
290290
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
291-
errmsg("value \"%s\" is out of range for type money",
292-
str)));
291+
errmsg("value \"%s\" is out of range for type %s",
292+
str, "money")));
293293
}
294294
else
295295
result = value;

src/backend/utils/adt/encode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ esc_decode(const char *src, unsigned srclen, char *dst)
439439
*/
440440
ereport(ERROR,
441441
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
442-
errmsg("invalid input syntax for type bytea")));
442+
errmsg("invalid input syntax for type %s", "bytea")));
443443
}
444444

445445
len++;
@@ -504,7 +504,7 @@ esc_dec_len(const char *src, unsigned srclen)
504504
*/
505505
ereport(ERROR,
506506
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
507-
errmsg("invalid input syntax for type bytea")));
507+
errmsg("invalid input syntax for type %s", "bytea")));
508508
}
509509

510510
len++;

src/backend/utils/adt/float.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ float4in(PG_FUNCTION_ARGS)
241241
if (*num == '\0')
242242
ereport(ERROR,
243243
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
244-
errmsg("invalid input syntax for type real: \"%s\"",
245-
orig_num)));
244+
errmsg("invalid input syntax for type %s: \"%s\"",
245+
"real", orig_num)));
246246

247247
errno = 0;
248248
val = strtod(num, &endptr);
@@ -315,8 +315,8 @@ float4in(PG_FUNCTION_ARGS)
315315
else
316316
ereport(ERROR,
317317
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
318-
errmsg("invalid input syntax for type real: \"%s\"",
319-
orig_num)));
318+
errmsg("invalid input syntax for type %s: \"%s\"",
319+
"real", orig_num)));
320320
}
321321
#ifdef HAVE_BUGGY_SOLARIS_STRTOD
322322
else
@@ -339,8 +339,8 @@ float4in(PG_FUNCTION_ARGS)
339339
if (*endptr != '\0')
340340
ereport(ERROR,
341341
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
342-
errmsg("invalid input syntax for type real: \"%s\"",
343-
orig_num)));
342+
errmsg("invalid input syntax for type %s: \"%s\"",
343+
"real", orig_num)));
344344

345345
/*
346346
* if we get here, we have a legal double, still need to check to see if

src/backend/utils/adt/int8.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ scanint8(const char *str, bool errorOK, int64 *result)
9595
else
9696
ereport(ERROR,
9797
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
98-
errmsg("invalid input syntax for integer: \"%s\"",
99-
str)));
98+
errmsg("invalid input syntax for %s: \"%s\"",
99+
"integer", str)));
100100
}
101101

102102
/* process digits */
@@ -111,8 +111,8 @@ scanint8(const char *str, bool errorOK, int64 *result)
111111
else
112112
ereport(ERROR,
113113
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
114-
errmsg("value \"%s\" is out of range for type bigint",
115-
str)));
114+
errmsg("value \"%s\" is out of range for type %s",
115+
str, "bigint")));
116116
}
117117
tmp = newtmp;
118118
}
@@ -130,8 +130,8 @@ scanint8(const char *str, bool errorOK, int64 *result)
130130
else
131131
ereport(ERROR,
132132
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
133-
errmsg("invalid input syntax for integer: \"%s\"",
134-
str)));
133+
errmsg("invalid input syntax for %s: \"%s\"",
134+
"integer", str)));
135135
}
136136

137137
*result = (sign < 0) ? -tmp : tmp;

0 commit comments

Comments
 (0)