> -----Original Message-----
> From: Hiroshi Inoue [mailto:Inoue@tpf.co.jp]
> 
> > -----Original Message-----
> > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> > 
> > "Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> > > Is pg_relcheck.rcsrc equivalent to the original raw constraint ?
> > 
> > To the best of deparse_expression()'s ability, it should be.
> > I'm not real sure why we bother to store it, rather than deparsing
> > rcbin on-the-fly on demand...
> >
> 
> I'm looking at DefineRelation() in commands/creartinh.c.
> In case of inheritance,constraints of super classes are
> stored using their pg_relcheck.rcbin-s. It seems bad 
> in case of multiple inheritance.  rcsrc-s may be available
> instead.
>

Oops,I've been completely off the point.
The raw expression of constraints seems to be really needed.

Is there any way to convert rcbin(cooked text format) to the
raw(pre-cooked) Node expression ? Or is there a way to
convert rcsrc to the pre-cooked Node expression ?
Or is there a way to convert rcsrc to the cooked expression ?

Here's a simple bug case.

=# create table p1 (id int4);
CREATE
=# create table p2 (dt text check (dt = 'a'));
CREATE
=# create table inh () inherits (p1,p2);
CREATE
=# \d inh
          Table "inh"
 Attribute |  Type   | Modifier
-----------+---------+----------
 id        | integer |
 dt        | text    |
Constraint: (id = 'a'::text)

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp

Fri, 4 Aug 2000 09:02:33 +0900
"Hiroshi Inoue" <Inoue@tpf.co.jp>
RE: Raw constraint & pg_relcheck.rcsrc 
"Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> Is there any way to convert rcbin(cooked text format) to the
> raw(pre-cooked) Node expression?

No.

> Or is there a way to
> convert rcsrc to the pre-cooked Node expression ?
> Or is there a way to convert rcsrc to the cooked expression ?

I think what you'd have to do is take the parent's rcsrc and run it
through the parse and transform phases again, using the new child
table as the reference for attribute name resolution.  Thomas might
have a clearer idea than I do about the cleanest way to interface
to the parser for that.

Another possibility is to determine the mapping from parent columns
to child columns, and then walk through the (cooked) expression tree
and substitute varattno field values in Var nodes accordingly.  I'm
not certain that's sufficient, but if it is it'd be a fairly small
amount of code (in fact you might be able to just call the routines in
the rewriter that do similar things).

			regards, tom lane

Thu, 03 Aug 2000 21:24:23 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Raw constraint & pg_relcheck.rcsrc 
> -----Original Message-----
> From: Tom Lane
> 
> "Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> > Is there any way to convert rcbin(cooked text format) to the
> > raw(pre-cooked) Node expression?
> 
> No.
> 
> > Or is there a way to
> > convert rcsrc to the pre-cooked Node expression ?
> > Or is there a way to convert rcsrc to the cooked expression ?
>

[snip]
 
> Another possibility is to determine the mapping from parent columns
> to child columns, and then walk through the (cooked) expression tree
> and substitute varattno field values in Var nodes accordingly.  I'm
> not certain that's sufficient, but if it is it'd be a fairly small
> amount of code (in fact you might be able to just call the routines in
> the rewriter that do similar things).
>

OK,I would try this way using expression_tree_walker() which I
used once in my trial for ALTER TABLE DROP COLUMN.

Thanks.

Hiroshi Inoue
Inoue@tpf.co.jp

Fri, 4 Aug 2000 11:41:21 +0900
"Hiroshi Inoue" <Inoue@tpf.co.jp>
RE: Raw constraint & pg_relcheck.rcsrc 