Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

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

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

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

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

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

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

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

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

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

+1-1
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")

src/test/regress/expected/alter_table.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ select * from def_test;
11131113

11141114
-- set defaults to an incorrect type: this should fail
11151115
alter table def_test alter column c1 set default 'wrong_datatype';
1116-
ERROR: invalid input syntax for integer: "wrong_datatype"
1116+
ERROR: invalid input syntax for type integer: "wrong_datatype"
11171117
alter table def_test alter column c2 set default 20;
11181118
-- set defaults on a non-existent column: this should fail
11191119
alter table def_test alter column c3 set default 30;

src/test/regress/expected/copy2.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ COPY x (a, b, c, d, e, d, c) from stdin;
3333
ERROR: column "d" specified more than once
3434
-- missing data: should fail
3535
COPY x from stdin;
36-
ERROR: invalid input syntax for integer: ""
36+
ERROR: invalid input syntax for type integer: ""
3737
CONTEXT: COPY x, line 1, column a: ""
3838
COPY x from stdin;
3939
ERROR: missing data for column "e"

src/test/regress/expected/int2.out

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ INSERT INTO INT2_TBL(f1) VALUES ('0 ');
66
INSERT INTO INT2_TBL(f1) VALUES (' 1234 ');
77
INSERT INTO INT2_TBL(f1) VALUES (' -1234');
88
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
9-
ERROR: invalid input syntax for integer: "34.5"
9+
ERROR: invalid input syntax for type integer: "34.5"
1010
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('34.5');
1111
^
1212
-- largest and smallest values
@@ -18,27 +18,27 @@ ERROR: value "100000" is out of range for type smallint
1818
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('100000');
1919
^
2020
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
21-
ERROR: invalid input syntax for integer: "asdf"
21+
ERROR: invalid input syntax for type integer: "asdf"
2222
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('asdf');
2323
^
2424
INSERT INTO INT2_TBL(f1) VALUES (' ');
25-
ERROR: invalid input syntax for integer: " "
25+
ERROR: invalid input syntax for type integer: " "
2626
LINE 1: INSERT INTO INT2_TBL(f1) VALUES (' ');
2727
^
2828
INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
29-
ERROR: invalid input syntax for integer: "- 1234"
29+
ERROR: invalid input syntax for type integer: "- 1234"
3030
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
3131
^
3232
INSERT INTO INT2_TBL(f1) VALUES ('4 444');
33-
ERROR: invalid input syntax for integer: "4 444"
33+
ERROR: invalid input syntax for type integer: "4 444"
3434
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('4 444');
3535
^
3636
INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
37-
ERROR: invalid input syntax for integer: "123 dt"
37+
ERROR: invalid input syntax for type integer: "123 dt"
3838
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
3939
^
4040
INSERT INTO INT2_TBL(f1) VALUES ('');
41-
ERROR: invalid input syntax for integer: ""
41+
ERROR: invalid input syntax for type integer: ""
4242
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('');
4343
^
4444
SELECT '' AS five, * FROM INT2_TBL;

src/test/regress/expected/int4.out

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ INSERT INTO INT4_TBL(f1) VALUES (' 0 ');
66
INSERT INTO INT4_TBL(f1) VALUES ('123456 ');
77
INSERT INTO INT4_TBL(f1) VALUES (' -123456');
88
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
9-
ERROR: invalid input syntax for integer: "34.5"
9+
ERROR: invalid input syntax for type integer: "34.5"
1010
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('34.5');
1111
^
1212
-- largest and smallest values
@@ -18,27 +18,27 @@ ERROR: value "1000000000000" is out of range for type integer
1818
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
1919
^
2020
INSERT INTO INT4_TBL(f1) VALUES ('asdf');
21-
ERROR: invalid input syntax for integer: "asdf"
21+
ERROR: invalid input syntax for type integer: "asdf"
2222
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('asdf');
2323
^
2424
INSERT INTO INT4_TBL(f1) VALUES (' ');
25-
ERROR: invalid input syntax for integer: " "
25+
ERROR: invalid input syntax for type integer: " "
2626
LINE 1: INSERT INTO INT4_TBL(f1) VALUES (' ');
2727
^
2828
INSERT INTO INT4_TBL(f1) VALUES (' asdf ');
29-
ERROR: invalid input syntax for integer: " asdf "
29+
ERROR: invalid input syntax for type integer: " asdf "
3030
LINE 1: INSERT INTO INT4_TBL(f1) VALUES (' asdf ');
3131
^
3232
INSERT INTO INT4_TBL(f1) VALUES ('- 1234');
33-
ERROR: invalid input syntax for integer: "- 1234"
33+
ERROR: invalid input syntax for type integer: "- 1234"
3434
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('- 1234');
3535
^
3636
INSERT INTO INT4_TBL(f1) VALUES ('123 5');
37-
ERROR: invalid input syntax for integer: "123 5"
37+
ERROR: invalid input syntax for type integer: "123 5"
3838
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('123 5');
3939
^
4040
INSERT INTO INT4_TBL(f1) VALUES ('');
41-
ERROR: invalid input syntax for integer: ""
41+
ERROR: invalid input syntax for type integer: ""
4242
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('');
4343
^
4444
SELECT '' AS five, * FROM INT4_TBL;

src/test/regress/expected/int8.out

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ INSERT INTO INT8_TBL VALUES(+4567890123456789,'4567890123456789');
1010
INSERT INTO INT8_TBL VALUES('+4567890123456789','-4567890123456789');
1111
-- bad inputs
1212
INSERT INTO INT8_TBL(q1) VALUES (' ');
13-
ERROR: invalid input syntax for integer: " "
13+
ERROR: invalid input syntax for type bigint: " "
1414
LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' ');
1515
^
1616
INSERT INTO INT8_TBL(q1) VALUES ('xxx');
17-
ERROR: invalid input syntax for integer: "xxx"
17+
ERROR: invalid input syntax for type bigint: "xxx"
1818
LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('xxx');
1919
^
2020
INSERT INTO INT8_TBL(q1) VALUES ('3908203590239580293850293850329485');
@@ -26,15 +26,15 @@ ERROR: value "-1204982019841029840928340329840934" is out of range for type big
2626
LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340...
2727
^
2828
INSERT INTO INT8_TBL(q1) VALUES ('- 123');
29-
ERROR: invalid input syntax for integer: "- 123"
29+
ERROR: invalid input syntax for type bigint: "- 123"
3030
LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('- 123');
3131
^
3232
INSERT INTO INT8_TBL(q1) VALUES (' 345 5');
33-
ERROR: invalid input syntax for integer: " 345 5"
33+
ERROR: invalid input syntax for type bigint: " 345 5"
3434
LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' 345 5');
3535
^
3636
INSERT INTO INT8_TBL(q1) VALUES ('');
37-
ERROR: invalid input syntax for integer: ""
37+
ERROR: invalid input syntax for type bigint: ""
3838
LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('');
3939
^
4040
SELECT * FROM INT8_TBL;

src/test/regress/expected/plpgsql.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -3782,7 +3782,7 @@ begin
37823782
end;
37833783
$$ language plpgsql;
37843784
select compos();
3785-
ERROR: invalid input syntax for integer: "(1,hello)"
3785+
ERROR: invalid input syntax for type integer: "(1,hello)"
37863786
CONTEXT: PL/pgSQL function compos() while casting return value to function's return type
37873787
-- test: invalid use of composite expression in scalar-returning function
37883788
create or replace function compos() returns int as $$
@@ -3791,7 +3791,7 @@ begin
37913791
end;
37923792
$$ language plpgsql;
37933793
select compos();
3794-
ERROR: invalid input syntax for integer: "(1,hello)"
3794+
ERROR: invalid input syntax for type integer: "(1,hello)"
37953795
CONTEXT: PL/pgSQL function compos() while casting return value to function's return type
37963796
drop function compos();
37973797
drop type compostype;

src/test/regress/expected/select_parallel.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ ROLLBACK TO SAVEPOINT settings;
975975
SAVEPOINT settings;
976976
SET LOCAL force_parallel_mode = 1;
977977
select stringu1::int2 from tenk1 where unique1 = 1;
978-
ERROR: invalid input syntax for integer: "BAAAAA"
978+
ERROR: invalid input syntax for type integer: "BAAAAA"
979979
CONTEXT: parallel worker
980980
ROLLBACK TO SAVEPOINT settings;
981981
-- test interaction with set-returning functions

src/test/regress/expected/timestamptz.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ WITH tzs (tz) AS (VALUES
18341834

18351835
-- these should fail
18361836
SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '2');
1837-
ERROR: invalid input syntax for numeric time zone: "2"
1837+
ERROR: invalid input syntax for type numeric time zone: "2"
18381838
HINT: Numeric time zones must have "-" or "+" as first character.
18391839
SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '+16');
18401840
ERROR: numeric time zone "+16" out of range

src/test/regress/regress.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ widget_in(PG_FUNCTION_ARGS)
148148
if (i < NARGS)
149149
ereport(ERROR,
150150
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
151-
errmsg("invalid input syntax for type widget: \"%s\"",
152-
str)));
151+
errmsg("invalid input syntax for type %s: \"%s\"",
152+
"widget", str)));
153153

154154
result = (WIDGET *) palloc(sizeof(WIDGET));
155155
result->center.x = atof(coord[0]);

src/tutorial/complex.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ complex_in(PG_FUNCTION_ARGS)
3838
if (sscanf(str, " ( %lf , %lf )", &x, &y) != 2)
3939
ereport(ERROR,
4040
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
41-
errmsg("invalid input syntax for complex: \"%s\"",
42-
str)));
41+
errmsg("invalid input syntax for type %s: \"%s\"",
42+
"complex", str)));
4343

4444
result = (Complex *) palloc(sizeof(Complex));
4545
result->x = x;

0 commit comments

Comments
 (0)