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: Wed, 1 Apr 2020 16:08:42 +0900
Message-ID: <20200401070842.GD142683@paquier.xyz> (raw)
In-Reply-To: <20200328125303.4me6vetvzgebobw5@localhost>
References: <16325-809194cf742313ab@postgresql.org>
	<20200328125303.4me6vetvzgebobw5@localhost>

On Sat, Mar 28, 2020 at 01:53:03PM +0100, Dmitry Dolgov wrote:
> Thanks for reporting! Looks like transformPartitionBoundValue needs to
> check that the source collumn is collatable, then we get more expected
> result:
> 
>     =# create table part_coll partition of parted for values in ('1' collate "POSIX");
>     ERROR:  42804: collations are not supported by type integer

We have here a side effect of 7c079d74, that has given the possibility
to pass down general expressions for partition bounds.

> +        if (type_is_collatable(colType))
> +        {
> +            if (!OidIsValid(exprCollOid))
> +                ereport(ERROR,
> +                        (errcode(ERRCODE_INDETERMINATE_COLLATION),
> +                         errmsg("could not determine which collation to use for partition expression"),
> +                         errhint("Use the COLLATE clause to set the collation explicitly.")));
> +        }
> +        else
> +        {
> +            if (OidIsValid(exprCollOid))
> +                ereport(ERROR,
> +                        (errcode(ERRCODE_DATATYPE_MISMATCH),
> +                         errmsg("collations are not supported by type %s",
> +                                format_type_be(colType))));
> +        }
> +

It seems to me that the first error cannot happen, and should not
happen.  When the expression is transformed, there is a lookup at the
collation used via transformCollateClause() -> LookupCollation() ->
get_collation_oid() which would never return an invalid OID if the
collation exists, throwing an error instead.  The reason why a similar
check exists in tablecmds.c is that there can be a collation override,
no?
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (9+ messages)  latest in thread

Message-ID: <20200401070842.GD142683@paquier.xyz>
Permalink:  ../20200401070842.GD142683@paquier.xyz/
Also on:    postgresql.org/message-id/20200401070842.GD142683@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: <20200401070842.GD142683@paquier.xyz>
  References: <16325-809194cf742313ab@postgresql.org> <20200328125303.4me6vetvzgebobw5@localhost> <20200401070842.GD142683@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