Does the "don't use errors for flow control" axiom apply to postgres?
5
votes
1
answer
444
views
In traditional programming there is an axiom that states, "do not use errors for flow control". A general example is to throw an error then catch the error instead of using an ordinary conditional statement or break statement. This is harmful because the application has to unwind the call stack and invoke some relatively expensive exception handling logic versus simply handling a conditional statement.
I am working with a Postgres system where a user is calling a function in Postgres that throws an error instead of returning no rows when a condition is not met. The condition is roughly a "this input value does not exist, nothing to do" as opposed to a truly exceptional case.
Does Postgres incur runtime costs when an error is thrown in a similar manner traditional programming? In other words is using exceptions as flow control in Postgres harmful to performance or just sloppy?
Asked by Freiheit
(249 rep)
Mar 28, 2019, 01:38 PM
Last activity: Dec 13, 2023, 11:11 PM
Last activity: Dec 13, 2023, 11:11 PM