Immutable functions, Exceptions and the Query Optimizer - Mailing list pgsql-general

From Cochise Ruhulessin
Subject Immutable functions, Exceptions and the Query Optimizer
Date
Msg-id CAF1QUC7vR8-vLga91ztR-p+NtMmU3VTZ3SkObU7Dc6V2c4nFiA@mail.gmail.com
Whole thread Raw
Responses Re: Immutable functions, Exceptions and the Query Optimizer
List pgsql-general
Hello all,

If an immutable function raises an exception, is that exception cached by
the query optimizer? Or does it only cache in the case that a function
actually returns a value?

The use case is a table books(book_id NOT NULL PRIMARY KEY, type_id)
wherein type_id is considered immutable (enforced with a trigger).

The function f() must return type_id given book_id, and raise an exception
if no entity with book_id exists. I'd like this function to be immutable so
it can be used as a check constraint.

Kind regards,

Cochise Ruhulessin

pgsql-general by date:

Previous
From: Joe Conway
Date:
Subject: SCALE goes to 11, and so does PostgreSQL!
Next
From: Joe Van Dyk
Date:
Subject: Avoiding duplication of code via views -- slower? How do people typically do this?