Re: Missing information about CREATE TRIGGER on temporary tables - Mailing list pgsql-docs

From Tom Lane
Subject Re: Missing information about CREATE TRIGGER on temporary tables
Date
Msg-id 370487.1646757549@sss.pgh.pa.us
Whole thread Raw
In response to Missing information about CREATE TRIGGER on temporary tables  (PG Doc comments form <noreply@postgresql.org>)
List pgsql-docs
PG Doc comments form <noreply@postgresql.org> writes:
> The reference page about CREATE TRIGGER should indicate if it's allowed to
> create triggers on temp tables.
> This seems to be the supported, but I was wondering what happens with the
> trigger name when created on a temp table.

The page already says

    The name to give the new trigger. This must be distinct from the name
    of any other trigger for the same table.

That seems to be sufficient.  There's no reason to mention temp tables
explicitly, because the rule isn't any different for them.

If you want to confirm that the documentation knows what it's talking
about, you could have a look at the system catalogs.  The table that
stores triggers is pg_trigger, and "\d pg_trigger" in psql shows

=# \d pg_trigger
                 Table "pg_catalog.pg_trigger"
     Column     |     Type     | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
 oid            | oid          |           | not null |
 tgrelid        | oid          |           | not null |
 tgparentid     | oid          |           | not null |
 tgname         | name         |           | not null |
...
Indexes:
    "pg_trigger_oid_index" PRIMARY KEY, btree (oid)
    "pg_trigger_tgconstraint_index" btree (tgconstraint)
    "pg_trigger_tgrelid_tgname_index" UNIQUE CONSTRAINT, btree (tgrelid, tgname)

So the uniqueness constraint is on table's OID + trigger's name.
Schemas don't enter into it.

            regards, tom lane



pgsql-docs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Missing information about CREATE TRIGGER on temporary tables
Next
From: "David G. Johnston"
Date:
Subject: Update wording of INSERT ON CONFLICT "rows proposed for insertion"