pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16325: Assert failure on partitioning by int for a text value with a collation
Date: Tue, 7 Apr 2020 16:49:44 +0900
Message-ID: <20200407074944.GA6655@paquier.xyz> (raw)
In-Reply-To: <20200403152910.rsdc2yg7bisqaltb@localhost>
References: <16325-809194cf742313ab@postgresql.org>
	<20200328125303.4me6vetvzgebobw5@localhost>
	<20200401070842.GD142683@paquier.xyz>
	<20200401120117.qkmjxi3xrumbnd3s@localhost>
	<20200402020150.GA2803@paquier.xyz>
	<20200403152910.rsdc2yg7bisqaltb@localhost>

On Fri, Apr 03, 2020 at 05:29:10PM +0200, Dmitry Dolgov wrote:
> Thanks for the suggestion. It's not strictly related to the fix I guess,
> but of course you're right, and we can indeed improve this part and
> replace the check with an assert.

Thanks for the new version of the patch.  I have been playing a bit
today, and finished with the version attached.  Some comments have
been tweaked, and I have moved the test in the block with the other
invalid cases for consistency, adding an extra test able to trigger a
similar error within the transformation step where a parse context
exists.  It is a bit late now so I cannot push that today, but I'll
do that tomorrow.
--
Michael

Attachments:

part_value_collations_v4.patch (text/x-diff, 3.0K) download diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 2b9598c2da..a48b4b0d3a 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -4081,8 +4081,20 @@ transformPartitionBoundValue(ParseState *pstate, Node *val, { Oid exprCollOid = exprCollation(value); - if (OidIsValid(exprCollOid) && - exprCollOid != DEFAULT_COLLATION_OID && + /* + * Note that the expression transformation above ensures the + * existence of the collation as a lookup of its name has been + * done. + */ + Assert(OidIsValid(exprCollOid)); + + if (!type_is_collatable(colType)) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("collations are not supported by type %s", + format_type_be(colType)))); + + if (exprCollOid != DEFAULT_COLLATION_OID && exprCollOid != partCollation) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out index 6acf31725f..1c72f23bc9 100644 --- a/src/test/regress/expected/create_table.out +++ b/src/test/regress/expected/create_table.out @@ -652,6 +652,12 @@ CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (genera ERROR: set-returning functions are not allowed in partition bound LINE 1: ...expr_fail PARTITION OF list_parted FOR VALUES IN (generate_s... ^ +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ('1' collate "POSIX"); +ERROR: collations are not supported by type integer +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((1+1) collate "POSIX"); +ERROR: collations are not supported by type integer +LINE 1: ...ail PARTITION OF list_parted FOR VALUES IN ((1+1) collate "P... + ^ -- syntax does not allow empty list of values for list partitions CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN (); ERROR: syntax error at or near ")" diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql index a670438c48..9b1adcb8ad 100644 --- a/src/test/regress/sql/create_table.sql +++ b/src/test/regress/sql/create_table.sql @@ -549,6 +549,8 @@ CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(so CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(1)); CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((select 1)); CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (generate_series(4, 6)); +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ('1' collate "POSIX"); +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((1+1) collate "POSIX"); -- syntax does not allow empty list of values for list partitions CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN ();
signature.asc (application/pgp-signature, 832B) download

view thread (9+ messages)  latest in thread

Message-ID: <20200407074944.GA6655@paquier.xyz>
Permalink:  ../20200407074944.GA6655@paquier.xyz/
Also on:    postgresql.org/message-id/20200407074944.GA6655@paquier.xyz

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: michael@paquier.xyz, 9erthalion6@gmail.com, exclusion@gmail.com
  Subject: Re: BUG #16325: Assert failure on partitioning by int for a text value with a collation
  In-Reply-To: <20200407074944.GA6655@paquier.xyz>
  References: <16325-809194cf742313ab@postgresql.org> <20200328125303.4me6vetvzgebobw5@localhost> <20200401070842.GD142683@paquier.xyz> <20200401120117.qkmjxi3xrumbnd3s@localhost> <20200402020150.GA2803@paquier.xyz> <20200403152910.rsdc2yg7bisqaltb@localhost> <20200407074944.GA6655@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox