mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
Fix misleading error message context
Author: Pavel Stehule <pavel.stehule@gmail.com> Reviewed-by: Stepan Neretin <sncfmgg@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CAFj8pRAw+OkVW=FgMKHKyvY3CgtWy3cWdY7XT+S5TJaTttu=oA@mail.gmail.com
This commit is contained in:
@ -2978,7 +2978,7 @@ _SPI_error_callback(void *arg)
|
|||||||
switch (carg->mode)
|
switch (carg->mode)
|
||||||
{
|
{
|
||||||
case RAW_PARSE_PLPGSQL_EXPR:
|
case RAW_PARSE_PLPGSQL_EXPR:
|
||||||
errcontext("SQL expression \"%s\"", query);
|
errcontext("PL/pgSQL expression \"%s\"", query);
|
||||||
break;
|
break;
|
||||||
case RAW_PARSE_PLPGSQL_ASSIGN1:
|
case RAW_PARSE_PLPGSQL_ASSIGN1:
|
||||||
case RAW_PARSE_PLPGSQL_ASSIGN2:
|
case RAW_PARSE_PLPGSQL_ASSIGN2:
|
||||||
|
@ -272,7 +272,7 @@ NOTICE: r1.q1 = <NULL>
|
|||||||
NOTICE: r1.q2 = <NULL>
|
NOTICE: r1.q2 = <NULL>
|
||||||
NOTICE: r1 = <NULL>
|
NOTICE: r1 = <NULL>
|
||||||
ERROR: record "r1" has no field "nosuchfield"
|
ERROR: record "r1" has no field "nosuchfield"
|
||||||
CONTEXT: SQL expression "r1.nosuchfield"
|
CONTEXT: PL/pgSQL expression "r1.nosuchfield"
|
||||||
PL/pgSQL function inline_code_block line 7 at RAISE
|
PL/pgSQL function inline_code_block line 7 at RAISE
|
||||||
-- records, not so much
|
-- records, not so much
|
||||||
do $$
|
do $$
|
||||||
@ -286,7 +286,7 @@ end$$;
|
|||||||
NOTICE: r1 = <NULL>
|
NOTICE: r1 = <NULL>
|
||||||
ERROR: record "r1" is not assigned yet
|
ERROR: record "r1" is not assigned yet
|
||||||
DETAIL: The tuple structure of a not-yet-assigned record is indeterminate.
|
DETAIL: The tuple structure of a not-yet-assigned record is indeterminate.
|
||||||
CONTEXT: SQL expression "r1.f1"
|
CONTEXT: PL/pgSQL expression "r1.f1"
|
||||||
PL/pgSQL function inline_code_block line 5 at RAISE
|
PL/pgSQL function inline_code_block line 5 at RAISE
|
||||||
-- but OK if you assign first
|
-- but OK if you assign first
|
||||||
do $$
|
do $$
|
||||||
@ -304,7 +304,7 @@ NOTICE: r1.f1 = 1
|
|||||||
NOTICE: r1.f2 = 2
|
NOTICE: r1.f2 = 2
|
||||||
NOTICE: r1 = (1,2)
|
NOTICE: r1 = (1,2)
|
||||||
ERROR: record "r1" has no field "nosuchfield"
|
ERROR: record "r1" has no field "nosuchfield"
|
||||||
CONTEXT: SQL expression "r1.nosuchfield"
|
CONTEXT: PL/pgSQL expression "r1.nosuchfield"
|
||||||
PL/pgSQL function inline_code_block line 9 at RAISE
|
PL/pgSQL function inline_code_block line 9 at RAISE
|
||||||
-- check %type with block-qualified variable names
|
-- check %type with block-qualified variable names
|
||||||
do $$
|
do $$
|
||||||
@ -598,7 +598,7 @@ create function getf3(x mutable) returns int language plpgsql as
|
|||||||
$$ begin return x.f3; end $$;
|
$$ begin return x.f3; end $$;
|
||||||
select getf3(null::mutable); -- doesn't work yet
|
select getf3(null::mutable); -- doesn't work yet
|
||||||
ERROR: record "x" has no field "f3"
|
ERROR: record "x" has no field "f3"
|
||||||
CONTEXT: SQL expression "x.f3"
|
CONTEXT: PL/pgSQL expression "x.f3"
|
||||||
PL/pgSQL function getf3(mutable) line 1 at RETURN
|
PL/pgSQL function getf3(mutable) line 1 at RETURN
|
||||||
alter table mutable add column f3 int;
|
alter table mutable add column f3 int;
|
||||||
select getf3(null::mutable); -- now it works
|
select getf3(null::mutable); -- now it works
|
||||||
|
@ -76,7 +76,7 @@ begin
|
|||||||
raise notice 'x = %', x;
|
raise notice 'x = %', x;
|
||||||
end$$;
|
end$$;
|
||||||
ERROR: division by zero
|
ERROR: division by zero
|
||||||
CONTEXT: SQL expression "1/0"
|
CONTEXT: PL/pgSQL expression "1/0"
|
||||||
PL/pgSQL function inline_code_block line 2 during statement block local variable initialization
|
PL/pgSQL function inline_code_block line 2 during statement block local variable initialization
|
||||||
do $$
|
do $$
|
||||||
declare x bigint[] := array[1,3,5];
|
declare x bigint[] := array[1,3,5];
|
||||||
|
@ -2388,7 +2388,7 @@ begin
|
|||||||
end $$ language plpgsql;
|
end $$ language plpgsql;
|
||||||
select namedparmcursor_test7();
|
select namedparmcursor_test7();
|
||||||
ERROR: division by zero
|
ERROR: division by zero
|
||||||
CONTEXT: SQL expression "42/0 AS p1, 77 AS p2"
|
CONTEXT: PL/pgSQL expression "42/0 AS p1, 77 AS p2"
|
||||||
PL/pgSQL function namedparmcursor_test7() line 6 at OPEN
|
PL/pgSQL function namedparmcursor_test7() line 6 at OPEN
|
||||||
-- check that line comments work correctly within the argument list
|
-- check that line comments work correctly within the argument list
|
||||||
-- (this used to require a special hack in the code; it no longer does,
|
-- (this used to require a special hack in the code; it no longer does,
|
||||||
@ -4563,11 +4563,11 @@ end
|
|||||||
$$;
|
$$;
|
||||||
select fail();
|
select fail();
|
||||||
ERROR: division by zero
|
ERROR: division by zero
|
||||||
CONTEXT: SQL expression "1/0"
|
CONTEXT: PL/pgSQL expression "1/0"
|
||||||
PL/pgSQL function fail() line 3 at RETURN
|
PL/pgSQL function fail() line 3 at RETURN
|
||||||
select fail();
|
select fail();
|
||||||
ERROR: division by zero
|
ERROR: division by zero
|
||||||
CONTEXT: SQL expression "1/0"
|
CONTEXT: PL/pgSQL expression "1/0"
|
||||||
PL/pgSQL function fail() line 3 at RETURN
|
PL/pgSQL function fail() line 3 at RETURN
|
||||||
drop function fail();
|
drop function fail();
|
||||||
-- Test handling of string literals.
|
-- Test handling of string literals.
|
||||||
|
Reference in New Issue
Block a user