Re: BUG #14666: Question on money type as the key of partitioned table

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: tianbing(at)highgo(dot)com
Cc: PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14666: Question on money type as the key of partitioned table
Date: 2017-05-24 14:54:30
Message-ID: CAB7nPqS65UhQG34AG7KACB_kLaFSB=M1iNMSrR531CptD8AMCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, May 23, 2017 at 10:45 PM, <tianbing(at)highgo(dot)com> wrote:
> When I use the money type as the key to create the partition table as
> follows:
>
> postgres=# create table test(m money) partition by list(m);
> CREATE TABLE
> postgres=# create table test_1 partition of test for values in (10);
> CREATE TABLE
>
> Partition bounds without apostrophe can be created, but it store the null
> value,not '10' value.
>
> In fact, Correct grammar for creating partition is with apostrophe like
> this:
> postgres=# create table test_1 partition of test for values in ('10');
>
> But the first creating partition without apostrophe should report an error
> like "ERROR: operator does not exist: money = integer" as adding a check
> constraint.
>
> Looking forward to your reply.

This looks like a justified complain to me, so added to the open item
list. Those INSERTs should work:
=# insert into test_1 values (10);
ERROR: 23514: new row for relation "test_1" violates partition constraint
DETAIL: Failing row contains ($10.00).
LOCATION: ExecConstraints, execMain.c:2037
=# insert into test values (10);
ERROR: 23514: no partition of relation "test" found for row
DETAIL: Partition key of the failing row contains (m) = ($10.00).
LOCATION: ExecFindPartition, execMain.c:3343
=# insert into test values ('10');
ERROR: 23514: no partition of relation "test" found for row
DETAIL: Partition key of the failing row contains (m) = ($10.00).
LOCATION: ExecFindPartition, execMain.c:3343
The shape of the partition definition looks broken.
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2017-05-24 15:39:38 Re: Can't restore view with pg_restore
Previous Message Robert Haas 2017-05-24 14:52:37 Re: [HACKERS] Concurrent ALTER SEQUENCE RESTART Regression