Re: Confusion on Assert() definition

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Егор Будюкин <zhora(dot)budyukin111(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Confusion on Assert() definition
Date: 2025-03-26 14:39:56
Message-ID: 1449617.1742999996@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?UTF-8?B?0JXQs9C+0YAg0JHRg9C00Y7QutC40L0=?= <zhora(dot)budyukin111(at)gmail(dot)com> 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Phillip Diffley 2025-03-26 14:55:06 Re: Replication slot WAL reservation
Previous Message Егор Будюкин 2025-03-26 11:33:56 Confusion on Assert() definition