Re: BUG #15855: Using 'nextval' inside INSERT RULE in case of bulk data insertion. - Mailing list pgsql-bugs

From Andrew Gierth
Subject Re: BUG #15855: Using 'nextval' inside INSERT RULE in case of bulk data insertion.
Date
Msg-id 87fto51pm3.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to BUG #15855: Using 'nextval' inside INSERT RULE in case of bulk data insertion.  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
>>>>> "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)



pgsql-bugs by date:

Previous
From: Juan José Santamaría Flecha
Date:
Subject: Re: BUG #15858: could not stat file - over 4GB
Next
From: Tom Lane
Date:
Subject: Re: BUG #15858: could not stat file - over 4GB