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 1jLizc-00032s-TG for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Apr 2020 07:49:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jLizb-00066S-OY for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Apr 2020 07:49:55 +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 1jLiza-00066K-Qh for pgsql-bugs@lists.postgresql.org; Tue, 07 Apr 2020 07:49:55 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLizY-0000vp-3Y for pgsql-bugs@lists.postgresql.org; Tue, 07 Apr 2020 07:49:53 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 8099B5C02BE; Tue, 7 Apr 2020 03:49:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 07 Apr 2020 03:49:49 -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=WaaNR61ghG10mipRv66ROgqTgm4 Pz5JQwf8lrQb72uY=; b=JK4BHKqMR7igK+91TF8Q8fyppaAcRQmno+N6zno71ET neYSxXCFzLbY7sKNC6924ch6pgnVoUtjgkbTy7v+tnon5ZYfHInVspjsbFjiEU3J bmSpCg68UPOLRd6gnXPrM3NVU6EqmeoQZhKWbhNevqVQNVY6Fb+TzdJzEHc4/r3E 2My3bKqfndvDFyLt8Q1xNSldwJTBkTWOngU7QuxGS6dXcmYBt0Wzx9EJ2ePSEc60 R/Fq1nRKKmoF2x26/tAJ0xT+VA/PK9sonJ6lT44JPSpvg568iJhfHG7YHtohO3m5 za07iSwVefe0msNgBOo5ByHVcskMeD9ILXmjOE3TV2Q== 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=WaaNR6 1ghG10mipRv66ROgqTgm4Pz5JQwf8lrQb72uY=; b=1YH6Icqu7OGLknPemCxQ4F iYDQOBicgiH76gUvQsUqzJa6ZqSvUtzmpU3NmLpKmnrk3gRnDwmYj+erw1hAzU24 Hi2SU3X4TtfSKvOd6/JRYG/iAuzMzD753OQY8Wj/BsmGNiM/Tnaaq7aSfi8Mu+cu yL52UzAJ59Laj73t6u+MSoOonKYyppPfgF81Qi1vlQafMWFA5RouRZoJN9nX81jf tZM6g9+HfqyMpyaiV0YkxMwG1usrtxomTcVvqzh2TLOhJt1dZMb9xY1UpzFJh7Ik MkFg/MzdkZQAUd/vlX5s+OOjoWctm9+Obe4QBJIjjsvlRQmcOhbs7buY3lVLnbmw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudeggdduvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhf fvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucfkphepudduuddrud dtvddrudektddrudekheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 11B28306D517; Tue, 7 Apr 2020 03:49:47 -0400 (EDT) Date: Tue, 7 Apr 2020 16:49:44 +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: <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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="DBIVS5p969aUjpLe" Content-Disposition: inline In-Reply-To: <20200403152910.rsdc2yg7bisqaltb@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --DBIVS5p969aUjpLe Content-Type: multipart/mixed; boundary="uAKRQypu60I7Lcqm" Content-Disposition: inline --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --uAKRQypu60I7Lcqm Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="part_value_collations_v4.patch" Content-Transfer-Encoding: quoted-printable 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, Nod= e *val, { Oid exprCollOid =3D exprCollation(value); =20 - if (OidIsValid(exprCollOid) && - exprCollOid !=3D 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 !=3D DEFAULT_COLLATION_OID && exprCollOid !=3D 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_pa= rted 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/c= reate_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_par= ted 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"); =20 -- syntax does not allow empty list of values for list partitions CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN (); --uAKRQypu60I7Lcqm-- --DBIVS5p969aUjpLe Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl6MMJgACgkQnvQgOdby QH3I0RAAi+2wRr6PE/T+Pd7FPYqgUcEHWjXcSFT8Q8VLBhwUl0kVeHWNrM3ScYni LZdxHcaoCFYbKCuTrciIT0fn1wL9rcI6lsolCFmVnHhUzYM2xOpkf/Z3JKgQhvlX k+W/CLIznwAO7SE5eR30/p85Tro5T5SNGwY0wh265Ii+V30CzKL6VtwkbpjWqnIk ztV/Wx8TCjNQfso1oK4NLAdzUWXEOlT8HMMLk4uG+9l+Mij49Qcix7Jq4RCJh76n ZRtcXRO6ivqh2+cHd+9SF3BufejWqF2Ab6+4bR1HlYCdDcMXm0UzlIp8gqgO4vkq jhNJ7Lh8mFB0A0PXz2ChvGNZJEJEqUkm8eB1fDz2njRjmstZur3JR6newLlQh86w gaC2dUAXWl9SnFexWLsp6kOMw5Uid1W0Q803I12wOvlnNBh5lqoEj0I9CjsxjY2T 6znJ/y6t2S9iMH10b6I1ISPcKuaEphLkBFIvI+x2r5zjpX2I+qoSBIFcourKe3TH 7YS7JG8wPgIvxoC5+wDo7vRRntjBFH6eUDnSZ6Iwc+OiGHM7zQPcPj0B0mDlo9mV zXQ6Gge6MRb9mP+O3gnUv3bCcgsLqoXyv4o3cMbMoNWP2Wx1CRNxfSLstW4xeNl2 1GqG3tTWi2IWhrAAfxS7iRfR8cFNYu5s7dlWJnXJxr7Qf8VxlyE= =1zo4 -----END PGP SIGNATURE----- --DBIVS5p969aUjpLe--