Skip to content

Commit fe157ec

Browse files
Moritz EyssenMoritz Eyssen
authored andcommitted
Merge with master
2 parents 0d59785 + 6dade78 commit fe157ec

24 files changed

Lines changed: 1630 additions & 2079 deletions

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ cmake-build-debug/
4545
*.swp
4646

4747
*.csv
48+
49+
# macOS compilation dirs
50+
*.dSYM

‎.travis.yml‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ language: cpp
44
install:
55
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
66
- sudo apt-get -qq update
7-
- sudo apt-get install -y g++-4.8 libstdc++-4.8-dev
8-
- sudo apt-get install -y flex valgrind
9-
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90
10-
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 90
7+
- sudo apt-get install -y g++-6 libstdc++-6-dev
8+
- sudo apt-get install -y valgrind
9+
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90
10+
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 90
1111

1212
# Install bison 3.0.4.
1313
- wget http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz
@@ -16,21 +16,34 @@ install:
1616
- ./configure && make && sudo make install
1717
- cd ..
1818

19+
# Install flex 2.6.4
20+
- wget https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz
21+
- tar -xvzf flex-2.6.4.tar.gz
22+
- cd flex-2.6.4
23+
- ./configure && make && sudo make install
24+
- cd ..
25+
1926
# Show installed versions.
2027
- which g++
2128
- g++ -v
2229
- bison --version
2330
- flex --version
2431
- valgrind --version
32+
- if [ "$CXX" = "clang++" ]; then export CXXFLAGS="-stdlib=libc++"; fi
2533

2634
compiler:
2735
- gcc
2836
- clang
2937

3038
script:
31-
- make cleanall
39+
# bi build with flex/bison files checked into repo
3240
- make -j4
41+
- make test
42+
- make test_example
3343

44+
# build flex/bison files in CI
45+
- make cleanall
46+
- make -j4
3447
- make test
3548
- make test_example
3649

‎Makefile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ GMAKE = make mode=$(mode)
3636
NAME := sqlparser
3737
PARSER_CPP = $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
3838
PARSER_H = $(SRCPARSER)/bison_parser.h $(SRCPARSER)/flex_lexer.h
39-
LIB_CFLAGS = -std=c++11 -Wall -Werror $(OPT_FLAG)
39+
LIB_CFLAGS = -std=c++1z -Wall -Werror $(OPT_FLAG)
4040

4141
static ?= no
4242
ifeq ($(static), yes)
@@ -60,7 +60,7 @@ $(LIB_BUILD): $(LIB_OBJ)
6060
$(LIBLINKER) $(LIB_LFLAGS) $(LIB_BUILD) $(LIB_OBJ)
6161

6262
$(SRCPARSER)/flex_lexer.o: $(SRCPARSER)/flex_lexer.cpp $(SRCPARSER)/bison_parser.cpp
63-
$(CXX) $(LIB_CFLAGS) -c -o $@ $< -Wno-sign-compare -Wno-unneeded-internal-declaration -Wno-deprecated-register
63+
$(CXX) $(LIB_CFLAGS) -c -o $@ $< -Wno-sign-compare -Wno-unneeded-internal-declaration
6464

6565
%.o: %.cpp $(PARSER_CPP) $(LIB_H)
6666
$(CXX) $(LIB_CFLAGS) -c -o $@ $<
@@ -120,7 +120,7 @@ $(BM_BUILD): $(BM_ALL) $(LIB_BUILD)
120120
############ Test & Example ############
121121
########################################
122122
TEST_BUILD = $(BIN)/tests
123-
TEST_CFLAGS = -std=c++11 -Wall -Werror -Isrc/ -Itest/ -L./ $(OPT_FLAG)
123+
TEST_CFLAGS = -std=c++1z -Wall -Werror -Isrc/ -Itest/ -L./ $(OPT_FLAG)
124124
TEST_CPP = $(shell find test/ -name '*.cpp')
125125
TEST_ALL = $(shell find test/ -name '*.cpp') $(shell find test/ -name '*.h')
126126
EXAMPLE_SRC = $(shell find example/ -name '*.cpp') $(shell find example/ -name '*.h')

‎docs/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Documentation
44
Internal Links:
55

66
* [Developer Documentation](dev-docs.md)
7-
* [Working SQL Syntax Examples](syntax-examples.md)
7+
* [Supported SQL Queries](syntax-support.md)
8+
* [Known Limitations & Missing Features](known-limitations.md)
89

910

1011
External Resources:

‎docs/known-limitations.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Known Limitations & Missing Features
2+
====================================
3+
4+
This page contains an overview of known missing limitations and missing features in our SQL parser project. In general, we would like to see all of these features being supported at some point. If you are particularly interested in a specific feature, feel free to contribute to this project through a pull request.
5+
6+
### Completely Missing Statement Types
7+
8+
* EXPLAIN
9+
* EXPORT
10+
* RENAME
11+
* ALTER
12+
13+
Additionally, there are a lot of statement types that are specific to certain database systems. Supporting all of these is not on our roadmap, but if someone implements support for such a statement, we can also integrate it.
14+
15+
### Other SQL Limitations
16+
17+
* Tables names ignore the schema name (see grammar rule `table_name`). This affects, for example, `INSERT, IMPORT, DROP, DELETE`.
18+
* Column data types only support `INT, DOUBLE, TEXT`.

‎docs/syntax-examples.md‎

Lines changed: 0 additions & 44 deletions
This file was deleted.

‎docs/syntax-support.md‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Supported SQL Queries
2+
=====================
3+
4+
This page contains a short list of queries that can be correctly parsed with our parser. If you are interested in finding out if a certain feature is supported, it is probably the easiest to checkout the repository and try the example project or check our [list of known limitations](known-limitations.md). Also the file [queries-good.sql](../test/queries/queries-good.sql) shows a list of queries which are parsable with the current version.
5+
6+
7+
## Select Statements
8+
9+
We implement a broad support for the most common elements for `SELECT` statements. Following are a few examples of basic constructs that are supported.
10+
11+
```sql
12+
SELECT name, city, *
13+
FROM students AS t1 JOIN students AS t2 ON t1.city = t2.city
14+
WHERE t1.grade < 2.0 AND
15+
t2.grade > 2.0 AND
16+
t1.city = 'Frohnau'
17+
ORDER BY t1.grade DESC;
18+
19+
SELECT city, AVG(grade) AS average,
20+
MIN(grade) AS best, MAX(grade) AS worst
21+
FROM students
22+
GROUP BY city;
23+
```
24+
25+
## Data Definition & Modification
26+
27+
**Create Tables**
28+
```sql
29+
CREATE TABLE students (
30+
name TEXT,
31+
student_number INTEGER,
32+
city TEXT,
33+
grade DOUBLE
34+
);
35+
```
36+
37+
**Update and Delete**
38+
```sql
39+
UPDATE students SET name='Max Mustermann' WHERE name = 'Ralf Mustermann';
40+
41+
DELETE FROM students WHERE name = 'Max Mustermann';
42+
```
43+
44+
45+
## Prepared Statements
46+
47+
The definition and execution of prepared statements is supported using the following syntax.
48+
49+
```sql
50+
PREPARE select_test FROM 'SELECT * FROM customer WHERE c_name = ?;';
51+
52+
EXECUTE select_test('Max Mustermann');
53+
```

‎example/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
CFLAGS = -std=c++11 -lstdc++ -Wall -Werror -I../src/ -L../
2+
CFLAGS = -std=c++1z -lstdc++ -Wall -Werror -I../src/ -L../
33

44
all:
55
$(CXX) $(CFLAGS) example.cpp -o example -lsqlparser

0 commit comments

Comments
 (0)