Skip to content

Commit d4feade

Browse files
committed
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
1 parent c60e520 commit d4feade

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/backend/commands/prepare.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ EvaluateParams(PreparedStatement *pstmt, List *params,
381381
i + 1,
382382
format_type_be(given_type_id),
383383
format_type_be(expected_type_id)),
384-
errhint("You will need to rewrite or cast the expression.")));
384+
errhint("You will need to rewrite or cast the expression."),
385+
parser_errposition(pstate, exprLocation(lfirst(l)))));
385386

386387
/* Take care of collations in the finished expression. */
387388
assign_expr_collations(pstate, expr);

src/test/regress/expected/prepare.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ DETAIL: Expected 5 parameters but got 6.
113113
-- wrong param types
114114
EXECUTE q3(5::smallint, 10.5::float, false, 4::bigint, 'bytea');
115115
ERROR: parameter $3 of type boolean cannot be coerced to the expected type double precision
116+
LINE 1: EXECUTE q3(5::smallint, 10.5::float, false, 4::bigint, 'byte...
117+
^
116118
HINT: You will need to rewrite or cast the expression.
117119
-- invalid type
118120
PREPARE q4(nonexistenttype) AS SELECT $1;

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