Skip site navigation (1) Skip section navigation (2)

BUG #2857: Sequence and table partitioning

From: "Tomislav Karastojkovic" <karastojko(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2857: Sequence and table partitioning
Date: 2006-12-22 09:16:59
Message-ID: 200612220916.kBM9GxKX032351@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      2857
Logged by:          Tomislav Karastojkovic
Email address:      karastojko(at)gmail(dot)com
PostgreSQL version: 8.1.4, 8.2.0
Operating system:   Linux
Description:        Sequence and table partitioning
Details: 

Sequence does not increase by 1 when tables is partitioned!
For example, let define 'parent' and 'child' tables, with column 'id' of
type 'serial':

CREATE TABLE parent(id serial, message text);
CREATE TABLE child() INHERITS(parent);
ALTER TABLE child ALTER id DROP DEFAULT;

Default value is dropped from the child table, so sequence is used only in
the 'parent' table.
If we set a rule

CREATE OR REPLACE RULE r AS ON INSERT TO parent DO INSTEAD INSERT INTO child
VALUES(NEW.id, NEW.message);

then each inserting into table 'parent' increases sequence 'parent_id_seq'
by 1, as it should. But if we add a condition for 'id' when setting the rule
like

CREATE OR REPLACE RULE r AS ON INSERT TO parent WHERE id>=1 AND id <= 100 DO
INSTEAD INSERT INTO child VALUES(NEW.id, NEW.message);

then the sequence is increasing by 5 when inserting into 'parent' table.
This seems to be a bug.

Responses

pgsql-bugs by date

Next:From: Robert LockeDate: 2006-12-22 10:39:19
Subject: BUG #2858: postgres periodically restarts (problem with MemoryContextAllocZeroAligned)...
Previous:From: Steve LangridgeDate: 2006-12-22 08:35:55
Subject: BUG #2856: Jdbc 4 connector running on JDK 1.6 should not raise exception for getClientInfo/setClientInfo

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group