Re: Oracle date type compat. functions: next_day, last_day,

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Oracle date type compat. functions: next_day, last_day,
Дата
Msg-id Pine.LNX.4.44.0506021953530.4622-100000@kix.fsv.cvut.cz
обсуждение исходный текст
Ответ на Re: Oracle date type compat. functions: next_day, last_day,  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Oracle date type compat. functions: next_day, last_day,
Следующее
От: Mary Edie Meredith
Дата:
Сообщение: Re: O_DIRECT for WAL writes