plpgsql: check domain constraints - Mailing list pgsql-patches

From Neil Conway
Subject plpgsql: check domain constraints
Date
Msg-id 1136781040.8718.24.camel@localhost.localdomain
Whole thread Raw
Responses Re: plpgsql: check domain constraints  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Attached is a patch that makes the following changes:

(1) refactor execQual.c to expose a function for checking an instance of
a domain value against a list of domain constraints

(2) adjust pl/pgsql to fetch the constraints associated with the
function's return value. Because this is expensive, the constraints are
fetched once per session, when the function is compiled. I then modified
pl/pgsql to check any applicable constraints on the return value of a
function before returning it to the backend.

(3) add some regression tests for #2

The patch does NOT add checking of domain constraints for other PLs, or
for intermediate values in PL/PgSQL -- I plan to take a look at doing
one or both of those soon.

I also made a few semi-related cleanups. In pl_exec.c, it seems to me
that estate.eval_econtext MUST be non-NULL during the guts of both
plpgsql_exec_trigger() and plpgsql_exec_function(). Therefore checking
that estate.eval_econtext is non-NULL when cleaning up is unnecessary
(line 649 and 417 in current sources, respectively), so I've removed the
checks. Am I missing something?

Barring any objections I'll apply this patch tomorrow some time.

-Neil


Attachment

pgsql-patches by date:

Previous
From: Qingqing Zhou
Date:
Subject: Re: Change BgWriterCommLock to spinlock
Next
From: Tom Lane
Date:
Subject: Re: plpgsql: check domain constraints