Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tGJlt-002Cgd-Ik for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Nov 2024 15:16:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tGJls-00FmfE-6p for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Nov 2024 15:16:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFroX-005d2D-4F for pgsql-hackers@lists.postgresql.org; Tue, 26 Nov 2024 09:24:57 +0000 Received: from vserv.cifnet.com ([208.76.170.74]) by makus.postgresql.org with esmtps (TLS1.0) tls TLS_RSA_WITH_AES_256_CBC_SHA (Exim 4.94.2) (envelope-from ) id 1tFroS-003xTB-V2 for pgsql-hackers@postgresql.org; Tue, 26 Nov 2024 09:24:55 +0000 Received: from LU-NOTEBOOK ([37.232.161.105]) (authenticated bits=0) by vserv.cifnet.com (8.13.8/8.13.8) with ESMTP id 4AQ9OhWt090703 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Tue, 26 Nov 2024 03:24:46 -0600 (CST) (envelope-from pgsql-hackers@dima.nikitin.name) Date: Tue, 26 Nov 2024 12:24:37 +0300 From: Dmitry Nikitin Reply-To: Dmitry Nikitin Message-ID: <172136986.20241126122437@dima.nikitin.name> X-Confirm-Reading-To: pgsql-hackers@dima.nikitin.name Disposition-Notification-To: pgsql-hackers@dima.nikitin.name Return-Receipt-To: pgsql-hackers@dima.nikitin.name To: Alvaro Herrera CC: pgsql-hackers@postgresql.org Subject: Re: [PATCH] Missing Assert in the code In-Reply-To: <202411251951.hblpeyqnncy2@alvherre.pgsql> References: <196971412.20241125103227@dima.nikitin.name> <202411251951.hblpeyqnncy2@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Alvaro, Monday, November 25, 2024, 10:51:31 PM, you wrote: AH> Hmm, I think if we believe this to be really possible, we should have an AH> 'if/elog' test (or maybe a full ereport with ERRCODE_DATA_CORRUPTED AH> errcode) rather than an assertion. I think the assertion adds nothing AH> of value here, but maybe an 'if' test would. I don't mind of 'if' however it's not clear for me what to follow on other (error) branch of that 'if'. AH> Did you examine the other callers of PageGetMaxOffsetNumber()? It's a AH> large bunch. Mostly it used in loops. So some code will be gracefully skipped and that's it. However the case discussed is different because -1 index of an array will be accessed. Which is much worse than a bare assertion at least. -- Best regards, Dmitry mailto:pgsql-hackers@dima.nikitin.name