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: Thu, 2 Apr 2020 11:01:50 +0900
Message-ID: <20200402020150.GA2803@paquier.xyz> (raw)
In-Reply-To: <20200401120117.qkmjxi3xrumbnd3s@localhost>
References: <16325-809194cf742313ab@postgresql.org>
	<20200328125303.4me6vetvzgebobw5@localhost>
	<20200401070842.GD142683@paquier.xyz>
	<20200401120117.qkmjxi3xrumbnd3s@localhost>

On Wed, Apr 01, 2020 at 02:01:17PM +0200, Dmitry Dolgov wrote:
> On Wed, Apr 01, 2020 at 04:08:42PM +0900, Michael Paquier wrote:
>> 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?
> 
> Good point, I believe you're right. This means that the fix can be
> reduced as in attachments.

Thanks.

> +		/*
> +		 * No need to check if exprCollOid is invalid, since if it would be,
> +		 * then transformCollateClause will throw an error earlier
> +		 */
> +		if (!type_is_collatable(colType))
> +			ereport(ERROR,
> +					(errcode(ERRCODE_DATATYPE_MISMATCH),
> +					 errmsg("collations are not supported by type %s",
> +							format_type_be(colType))));
> +
>
>  		if (OidIsValid(exprCollOid) &&
>  			exprCollOid != DEFAULT_COLLATION_OID &&
>  			exprCollOid != partCollation)

Another point that could be made is that as we know that we are in the
presence of a CollateExpr() here, and exprCollOid will never be
InvalidOid.  So there could be a point in using an assertion instead
of the check done below making sure that exprCollOid is always valid?
--
Michael

Attachments:

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

view thread (9+ messages)  latest in thread

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