WIP: hooking parser - Mailing list pgsql-hackers

From Pavel Stehule
Subject WIP: hooking parser
Date
Msg-id 162867790902110205s7878330ax67a7e6f2bdbeb53@mail.gmail.com
Whole thread Raw
Responses Re: WIP: hooking parser
Re: WIP: hooking parser
List pgsql-hackers
Hello

some years ago there was some plans about parser's extensibility. I am
able write bison extensions, but I thing, so lot of work should be
done via hooking of transform stage.

I did small example - real implementation of Oracle's decode function.
It's based on hooking transformExpr function.

It works. And I thing, this should to solve lot of special task
related to increase compatibility with Oracle, Informix, or it could
be usefull for some others (json support).

postgres=# load 'decode';
LOAD
postgres=# select
decode(null::integer,2,'ahoj',3,'Petr',1,'Pavel',null, 'jaja');
 decode
--------
 jaja
(1 row)

postgres=# select decode(3,2,'ahoj',3,'Petr',1,'Pavel',null, 'jaja');
 decode
--------
 Petr
(1 row)

postgres=# select decode(6,2,'ahoj',3,'Petr',1,'Pavel',null, 'jaja');
 decode
--------

(1 row)

postgres=# select decode(6,2,'ahoj',3,'Petr',1,'Pavel',null, 'jaja', 'Milos');
 decode
--------
 Milos
(1 row)

Any ideas, notes?

regards
Pavel Stehule

Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: temporarily stop autovacuum
Next
From: Peter Eisentraut
Date:
Subject: Re: [PATCH] Psql List Languages