[HACKERS] Range Partitioning behaviour - query

Поиск
Список
Период
Сортировка
От Venkata B Nagothi
Тема [HACKERS] Range Partitioning behaviour - query
Дата
Msg-id CAEyp7J-gS3ixVUgdBYaxMc3w24W=wE_aVyPmVLL9nvWr6d08-A@mail.gmail.com
обсуждение исходный текст
Ответы Re: [HACKERS] Range Partitioning behaviour - query  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Список pgsql-hackers
Hi Hackers,

I have noticed the following behaviour in range partitioning which i felt is not quite correct (i missed reporting this) -

I have tested by creating a date ranged partition.

I created the following table.

db03=# CREATE TABLE orders (
        o_orderkey INTEGER,
        o_custkey INTEGER,
        o_orderstatus CHAR(1),
        o_totalprice REAL,
        o_orderdate DATE,
        o_orderpriority CHAR(15),
        o_clerk CHAR(15),
        o_shippriority INTEGER,
        o_comment VARCHAR(79)) partition by range (o_orderdate);
CREATE TABLE

Created the following partitioned tables :

db03=# CREATE TABLE orders_y1992
    PARTITION OF orders FOR VALUES FROM ('1992-01-01') TO ('1992-12-31');                     CREATE TABLE

db03=# CREATE TABLE orders_y1993
    PARTITION OF orders FOR VALUES FROM ('1993-01-01') TO ('1993-12-31');
CREATE TABLE

db03=# CREATE TABLE orders_y1994
   PARTITION OF orders FOR VALUES FROM ('1994-01-01') TO ('1994-12-31');
CREATE TABLE

The rows with the date "1993-12-31" gets rejected as shown below -

db03=# copy orders from '/data/orders.csv' delimiter '|';
ERROR:  no partition of relation "orders" found for row
DETAIL:  Failing row contains (353, 8878, F, 273342, 1993-12-31, 5-LOW          , Clerk#000002241, 0,  quiet ideas sleep. even instructions cajole slyly. silently spe).
CONTEXT:  COPY orders, line 89: "353|8878|F|273342|1993-12-31|5-LOW          |Clerk#000002241|0| quiet ideas sleep. even instructions..."

I would want the partition "orders_y1993" to accept all the rows with the date 1993-12-31.

To confirm this behaviour, I did another simple test with numbers -

I created two partitioned tables with range values from 1 to 5 and from 6 to 10 as shown below -

db03=# create table test_part ( col int) partition by range (col);
CREATE TABLE
db03=# create table test_part_5 partition of test_part for values from (1) to (5);
CREATE TABLE
db03=# create table test_part_10 partition of test_part for values from (6) to (10);
CREATE TABLE

When i try to insert value 5, it gets rejected as shown below

db03=# insert into test_part values (5);
ERROR:  no partition of relation "test_part" found for row
DETAIL:  Failing row contains (5).

The table partition "test_part_5" is not supposed to accept value 5 ? 

Am i missing anything here ? 

Regards,

Venkata B N
Database Consultant

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Make subquery alias optional in FROM clause
Следующее
От: Andres Freund
Дата:
Сообщение: Re: [HACKERS] Make subquery alias optional in FROM clause