public inbox for [email protected]  
help / color / mirror / Atom feed
Missing information about CREATE TRIGGER on temporary tables
3+ messages / 3 participants
[nested] [flat]

* Missing information about CREATE TRIGGER on temporary tables
@ 2022-03-08 15:32  PG Doc comments form <[email protected]>
  0 siblings, 2 replies; 3+ messages in thread

From: PG Doc comments form @ 2022-03-08 15:32 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/sql-createtrigger.html
Description:

To be confirmed by the developer community...
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.
It appears that no conflict can occur with other processes, and the same
trigger name can be used by different processes.
Checking the system tables, it appears that the trigger is created in user's
pg_my_temp_schema() ...


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Missing information about CREATE TRIGGER on temporary tables
@ 2022-03-08 16:38  David G. Johnston <[email protected]>
  parent: PG Doc comments form <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: David G. Johnston @ 2022-03-08 16:38 UTC (permalink / raw)
  To: Sebastien Flaesch <[email protected]>; Pg Docs <[email protected]>

On Tue, Mar 8, 2022 at 9:25 AM PG Doc comments form <[email protected]>
wrote:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/14/sql-createtrigger.html
> Description:
>
> To be confirmed by the developer community...
> 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.
> It appears that no conflict can occur with other processes, and the same
> trigger name can be used by different processes.
> Checking the system tables, it appears that the trigger is created in
> user's
> pg_my_temp_schema() ...
>

Assuming this was moderated and so delayed.  Answered on the -sql list
email thread:

https://www.postgresql.org/message-id/CAKFQuwZNZzgpo%2BP8bF6HG%3DVMq9ZZaw2kpvpgq1KaaL59NFVUTw%40mail...

In short, temporary tables are tables, and the naming behavior is
documented on this page.

David J.


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Missing information about CREATE TRIGGER on temporary tables
@ 2022-03-08 16:39  Tom Lane <[email protected]>
  parent: PG Doc comments form <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2022-03-08 16:39 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

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






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-03-08 16:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 15:32 Missing information about CREATE TRIGGER on temporary tables PG Doc comments form <[email protected]>
2022-03-08 16:38 ` David G. Johnston <[email protected]>
2022-03-08 16:39 ` Tom Lane <[email protected]>

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