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