table partition and column default

Fujii Masao <masao.fujii@gmail.com>

From: Fujii Masao <masao.fujii@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2019-12-25T03:19:04Z
Lists: pgsql-hackers
Hi,

As the document explains, column defaults can be specified separately for
each partition. But I found that INSERT via the partitioned table ignores
that default. Is this expected behavior or bug?

CREATE TABLE test (i INT, j INT) PARTITION BY RANGE (i);
CREATE TABLE test1 PARTITION OF test (j DEFAULT 99) FOR VALUES FROM (1) TO (10);
INSERT INTO test VALUES (1, DEFAULT);
INSERT INTO test1 VALUES (2, DEFAULT);
SELECT * FROM test;
 i |   j
---+--------
 1 | (null)
 2 |     99
(2 rows)

In the above example, INSERT accessing directly to the partition uses
the default, but INSERT via the partitioned table not.

Regards,

-- 
Fujii Masao



Commits

  1. Add note about how each partition's default value is treated, into the doc.