[fpc-devel] SQL parser
Michael Van Canneyt
michael at freepascal.org
Tue Aug 17 01:29:15 CEST 2010
Hi,
I've committed in the FPC packages (fcl-db/src/sql) a
SQL scanner/parser/Abstract Syntax Tree.
It can parse the complete SQL syntax, as implemented by Firebird, SQL
dialect 3 (which should come pretty close to SQL-92) and builds a syntax
tree from it. The Abstract Syntax Tree can re-create the SQL with limited
formatting support.
It comes with extensive test suite (over 750 testcases) and I have tested it
on almost 400.000 SQL statements; Nevertheless bugs may remain, so I'd
welcome any test results you may produce. Especially the GRANT/REVOKE statements
are tested only theoretically, since I don't use them. The test suite is committed
as well, it can serve as an example of how to use the units.
The scanner/parser have been set up so they should be able to cope with
other SQL dialects (using a set of flags) such as MySQL, but this support
is currently not implemented.
The purpose is 3-fold:
- Add SQL syntax checking to property editors in the Lazarus IDE.
- Add reverse engineering of database creation scripts to the
Lazarus Database Desktop (and change the SQL generation to use
the abstract syntax tree)
- Add the ability to reliably alter queries at runtime.
(adding fields, filters and whatnot).
If someone wants to implement support for dialects of other SQL databases,
let me know, and I'll do my best to explain what must be done.
Michael.
More information about the fpc-devel
mailing list