Re: BUG #2954: null is not checked against domain constraints in return clause

From: Sergiy Vyshnevetskiy <serg(at)vostok(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2954: null is not checked against domain constraints in return clause
Date: 2007-02-01 17:20:34
Message-ID: Pine.LNX.4.64.0702011910000.22446@uanet.vostok.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I believe the bug to be here:

/* Normal case for scalar results */
estate->retval = exec_eval_expr(estate, stmt->expr,
&(estate->retisnull),
&(estate->rettype));

in exec_stmt_return() in pl_exec.c.

As I understand it, exec_eval_expr overwrites(!) estate->rettype instead
of casting the result to it.

What should be done is something like:

Datum value;
Oid valtype;

value = exec_eval_expr(estate, stmt->expr, &(estate->retisnull),
&valtype);

estate->retval = exec_cast_value(value, valtype, estate->rettype,
reqinput,
reqioparam,
reqtypmod,
estate->retisnull);

but where to get reqinput, reqioparam and reqtypmod? They should be
accessed through estate pointer, I think.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2007-02-01 17:35:15 Re: BUG #2948: default null values for not-null domains
Previous Message Sergiy Vyshnevetskiy 2007-02-01 15:43:55 BUG #2954: null is not checked against domain constraints in return clause