1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

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
This commit is contained in:
Andres Freund
2018-07-22 14:58:01 -07:00
parent 04269320ae
commit 3522d0eaba
20 changed files with 53 additions and 53 deletions

View File

@ -1674,7 +1674,7 @@ LINE 1: select rank(3) within group (order by stringu1,stringu2) fro...
^
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).
select rank('fred') within group (order by x) from generate_series(1,5) x;
ERROR: invalid input syntax for integer: "fred"
ERROR: invalid input syntax for type integer: "fred"
LINE 1: select rank('fred') within group (order by x) from generate_...
^
select rank('adam'::text collate "C") within group (order by x collate "POSIX")

View File

@ -1113,7 +1113,7 @@ select * from def_test;
-- set defaults to an incorrect type: this should fail
alter table def_test alter column c1 set default 'wrong_datatype';
ERROR: invalid input syntax for integer: "wrong_datatype"
ERROR: invalid input syntax for type integer: "wrong_datatype"
alter table def_test alter column c2 set default 20;
-- set defaults on a non-existent column: this should fail
alter table def_test alter column c3 set default 30;

View File

@ -33,7 +33,7 @@ COPY x (a, b, c, d, e, d, c) from stdin;
ERROR: column "d" specified more than once
-- missing data: should fail
COPY x from stdin;
ERROR: invalid input syntax for integer: ""
ERROR: invalid input syntax for type integer: ""
CONTEXT: COPY x, line 1, column a: ""
COPY x from stdin;
ERROR: missing data for column "e"

View File

@ -6,7 +6,7 @@ INSERT INTO INT2_TBL(f1) VALUES ('0 ');
INSERT INTO INT2_TBL(f1) VALUES (' 1234 ');
INSERT INTO INT2_TBL(f1) VALUES (' -1234');
INSERT INTO INT2_TBL(f1) VALUES ('34.5');
ERROR: invalid input syntax for integer: "34.5"
ERROR: invalid input syntax for type integer: "34.5"
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('34.5');
^
-- largest and smallest values
@ -18,27 +18,27 @@ ERROR: value "100000" is out of range for type smallint
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('100000');
^
INSERT INTO INT2_TBL(f1) VALUES ('asdf');
ERROR: invalid input syntax for integer: "asdf"
ERROR: invalid input syntax for type integer: "asdf"
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('asdf');
^
INSERT INTO INT2_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for integer: " "
ERROR: invalid input syntax for type integer: " "
LINE 1: INSERT INTO INT2_TBL(f1) VALUES (' ');
^
INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
ERROR: invalid input syntax for integer: "- 1234"
ERROR: invalid input syntax for type integer: "- 1234"
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('- 1234');
^
INSERT INTO INT2_TBL(f1) VALUES ('4 444');
ERROR: invalid input syntax for integer: "4 444"
ERROR: invalid input syntax for type integer: "4 444"
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('4 444');
^
INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
ERROR: invalid input syntax for integer: "123 dt"
ERROR: invalid input syntax for type integer: "123 dt"
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('123 dt');
^
INSERT INTO INT2_TBL(f1) VALUES ('');
ERROR: invalid input syntax for integer: ""
ERROR: invalid input syntax for type integer: ""
LINE 1: INSERT INTO INT2_TBL(f1) VALUES ('');
^
SELECT '' AS five, * FROM INT2_TBL;

View File

@ -6,7 +6,7 @@ INSERT INTO INT4_TBL(f1) VALUES (' 0 ');
INSERT INTO INT4_TBL(f1) VALUES ('123456 ');
INSERT INTO INT4_TBL(f1) VALUES (' -123456');
INSERT INTO INT4_TBL(f1) VALUES ('34.5');
ERROR: invalid input syntax for integer: "34.5"
ERROR: invalid input syntax for type integer: "34.5"
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('34.5');
^
-- largest and smallest values
@ -18,27 +18,27 @@ ERROR: value "1000000000000" is out of range for type integer
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('1000000000000');
^
INSERT INTO INT4_TBL(f1) VALUES ('asdf');
ERROR: invalid input syntax for integer: "asdf"
ERROR: invalid input syntax for type integer: "asdf"
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('asdf');
^
INSERT INTO INT4_TBL(f1) VALUES (' ');
ERROR: invalid input syntax for integer: " "
ERROR: invalid input syntax for type integer: " "
LINE 1: INSERT INTO INT4_TBL(f1) VALUES (' ');
^
INSERT INTO INT4_TBL(f1) VALUES (' asdf ');
ERROR: invalid input syntax for integer: " asdf "
ERROR: invalid input syntax for type integer: " asdf "
LINE 1: INSERT INTO INT4_TBL(f1) VALUES (' asdf ');
^
INSERT INTO INT4_TBL(f1) VALUES ('- 1234');
ERROR: invalid input syntax for integer: "- 1234"
ERROR: invalid input syntax for type integer: "- 1234"
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('- 1234');
^
INSERT INTO INT4_TBL(f1) VALUES ('123 5');
ERROR: invalid input syntax for integer: "123 5"
ERROR: invalid input syntax for type integer: "123 5"
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('123 5');
^
INSERT INTO INT4_TBL(f1) VALUES ('');
ERROR: invalid input syntax for integer: ""
ERROR: invalid input syntax for type integer: ""
LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('');
^
SELECT '' AS five, * FROM INT4_TBL;

View File

@ -10,11 +10,11 @@ INSERT INTO INT8_TBL VALUES(+4567890123456789,'4567890123456789');
INSERT INTO INT8_TBL VALUES('+4567890123456789','-4567890123456789');
-- bad inputs
INSERT INTO INT8_TBL(q1) VALUES (' ');
ERROR: invalid input syntax for integer: " "
ERROR: invalid input syntax for type bigint: " "
LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' ');
^
INSERT INTO INT8_TBL(q1) VALUES ('xxx');
ERROR: invalid input syntax for integer: "xxx"
ERROR: invalid input syntax for type bigint: "xxx"
LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('xxx');
^
INSERT INTO INT8_TBL(q1) VALUES ('3908203590239580293850293850329485');
@ -26,15 +26,15 @@ ERROR: value "-1204982019841029840928340329840934" is out of range for type big
LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340...
^
INSERT INTO INT8_TBL(q1) VALUES ('- 123');
ERROR: invalid input syntax for integer: "- 123"
ERROR: invalid input syntax for type bigint: "- 123"
LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('- 123');
^
INSERT INTO INT8_TBL(q1) VALUES (' 345 5');
ERROR: invalid input syntax for integer: " 345 5"
ERROR: invalid input syntax for type bigint: " 345 5"
LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' 345 5');
^
INSERT INTO INT8_TBL(q1) VALUES ('');
ERROR: invalid input syntax for integer: ""
ERROR: invalid input syntax for type bigint: ""
LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('');
^
SELECT * FROM INT8_TBL;

View File

@ -3782,7 +3782,7 @@ begin
end;
$$ language plpgsql;
select compos();
ERROR: invalid input syntax for integer: "(1,hello)"
ERROR: invalid input syntax for type integer: "(1,hello)"
CONTEXT: PL/pgSQL function compos() while casting return value to function's return type
-- test: invalid use of composite expression in scalar-returning function
create or replace function compos() returns int as $$
@ -3791,7 +3791,7 @@ begin
end;
$$ language plpgsql;
select compos();
ERROR: invalid input syntax for integer: "(1,hello)"
ERROR: invalid input syntax for type integer: "(1,hello)"
CONTEXT: PL/pgSQL function compos() while casting return value to function's return type
drop function compos();
drop type compostype;

View File

@ -975,7 +975,7 @@ ROLLBACK TO SAVEPOINT settings;
SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
select stringu1::int2 from tenk1 where unique1 = 1;
ERROR: invalid input syntax for integer: "BAAAAA"
ERROR: invalid input syntax for type integer: "BAAAAA"
CONTEXT: parallel worker
ROLLBACK TO SAVEPOINT settings;
-- test interaction with set-returning functions

View File

@ -1834,7 +1834,7 @@ WITH tzs (tz) AS (VALUES
-- these should fail
SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '2');
ERROR: invalid input syntax for numeric time zone: "2"
ERROR: invalid input syntax for type numeric time zone: "2"
HINT: Numeric time zones must have "-" or "+" as first character.
SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '+16');
ERROR: numeric time zone "+16" out of range

View File

@ -148,8 +148,8 @@ widget_in(PG_FUNCTION_ARGS)
if (i < NARGS)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type widget: \"%s\"",
str)));
errmsg("invalid input syntax for type %s: \"%s\"",
"widget", str)));
result = (WIDGET *) palloc(sizeof(WIDGET));
result->center.x = atof(coord[0]);