Immutable functions, Exceptions and the Query Optimizer

From: Cochise Ruhulessin <cochiseruhulessin(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Immutable functions, Exceptions and the Query Optimizer
Date: 2013-02-14 18:54:44
Message-ID: CAF1QUC7vR8-vLga91ztR-p+NtMmU3VTZ3SkObU7Dc6V2c4nFiA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben Chobot 2013-02-14 20:02:51 bug, bad memory, or bad disk?
Previous Message François Beausoleil 2013-02-14 17:09:02 PGbouncer and batch vs real-time pools