Re: Oracle date type compat. functions: next_day, last_day, - Mailing list pgsql-patches

From Pavel Stehule
Subject Re: Oracle date type compat. functions: next_day, last_day,
Date
Msg-id Pine.LNX.4.44.0506021953530.4622-100000@kix.fsv.cvut.cz
Whole thread Raw
In response to Re: Oracle date type compat. functions: next_day, last_day,  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
On Thu, 2 Jun 2005, Tom Lane wrote:

> Pavel Stehule <stehule@kix.fsv.cvut.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;
                                }





pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Oracle date type compat. functions: next_day, last_day,
Next
From: Mary Edie Meredith
Date:
Subject: Re: O_DIRECT for WAL writes