Re: Extension to rewrite queries before execution

From: Andy Colson <andy(at)squeakycode(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Extension to rewrite queries before execution
Date: 2015-08-14 21:50:35
Message-ID: 55CE62AB.6030503@squeakycode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/13/2015 2:49 PM, Jeff Janes wrote:
> I am looking for an extension or a technique that will allow me to
> intercept a query by the exact query text, and replace that query with a
> different one.
>
> The context is running a third-party app which issues queries I have no
> control over. I'd like to intercept a specific query (which has no bind
> parameters) and either replace the query text with a different text
> which, for example, swaps out an "in list" clause to instead be an
> "exists (subquery)".
>
> Or just wrap the query in a "set enable_* =off;" or "set work_mem=*;"
> before and a reset of it after.
>
> Is there anything out there like this? This would be for 9.4.
>
> I'm willing to put the query text, and its replacement, directly into
> the extension source code and compile it, but of course something more
> flexible would be ideal.
>
> Thanks,
>
> Jeff

Have you looked at pg_bouncer? You'd have to make changes to the
source, but it's got a bunch of what you'd need. It sits in the middle
and could swap out text pretty easy. I'd guess.

-Andy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Nelson 2015-08-15 01:31:33 Re: Count of non-null values per table column
Previous Message Melvin Davidson 2015-08-14 19:26:49 Re: PostgreSQL - The Best Overall Database