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:
parent
04269320ae
commit
3522d0eaba
@ -1154,7 +1154,7 @@ FROM dblink_fetch('myconn','error_cursor', 1) AS t(i int);
|
||||
|
||||
SELECT *
|
||||
FROM dblink_fetch('myconn','error_cursor', 1) AS t(i int);
|
||||
ERROR: invalid input syntax for integer: "not an int"
|
||||
ERROR: invalid input syntax for type integer: "not an int"
|
||||
-- Make sure that the local settings have retained their values in spite
|
||||
-- of shenanigans on the connection.
|
||||
SHOW datestyle;
|
||||
|
@ -4087,16 +4087,16 @@ DROP FUNCTION f_test(int);
|
||||
-- ===================================================================
|
||||
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE int;
|
||||
SELECT * FROM ft1 WHERE c1 = 1; -- ERROR
|
||||
ERROR: invalid input syntax for integer: "foo"
|
||||
ERROR: invalid input syntax for type integer: "foo"
|
||||
CONTEXT: column "c8" of foreign table "ft1"
|
||||
SELECT ft1.c1, ft2.c2, ft1.c8 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; -- ERROR
|
||||
ERROR: invalid input syntax for integer: "foo"
|
||||
ERROR: invalid input syntax for type integer: "foo"
|
||||
CONTEXT: column "c8" of foreign table "ft1"
|
||||
SELECT ft1.c1, ft2.c2, ft1 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; -- ERROR
|
||||
ERROR: invalid input syntax for integer: "foo"
|
||||
ERROR: invalid input syntax for type integer: "foo"
|
||||
CONTEXT: whole-row reference to foreign table "ft1"
|
||||
SELECT sum(c2), array_agg(c8) FROM ft1 GROUP BY c8; -- ERROR
|
||||
ERROR: invalid input syntax for integer: "foo"
|
||||
ERROR: invalid input syntax for type integer: "foo"
|
||||
CONTEXT: processing expression at position 2 in select list
|
||||
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE user_enum;
|
||||
-- ===================================================================
|
||||
|
@ -86,8 +86,8 @@ complex_in(PG_FUNCTION_ARGS)
|
||||
if (sscanf(str, " ( %lf , %lf )", &x, &y) != 2)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for complex: \"%s\"",
|
||||
str)));
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"complex", str)));
|
||||
|
||||
result = (Complex *) palloc(sizeof(Complex));
|
||||
result->x = x;
|
||||
|
@ -121,8 +121,8 @@ invalid_syntax:
|
||||
if (!errorOK)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for integer: \"%s\"",
|
||||
str)));
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"bigint", str)));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,8 @@ pg_atoi(const char *s, int size, int c)
|
||||
if (*s == 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for integer: \"%s\"",
|
||||
s)));
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"integer", s)));
|
||||
|
||||
errno = 0;
|
||||
l = strtol(s, &badp, 10);
|
||||
@ -58,8 +58,8 @@ pg_atoi(const char *s, int size, int c)
|
||||
if (s == badp)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for integer: \"%s\"",
|
||||
s)));
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"integer", s)));
|
||||
|
||||
switch (size)
|
||||
{
|
||||
@ -102,8 +102,8 @@ pg_atoi(const char *s, int size, int c)
|
||||
if (*badp && *badp != c)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for integer: \"%s\"",
|
||||
s)));
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"integer", s)));
|
||||
|
||||
return (int32) l;
|
||||
}
|
||||
|
@ -480,8 +480,8 @@ parse_sane_timezone(struct pg_tm *tm, text *zone)
|
||||
if (isdigit((unsigned char) *tzname))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid input syntax for numeric time zone: \"%s\"",
|
||||
tzname),
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"numeric time zone", tzname),
|
||||
errhint("Numeric time zones must have \"-\" or \"+\" as first character.")));
|
||||
|
||||
rt = DecodeTimezone(tzname, &tz);
|
||||
|
@ -43,7 +43,7 @@ SELECT * FROM subtransaction_tbl;
|
||||
|
||||
TRUNCATE subtransaction_tbl;
|
||||
SELECT subtransaction_test('SPI');
|
||||
ERROR: spiexceptions.InvalidTextRepresentation: invalid input syntax for integer: "oops"
|
||||
ERROR: spiexceptions.InvalidTextRepresentation: invalid input syntax for type integer: "oops"
|
||||
LINE 1: INSERT INTO subtransaction_tbl VALUES ('oops')
|
||||
^
|
||||
QUERY: INSERT INTO subtransaction_tbl VALUES ('oops')
|
||||
@ -95,7 +95,7 @@ SELECT * FROM subtransaction_tbl;
|
||||
|
||||
TRUNCATE subtransaction_tbl;
|
||||
SELECT subtransaction_ctx_test('SPI');
|
||||
ERROR: spiexceptions.InvalidTextRepresentation: invalid input syntax for integer: "oops"
|
||||
ERROR: spiexceptions.InvalidTextRepresentation: invalid input syntax for type integer: "oops"
|
||||
LINE 1: INSERT INTO subtransaction_tbl VALUES ('oops')
|
||||
^
|
||||
QUERY: INSERT INTO subtransaction_tbl VALUES ('oops')
|
||||
|
@ -684,7 +684,7 @@ CREATE FUNCTION test_type_conversion_array_mixed2() RETURNS int[] AS $$
|
||||
return [123, 'abc']
|
||||
$$ LANGUAGE plpythonu;
|
||||
SELECT * FROM test_type_conversion_array_mixed2();
|
||||
ERROR: invalid input syntax for integer: "abc"
|
||||
ERROR: invalid input syntax for type integer: "abc"
|
||||
CONTEXT: while creating return value
|
||||
PL/Python function "test_type_conversion_array_mixed2"
|
||||
CREATE FUNCTION test_type_conversion_mdarray_malformed() RETURNS int[] AS $$
|
||||
|
@ -71,9 +71,9 @@ SELECT * FROM subtransaction_tbl;
|
||||
|
||||
TRUNCATE subtransaction_tbl;
|
||||
SELECT pltcl_wrapper('SELECT subtransaction_ctx_test(''SPI'')');
|
||||
pltcl_wrapper
|
||||
-------------------------------------------------
|
||||
ERROR: invalid input syntax for integer: "oops"
|
||||
pltcl_wrapper
|
||||
------------------------------------------------------
|
||||
ERROR: invalid input syntax for type integer: "oops"
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM subtransaction_tbl;
|
||||
|
@ -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")
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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]);
|
||||
|
@ -38,8 +38,8 @@ complex_in(PG_FUNCTION_ARGS)
|
||||
if (sscanf(str, " ( %lf , %lf )", &x, &y) != 2)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for complex: \"%s\"",
|
||||
str)));
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"complex", str)));
|
||||
|
||||
result = (Complex *) palloc(sizeof(Complex));
|
||||
result->x = x;
|
||||
|
Loading…
x
Reference in New Issue
Block a user