Table partionning : INSERT with inconsistent return ligne inserted.

From: STERBECQ Didier <didier(dot)sterbecq(at)ratp(dot)fr>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Table partionning : INSERT with inconsistent return ligne inserted.
Date: 2017-10-18 08:24:49
Message-ID: C0685475FF6E374E989150721491820A13FB38DE@SV003314.info.ratp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I use PostgreSQL 9.6 (9.6.3) with table partitioning, when I use INSERT order psql, it does not show the number of lines inserted.
I do not see any information in the version notes from the PostgreSQL documentation, even with the 9.6.5 update, is it some bug ?

Here is a short test case :

--
-- table
--

CREATE TABLE t1_part

( id BIGINT ,
libelle VARCHAR(30 )
)
WITH ( FILLFACTOR = 70 )
TABLESPACE data_1
;

--
-- partitions : 2.
--
CREATE TABLE t1_part_01
( CHECK ( id >= 1 AND id <= 1000 )
)
INHERITS ( t1_part ) ;

CREATE TABLE t1_part_02
( CHECK ( id > 1000 AND id <= 22000000 )
)
INHERITS ( t1_part ) ;

--
-- function of partitionning
--

CREATE FUNCTION t1_part_test_trigger()
RETURNS TRIGGER AS $$
BEGIN
IF NEW.id >= 1 AND NEW.id <= 1000 THEN
INSERT INTO t1_part_01 VALUES (NEW.*);
ELSIF NEW.id > 1000 AND NEW.id <= 22000000 THEN
INSERT INTO t1_part_02 VALUES (NEW.*);
END IF ;
RETURN NULL;
END;
$$
LANGUAGE plpgsql;

--
-- trigger
--

CREATE TRIGGER insert_t1_part
BEFORE INSERT ON t1_part
FOR EACH ROW EXECUTE PROCEDURE t1_part_test_trigger();

--
-- Insert
--

hba=> insert into t1_part values (3000001, '3000001' ) ;
INSERT 0 0 -- should be "INSERT 0 1"

hba=> select * from t1_part ;
id | libelle
---------+----------
3000001 | 3000001
(1 row) -- proof of successful insert.

Thanks by advance.
Didier Sterbecq

Responses

Browse pgsql-general by date

  From Date Subject
Next Message legrand legrand 2017-10-18 09:30:10 Re: Log storage
Previous Message Ivan Sagalaev 2017-10-18 06:18:18 Log storage