@@ -366,6 +366,7 @@ SELECT * FROM dropped_objects WHERE type = 'schema';
366
366
DROP ROLE regress_evt_user;
367
367
DROP EVENT TRIGGER regress_event_trigger_drop_objects;
368
368
DROP EVENT TRIGGER undroppable;
369
+ -- Event triggers on relations.
369
370
CREATE OR REPLACE FUNCTION event_trigger_report_dropped()
370
371
RETURNS event_trigger
371
372
LANGUAGE plpgsql
@@ -384,41 +385,92 @@ BEGIN
384
385
END; $$;
385
386
CREATE EVENT TRIGGER regress_event_trigger_report_dropped ON sql_drop
386
387
EXECUTE PROCEDURE event_trigger_report_dropped();
388
+ CREATE OR REPLACE FUNCTION event_trigger_report_end()
389
+ RETURNS event_trigger
390
+ LANGUAGE plpgsql
391
+ AS $$
392
+ DECLARE r RECORD;
393
+ BEGIN
394
+ FOR r IN SELECT * FROM pg_event_trigger_ddl_commands()
395
+ LOOP
396
+ RAISE NOTICE 'END: command_tag=% type=% identity=%',
397
+ r.command_tag, r.object_type, r.object_identity;
398
+ END LOOP;
399
+ EXCEPTION WHEN SQLSTATE 'XX000' THEN
400
+ RAISE NOTICE 'END: got internal exception';
401
+ END; $$;
402
+ CREATE EVENT TRIGGER regress_event_trigger_report_end ON ddl_command_end
403
+ EXECUTE PROCEDURE event_trigger_report_end();
387
404
CREATE SCHEMA evttrig
388
- CREATE TABLE one (col_a SERIAL PRIMARY KEY, col_b text DEFAULT 'forty two')
405
+ CREATE TABLE one (col_a SERIAL PRIMARY KEY, col_b text DEFAULT 'forty two', col_c SERIAL )
389
406
CREATE INDEX one_idx ON one (col_b)
390
- CREATE TABLE two (col_c INTEGER CHECK (col_c > 0) REFERENCES one DEFAULT 42);
407
+ CREATE TABLE two (col_c INTEGER CHECK (col_c > 0) REFERENCES one DEFAULT 42)
408
+ CREATE TABLE id (col_d int NOT NULL GENERATED ALWAYS AS IDENTITY);
409
+ NOTICE: END: command_tag=CREATE SCHEMA type=schema identity=evttrig
410
+ NOTICE: END: command_tag=CREATE SEQUENCE type=sequence identity=evttrig.one_col_a_seq
411
+ NOTICE: END: command_tag=CREATE SEQUENCE type=sequence identity=evttrig.one_col_c_seq
412
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.one
413
+ NOTICE: END: command_tag=CREATE INDEX type=index identity=evttrig.one_pkey
414
+ NOTICE: END: command_tag=ALTER SEQUENCE type=sequence identity=evttrig.one_col_a_seq
415
+ NOTICE: END: command_tag=ALTER SEQUENCE type=sequence identity=evttrig.one_col_c_seq
416
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.two
417
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.two
418
+ NOTICE: END: command_tag=CREATE SEQUENCE type=sequence identity=evttrig.id_col_d_seq
419
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.id
420
+ NOTICE: END: command_tag=ALTER SEQUENCE type=sequence identity=evttrig.id_col_d_seq
421
+ NOTICE: END: command_tag=CREATE INDEX type=index identity=evttrig.one_idx
391
422
-- Partitioned tables with a partitioned index
392
423
CREATE TABLE evttrig.parted (
393
424
id int PRIMARY KEY)
394
425
PARTITION BY RANGE (id);
426
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.parted
427
+ NOTICE: END: command_tag=CREATE INDEX type=index identity=evttrig.parted_pkey
395
428
CREATE TABLE evttrig.part_1_10 PARTITION OF evttrig.parted (id)
396
429
FOR VALUES FROM (1) TO (10);
430
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.part_1_10
397
431
CREATE TABLE evttrig.part_10_20 PARTITION OF evttrig.parted (id)
398
432
FOR VALUES FROM (10) TO (20) PARTITION BY RANGE (id);
433
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.part_10_20
399
434
CREATE TABLE evttrig.part_10_15 PARTITION OF evttrig.part_10_20 (id)
400
435
FOR VALUES FROM (10) TO (15);
436
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.part_10_15
401
437
CREATE TABLE evttrig.part_15_20 PARTITION OF evttrig.part_10_20 (id)
402
438
FOR VALUES FROM (15) TO (20);
439
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.part_15_20
403
440
ALTER TABLE evttrig.two DROP COLUMN col_c;
404
441
NOTICE: NORMAL: orig=t normal=f istemp=f type=table column identity=evttrig.two.col_c name={evttrig,two,col_c} args={}
405
442
NOTICE: NORMAL: orig=f normal=t istemp=f type=table constraint identity=two_col_c_check on evttrig.two name={evttrig,two,two_col_c_check} args={}
443
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.two
406
444
ALTER TABLE evttrig.one ALTER COLUMN col_b DROP DEFAULT;
407
445
NOTICE: NORMAL: orig=t normal=f istemp=f type=default value identity=for evttrig.one.col_b name={evttrig,one,col_b} args={}
446
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.one
408
447
ALTER TABLE evttrig.one DROP CONSTRAINT one_pkey;
409
448
NOTICE: NORMAL: orig=t normal=f istemp=f type=table constraint identity=one_pkey on evttrig.one name={evttrig,one,one_pkey} args={}
449
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.one
450
+ ALTER TABLE evttrig.one DROP COLUMN col_c;
451
+ NOTICE: NORMAL: orig=t normal=f istemp=f type=table column identity=evttrig.one.col_c name={evttrig,one,col_c} args={}
452
+ NOTICE: NORMAL: orig=f normal=t istemp=f type=default value identity=for evttrig.one.col_c name={evttrig,one,col_c} args={}
453
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.one
454
+ ALTER TABLE evttrig.id ALTER COLUMN col_d SET DATA TYPE bigint;
455
+ NOTICE: END: command_tag=ALTER SEQUENCE type=sequence identity=evttrig.id_col_d_seq
456
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.id
457
+ ALTER TABLE evttrig.id ALTER COLUMN col_d DROP IDENTITY,
458
+ ALTER COLUMN col_d SET DATA TYPE int;
459
+ NOTICE: END: got internal exception
410
460
DROP INDEX evttrig.one_idx;
411
461
NOTICE: NORMAL: orig=t normal=f istemp=f type=index identity=evttrig.one_idx name={evttrig,one_idx} args={}
412
462
DROP SCHEMA evttrig CASCADE;
413
- NOTICE: drop cascades to 3 other objects
463
+ NOTICE: drop cascades to 4 other objects
414
464
DETAIL: drop cascades to table evttrig.one
415
465
drop cascades to table evttrig.two
466
+ drop cascades to table evttrig.id
416
467
drop cascades to table evttrig.parted
417
468
NOTICE: NORMAL: orig=t normal=f istemp=f type=schema identity=evttrig name={evttrig} args={}
418
469
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.one name={evttrig,one} args={}
419
470
NOTICE: NORMAL: orig=f normal=t istemp=f type=sequence identity=evttrig.one_col_a_seq name={evttrig,one_col_a_seq} args={}
420
471
NOTICE: NORMAL: orig=f normal=t istemp=f type=default value identity=for evttrig.one.col_a name={evttrig,one,col_a} args={}
421
472
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.two name={evttrig,two} args={}
473
+ NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.id name={evttrig,id} args={}
422
474
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.parted name={evttrig,parted} args={}
423
475
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.part_1_10 name={evttrig,part_1_10} args={}
424
476
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.part_10_20 name={evttrig,part_10_20} args={}
@@ -427,6 +479,7 @@ NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.part_15_20
427
479
DROP TABLE a_temp_tbl;
428
480
NOTICE: NORMAL: orig=t normal=f istemp=t type=table identity=pg_temp.a_temp_tbl name={pg_temp,a_temp_tbl} args={}
429
481
DROP EVENT TRIGGER regress_event_trigger_report_dropped;
482
+ DROP EVENT TRIGGER regress_event_trigger_report_end;
430
483
-- only allowed from within an event trigger function, should fail
431
484
select pg_event_trigger_table_rewrite_oid();
432
485
ERROR: pg_event_trigger_table_rewrite_oid() can only be called in a table_rewrite event trigger function
0 commit comments