public inbox for [email protected]
help / color / mirror / Atom feedConfusion on Assert() definition
2+ messages / 2 participants
[nested] [flat]
* Confusion on Assert() definition
@ 2025-03-26 11:33 Егор Будюкин <[email protected]>
2025-03-26 14:39 ` Re: Confusion on Assert() definition Tom Lane <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Егор Будюкин @ 2025-03-26 11:33 UTC (permalink / raw)
To: [email protected]
Hi all!
There's something about the definition of Assert() in postgres that I
don't really understand. Refering to src/include/c.h, if
USE_ASSERT_CHECKING is not defined, Assert() is defined to be always
true regardless of FRONTEND? Additionally, I lack understanding of why
Assert() is meant to only be used for debugging when it has a lot of
potential at error intercepting. PipelineDB, for example, has a risk
of few null dereferences because of disabled Assert().
It bugs me that I can't get over something seemingly obvious, so I'd
be very grateful for clarification!
Best regards,
Egor Budyukin,
confused static analysis specialist.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Confusion on Assert() definition
2025-03-26 11:33 Confusion on Assert() definition Егор Будюкин <[email protected]>
@ 2025-03-26 14:39 ` Tom Lane <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2025-03-26 14:39 UTC (permalink / raw)
To: Егор Будюкин <[email protected]>; +Cc: [email protected]
=?UTF-8?B?0JXQs9C+0YAg0JHRg9C00Y7QutC40L0=?= <[email protected]> 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-03-26 14:39 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-26 11:33 Confusion on Assert() definition Егор Будюкин <[email protected]>
2025-03-26 14:39 ` Tom Lane <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox