Re: plpgsql function-parsing

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: chris <chrisk(at)pgsqlrocket(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: plpgsql function-parsing
Date: 2018-03-06 18:11:38
Message-ID: CAFj8pRBef9B2qzmhz5BZxX1Zcr_+RGkBd+D+UfoeB_neL52WcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

2018-03-06 16:51 GMT+01:00 chris <chrisk(at)pgsqlrocket(dot)com>:

> Hi,
>
> I am trying to create a function that gets passed a statement as a string
> and then I need to change the table_name within the string by adding a
> "_cdc" to it, then execute the statement
>
> ex:
>
> string passed could be GRANT all ON authors TO bob.
>
> then
>
> EXECUTE GRANT all ON authors_cdc TO bob
>
>
> I'm looking into parsing the string but i can't find a way to parse in a
> way that'll work. Any ideas?
>

The extension Orafce https://github.com/orafce/orafce has some basic
library for parsing SQL PLVlex.

Another solution can be using regular expressions
https://www.postgresql.org/docs/current/static/functions-matching.html

Regards

Pavel

>
> Thanks,
>
> Chris
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Poty 2018-03-06 19:53:19 Barman versus pgBackRest
Previous Message Andres Freund 2018-03-06 16:55:57 Re: dirty_ratio & dirty_background_ratio settings with huge memory