aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2019-11-29 09:10:17 +0100
committerPeter Eisentraut <peter@eisentraut.org>2019-11-29 09:10:17 +0100
commitd4feadeca1591fd5fe91bdf73a7897553f5366d7 (patch)
treed3afeca7871ea2a05e9ed645dc4e0c7221d6c058
parentc60e520f6e0e8db9618cad042df071a6752f3c06 (diff)
downloadpostgresql-d4feadeca1591fd5fe91bdf73a7897553f5366d7.tar.gz
postgresql-d4feadeca1591fd5fe91bdf73a7897553f5366d7.zip
Add error position to an error message
Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/6e7aa4a1-be6a-1a75-b1f9-83a678e5184a@2ndquadrant.com
-rw-r--r--src/backend/commands/prepare.c3
-rw-r--r--src/test/regress/expected/prepare.out2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index 7e0a041fabf..47bae957dc4 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -381,7 +381,8 @@ EvaluateParams(PreparedStatement *pstmt, List *params,
i + 1,
format_type_be(given_type_id),
format_type_be(expected_type_id)),
- errhint("You will need to rewrite or cast the expression.")));
+ errhint("You will need to rewrite or cast the expression."),
+ parser_errposition(pstate, exprLocation(lfirst(l)))));
/* Take care of collations in the finished expression. */
assign_expr_collations(pstate, expr);
diff --git a/src/test/regress/expected/prepare.out b/src/test/regress/expected/prepare.out
index 717732300d1..3306c696b17 100644
--- a/src/test/regress/expected/prepare.out
+++ b/src/test/regress/expected/prepare.out
@@ -113,6 +113,8 @@ DETAIL: Expected 5 parameters but got 6.
-- wrong param types
EXECUTE q3(5::smallint, 10.5::float, false, 4::bigint, 'bytea');
ERROR: parameter $3 of type boolean cannot be coerced to the expected type double precision
+LINE 1: EXECUTE q3(5::smallint, 10.5::float, false, 4::bigint, 'byte...
+ ^
HINT: You will need to rewrite or cast the expression.
-- invalid type
PREPARE q4(nonexistenttype) AS SELECT $1;