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 1txRvE-009VpR-Ha for pgsql-general@arkaria.postgresql.org; Wed, 26 Mar 2025 14:40:00 +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 1txRvD-004MCy-8d for pgsql-general@arkaria.postgresql.org; Wed, 26 Mar 2025 14:39:59 +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 1txRvC-004MCj-Ue for pgsql-general@lists.postgresql.org; Wed, 26 Mar 2025 14:39:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1txRvB-001Fhu-1K for pgsql-general@lists.postgresql.org; Wed, 26 Mar 2025 14:39:58 +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 52QEdu3w1449619; Wed, 26 Mar 2025 10:39:56 -0400 From: Tom Lane To: =?UTF-8?B?0JXQs9C+0YAg0JHRg9C00Y7QutC40L0=?= cc: pgsql-general@lists.postgresql.org Subject: Re: Confusion on Assert() definition In-reply-to: References: Comments: In-reply-to =?UTF-8?B?0JXQs9C+0YAg0JHRg9C00Y7QutC40L0=?= message dated "Wed, 26 Mar 2025 14:33:56 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1449616.1742999996.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 26 Mar 2025 10:39:56 -0400 Message-ID: <1449617.1742999996@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?UTF-8?B?0JXQs9C+0YAg0JHRg9C00Y7QutC40L0=3D?=3D writes: > There's something about the definition of Assert() in postgres that I > don't really understand. Asserts are meant to be used for "can't happen" cases that would represent programming bugs. As such, they are made to do something in debug builds but be no-ops in production builds. If you think there's actually a realistic chance of the case happening in a production context, you should use a regular if-test-and-ereport instead of an Assert. regards, tom lane