From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: pgsql-bugs@lists.postgresql.org
To: lizardus@ya.ru
Subject: Re: BUG #15855: Using 'nextval' inside INSERT RULE in case of bulk data insertion.
Date: Wed, 19 Jun 2019 18:06:26 +0100
Message-ID: <87fto51pm3.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <15855-52f9fbeb62a30b76@postgresql.org>
References: <15855-52f9fbeb62a30b76@postgresql.org>
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.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)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk, lizardus@ya.ru
Subject: Re: BUG #15855: Using 'nextval' inside INSERT RULE in case of bulk data insertion.
In-Reply-To: <87fto51pm3.fsf@news-spur.riddles.org.uk>
References: <15855-52f9fbeb62a30b76@postgresql.org> <87fto51pm3.fsf@news-spur.riddles.org.uk>
* 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