Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hFm4x-0006XP-Pq for pgsql-hackers@arkaria.postgresql.org; Sun, 14 Apr 2019 20:50:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hFm4w-0003eE-DU for pgsql-hackers@arkaria.postgresql.org; Sun, 14 Apr 2019 20:50:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hFm4w-0003ap-3H for pgsql-hackers@lists.postgresql.org; Sun, 14 Apr 2019 20:50:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hFm4t-0006Kr-3e for pgsql-hackers@lists.postgresql.org; Sun, 14 Apr 2019 20:50:17 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x3EKo74l030552; Sun, 14 Apr 2019 16:50:07 -0400 From: Tom Lane To: jesper.pedersen@redhat.com cc: Amit Langote , sulamul@gmail.com, PostgreSQL Developers , Peter Eisentraut Subject: Re: COLLATE: Hash partition vs UPDATE In-reply-to: <826e4d52-234a-4d35-73b2-7c6b0a92220e@redhat.com> References: <826e4d52-234a-4d35-73b2-7c6b0a92220e@redhat.com> Comments: In-reply-to Jesper Pedersen message dated "Tue, 09 Apr 2019 08:43:57 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30550.1555275007.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 14 Apr 2019 16:50:07 -0400 Message-ID: <30551.1555275007@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jesper Pedersen writes: > Yeah, that works here - apart from an issue with the test case; fixed in= = > the attached. Couple issues spotted in an eyeball review of that: * There is code that supposes that partsupfunc[] is the last field of ColumnsHashData, eg fcinfo->flinfo->fn_extra =3D MemoryContextAllocZero(fcinfo->flinfo->fn_mcxt, offsetof(ColumnsHashData, partsupfu= nc) + sizeof(FmgrInfo) * nargs); I'm a bit surprised that this patch manages to run without crashing, because this would certainly not allocate space for partcollid[]. I think we would likely be well advised to do - FmgrInfo partsupfunc[PARTITION_MAX_KEYS]; + FmgrInfo partsupfunc[FLEXIBLE_ARRAY_MEMBER]; to make it more obvious that that has to be the last field. Or else drop the cuteness with variable-size allocations of ColumnsHashData. FmgrInfo is only 48 bytes, I'm not really sure that it's worth the risk of bugs to "optimize" this. * I see collation-less calls of the partsupfunc at both partbounds.c:2931 and partbounds.c:2970, but this patch touches only the first one. How can that be right? regards, tom lane