Re: is there a hook by which we can modify input query before postgresql builds raw parse tree

Lists: pgsql-hackers
From: Rajmohan C <csrajmohan(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: is there a hook by which we can modify input query before postgresql builds raw parse tree
Date: 2014-05-02 04:37:30
Message-ID: CAHaqV0hze7+qCrFQTh6mpf0p2iaNjka0GMLTepNT0O0Qi8c7qA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I want to know is there a way to use a hook to modify the input query
before Postgresql parses and builds the parse tree for the query.


From: Atri Sharma <atri(dot)jiit(at)gmail(dot)com>
To: Rajmohan C <csrajmohan(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: is there a hook by which we can modify input query before postgresql builds raw parse tree
Date: 2014-05-02 04:39:26
Message-ID: CAOeZVidzh+R7dOD6PtHiO9RUtepVxx8W_6K0yUf8b3J4nn1h4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, May 2, 2014 at 10:07 AM, Rajmohan C <csrajmohan(at)gmail(dot)com> wrote:

> Hi,
>
> I want to know is there a way to use a hook to modify the input query
> before Postgresql parses and builds the parse tree for the query.
>

Uh...the rewriter?

--
Regards,

Atri
*l'apprenant*


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Rajmohan C <csrajmohan(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: is there a hook by which we can modify input query before postgresql builds raw parse tree
Date: 2014-05-02 05:06:08
Message-ID: CAB7nPqRxcMDm8fQ6_xpYbqZ7vctiyVRGkjB5gfRyteqCVxdk9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, May 2, 2014 at 1:37 PM, Rajmohan C <csrajmohan(at)gmail(dot)com> wrote:
> Hi,
>
> I want to know is there a way to use a hook to modify the input query
> before Postgresql parses and builds the parse tree for the query.
Not that I know of. I am not sure that enforcing query rewrite on the
server side is a good idea at this may trap your applications and have
them face unexpected behaviors.

FWIW, a presentation about hooks has been done at PGCon 2012, you can
refer to it as well for your future work:
http://wiki.postgresql.org/images/e/e3/Hooks_in_postgresql.pdf
--
Michael


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Rajmohan C <csrajmohan(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: is there a hook by which we can modify input query before postgresql builds raw parse tree
Date: 2014-05-02 05:16:23
Message-ID: CAB7nPqQtgzr=-hetb+UiqB4LT5gvXs3Uzx=xbLEDMfps00-UBg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, May 2, 2014 at 2:06 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> Not that I know of. I am not sure that enforcing query rewrite on the
> server side is a good idea at this may trap your applications and have
> them face unexpected behaviors.
Note as well that there is a hook *before* the rewriter and *after*
parse/analyze of query called post_parse_analyze_hook in
parser/analyze.h.
--
Michael