plpgsql: check domain constraints

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: plpgsql: check domain constraints
Date: 2006-01-09 04:30:40
Message-ID: 1136781040.8718.24.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers 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 Content-Type Size
plpgsql_domain_constr-2.patch text/x-patch 10.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-01-09 04:56:52 Re: plpgsql: check domain constraints
Previous Message Waso Training Center 2006-01-09 04:04:18 พนักงานธุรการยุคใหม่ Modern Office Management System

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-01-09 04:56:52 Re: plpgsql: check domain constraints
Previous Message Qingqing Zhou 2006-01-09 01:13:25 Re: Change BgWriterCommLock to spinlock