pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
CREATE TRIGGER documentation inconsistensies
3+ messages / 3 participants
[nested] [flat]

* CREATE TRIGGER documentation inconsistensies
@ 2023-08-24 07:50 PG Doc comments form <noreply@postgresql.org>
  2023-08-24 09:27 ` Re: CREATE TRIGGER documentation inconsistensies Erik Wienhold <ewie@ewie.name>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Doc comments form @ 2023-08-24 07:50 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org; +Cc: at@mtc.md

The following documentation comment has been logged on the website:

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

In PostgreSQL 14 and 15 (previous versions I've not checked) is stated that
CREATE TRIGGER statement is as follows:

CREATE [OR REPLACE] [CONSTRAINT] TRIGGER

however while CREATE TRIGGER works correctly the CREATE OR REPLACE TRIGGER
construction leads to

SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "TRIGGER"

looks like CREATE TRIGGER doesn't support OR REPLACE, but documentation is
then incorrect.


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

* Re: CREATE TRIGGER documentation inconsistensies
  2023-08-24 07:50 CREATE TRIGGER documentation inconsistensies PG Doc comments form <noreply@postgresql.org>
@ 2023-08-24 09:27 ` Erik Wienhold <ewie@ewie.name>
  2023-08-25 18:09   ` Re: CREATE TRIGGER documentation inconsistensies Andrei Tihonovschi <at@mtc.md>
  0 siblings, 1 reply; 3+ messages in thread

From: Erik Wienhold @ 2023-08-24 09:27 UTC (permalink / raw)
  To: at@mtc.md; pgsql-docs@lists.postgresql.org

> On 24/08/2023 09:50 CEST PG Doc comments form <noreply@postgresql.org> wrote:
>
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/14/sql-createtrigger.html
> Description:
>
> In PostgreSQL 14 and 15 (previous versions I've not checked) is stated that
> CREATE TRIGGER statement is as follows:
>
> CREATE [OR REPLACE] [CONSTRAINT] TRIGGER
>
> however while CREATE TRIGGER works correctly the CREATE OR REPLACE TRIGGER
> construction leads to
>
> SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "TRIGGER"
>
> looks like CREATE TRIGGER doesn't support OR REPLACE, but documentation is
> then incorrect.

Works for me on 14.9 and 15.4:

	BEGIN;
	CREATE TABLE mytbl (f1 int);
	CREATE FUNCTION mytrigger()
	  RETURNS trigger
	  LANGUAGE plpgsql
	  AS $$ BEGIN RETURN null; END $$;
	CREATE OR REPLACE TRIGGER mytrig
	  BEFORE INSERT
	  ON mytbl
	  EXECUTE FUNCTION mytrigger();
	COMMIT;

CREATE OR REPLACE TRIGGER was added in 14.  Did you test on an older version?

--
Erik





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

* Re: CREATE TRIGGER documentation inconsistensies
  2023-08-24 07:50 CREATE TRIGGER documentation inconsistensies PG Doc comments form <noreply@postgresql.org>
  2023-08-24 09:27 ` Re: CREATE TRIGGER documentation inconsistensies Erik Wienhold <ewie@ewie.name>
@ 2023-08-25 18:09   ` Andrei Tihonovschi <at@mtc.md>
  0 siblings, 0 replies; 3+ messages in thread

From: Andrei Tihonovschi @ 2023-08-25 18:09 UTC (permalink / raw)
  To: Erik Wienhold <ewie@ewie.name>; +Cc: pgsql-docs@lists.postgresql.org

Thanks for clarifying, Erik.

That was my fault. I was absolutely sure I've upgraded PostgreSQL to v.14 but actually I've had v.13 running.
After upgrading to v.14 the CREATE OR REPLACE TRIGGER construction works as it was stated in the documentation.

Thanks again.

Sent by from my Android device.


24 августа 2023 г., 12:27, Erik Wienhold написал (-а):
On 24/08/2023 09:50 CEST PG Doc comments form <noreply@postgresql.org> wrote:

The following documentation comment has been logged on the website:

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

In PostgreSQL 14 and 15 (previous versions I've not checked) is stated that
CREATE TRIGGER statement is as follows:

CREATE [OR REPLACE] [CONSTRAINT] TRIGGER

however while CREATE TRIGGER works correctly the CREATE OR REPLACE TRIGGER
construction leads to

SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "TRIGGER"

looks like CREATE TRIGGER doesn't support OR REPLACE, but documentation is
then incorrect.

Works for me on 14.9 and 15.4:

BEGIN;
CREATE TABLE mytbl (f1 int);
CREATE FUNCTION mytrigger()
  RETURNS trigger
  LANGUAGE plpgsql
  AS $$ BEGIN RETURN null; END $$;
CREATE OR REPLACE TRIGGER mytrig
  BEFORE INSERT
  ON mytbl
  EXECUTE FUNCTION mytrigger();
COMMIT;

CREATE OR REPLACE TRIGGER was added in 14.  Did you test on an older version?

--
Erik

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


end of thread, other threads:[~2023-08-25 18:09 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-08-24 07:50 CREATE TRIGGER documentation inconsistensies PG Doc comments form <noreply@postgresql.org>
2023-08-24 09:27 ` Erik Wienhold <ewie@ewie.name>
2023-08-25 18:09   ` Andrei Tihonovschi <at@mtc.md>

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