Re: BUG #15855: Using 'nextval' inside INSERT RULE in case of bulk data insertion.

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org, lizardus(at)ya(dot)ru
Subject: Re: BUG #15855: Using 'nextval' inside INSERT RULE in case of bulk data insertion.
Date: 2019-06-19 17:06:26
Message-ID: 87fto51pm3.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>>>> "PG" == PG Bug reporting form <noreply(at)postgresql(dot)org> writes:

PG> I use two SQL commands in RULE INSTEAD INSERT. I expect that in
PG> case of bulk data insertion they will be sequentially executed for
PG> each record. I expect that during a bulk insert, they will be
PG> sequentially executed for each record. However, firstly the first
PG> SQL-command is executed all records, then the second for all
PG> records. As a result, I get one value for all 'nextval' calls.

This isn't a bug, it's just how rules work.

Use triggers instead.

https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_rules

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-06-19 17:40:10 Re: BUG #15858: could not stat file - over 4GB
Previous Message Juan José Santamaría Flecha 2019-06-19 16:07:14 Re: BUG #15858: could not stat file - over 4GB