Re: Finishing Domains...

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Finishing Domains...
Date: 2002-11-05 01:37:28
Message-ID: 1036460249.66684.41.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2002-11-04 at 09:44, Tom Lane wrote:
> Rod Taylor <rbt(at)rbt(dot)ca> writes:
> > Is it safe to teach Var how to deal with values that do not originate
> > from a tuple? Or should I create a new primnode to deal with these
> > types of variables.
>
> I have no idea what you're talking about, but it sure sounds like
> something that should not be in Var ... perhaps you ought to post a
> more complete design document before you start coding.

Sorry, had planned on it. Anyway, below is a summary of what I think I
need to do.

Goal:
CREATE DOMAIN dom AS integer CHECK(VALUE = 4 OR VALUE = 10);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The constraint will be stored in pg_constraint with the conrelid set to
0, and contypid set to the domain pg_type oid. Domain check constraints
will be pulled out of the table and inserted into the executor tree in
coerce_type_constraints(), for execution by ExecEvalConstraintTest().

In the parser, I intend to represent the 'VALUE' term by a
DomainConstraintValue node which inherits the properties (TypId, TypMod)
of the domain base type. Requires some muckary in transformExpr() to
carry the current datatype through it, much like carrying a context
through the executor.

It has been mentioned a few times that parse nodes should not be used in
the executor as they tend to be bug prone, so I don't want to use
DomainConstraintValue in the executor. So, I need a way to represent
VALUE in both the stored pg_constraint.conbin column and the executor,
which is replaced with the Datum being operated on during
ExecEvalConstraintTest().

The Datum is created in ExecEvalConstraintTest, so it's easy to add it
to the local context, and call ExecEvalExpr on the (VALUE = 4 OR VALUE =
10) expression. ExecEvalExpr runs through the Node passed and fills in
subexpressions (Var nodes for example).

Do I teach ExecEvalVar how to pull out an arbitrary value from
ExprContext (since this is technically a variable), or do I create a
different 'Var' for managing variables which do not come in the Tuple
format. All I need is the datatype, and a little knowledge of the
variable thats in ExprContext.

--
Rod Taylor

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-11-05 01:43:26 Re: Float output formatting options
Previous Message Satoshi Nagayasu 2002-11-05 01:33:16 Re: protocol change in 7.4