Skip to content

Commit 3522d0e

Browse files
committed
Deduplicate "invalid input syntax" messages for various types.
Previously a lot of the error messages referenced the type in the error message itself. That requires that the message is translated separately for each type. Note that currently a few smallint cases continue to reference the integer, rather than smallint, type. A later patch will create a separate routine for 16bit input. Author: Andres Freund Discussion: https://postgr.es/m/20180707200158.wpqkd7rjr4jxq5g7@alap3.anarazel.de
1 parent 0426932 commit 3522d0e

File tree

20 files changed

+53
-53
lines changed

20 files changed

+53
-53
lines changed

contrib/dblink/expected/dblink.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ FROM dblink_fetch('myconn','error_cursor', 1) AS t(i int);
11541154

11551155
SELECT *
11561156
FROM dblink_fetch('myconn','error_cursor', 1) AS t(i int);
1157-
ERROR: invalid input syntax for integer: "not an int"
1157+
ERROR: invalid input syntax for type integer: "not an int"
11581158
-- Make sure that the local settings have retained their values in spite
11591159
-- of shenanigans on the connection.
11601160
SHOW datestyle;

contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4087,16 +4087,16 @@ DROP FUNCTION f_test(int);
40874087
-- ===================================================================
40884088
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE int;
40894089
SELECT * FROM ft1 WHERE c1 = 1; -- ERROR
4090-
ERROR: invalid input syntax for integer: "foo"
4090+
ERROR: invalid input syntax for type integer: "foo"
40914091
CONTEXT: column "c8" of foreign table "ft1"
40924092
SELECT ft1.c1, ft2.c2, ft1.c8 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; -- ERROR
4093-
ERROR: invalid input syntax for integer: "foo"
4093+
ERROR: invalid input syntax for type integer: "foo"
40944094
CONTEXT: column "c8" of foreign table "ft1"
40954095
SELECT ft1.c1, ft2.c2, ft1 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; -- ERROR
4096-
ERROR: invalid input syntax for integer: "foo"
4096+
ERROR: invalid input syntax for type integer: "foo"
40974097
CONTEXT: whole-row reference to foreign table "ft1"
40984098
SELECT sum(c2), array_agg(c8) FROM ft1 GROUP BY c8; -- ERROR
4099-
ERROR: invalid input syntax for integer: "foo"
4099+
ERROR: invalid input syntax for type integer: "foo"
41004100
CONTEXT: processing expression at position 2 in select list
41014101
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE user_enum;
41024102
-- ===================================================================

doc/src/sgml/xtypes.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ complex_in(PG_FUNCTION_ARGS)
8686
if (sscanf(str, " ( %lf , %lf )", &x, &y) != 2)
8787
ereport(ERROR,
8888
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
89-
errmsg("invalid input syntax for complex: \"%s\"",
90-
str)));
89+
errmsg("invalid input syntax for type %s: \"%s\"",
90+
"complex", str)));
9191

9292
result = (Complex *) palloc(sizeof(Complex));
9393
result->x = x;

src/backend/utils/adt/int8.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ scanint8(const char *str, bool errorOK, int64 *result)
121121
if (!errorOK)
122122
ereport(ERROR,
123123
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
124-
errmsg("invalid input syntax for integer: \"%s\"",
125-
str)));
124+
errmsg("invalid input syntax for type %s: \"%s\"",
125+
"bigint", str)));
126126
return false;
127127
}
128128

src/backend/utils/adt/numutils.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ pg_atoi(const char *s, int size, int c)
4848
if (*s == 0)
4949
ereport(ERROR,
5050
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
51-
errmsg("invalid input syntax for integer: \"%s\"",
52-
s)));
51+
errmsg("invalid input syntax for type %s: \"%s\"",
52+
"integer", s)));
5353

5454
errno = 0;
5555
l = strtol(s, &badp, 10);
@@ -58,8 +58,8 @@ pg_atoi(const char *s, int size, int c)
5858
if (s == badp)
5959
ereport(ERROR,
6060
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
61-
errmsg("invalid input syntax for integer: \"%s\"",
62-
s)));
61+
errmsg("invalid input syntax for type %s: \"%s\"",
62+
"integer", s)));
6363

6464
switch (size)
6565
{
@@ -102,8 +102,8 @@ pg_atoi(const char *s, int size, int c)
102102
if (*badp && *badp != c)
103103
ereport(ERROR,
104104
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
105-
errmsg("invalid input syntax for integer: \"%s\"",
106-
s)));
105+
errmsg("invalid input syntax for type %s: \"%s\"",
106+
"integer", s)));
107107

108108
return (int32) l;
109109
}

src/backend/utils/adt/timestamp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ parse_sane_timezone(struct pg_tm *tm, text *zone)
480480
if (isdigit((unsigned char) *tzname))
481481
ereport(ERROR,
482482
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
483-
errmsg("invalid input syntax for numeric time zone: \"%s\"",
484-
tzname),
483+
errmsg("invalid input syntax for type %s: \"%s\"",
484+
"numeric time zone", tzname),
485485
errhint("Numeric time zones must have \"-\" or \"+\" as first character.")));
486486

487487
rt = DecodeTimezone(tzname, &tz);

src/pl/plpython/expected/plpython_subtransaction.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ SELECT * FROM subtransaction_tbl;
4343

4444
TRUNCATE subtransaction_tbl;
4545
SELECT subtransaction_test('SPI');
46-
ERROR: spiexceptions.InvalidTextRepresentation: invalid input syntax for integer: "oops"
46+
ERROR: spiexceptions.InvalidTextRepresentation: invalid input syntax for type integer: "oops"
4747
LINE 1: INSERT INTO subtransaction_tbl VALUES ('oops')
4848
^
4949
QUERY: INSERT INTO subtransaction_tbl VALUES ('oops')
@@ -95,7 +95,7 @@ SELECT * FROM subtransaction_tbl;
9595

9696
TRUNCATE subtransaction_tbl;
9797
SELECT subtransaction_ctx_test('SPI');
98-
ERROR: spiexceptions.InvalidTextRepresentation: invalid input syntax for integer: "oops"
98+
ERROR: spiexceptions.InvalidTextRepresentation: invalid input syntax for type integer: "oops"
9999
LINE 1: INSERT INTO subtransaction_tbl VALUES ('oops')
100100
^
101101
QUERY: INSERT INTO subtransaction_tbl VALUES ('oops')

src/pl/plpython/expected/plpython_types.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ CREATE FUNCTION test_type_conversion_array_mixed2() RETURNS int[] AS $$
684684
return [123, 'abc']
685685
$$ LANGUAGE plpythonu;
686686
SELECT * FROM test_type_conversion_array_mixed2();
687-
ERROR: invalid input syntax for integer: "abc"
687+
ERROR: invalid input syntax for type integer: "abc"
688688
CONTEXT: while creating return value
689689
PL/Python function "test_type_conversion_array_mixed2"
690690
CREATE FUNCTION test_type_conversion_mdarray_malformed() RETURNS int[] AS $$

src/pl/tcl/expected/pltcl_subxact.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ SELECT * FROM subtransaction_tbl;
7171

7272
TRUNCATE subtransaction_tbl;
7373
SELECT pltcl_wrapper('SELECT subtransaction_ctx_test(''SPI'')');
74-
pltcl_wrapper
75-
-------------------------------------------------
76-
ERROR: invalid input syntax for integer: "oops"
74+
pltcl_wrapper
75+
------------------------------------------------------
76+
ERROR: invalid input syntax for type integer: "oops"
7777
(1 row)
7878

7979
SELECT * FROM subtransaction_tbl;

src/test/regress/expected/aggregates.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ LINE 1: select rank(3) within group (order by stringu1,stringu2) fro...
16741674
^
16751675
HINT: To use the hypothetical-set aggregate rank, the number of hypothetical direct arguments (here 1) must match the number of ordering columns (here 2).
16761676
select rank('fred') within group (order by x) from generate_series(1,5) x;
1677-
ERROR: invalid input syntax for integer: "fred"
1677+
ERROR: invalid input syntax for type integer: "fred"
16781678
LINE 1: select rank('fred') within group (order by x) from generate_...
16791679
^
16801680
select rank('adam'::text collate "C") within group (order by x collate "POSIX")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy