pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: szittya314@gmail.com
Subject: BUG #17554: when i use rule on table which have serial column, the nextval exec twice.
Date: Mon, 18 Jul 2022 09:55:26 +0000
Message-ID: <17554-3a1ae834cdb577ac@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      17554
Logged by:          Szabolcs Klement
Email address:      szittya314@gmail.com
PostgreSQL version: 14.4
Operating system:   Rocky Linux release 8.5 (Green Obsidian)
Description:        

Hi,
(sorry my poor english)
the problem is in 10-14 postgresql too.

this a sample what make gap in sequence:
create table aa (id serial primary key,tt text);
create or replace function fika1(p1 aa) returns boolean language sql as
$body$
	select (p1.id)::boolean;
$body$;
create or replace rule birkman as on insert to aa do select fika1(new);

insert into aa (tt) values ('uu');
select * from aa order by id;

(when inner the function isnt reference a new record, there isnt gap:
create or replace function fika1(p1 aa) returns boolean language sql as
$body$ select true;	$body$;
)

inner the function then p1.id is always X, but after the insert in the new
record is X-1;

i try with plpgsql function:
create or replace function fika1(p1 aa) returns boolean language plpgsql
as
$body$
  begin
  	raise notice 'id:%', p1.id;
	return true;	--I didnt referenced the new value
  end;
$body$;

Best regards
Szabolcs



view thread (2+ messages)  latest in thread

Message-ID: <17554-3a1ae834cdb577ac@postgresql.org>
Permalink:  ../17554-3a1ae834cdb577ac@postgresql.org/
Also on:    postgresql.org/message-id/17554-3a1ae834cdb577ac@postgresql.org

 · 

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: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, szittya314@gmail.com
  Subject: Re: BUG #17554: when i use rule on table which have serial column, the nextval exec twice.
  In-Reply-To: <17554-3a1ae834cdb577ac@postgresql.org>

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

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