From: | Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Neil Conway <neilc(at)samurai(dot)com>, <pgsql-patches(at)postgresql(dot)org>, <david(at)fetter(dot)org>, <kzak(at)redhat(dot)com>, <hsn(at)netmag(dot)cz> |
Subject: | Re: Oracle date type compat. functions: next_day, last_day, |
Date: | 2005-06-02 18:13:10 |
Message-ID: | Pine.LNX.4.44.0506021953530.4622-100000@kix.fsv.cvut.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
On Thu, 2 Jun 2005, Tom Lane wrote:
> Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz> writes:
> > b) some functions need patch to parser - greatest, least and decode.
>
> Why?
>
they has variable number of argument, they are polymorphic. They are not
functions, more special form of operators.
Maybe it is possible. I don't know PostgreSQL internal structures best,
but I can't to write similar functions without change parser.
Is it possible? I didn't find any example.
And code
for greatest and least is easy now, no more than 100 lines of code. Decode
is more compliceted (like case operator). Least and greatest use equal
functions and decode only different last ExecEvalVarargDecode. And calling
of these functions are much cheeper than calling true function.
Pavel Stehule
the change of parser is minimalistic:
| COALESCE '(' expr_list ')'
{
CoalesceExpr *c =
makeNode(CoalesceExpr);
c->args = $3;
$$ = (Node *)c;
}
| GREATEST '(' expr_list ')'
{
VarargExpr *v =
makeNode(VarargExpr);
v->args = $3;
v->type = IS_GREATEST;
$$ = (Node *)v;
}
| LEAST '(' expr_list ')'
{
VarargExpr *v =
makeNode(VarargExpr);
v->args = $3;
v->type = IS_LEAST;
$$ = (Node *)v;
}
| DECODE '(' expr_list ')'
{
VarargExpr *v =
makeNode(VarargExpr);
v->args = $3;
v->type = IS_DECODE;
$$ = (Node *)v;
}
From | Date | Subject | |
---|---|---|---|
Next Message | Mary Edie Meredith | 2005-06-02 18:49:28 | Re: O_DIRECT for WAL writes |
Previous Message | Tom Lane | 2005-06-02 17:49:07 | Re: Oracle date type compat. functions: next_day, last_day, |