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

Commit2624de7

Browse files
committed
Fix another issue with ENABLE/DISABLE TRIGGER on partitioned tables.
In v13 and v14, the ENABLE/DISABLE TRIGGER USER variant malfunctionedon cloned triggers, failing to find the clones because it thought theywere system triggers. Other variants of ENABLE/DISABLE TRIGGER wouldimproperly apply a superuserness check. Fix by adjusting the is-it-a-system-trigger check to match reality in those branches. (As faras I can find, this is the only place that got it wrong.)There's no such bug in v15/HEAD, because we revised the catalogrepresentation of system triggers to be what this code was expecting.However, add the test case to these branches anyway, because this areais visibly pretty fragile. Also remove an obsoleted comment.The recent v15/HEAD commit6949b92 fixed a nearby bug. I now seethat my commit message for that was inaccurate: the behavior ofrecursing to clone triggers is older than v15, but it didn't applyto the case in v13/v14 because in those branches parent partitionedtables have no pg_trigger entries for foreign-key triggers. But addthe test case from that commit to v13/v14, just to show what ishappening there.Per bug #17886 from DzmitryH.Discussion:https://postgr.es/m/17886-5406d5d828aa4aa3@postgresql.org
1 parentf5d60b1 commit2624de7

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

‎src/backend/commands/trigger.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -868,11 +868,6 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
868868

869869
/*
870870
* Build the new pg_trigger tuple.
871-
*
872-
* When we're creating a trigger in a partition, we mark it as internal,
873-
* even though we don't do the isInternal magic in this function. This
874-
* makes the triggers in partitions identical to the ones in the
875-
* partitioned tables, except that they are marked internal.
876871
*/
877872
memset(nulls, false,sizeof(nulls));
878873

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,6 +2718,18 @@ select tgrelid::regclass, tgname, tgenabled from pg_trigger
27182718
parent | tg_stmt | A
27192719
(3 rows)
27202720

2721+
-- This variant malfunctioned in some releases.
2722+
alter table parent disable trigger user;
2723+
select tgrelid::regclass, tgname, tgenabled from pg_trigger
2724+
where tgrelid in ('parent'::regclass, 'child1'::regclass)
2725+
order by tgrelid::regclass::text, tgname;
2726+
tgrelid | tgname | tgenabled
2727+
---------+---------+-----------
2728+
child1 | tg | D
2729+
parent | tg | D
2730+
parent | tg_stmt | D
2731+
(3 rows)
2732+
27212733
drop table parent, child1;
27222734
-- Check processing of foreign key triggers
27232735
create table parent (a int primary key, f int references parent)

‎src/test/regress/sql/triggers.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,11 @@ select tgrelid::regclass, tgname, tgenabled from pg_trigger
18781878
-- The following is a no-op for the parent trigger but not so
18791879
-- for the child trigger, so recursion should be applied.
18801880
altertable parent enable always trigger tg;
1881+
select tgrelid::regclass, tgname, tgenabledfrom pg_trigger
1882+
where tgrelidin ('parent'::regclass,'child1'::regclass)
1883+
order by tgrelid::regclass::text, tgname;
1884+
-- This variant malfunctioned in some releases.
1885+
altertable parent disable trigger user;
18811886
select tgrelid::regclass, tgname, tgenabledfrom pg_trigger
18821887
where tgrelidin ('parent'::regclass,'child1'::regclass)
18831888
order by tgrelid::regclass::text, tgname;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp