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 1lxyUL-0006v8-1S for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Jun 2021 21:08:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lxyUJ-0006j2-2z for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Jun 2021 21:08:15 +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 1lxyUI-0006it-Si for pgsql-bugs@lists.postgresql.org; Mon, 28 Jun 2021 21:08:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lxyUG-0006e8-DA for pgsql-bugs@lists.postgresql.org; Mon, 28 Jun 2021 21:08:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15SL891t342123; Mon, 28 Jun 2021 17:08:09 -0400 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org, Peter Eisentraut Subject: Re: BUG #17076: Server crashes on composing an error message about invalid modulus for a new table partition In-reply-to: <17076-89a16ae835d329b9@postgresql.org> References: <17076-89a16ae835d329b9@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 28 Jun 2021 16:00:00 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <342121.1624914489.1@sss.pgh.pa.us> Date: Mon, 28 Jun 2021 17:08:09 -0400 Message-ID: <342122.1624914489@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > When executing the following query (based on create_table.sql): > CREATE TABLE hash_parted (a int) PARTITION BY HASH (a); > CREATE TABLE hpart_1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, > REMAINDER 0); > CREATE TABLE hpart_3 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 200, > REMAINDER 2); > CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS > 150, REMAINDER 3); > Server crashes with the following stack: So this is evidently the fault of efbfb6424, which isn't accounting for the possibility that the next remainder has no associated partition. That results in boundinfo->indexes[offset + 1] being -1, whereupon we pass garbage to get_rel_name() and get back a NULL. I think the patch has got more problems than that too, as it's far from clear why the next remainder would have anything to do with the next larger modulus. IOW I suspect that when it does manage to print a partition name without crashing, it's very likely to print the wrong partition. I'm inclined to think we should just revert efbfb6424, and maybe try again some other time. regards, tom lane