Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4c3754f

Browse files
committed
Fix a few bogus statement type names in plpgsql error messages.
plpgsql's error location context messages ("PL/pgSQL function fn-name lineline-no at stmt-type") would misreport a CONTINUE statement as being anEXIT, and misreport a MOVE statement as being a FETCH. These are clearbugs that have been there a long time, so back-patch to all supportedbranches.In addition, in 9.5 and HEAD, change the description of EXECUTE from"EXECUTE statement" to just plain EXECUTE; there seems no good reason whythis statement type should be described differently from others that havea well-defined head keyword. And distinguish GET STACKED DIAGNOSTICS fromplain GET DIAGNOSTICS. These are a bit more of a judgment call, and alsoaffect existing regression-test outputs, so I did not back-patch intostable branches.Pavel Stehule and Tom Lane
1 parentf25087d commit4c3754f

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

‎src/pl/plpgsql/src/pl_funcs.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
235235
casePLPGSQL_STMT_FOREACH_A:
236236
return_("FOREACH over array");
237237
casePLPGSQL_STMT_EXIT:
238-
return"EXIT";
238+
return((PLpgSQL_stmt_exit*)stmt)->is_exit ?"EXIT" :"CONTINUE";
239239
casePLPGSQL_STMT_RETURN:
240240
return"RETURN";
241241
casePLPGSQL_STMT_RETURN_NEXT:
@@ -249,15 +249,16 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt)
249249
casePLPGSQL_STMT_EXECSQL:
250250
return_("SQL statement");
251251
casePLPGSQL_STMT_DYNEXECUTE:
252-
return_("EXECUTE statement");
252+
return"EXECUTE";
253253
casePLPGSQL_STMT_DYNFORS:
254254
return_("FOR over EXECUTE statement");
255255
casePLPGSQL_STMT_GETDIAG:
256-
return"GET DIAGNOSTICS";
256+
return ((PLpgSQL_stmt_getdiag*)stmt)->is_stacked ?
257+
"GET STACKED DIAGNOSTICS" :"GET DIAGNOSTICS";
257258
casePLPGSQL_STMT_OPEN:
258259
return"OPEN";
259260
casePLPGSQL_STMT_FETCH:
260-
return"FETCH";
261+
return((PLpgSQL_stmt_fetch*)stmt)->is_move ?"MOVE" :"FETCH";
261262
casePLPGSQL_STMT_CLOSE:
262263
return"CLOSE";
263264
casePLPGSQL_STMT_PERFORM:

‎src/test/regress/expected/event_trigger.out

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,15 @@ drop cascades to table schema_one."table two"
235235
drop cascades to table schema_one.table_three
236236
NOTICE: table "schema_two_table_two" does not exist, skipping
237237
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two"
238-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
238+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
239239
NOTICE: table "audit_tbls_schema_two_table_three" does not exist, skipping
240240
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three"
241-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
241+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
242242
SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
243-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
243+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
244244
ERROR: object audit_tbls.schema_two_table_three of type table cannot be dropped
245245
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
246-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
246+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
247247
DELETE FROM undroppable_objs WHERE object_identity = 'audit_tbls.schema_two_table_three';
248248
DROP SCHEMA schema_one, schema_two CASCADE;
249249
NOTICE: drop cascades to 7 other objects
@@ -256,21 +256,21 @@ drop cascades to table schema_one."table two"
256256
drop cascades to table schema_one.table_three
257257
NOTICE: table "schema_two_table_two" does not exist, skipping
258258
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two"
259-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
259+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
260260
NOTICE: table "audit_tbls_schema_two_table_three" does not exist, skipping
261261
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three"
262-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
262+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
263263
SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
264-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
264+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
265265
NOTICE: table "schema_one_table_one" does not exist, skipping
266266
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_one"
267-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
267+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
268268
NOTICE: table "schema_one_table two" does not exist, skipping
269269
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls."schema_one_table two""
270-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
270+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
271271
NOTICE: table "schema_one_table_three" does not exist, skipping
272272
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_three"
273-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
273+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
274274
ERROR: object schema_one.table_three of type table cannot be dropped
275275
DELETE FROM undroppable_objs WHERE object_identity = 'schema_one.table_three';
276276
DROP SCHEMA schema_one, schema_two CASCADE;
@@ -284,21 +284,21 @@ drop cascades to table schema_one."table two"
284284
drop cascades to table schema_one.table_three
285285
NOTICE: table "schema_two_table_two" does not exist, skipping
286286
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_two"
287-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
287+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
288288
NOTICE: table "audit_tbls_schema_two_table_three" does not exist, skipping
289289
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_two_table_three"
290-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
290+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
291291
SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_two_table_three"
292-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
292+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
293293
NOTICE: table "schema_one_table_one" does not exist, skipping
294294
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_one"
295-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
295+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
296296
NOTICE: table "schema_one_table two" does not exist, skipping
297297
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls."schema_one_table two""
298-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
298+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
299299
NOTICE: table "schema_one_table_three" does not exist, skipping
300300
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.schema_one_table_three"
301-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
301+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
302302
SELECT * FROM dropped_objects WHERE schema IS NULL OR schema <> 'pg_toast';
303303
type | schema | object
304304
--------------+------------+-------------------------------------
@@ -330,7 +330,7 @@ SELECT * FROM dropped_objects WHERE schema IS NULL OR schema <> 'pg_toast';
330330
DROP OWNED BY regression_bob;
331331
NOTICE: schema "audit_tbls" does not exist, skipping
332332
CONTEXT: SQL statement "DROP TABLE IF EXISTS audit_tbls.audit_tbls_schema_one_table_two"
333-
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE statement
333+
PL/pgSQL function test_evtrig_dropped_objects() line 8 at EXECUTE
334334
SELECT * FROM dropped_objects WHERE type = 'schema';
335335
type | schema | object
336336
--------+--------+------------

‎src/test/regress/expected/plpgsql.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,7 +3115,7 @@ begin
31153115
end$$ language plpgsql;
31163116
select footest();
31173117
ERROR: query returned no rows
3118-
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement
3118+
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
31193119
create or replace function footest() returns void as $$
31203120
declare x record;
31213121
begin
@@ -3125,7 +3125,7 @@ begin
31253125
end$$ language plpgsql;
31263126
select footest();
31273127
ERROR: query returned more than one row
3128-
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement
3128+
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
31293129
drop function footest();
31303130
-- test printing parameters after failure due to STRICT
31313131
set plpgsql.print_strict_params to true;
@@ -3177,7 +3177,7 @@ end$$ language plpgsql;
31773177
select footest();
31783178
ERROR: query returned no rows
31793179
DETAIL: parameters: $1 = '0', $2 = 'foo'
3180-
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement
3180+
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
31813181
create or replace function footest() returns void as $$
31823182
declare x record;
31833183
begin
@@ -3188,7 +3188,7 @@ end$$ language plpgsql;
31883188
select footest();
31893189
ERROR: query returned more than one row
31903190
DETAIL: parameters: $1 = '1'
3191-
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement
3191+
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
31923192
create or replace function footest() returns void as $$
31933193
declare x record;
31943194
begin
@@ -3198,7 +3198,7 @@ begin
31983198
end$$ language plpgsql;
31993199
select footest();
32003200
ERROR: query returned more than one row
3201-
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE statement
3201+
CONTEXT: PL/pgSQL function footest() line 5 at EXECUTE
32023202
create or replace function footest() returns void as $$
32033203
-- override the global
32043204
#print_strict_params off
@@ -4237,7 +4237,7 @@ end;
42374237
$$ language plpgsql;
42384238
select stacked_diagnostics_test();
42394239
ERROR: GET STACKED DIAGNOSTICS cannot be used outside an exception handler
4240-
CONTEXT: PL/pgSQL function stacked_diagnostics_test() line 6 at GET DIAGNOSTICS
4240+
CONTEXT: PL/pgSQL function stacked_diagnostics_test() line 6 at GETSTACKEDDIAGNOSTICS
42414241
drop function zero_divide();
42424242
drop function stacked_diagnostics_test();
42434243
-- check cases where implicit SQLSTATE variable could be confused with

‎src/test/regress/expected/triggers.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ CONTEXT: SQL statement "insert into depth_b values (new.id)"
14931493
PL/pgSQL function depth_a_tf() line 4 at SQL statement
14941494
NOTICE: depth_c_tr: depth = 3
14951495
CONTEXT: SQL statement "insert into depth_c values (1)"
1496-
PL/pgSQL function depth_b_tf() line 5 at EXECUTE statement
1496+
PL/pgSQL function depth_b_tf() line 5 at EXECUTE
14971497
SQL statement "insert into depth_b values (new.id)"
14981498
PL/pgSQL function depth_a_tf() line 4 at SQL statement
14991499
NOTICE: SQLSTATE = U9999: depth = 2
@@ -1504,12 +1504,12 @@ CONTEXT: SQL statement "insert into depth_b values (new.id)"
15041504
PL/pgSQL function depth_a_tf() line 4 at SQL statement
15051505
NOTICE: depth_c_tr: depth = 3
15061506
CONTEXT: SQL statement "insert into depth_c values (1)"
1507-
PL/pgSQL function depth_b_tf() line 12 at EXECUTE statement
1507+
PL/pgSQL function depth_b_tf() line 12 at EXECUTE
15081508
SQL statement "insert into depth_b values (new.id)"
15091509
PL/pgSQL function depth_a_tf() line 4 at SQL statement
15101510
ERROR: U9999
15111511
CONTEXT: SQL statement "insert into depth_c values (1)"
1512-
PL/pgSQL function depth_b_tf() line 12 at EXECUTE statement
1512+
PL/pgSQL function depth_b_tf() line 12 at EXECUTE
15131513
SQL statement "insert into depth_b values (new.id)"
15141514
PL/pgSQL function depth_a_tf() line 4 at SQL statement
15151515
select pg_trigger_depth();
@@ -1525,12 +1525,12 @@ CONTEXT: SQL statement "insert into depth_b values (new.id)"
15251525
PL/pgSQL function depth_a_tf() line 4 at SQL statement
15261526
NOTICE: depth_c_tr: depth = 3
15271527
CONTEXT: SQL statement "insert into depth_c values (2)"
1528-
PL/pgSQL function depth_b_tf() line 5 at EXECUTE statement
1528+
PL/pgSQL function depth_b_tf() line 5 at EXECUTE
15291529
SQL statement "insert into depth_b values (new.id)"
15301530
PL/pgSQL function depth_a_tf() line 4 at SQL statement
15311531
NOTICE: depth_c_tr: depth = 3
15321532
CONTEXT: SQL statement "insert into depth_c values (2)"
1533-
PL/pgSQL function depth_b_tf() line 5 at EXECUTE statement
1533+
PL/pgSQL function depth_b_tf() line 5 at EXECUTE
15341534
SQL statement "insert into depth_b values (new.id)"
15351535
PL/pgSQL function depth_a_tf() line 4 at SQL statement
15361536
NOTICE: depth_b_tr: depth = 2

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp