@@ -331,6 +331,7 @@ SELECT * FROM dropped_objects WHERE type = 'schema';
331
331
DROP ROLE regress_evt_user;
332
332
DROP EVENT TRIGGER regress_event_trigger_drop_objects;
333
333
DROP EVENT TRIGGER undroppable;
334
+ -- Event triggers on relations.
334
335
CREATE OR REPLACE FUNCTION event_trigger_report_dropped()
335
336
RETURNS event_trigger
336
337
LANGUAGE plpgsql
@@ -349,41 +350,92 @@ BEGIN
349
350
END; $$;
350
351
CREATE EVENT TRIGGER regress_event_trigger_report_dropped ON sql_drop
351
352
EXECUTE PROCEDURE event_trigger_report_dropped();
353
+ CREATE OR REPLACE FUNCTION event_trigger_report_end()
354
+ RETURNS event_trigger
355
+ LANGUAGE plpgsql
356
+ AS $$
357
+ DECLARE r RECORD;
358
+ BEGIN
359
+ FOR r IN SELECT * FROM pg_event_trigger_ddl_commands()
360
+ LOOP
361
+ RAISE NOTICE 'END: command_tag=% type=% identity=%',
362
+ r.command_tag, r.object_type, r.object_identity;
363
+ END LOOP;
364
+ EXCEPTION WHEN SQLSTATE 'XX000' THEN
365
+ RAISE NOTICE 'END: got internal exception';
366
+ END; $$;
367
+ CREATE EVENT TRIGGER regress_event_trigger_report_end ON ddl_command_end
368
+ EXECUTE PROCEDURE event_trigger_report_end();
352
369
CREATE SCHEMA evttrig
353
- CREATE TABLE one (col_a SERIAL PRIMARY KEY, col_b text DEFAULT 'forty two')
370
+ CREATE TABLE one (col_a SERIAL PRIMARY KEY, col_b text DEFAULT 'forty two', col_c SERIAL )
354
371
CREATE INDEX one_idx ON one (col_b)
355
- CREATE TABLE two (col_c INTEGER CHECK (col_c > 0) REFERENCES one DEFAULT 42);
372
+ CREATE TABLE two (col_c INTEGER CHECK (col_c > 0) REFERENCES one DEFAULT 42)
373
+ CREATE TABLE id (col_d int NOT NULL GENERATED ALWAYS AS IDENTITY);
374
+ NOTICE: END: command_tag=CREATE SCHEMA type=schema identity=evttrig
375
+ NOTICE: END: command_tag=CREATE SEQUENCE type=sequence identity=evttrig.one_col_a_seq
376
+ NOTICE: END: command_tag=CREATE SEQUENCE type=sequence identity=evttrig.one_col_c_seq
377
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.one
378
+ NOTICE: END: command_tag=CREATE INDEX type=index identity=evttrig.one_pkey
379
+ NOTICE: END: command_tag=AL
8000
TER SEQUENCE type=sequence identity=evttrig.one_col_a_seq
380
+ NOTICE: END: command_tag=ALTER SEQUENCE type=sequence identity=evttrig.one_col_c_seq
381
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.two
382
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.two
383
+ NOTICE: END: command_tag=CREATE SEQUENCE type=sequence identity=evttrig.id_col_d_seq
384
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.id
385
+ NOTICE: END: command_tag=ALTER SEQUENCE type=sequence identity=evttrig.id_col_d_seq
386
+ NOTICE: END: command_tag=CREATE INDEX type=index identity=evttrig.one_idx
356
387
-- Partitioned tables with a partitioned index
357
388
CREATE TABLE evttrig.parted (
358
389
id int PRIMARY KEY)
359
390
PARTITION BY RANGE (id);
391
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.parted
392
+ NOTICE: END: command_tag=CREATE INDEX type=index identity=evttrig.parted_pkey
360
393
CREATE TABLE evttrig.part_1_10 PARTITION OF evttrig.parted (id)
361
394
FOR VALUES FROM (1) TO (10);
395
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.part_1_10
362
396
CREATE TABLE evttrig.part_10_20 PARTITION OF evttrig.parted (id)
363
397
FOR VALUES FROM (10) TO (20) PARTITION BY RANGE (id);
398
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.part_10_20
364
399
CREATE TABLE evttrig.part_10_15 PARTITION OF evttrig.part_10_20 (id)
365
400
FOR VALUES FROM (10) TO (15);
401
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.part_10_15
366
402
CREATE TABLE evttrig.part_15_20 PARTITION OF evttrig.part_10_20 (id)
367
403
FOR VALUES FROM (15) TO (20);
404
+ NOTICE: END: command_tag=CREATE TABLE type=table identity=evttrig.part_15_20
368
405
ALTER TABLE evttrig.two DROP COLUMN col_c;
369
406
NOTICE: NORMAL: orig=t normal=f istemp=f type=table column identity=evttrig.two.col_c name={evttrig,two,col_c} args={}
370
407
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={}
408
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.two
371
409
ALTER TABLE evttrig.one ALTER COLUMN col_b DROP DEFAULT;
372
410
NOTICE: NORMAL: orig=t normal=f istemp=f type=default value identity=for evttrig.one.col_b name={evttrig,one,col_b} args={}
411
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.one
373
412
ALTER TABLE evttrig.one DROP CONSTRAINT one_pkey;
374
413
NOTICE: NORMAL: orig=t normal=f istemp=f type=table constraint identity=one_pkey on evttrig.one name={evttrig,one,one_pkey} args={}
414
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.one
415
+ ALTER TABLE evttrig.one DROP COLUMN col_c;
416
+ NOTICE: NORMAL: orig=t normal=f istemp=f type=table column identity=evttrig.one.col_c name={evttrig,one,col_c} args={}
417
+ NOTICE: NORMAL: orig=f normal=t istemp=f type=default value identity=for evttrig.one.col_c name={evttrig,one,col_c} args={}
418
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.one
419
+ ALTER TABLE evttrig.id ALTER COLUMN col_d SET DATA TYPE bigint;
420
+ NOTICE: END: command_tag=ALTER SEQUENCE type=sequence identity=evttrig.id_col_d_seq
421
+ NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.id
422
+ ALTER TABLE evttrig.id ALTER COLUMN col_d DROP IDENTITY,
423
+ ALTER COLUMN col_d SET DATA TYPE int;
424
+ NOTICE: END: got internal exception
375
425
DROP INDEX evttrig.one_idx;
376
426
NOTICE: NORMAL: orig=t normal=f istemp=f type=index identity=evttrig.one_idx name={evttrig,one_idx} args={}
377
427
DROP SCHEMA evttrig CASCADE;
378
- NOTICE: drop cascades to 3 other objects
428
+ NOTICE: drop cascades to 4 other objects
379
429
DETAIL: drop cascades to table evttrig.one
380
430
drop cascades to table evttrig.two
431
+ drop cascades to table evttrig.id
381
432
drop cascades to table evttrig.parted
382
433
NOTICE: NORMAL: orig=t normal=f istemp=f type=schema identity=evttrig name={evttrig} args={}
383
434
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.one name={evttrig,one} args={}
384
435
NOTICE: NORMAL: orig=f normal=t istemp=f type=sequence identity=evttrig.one_col_a_seq name={evttrig,one_col_a_seq} args={}
385
436
NOTICE: NORMAL: orig=f normal=t istemp=f type=default value identity=for evttrig.one.col_a name={evttrig,one,col_a} args={}
386
437
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.two name={evttrig,two} args={}
438
+ NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.id name={evttrig,id} args={}
387
439
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.parted name={evttrig,parted} args={}
388
440
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.part_1_10 name={evttrig,part_1_10} args={}
389
441
NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.part_10_20 name={evttrig,part_10_20} args={}
@@ -392,6 +444,7 @@ NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.part_15_20
392
444
DROP TABLE a_temp_tbl;
393
445
NOTICE: NORMAL: orig=t normal=f istemp=t type=table identity=pg_temp.a_temp_tbl name={pg_temp,a_temp_tbl} args={}
394
446
DROP EVENT TRIGGER regress_event_trigger_report_dropped;
447
+ DROP EVENT TRIGGER regress_event_trigger_report_end;
395
448
-- only allowed from within an event trigger function, should fail
396
449
select pg_event_trigger_table_rewrite_oid();
397
450
ERROR: pg_event_trigger_table_rewrite_oid() can only be called in a table_rewrite event trigger function
0 commit comments