Re: Standalone Parser for PL/pgSQL

Поиск
Список
Период
Сортировка
От Matt Miller
Тема Re: Standalone Parser for PL/pgSQL
Дата
Msg-id 1121355523.3603.36.camel@dbamm01-linux
обсуждение исходный текст
Ответ на Re: Standalone Parser for PL/pgSQL  (Neil Conway <neilc@samurai.com>)
Ответы Re: Standalone Parser for PL/pgSQL  (Richard_D_Levine@raytheon.com)
Re: Standalone Parser for PL/pgSQL  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Re: Standalone Parser for PL/pgSQL  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Standalone Parser for PL/pgSQL  (Tino Wildenhain <tino@wildenhain.de>)
Список pgsql-general
On Thu, 2005-07-14 at 14:32 +1000, Neil Conway wrote:
> Alvaro Herrera wrote:
> > I don't think you can use just plpgsql's parser.  ... it
> > relies on the main backend parser
>
> If you're content to treat expressions and SQL queries as
> opaque strings, you shouldn't need to concern yourself with the main SQL
> parser.

Treating queries as terminal nodes in the parse tree would be fine as a
starting point.

> > The main parser depends (at least) on the List handling and memory
> > handling.
>
> The PL/PgSQL parser also depends on these, although to a lesser degree.

I suppose these dependencies are okay as long as I can just link my
parser to a library (e.g. src/pl/plpgsql/src/libplpgsql.so) and
everything magically works.

My fantasy here is to perform some straightforward surgery and bring to
life an executable that accepts PL/pgSQL code (e.g. as text on STDIN)
and creates a parse tree in memory.  The stuff in src/pl/plpgsql/src/
looked like a good starting point.  gram.y and scan.l are there.
pl_funcs.c has some cool-looking "dump*" functions.  Now, can this stuff
be "straightforwardly" hacked into a program that gets its PL/pgSQL
source code from STDIN or from a text file, instead of from the "AS"
clause of a "CREATE FUNCTION" statement?

My goal is to automate (as much as possible) the conversion of Oracle
PL/SQL stored procedures into PL/pgSQL.  Up to this point I've been
exploring Perl as a tool for this, but things are getting a bit thick
for me to rely on Perl regexes as my most-powerful weapon.  Instead of
growing my Perl stuff to look more and more like a parser, I went
looking for a parser, and ended up in src/pl/plpgslq/src.

В списке pgsql-general по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: To Postgres or not
Следующее
От: Peter Fein
Дата:
Сообщение: Re: Quotation marks in queries