pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15100: sequence behavior on failed insert to a partitioned table
2+ messages / 2 participants
[nested] [flat]
* BUG #15100: sequence behavior on failed insert to a partitioned table
@ 2018-03-07 11:29 PG Bug reporting form <noreply@postgresql.org>
2018-03-07 11:42 ` Re: BUG #15100: sequence behavior on failed insert to a partitioned table Sergei Kornilov <sk@zsrv.org>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2018-03-07 11:29 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: kassai1972@gmail.com
The following bug has been logged on the website:
Bug reference: 15100
Logged by: Istvan Kassai
Email address: kassai1972@gmail.com
PostgreSQL version: 10.3
Operating system: linux
Description:
Hi!
I started to deal with the new declarative table partitioning in 10.
I found that a failed insert (due to the field I've tried to insert is out
of partition range) also increments the sequence of the base table, even if
the insert is rejected.
A simple sample:
Column | Type | Collation | Nullable |
Default | Storage | Stats target | Description
----------+------------------------+-----------+----------+-----------------------------------------+----------+--------------+-------------
sor_azon | integer | | not null |
nextval('teszt_sor_azon_seq'::regclass) | plain | |
szoveg | character varying(100) | | |
| extended | |
Partition key: RANGE (szoveg)
Partitions: teszt_a FOR VALUES FROM ('a%') TO ('b%'),
teszt_b FOR VALUES FROM ('b%') TO ('c%')
I've inserted two rows to test if it is working well:
o=# insert into teszt (szoveg) values('aladár');
INSERT 0 1
o=# insert into teszt (szoveg) values('béla');
INSERT 0 1
then I inserted an out-of-range value:
o=# insert into teszt (szoveg) values('cicu');
ERROR: no partition of relation "teszt" found for row
DETAIL: Partition key of the failing row contains (szoveg) = (cicu).
It is working as expected.
After it I queried the content for the table:
o=# select * from teszt;
sor_azon | szoveg
----------+--------
1 | aladár
2 | béla
(2 rows)
Seems all is good. BUT!
After it I created a new partition:
o=# CREATE TABLE teszt_c PARTITION OF teszt
FOR VALUES FROM ('c%') TO ('z%');
CREATE TABLE
Then I tried to insert the last recently rejected value again:
o=# insert into teszt (szoveg) values('cicu');
INSERT 0 1
And a query again:
o=# select * from teszt;
sor_azon | szoveg
----------+--------
1 | aladár
2 | béla
4 | cicu
(3 rows)
As you can see the sor_azon isn't continous. The #3 is missing.
As I think the sequence hasn't rolled back after a failed insert.
I'm not sure is it a bug, but it is better you know about it.
bye
Istvan
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #15100: sequence behavior on failed insert to a partitioned table
2018-03-07 11:29 BUG #15100: sequence behavior on failed insert to a partitioned table PG Bug reporting form <noreply@postgresql.org>
@ 2018-03-07 11:42 ` Sergei Kornilov <sk@zsrv.org>
0 siblings, 0 replies; 2+ messages in thread
From: Sergei Kornilov @ 2018-03-07 11:42 UTC (permalink / raw)
To: kassai1972@gmail.com <kassai1972@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
<div>Hello</div><div>This is not bug. Sequences are never rollback by design.</div><div> </div><div>https://www.postgresql.org/docs/current/static/sql-createsequence.html</div><div>> Because <code>nextval</code> and <code>setval</code> calls are never rolled back, sequence objects cannot be used if <span>“<span>gapless</span>”</span> assignment of sequence numbers is needed.</div><div> </div><div>regards, Sergei</div>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-03-07 11:42 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07 11:29 BUG #15100: sequence behavior on failed insert to a partitioned table PG Bug reporting form <noreply@postgresql.org>
2018-03-07 11:42 ` Sergei Kornilov <sk@zsrv.org>
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