List:Internals« Previous MessageNext Message »
From:Philip Stoev Date:August 16 2005 6:11pm
Subject:Re: Question about using the MySQL SQL parser
View as plain text  
Hello,

My intention is to provide an interface to the MySQL SQL parser to the Perl
community, since no fully-featured generic SQL parser is avilable for Perl.

A working Perl module is available from
http://search.cpan.org/~philips/DBIx-MyParse-0.20/.

I think I have sorted all the issues up to the point that functional parse
trees are created for most common SQL statements. There are issues with some
MySQL-specific functions, since some of the Item objects have members that
are, IMHO, needlessly private (see bug
http://bugs.mysql.com/bug.php?id=12377). Can this be helped and is there a
way for the MySQL source code to be changed?

As far as the usage of the parser, my ultimate goal is to enable Perl to
manipulate the MySQL parse tree either by reconstructing the SQL statement
after modifying the tree and parsing it and executing it again, or by
directly modifying the parse tree and passing it on to be executed. I
already have certain transformations in mind
(http://www.stoev.org/SQLAggregates.html), which I intend to implement.

Philip


----- Original Message ----- 
From: "Konstantin Osipov" <konstantin@stripped>
To: "Philip Stoev" <philip@stripped>
Cc: <internals@stripped>
Sent: Tuesday, August 16, 2005 1:43 PM
Subject: Re: Question about using the MySQL SQL parser


> * Philip Stoev <philip@stripped> [05/08/04 10:51]:
>
> > I would like to ask if you think it is possible to give the SQL parser
in
> > sql_yacc.yy a Perl interface so that it can be used to produce parse
trees
> > for statements fed directly into it. The rationale of this is that such
a
> > parser would be almost self-maintaining since it will always use the SQL
> > schema and parsing code from the most recent MySQL version.
> >
> > The way I see it, one can set up a fake TID object (mabe even fake the
IO)
> > and call mysql_stmt_prepare directly and then reap the results without
any
> > changes to the actual MySQL code.
> >
> > However this soon turns into a linkage nightmare. In my humble opinion
> > mysql_stmt_prepare ultimately depends on variables declared in
mysqld.cc,
> > which in turn has a main() function that I do not really want to bring
in.
> >
> > Any pointers would be much appreciated, including links to other
projects
> > that attempt to reuse portions of MySQL's code base. Please accept my
> > apologies if all this is complete nonsense.
>
> Could you elaborate more on the goal the project?
> What do you need the parse trees for?
>
> -- 
> Konstantin Osipov, Software Developer
> MySQL AB, www.mysql.com
>
>

-- 
Mi Bandeja de entrada es protegida por SPAMfighter
2926 hasta ahora los spam correos que han sido bloqueados. 
¡Descargado libremente www.spamfighter.com (gratis) hoy! 

Thread
Question about using the MySQL SQL parserPhilip Stoev26 Jul
  • Re: Question about using the MySQL SQL parserKonstantin Osipov16 Aug
  • Re: Question about using the MySQL SQL parserPhilip Stoev16 Aug
    • Re: Question about using the MySQL SQL parserBrian Aker16 Aug