public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: Missing information about CREATE TRIGGER on temporary tables
Date: Tue, 08 Mar 2022 11:39:09 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <164675354342.1369298.14513879086676370656@wrigleys.postgresql.org>
References: <164675354342.1369298.14513879086676370656@wrigleys.postgresql.org>

PG Doc comments form <[email protected]> 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






reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Missing information about CREATE TRIGGER on temporary tables
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox