Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJpBK-0001t3-Ky for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Apr 2020 02:02:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jJpBI-0005cU-7P for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Apr 2020 02:02:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJpBH-0005bS-1f for pgsql-bugs@lists.postgresql.org; Thu, 02 Apr 2020 02:02:07 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJpBE-0002XD-9b for pgsql-bugs@lists.postgresql.org; Thu, 02 Apr 2020 02:02:05 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 3206B3AA; Wed, 1 Apr 2020 22:02:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 01 Apr 2020 22:02:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=L4heiZxkhFOPBrmNq/gHLB/MFwn x27gU0z4ZC96MuBM=; b=I0zD7+F2JnOx5r4ifh4Qnmgcs+c8VQATa6hri7JMkk6 7kA8bJzWpKBUKJFCkLuQcumhYos795vn16ThOBWuQsT7aLHICv0A8smGRPXFQVdn oamwusfG3/UP/2RJp6d9x4Cyy9gMMI63h950SlVNzYoRSg5mV01SsIsScnnvr6cE CyPAdgmQLtKqKZ6z1vBtOstsR6Z6h2ctRBTrPSsf4tU7FHtmcpsRIjQd0+HnnQI7 nIAUTITuQISDxq8QpxFp9urvbT2ZPh8Gn5sPq+IPfAVWR95gr4I8KlN5un7B42gG Y1kueDXPslkQNew1hr9GXnNCq9F4aovwTvKowyy9rYg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=L4heiZ xkhFOPBrmNq/gHLB/MFwnx27gU0z4ZC96MuBM=; b=qX2M6Ng0EEowj8WVrkA8J8 ZXkHHStr/IPgO65EQrPuIwhrmnR3VX4OntdkJzYMvmqDOPkFj/NVKykAFIPmXlAY Y8siwaEzK4fzAy1bsgHTAfKy2K2MSkFJ788lXgKqV19d8qbGNw2t2kY+UvydnQlK C01EjaprHY0rhbgkVXldZs/9ssS7n+Uc3PsP5qtYOUTA7I0EcqKl8yBkV7blF9Y+ W9uRt+3C/UIa9KtAbvAlxv7nKI0ALEkay8AfWr4P/KLg4dL9nowCMYCst9bxY2M6 Y9Zk1zsEr7tJwH/IdznXCfkDv2JPcgr3c83LK4FF20/eenVRiU+jmzYwvSUg/rAQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrtdefgdehhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvf fukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhi vghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecukfhppeduudekrddvge durddvgeekrddvvdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: from paquier.xyz (mp76f1f8e3.ap.nuro.jp [118.241.248.227]) by mail.messagingengine.com (Postfix) with ESMTPA id E69A3328005A; Wed, 1 Apr 2020 22:01:59 -0400 (EDT) Date: Thu, 2 Apr 2020 11:01:50 +0900 From: Michael Paquier To: Dmitry Dolgov <9erthalion6@gmail.com> Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16325: Assert failure on partitioning by int for a text value with a collation Message-ID: <20200402020150.GA2803@paquier.xyz> References: <16325-809194cf742313ab@postgresql.org> <20200328125303.4me6vetvzgebobw5@localhost> <20200401070842.GD142683@paquier.xyz> <20200401120117.qkmjxi3xrumbnd3s@localhost> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="TB36FDmn/VVEgNH/" Content-Disposition: inline In-Reply-To: <20200401120117.qkmjxi3xrumbnd3s@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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? >=20 > 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 !=3D DEFAULT_COLLATION_OID && > exprCollOid !=3D 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 --TB36FDmn/VVEgNH/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl6FR44ACgkQnvQgOdby QH1OEBAAoeclALVAUN4IHOuHmXGYMyKNQADN6AQWw0DD2qmCfAeXTUReTEfqSn9w E85i0KIiIBXt3tnrzlRVPxONEDVmXEIBfPNegHg79hKfp/UIuEnjwg6flALqqnjy e8qqRwdgPXREeXK/6liO4tVSdSElqteDR25CQ+44zKh4jVlwhW67pfj8ewLeZFKi g9OycC5qdoHzLyCGa38LznmhMTD8oawFcgfqBj3EM0WZ+RQP+qeujqEm2VAaojEv cCFP5Eu3fTNIK0N5UTvxTVP3hLO+kNn4uW/KGLU4MMJAvWpvPZXlhXzreiq4zM3o wJXa5KTHULjsEktQ8NpGiXxpAqW+/kdkoWunMBeQRNHKvzcRX8Qn3jEh3uVMTUgN d9PHx8Hc5SuE1P7Ly0mTlAKhc5e3VGnkhVEWE5WlfwefOTkteFjUzG4j66oiIQ9/ jzgpt5jvlHh9tkCCGrCpgrkKL+sEVAMGIIKaKMze5NEVF/uStUPzgU8i09eYY8Ld OBVqTFoi/aOK22h1WZqY79t9vm2WRoNdw3WZoRxGQfJLfyYlZW2py1Z/HyMFSovI 1vQbwZ3QKPSDqa4fFfHNaqEHycDoFZIZYw07qU9EizGPb7V3LutLuEn9lcqmiZvI 7diLUtNqijzNV1IlFhNa5ySmOxGpJb5z0J0AmWh1o+hCptfKWO4= =EF/c -----END PGP SIGNATURE----- --TB36FDmn/VVEgNH/--