Commit 2edb9491 authored by Tom Lane's avatar Tom Lane

Fix a few bogus statement type names in plpgsql error messages.

plpgsql's error location context messages ("PL/pgSQL function fn-name line
line-no at stmt-type") would misreport a CONTINUE statement as being an
EXIT, and misreport a MOVE statement as being a FETCH.  These are clear
bugs that have been there a long time, so back-patch to all supported
branches.

In addition, in 9.5 and HEAD, change the description of EXECUTE from
"EXECUTE statement" to just plain EXECUTE; there seems no good reason why
this statement type should be described differently from others that have
a well-defined head keyword.  And distinguish GET STACKED DIAGNOSTICS from
plain GET DIAGNOSTICS.  These are a bit more of a judgment call, and also
affect existing regression-test outputs, so I did not back-patch into
stable branches.

Pavel Stehule and Tom Lane
parent db5a703b
...@@ -235,7 +235,7 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt) ...@@ -235,7 +235,7 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
case PLPGSQL_STMT_FOREACH_A: case PLPGSQL_STMT_FOREACH_A:
return _("FOREACH over array"); return _("FOREACH over array");
case PLPGSQL_STMT_EXIT: case PLPGSQL_STMT_EXIT:
return "EXIT"; return ((PLpgSQL_stmt_exit *) stmt)->is_exit ? "EXIT" : "CONTINUE";
case PLPGSQL_STMT_RETURN: case PLPGSQL_STMT_RETURN:
return "RETURN"; return "RETURN";
case PLPGSQL_STMT_RETURN_NEXT: case PLPGSQL_STMT_RETURN_NEXT:
...@@ -249,15 +249,16 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt) ...@@ -249,15 +249,16 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
case PLPGSQL_STMT_EXECSQL: case PLPGSQL_STMT_EXECSQL:
return _("SQL statement"); return _("SQL statement");
case PLPGSQL_STMT_DYNEXECUTE: case PLPGSQL_STMT_DYNEXECUTE:
return _("EXECUTE statement"); return "EXECUTE";
case PLPGSQL_STMT_DYNFORS: case PLPGSQL_STMT_DYNFORS:
return _("FOR over EXECUTE statement"); return _("FOR over EXECUTE statement");
case PLPGSQL_STMT_GETDIAG: case PLPGSQL_STMT_GETDIAG:
return "GET DIAGNOSTICS"; return ((PLpgSQL_stmt_getdiag *) stmt)->is_stacked ?
"GET STACKED DIAGNOSTICS" : "GET DIAGNOSTICS";
case PLPGSQL_STMT_OPEN: case PLPGSQL_STMT_OPEN:
return "OPEN"; return "OPEN";
case PLPGSQL_STMT_FETCH: case PLPGSQL_STMT_FETCH:
return "FETCH"; return ((PLpgSQL_stmt_fetch *) stmt)->is_move ? "MOVE" : "FETCH";
case PLPGSQL_STMT_CLOSE: case PLPGSQL_STMT_CLOSE:
return "CLOSE"; return "CLOSE";
case PLPGSQL_STMT_PERFORM: case PLPGSQL_STMT_PERFORM:
......
...@@ -235,15 +235,15 @@ drop cascades to table schema_one."table two" ...@@ -235,15 +235,15 @@ drop cascades to table schema_one."table two"
drop cascades to table schema_one.table_three drop cascades to table schema_one.table_three
NOTICE: table "schema_two_table_two" does not exist, skipping NOTICE: table "schema_two_table_two" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
NOTICE: table "audit_tbls_schema_two_table_three" does not exist, skipping NOTICE: table "audit_tbls_schema_two_table_three" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three" SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
ERROR: object audit_tbls.schema_two_table_three of type table cannot be dropped ERROR: object audit_tbls.schema_two_table_three of type table cannot be dropped
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
DELETE FROM undroppable_objs WHERE object_identity = 'audit_tbls.schema_two_table_three'; DELETE FROM undroppable_objs WHERE object_identity = 'audit_tbls.schema_two_table_three';
DROP SCHEMA schema_one, schema_two CASCADE; DROP SCHEMA schema_one, schema_two CASCADE;
NOTICE: drop cascades to 7 other objects NOTICE: drop cascades to 7 other objects
...@@ -256,21 +256,21 @@ drop cascades to table schema_one."table two" ...@@ -256,21 +256,21 @@ drop cascades to table schema_one."table two"
drop cascades to table schema_one.table_three drop cascades to table schema_one.table_three
NOTICE: table "schema_two_table_two" does not exist, skipping NOTICE: table "schema_two_table_two" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
NOTICE: table "audit_tbls_schema_two_table_three" does not exist, skipping NOTICE: table "audit_tbls_schema_two_table_three" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three" SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
NOTICE: table "schema_one_table_one" does not exist, skipping NOTICE: table "schema_one_table_one" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_one" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_one"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
NOTICE: table "schema_one_table two" does not exist, skipping NOTICE: table "schema_one_table two" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls."schema_one_table two"" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls."schema_one_table two""
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
NOTICE: table "schema_one_table_three" does not exist, skipping NOTICE: table "schema_one_table_three" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_three" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_three"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
ERROR: object schema_one.table_three of type table cannot be dropped ERROR: object schema_one.table_three of type table cannot be dropped
DELETE FROM undroppable_objs WHERE object_identity = 'schema_one.table_three'; DELETE FROM undroppable_objs WHERE object_identity = 'schema_one.table_three';
DROP SCHEMA schema_one, schema_two CASCADE; DROP SCHEMA schema_one, schema_two CASCADE;
...@@ -284,21 +284,21 @@ drop cascades to table schema_one."table two" ...@@ -284,21 +284,21 @@ drop cascades to table schema_one."table two"
drop cascades to table schema_one.table_three drop cascades to table schema_one.table_three
NOTICE: table "schema_two_table_two" does not exist, skipping NOTICE: table "schema_two_table_two" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
NOTICE: table "audit_tbls_schema_two_table_three" does not exist, skipping NOTICE: table "audit_tbls_schema_two_table_three" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three" SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
NOTICE: table "schema_one_table_one" does not exist, skipping NOTICE: table "schema_one_table_one" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_one" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_one"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
NOTICE: table "schema_one_table two" does not exist, skipping NOTICE: table "schema_one_table two" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls."schema_one_table two"" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls."schema_one_table two""
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
NOTICE: table "schema_one_table_three" does not exist, skipping NOTICE: table "schema_one_table_three" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_three" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_three"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
SELECT * FROM dropped_objects WHERE schema IS NULL OR schema <> 'pg_toast'; SELECT * FROM dropped_objects WHERE schema IS NULL OR schema <> 'pg_toast';
type | schema | object type | schema | object
--------------+------------+------------------------------------- --------------+------------+-------------------------------------
...@@ -330,7 +330,7 @@ SELECT * FROM dropped_objects WHERE schema IS NULL OR schema <> 'pg_toast'; ...@@ -330,7 +330,7 @@ SELECT * FROM dropped_objects WHERE schema IS NULL OR schema <> 'pg_toast';
DROP OWNED BY regression_bob; DROP OWNED BY regression_bob;
NOTICE: schema "audit_tbls" does not exist, skipping NOTICE: schema "audit_tbls" does not exist, skipping
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_one_table_two" CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_one_table_two"
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
SELECT * FROM dropped_objects WHERE type = 'schema'; SELECT * FROM dropped_objects WHERE type = 'schema';
type | schema | object type | schema | object
--------+--------+------------ --------+--------+------------
......
...@@ -3115,7 +3115,7 @@ begin ...@@ -3115,7 +3115,7 @@ begin
end$$ language plpgsql; end$$ language plpgsql;
select footest(); select footest();
ERROR: query returned no rows ERROR: query returned no rows
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
create or replace function footest() returns void as $$ create or replace function footest() returns void as $$
declare x record; declare x record;
begin begin
...@@ -3125,7 +3125,7 @@ begin ...@@ -3125,7 +3125,7 @@ begin
end$$ language plpgsql; end$$ language plpgsql;
select footest(); select footest();
ERROR: query returned more than one row ERROR: query returned more than one row
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
drop function footest(); drop function footest();
-- test printing parameters after failure due to STRICT -- test printing parameters after failure due to STRICT
set plpgsql.print_strict_params to true; set plpgsql.print_strict_params to true;
...@@ -3177,7 +3177,7 @@ end$$ language plpgsql; ...@@ -3177,7 +3177,7 @@ end$$ language plpgsql;
select footest(); select footest();
ERROR: query returned no rows ERROR: query returned no rows
DETAIL: parameters: $1 = '0', $2 = 'foo' DETAIL: parameters: $1 = '0', $2 = 'foo'
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
create or replace function footest() returns void as $$ create or replace function footest() returns void as $$
declare x record; declare x record;
begin begin
...@@ -3188,7 +3188,7 @@ end$$ language plpgsql; ...@@ -3188,7 +3188,7 @@ end$$ language plpgsql;
select footest(); select footest();
ERROR: query returned more than one row ERROR: query returned more than one row
DETAIL: parameters: $1 = '1' DETAIL: parameters: $1 = '1'
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
create or replace function footest() returns void as $$ create or replace function footest() returns void as $$
declare x record; declare x record;
begin begin
...@@ -3198,7 +3198,7 @@ begin ...@@ -3198,7 +3198,7 @@ begin
end$$ language plpgsql; end$$ language plpgsql;
select footest(); select footest();
ERROR: query returned more than one row ERROR: query returned more than one row
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
create or replace function footest() returns void as $$ create or replace function footest() returns void as $$
-- override the global -- override the global
#print_strict_params off #print_strict_params off
...@@ -4237,7 +4237,7 @@ end; ...@@ -4237,7 +4237,7 @@ end;
$$ language plpgsql; $$ language plpgsql;
select stacked_diagnostics_test(); select stacked_diagnostics_test();
ERROR: GET STACKED DIAGNOSTICS cannot be used outside an exception handler ERROR: GET STACKED DIAGNOSTICS cannot be used outside an exception handler
CONTEXT: PL/pgSQL function stacked_diagnostics_test() line 6 at GET DIAGNOSTICS CONTEXT: PL/pgSQL function stacked_diagnostics_test() line 6 at GET STACKED DIAGNOSTICS
drop function zero_divide(); drop function zero_divide();
drop function stacked_diagnostics_test(); drop function stacked_diagnostics_test();
-- check cases where implicit SQLSTATE variable could be confused with -- check cases where implicit SQLSTATE variable could be confused with
......
...@@ -1493,7 +1493,7 @@ CONTEXT: SQL statement "insert into depth_b values (new.id)" ...@@ -1493,7 +1493,7 @@ CONTEXT: SQL statement "insert into depth_b values (new.id)"
PL/pgSQL function depth_a_tf() line 4 at SQL statement PL/pgSQL function depth_a_tf() line 4 at SQL statement
NOTICE: depth_c_tr: depth = 3 NOTICE: depth_c_tr: depth = 3
CONTEXT: SQL statement "insert into depth_c values (1)" CONTEXT: SQL statement "insert into depth_c values (1)"
PL/pgSQL function depth_b_tf() line 5 at EXECUTE statement PL/pgSQL function depth_b_tf() line 5 at EXECUTE
SQL statement "insert into depth_b values (new.id)" SQL statement "insert into depth_b values (new.id)"
PL/pgSQL function depth_a_tf() line 4 at SQL statement PL/pgSQL function depth_a_tf() line 4 at SQL statement
NOTICE: SQLSTATE = U9999: depth = 2 NOTICE: SQLSTATE = U9999: depth = 2
...@@ -1504,12 +1504,12 @@ CONTEXT: SQL statement "insert into depth_b values (new.id)" ...@@ -1504,12 +1504,12 @@ CONTEXT: SQL statement "insert into depth_b values (new.id)"
PL/pgSQL function depth_a_tf() line 4 at SQL statement PL/pgSQL function depth_a_tf() line 4 at SQL statement
NOTICE: depth_c_tr: depth = 3 NOTICE: depth_c_tr: depth = 3
CONTEXT: SQL statement "insert into depth_c values (1)" CONTEXT: SQL statement "insert into depth_c values (1)"
PL/pgSQL function depth_b_tf() line 12 at EXECUTE statement PL/pgSQL function depth_b_tf() line 12 at EXECUTE
SQL statement "insert into depth_b values (new.id)" SQL statement "insert into depth_b values (new.id)"
PL/pgSQL function depth_a_tf() line 4 at SQL statement PL/pgSQL function depth_a_tf() line 4 at SQL statement
ERROR: U9999 ERROR: U9999
CONTEXT: SQL statement "insert into depth_c values (1)" CONTEXT: SQL statement "insert into depth_c values (1)"
PL/pgSQL function depth_b_tf() line 12 at EXECUTE statement PL/pgSQL function depth_b_tf() line 12 at EXECUTE
SQL statement "insert into depth_b values (new.id)" SQL statement "insert into depth_b values (new.id)"
PL/pgSQL function depth_a_tf() line 4 at SQL statement PL/pgSQL function depth_a_tf() line 4 at SQL statement
select pg_trigger_depth(); select pg_trigger_depth();
...@@ -1525,12 +1525,12 @@ CONTEXT: SQL statement "insert into depth_b values (new.id)" ...@@ -1525,12 +1525,12 @@ CONTEXT: SQL statement "insert into depth_b values (new.id)"
PL/pgSQL function depth_a_tf() line 4 at SQL statement PL/pgSQL function depth_a_tf() line 4 at SQL statement
NOTICE: depth_c_tr: depth = 3 NOTICE: depth_c_tr: depth = 3
CONTEXT: SQL statement "insert into depth_c values (2)" CONTEXT: SQL statement "insert into depth_c values (2)"
PL/pgSQL function depth_b_tf() line 5 at EXECUTE statement PL/pgSQL function depth_b_tf() line 5 at EXECUTE
SQL statement "insert into depth_b values (new.id)" SQL statement "insert into depth_b values (new.id)"
PL/pgSQL function depth_a_tf() line 4 at SQL statement PL/pgSQL function depth_a_tf() line 4 at SQL statement
NOTICE: depth_c_tr: depth = 3 NOTICE: depth_c_tr: depth = 3
CONTEXT: SQL statement "insert into depth_c values (2)" CONTEXT: SQL statement "insert into depth_c values (2)"
PL/pgSQL function depth_b_tf() line 5 at EXECUTE statement PL/pgSQL function depth_b_tf() line 5 at EXECUTE
SQL statement "insert into depth_b values (new.id)" SQL statement "insert into depth_b values (new.id)"
PL/pgSQL function depth_a_tf() line 4 at SQL statement PL/pgSQL function depth_a_tf() line 4 at SQL statement
NOTICE: depth_b_tr: depth = 2 NOTICE: depth_b_tr: depth = 2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment