1
Fork 0

change website index to be asciidoc

This commit is contained in:
Jake Wheat 2015-08-08 21:19:18 +03:00
parent 61e7a89416
commit 60963de5e0
2 changed files with 136 additions and 127 deletions

View file

@ -1,4 +1,12 @@
# simple-sql-parser
:toc: right
:sectnums:
:toclevels: 10
:source-highlighter: pygments
= simple-sql-parser
== Overview
A parser for SQL in Haskell. Also includes a pretty printer which A parser for SQL in Haskell. Also includes a pretty printer which
formats output nicely. Current target is to parse most SQL:2011 formats output nicely. Current target is to parse most SQL:2011
@ -7,24 +15,26 @@ management, access control and session management.
This is the documentation for version 0.5.0. This is the documentation for version 0.5.0.
Status: Covers a lot of queries already, but the public API is Status: covers a lot of queries already, but the public API is
probably not very stable, since adding support for all the probably not very stable, since adding support for all the
not-yet-supported ANSI SQL syntax, then other dialects of SQL is not-yet-supported ANSI SQL syntax, then other dialects of SQL is
likely to change the abstract syntax types considerably. likely to change the abstract syntax types considerably.
Tested with GHC 7.10.2, 7.8.4 and 7.6.3. Tested with GHC 7.10.2, 7.8.4 and 7.6.3.
# Examples == Examples
Simple expression: Simple expression:
~~~~{.sql} [source,sql]
----
select a + b * c select a + b * c
~~~~ ----
Parsed AST: Parsed AST:
~~~~{.haskell} [source,haskell]
----
Select{qeSetQuantifier = All, Select{qeSetQuantifier = All,
qeSelectList = qeSelectList =
[(BinOp (Iden (Name "a")) (Name "+") [(BinOp (Iden (Name "a")) (Name "+")
@ -32,11 +42,12 @@ Select{qeSetQuantifier = All,
Nothing)], Nothing)],
qeFrom = [], qeWhere = Nothing, qeGroupBy = [], qeHaving = Nothing, qeFrom = [], qeWhere = Nothing, qeGroupBy = [], qeHaving = Nothing,
qeOrderBy = [], qeOffset = Nothing, qeFetchFirst = Nothing} qeOrderBy = [], qeOffset = Nothing, qeFetchFirst = Nothing}
~~~~ ----
TPC-H query 21: TPC-H query 21:
~~~~{.sql} [source,sql]
----
select select
s_name, s_name,
count(*) as numwait count(*) as numwait
@ -77,11 +88,12 @@ order by
numwait desc, numwait desc,
s_name s_name
fetch first 100 rows only; fetch first 100 rows only;
~~~~ ----
Parsed: Parsed:
~~~~{.haskell} [source,haskell]
----
Select{qeSetQuantifier = All, Select{qeSetQuantifier = All,
qeSelectList = qeSelectList =
[(Iden (Name "s_name"), Nothing), [(Iden (Name "s_name"), Nothing),
@ -183,11 +195,13 @@ Select{qeSetQuantifier = All,
SortSpec (Iden (Name "s_name")) Asc NullsOrderDefault], SortSpec (Iden (Name "s_name")) Asc NullsOrderDefault],
qeOffset = Nothing, qeFetchFirst = Just (NumLit "100")}) qeOffset = Nothing, qeFetchFirst = Just (NumLit "100")})
~~~~ ----
Output from the simple-sql-parser pretty printer: Output from the simple-sql-parser pretty printer:
~~~~{.sql} [source,sql]
----
select s_name, count(*) as numwait select s_name, count(*) as numwait
from supplier, from supplier,
lineitem as l1, lineitem as l1,
@ -211,206 +225,200 @@ where s_suppkey = l1.l_suppkey
group by s_name group by s_name
order by numwait desc, s_name order by numwait desc, s_name
fetch first 100 rows only; fetch first 100 rows only;
~~~~ ----
# Feature support
== Feature support
* query expressions * query expressions
* * select lists ** select lists
* * from clause ** from clause
* * where clause ** where clause
* * group by clause ** group by clause
* * having clause ** having clause
* * order by clause ** order by clause
* * offset and fetch ** offset and fetch
* * set operators ** set operators
* * common table expressions ** common table expressions
* * wide range of value expressions ** wide range of value expressions
* DDL * DDL
* * TODO ** TODO
* non-query DML * non-query DML
* * TODO ** TODO
* Access control * Access control
* * TODO ** TODO
* Transaction management * Transaction management
* * TODO ** TODO
* Session management * Session management
* * TODO ** TODO
See the [supported_sql.html](supported_sql.html) page for details on See the link:supported_sql.html page for details on
the supported SQL. the supported SQL.
Here is a document with all the [simple-sql-parser test Here is a document with all the link:test_cases.html[simple-sql-parser
cases](test_cases.html) rendered in a webpage so you can get an idea test cases] rendered in a webpage so you can get an idea of what it
of what it supports. supports.
# Installation == Installation
Installing the latest release from Hackage. Installing the latest release from Hackage.
~~~~ ----
cabal update && cabal install simple-sql-parser cabal update && cabal install simple-sql-parser
~~~~ ----
Working with the latest development version: Working with the latest development version:
~~~~ ----
git clone https://github.com/JakeWheat/simple-sql-parser.git git clone https://github.com/JakeWheat/simple-sql-parser.git
cd simple-sql-parser cd simple-sql-parser
cabal sandbox init cabal sandbox init
cabal install --only-dependencies cabal install --only-dependencies
cabal build cabal build
~~~~ ----
## Running the tests === Running the tests
Get the source using 'cabal unpack' or 'git clone', then change to the Get the source using 'cabal unpack' or 'git clone', then change to the
source directory. source directory.
You can run the tests using cabal: You can run the tests using cabal:
~~~~ ----
cabal sandbox init cabal sandbox init
cabal install --only-dependencies --enable-tests cabal install --only-dependencies --enable-tests
cabal configure --enable-tests cabal configure --enable-tests
cabal test cabal test
~~~~ ----
Or you can run them directly which gives more options. The tests use Or you can run them directly which gives more options. The tests use
tasty, which provides the command line options. tasty, which provides the command line options.
~~~~ ----
cabal sandbox init cabal sandbox init
cabal install --only-dependencies --enable-tests cabal install --only-dependencies --enable-tests
cabal configure --enable-tests cabal configure --enable-tests
cabal build cabal build
dist/build/Tests/Tests dist/build/Tests/Tests
~~~~ ----
--hide-successes is a good option to use: --hide-successes is a good option to use:
~~~~ ----
dist/build/Tests/Tests --hide-successes dist/build/Tests/Tests --hide-successes
~~~~ ----
# Documentation == Documentation
* see the [simple-sql-parser test cases](test_cases.html) for * See the link:test_cases.html[simple-sql-parser test cases] for
examples. examples;
* [simple-sql-parser haddock](haddock/index.html) (the haddock on * link:haddock/index.html[simple-sql-parser haddock] (the haddock on
Hackage has source links) Hackage has source links).
# Recommended reading == Recommended reading
Here is some recommended reading on understanding SQL in depth. Here is some recommended reading on understanding SQL in depth.
\ +
\ +
\
SQL: The Complete Reference, 3rd Edition, James R. Groff, Paul SQL: The Complete Reference, 3rd Edition, James R. Groff, Paul
N. Weinberg, Andrew J. Oppel N. Weinberg, Andrew J. Oppel
This is a comprehensive book which covers up to the SQL:1999 standard. This is a comprehensive book which covers up to the SQL:1999 standard.
\ +
\ +
\ +
SQL in a Nutshell, Kevin Kline, Brand Hunt, Daniel Kline SQL in a Nutshell, Kevin Kline, Brand Hunt, Daniel Kline
This is another good book which covers some of the SQL:2003 and This is another good book which covers some of the SQL:2003 and
SQL:2008 standards. This means it covers a few newer things like SQL:2008 standards. This means it covers a few newer things like
window functions which 'SQL: The Complete Reference' doesn't. It also window functions which 'SQL: The Complete Reference' doesn't. It also
compares some main SQL product dialects. compares some main SQL product dialects.
\ +
\ +
\ +
SQL A Comparative Survey, Hugh Darwen SQL A Comparative Survey, Hugh Darwen +
http://bookboon.com/en/sql-a-comparative-survey-ebook http://bookboon.com/en/sql-a-comparative-survey-ebook
This is a book about SQL from a relational theory perspective. This is a book about SQL from a relational theory perspective.
\ +
\ +
\ +
SQL and Relational Theory, 2nd Edition, Chris Date SQL and Relational Theory, 2nd Edition, Chris Date
This also covers SQL from a partly theoretical perspective. This also covers SQL from a partly theoretical perspective.
\ +
\ +
\ +
A Guide to the SQL Standard, C. J. Date, Hugh Darwen A Guide to the SQL Standard, C. J. Date, Hugh Darwen
This is a fantastic book for covering all the little details of the This is a fantastic book for covering all the little details of the
SQL standard in depth. It only covers up to SQL:92. SQL standard in depth. It only covers up to SQL:92.
\ +
\ +
\ +
There are several other good books by Chris Date, some with Hugh There are several other good books by Chris Date, some with Hugh
Darwen and others, for instance 'Introduction to Database Systems', Darwen and others, for instance 'Introduction to Database Systems',
'Temporal Data & the Relational Model, Databases', 'Types and the 'Temporal Data & the Relational Model, Databases', 'Types and the
Relational Model'. Only the first one (Introduction to Relational Model'. Only the first one (Introduction to
Database Systems) really relates to SQL. Database Systems) really relates to SQL.
\ +
\ +
\ +
Database Systems: The Complete Book, Hector Garcia-Molina, Jeff Ullman, and Jennifer Widom. Database Systems: The Complete Book, Hector Garcia-Molina, Jeff Ullman, and Jennifer Widom.
This book is very comprehensive and has some interesting sections. This book is very comprehensive and has some interesting sections.
\ +
\ +
\ +
Some of the SQL draft standards are available to download for free (follow the Some of the SQL draft standards are available to download for free (follow the
links on the wikipedia page for SQL). They are a little tricky to links on the wikipedia page for SQL). They are a little tricky to
read and understand. read and understand. You can find some stuff at these links.
\
\
\
TODO: add web links for the pdfs below
\
\
\
IBM DB2 10.5 SQL Reference Volume 1
<http://public.dhe.ibm.com/ps/products/db2/info/vr105/pdf/en_US/DB2SQLRefVol1-db2s1e1050.pdf>
\
\
\
Oracle SQL Reference 12c release 1
<http://docs.oracle.com/cd/E16655_01/server.121/e17209.pdf>
\
\
\
Teradata:
TODO
\
\
\
Microsoft SQL Server 2012 TSQL reference online. I didn't find a PDF
for this.
<http://technet.microsoft.com/en-us/library/bb510741.aspx>
\
\
\
PostgreSQL 9.3 manual:
<http://www.postgresql.org/docs/9.3/interactive/index.html>
No PDF for the Postgres manual either, but the web pages are very
readable.
\
\
\
SQL BNF Grammars
http://savage.net.au/SQL/index.html http://savage.net.au/SQL/index.html
# Links http://www.wiscorp.com/SQLStandards.html
+
+
+
IBM DB2 10.5 SQL Reference Volume 1
* Homepage: <http://jakewheat.github.io/simple-sql-parser> http://public.dhe.ibm.com/ps/products/db2/info/vr105/pdf/en_US/DB2SQLRefVol1-db2s1e1050.pdf
* Hackage: <http://hackage.haskell.org/package/simple-sql-parser> +
* Repository: <https://github.com/JakeWheat/simple-sql-parser> +
* Bug tracker: <https://github.com/JakeWheat/simple-sql-parser/issues> +
Oracle SQL Reference 12c release 1
# Contact http://docs.oracle.com/cd/E16655_01/server.121/e17209.pdf
+
+
+
Teradata:
jakewheatmail@gmail.com TODO
+
+
+
Microsoft SQL Server 2012 TSQL reference online. I didn't find a PDF
for this.
http://technet.microsoft.com/en-us/library/bb510741.aspx
+
+
+
PostgreSQL 9.4 manual:
http://www.postgresql.org/docs/9.4/interactive/index.html
No PDF for the Postgres manual either, but the web pages are very
readable.
== Links
* Homepage: http://jakewheat.github.io/simple-sql-parser
* Hackage: http://hackage.haskell.org/package/simple-sql-parser
* Repository: https://github.com/JakeWheat/simple-sql-parser
* Bug tracker: https://github.com/JakeWheat/simple-sql-parser/issues
== Contact
+++jakewheatmail@gmail.com+++

View file

@ -11,7 +11,8 @@ cp website/main.css build
cp website/ocean.css build cp website/ocean.css build
# index # index
pandoc --from=markdown --to=html website/index.txt -o build/index.html -c main.css --title=simple-sql-parser --toc asciidoctor website/index.asciidoc -o build/index.html
#pandoc --from=markdown --to=html website/index.txt -o build/index.html -c main.css --title=simple-sql-parser --toc
pandoc --from=markdown --to=html website/supported_sql.txt -o build/supported_sql.html -c main.css '--title=simple-sql-parser supported SQL' --toc pandoc --from=markdown --to=html website/supported_sql.txt -o build/supported_sql.html -c main.css '--title=simple-sql-parser supported SQL' --toc
# tpch sql file # tpch sql file
# pandoc src/tpch.sql -s --highlight-style kate -o tpch.sql.html # pandoc src/tpch.sql -s --highlight-style kate -o tpch.sql.html