Skip to content

Commit 34b1359

Browse files
jwendellclaude
andcommitted
Merge upstream hyrise/sql-parser changes
This merge brings 107 commits from upstream hyrise/sql-parser while preserving the MySQL-specific extensions from the Envoy fork: Upstream features included: - Window functions support (hyrise#233) - Row locking grammar (hyrise#205) - FOREIGN KEY constraints (hyrise#252) - NULLS FIRST/LAST in ORDER BY (hyrise#257) - BIGINT, SMALLINT, TIMESTAMP, BOOLEAN data types - Date/interval literals - Named columns for joins fix (hyrise#240) - String vector deallocation fix (hyrise#221) - GCC-13 compatibility (hyrise#245) - ARM Mac support (hyrise#216) - CSV import options for DELIMITER, NULL, QUOTE (hyrise#256) - Various bug fixes and improvements Fork features preserved: - tablesAccessed() method for tracking table access operations - MySQL-specific syntax: backticks, LOW_PRIORITY, IGNORE, QUICK - MySQL statements: CREATE/DROP/ALTER DATABASE, SHOW DATABASES - TEMPORARY tables, ALTER TABLE ADD COLUMN - include/sqlparser/ directory structure Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Jonh Wendell <jwendell@redhat.com>
2 parents 3b40ba2 + ccd3f68 commit 34b1359

62 files changed

Lines changed: 4412 additions & 2903 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -1
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlinesLeft: true
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: true
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: All
14+
AllowShortIfStatementsOnASingleLine: true
15+
AllowShortLoopsOnASingleLine: true
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: true
19+
AlwaysBreakTemplateDeclarations: true
20+
BinPackArguments: true
21+
BinPackParameters: true
22+
BraceWrapping:
23+
AfterClass: false
24+
AfterControlStatement: false
25+
AfterEnum: false
26+
AfterFunction: false
27+
AfterNamespace: false
28+
AfterObjCDeclaration: false
29+
AfterStruct: false
30+
AfterUnion: false
31+
BeforeCatch: false
32+
BeforeElse: false
33+
IndentBraces: false
34+
BreakBeforeBinaryOperators: None
35+
BreakBeforeBraces: Attach
36+
BreakBeforeTernaryOperators: true
37+
BreakConstructorInitializersBeforeComma: false
38+
ColumnLimit: 120
39+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
40+
ConstructorInitializerIndentWidth: 4
41+
ContinuationIndentWidth: 4
42+
Cpp11BracedListStyle: true
43+
DerivePointerAlignment: false
44+
DisableFormat: false
45+
ExperimentalAutoDetectBinPacking: false
46+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
47+
IncludeCategories:
48+
- Regex: '^<.*\.h>'
49+
Priority: 1
50+
- Regex: '^<.*'
51+
Priority: 2
52+
- Regex: '.*'
53+
Priority: 3
54+
IndentCaseLabels: true
55+
IndentWidth: 2
56+
IndentWrappedFunctionNames: false
57+
KeepEmptyLinesAtTheStartOfBlocks: false
58+
MacroBlockBegin: ''
59+
MacroBlockEnd: ''
60+
MaxEmptyLinesToKeep: 1
61+
NamespaceIndentation: None
62+
ObjCBlockIndentWidth: 2
63+
ObjCSpaceAfterProperty: false
64+
ObjCSpaceBeforeProtocolList: false
65+
PenaltyBreakBeforeFirstCallParameter: 1
66+
PenaltyBreakComment: 300
67+
PenaltyBreakFirstLessLess: 120
68+
PenaltyBreakString: 1000
69+
PenaltyExcessCharacter: 1000000
70+
PenaltyReturnTypeOnItsOwnLine: 200
71+
PointerAlignment: Left
72+
ReflowComments: false
73+
SortIncludes: true
74+
SpaceAfterCStyleCast: false
75+
SpaceBeforeAssignmentOperators: true
76+
SpaceBeforeParens: ControlStatements
77+
SpaceInEmptyParentheses: false
78+
SpacesBeforeTrailingComments: 2
79+
SpacesInAngles: false
80+
SpacesInContainerLiterals: true
81+
SpacesInCStyleCastParentheses: false
82+
SpacesInParentheses: false
83+
SpacesInSquareBrackets: false
84+
Standard: Auto
85+
TabWidth: 8
86+
UseTab: Never
87+
...

.github/workflows/ci.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
name: ${{matrix.name}}
12+
runs-on: ${{matrix.os}}
13+
container: ${{matrix.container}}
14+
env:
15+
CC: ${{matrix.cc}}
16+
CXX: ${{matrix.cxx}}
17+
defaults:
18+
run:
19+
shell: bash
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
- name: gcc-6
25+
cc: gcc-6
26+
cxx: g++-6
27+
os: ubuntu-latest
28+
container: ubuntu:18.04
29+
30+
- name: gcc-14
31+
cc: gcc-14
32+
cxx: g++-14
33+
os: ubuntu-latest
34+
container: ubuntu:24.04
35+
# We need relaxed builds for debug mode with current GCC versions, see #218.
36+
build_options: "relaxed_build=on"
37+
38+
- name: clang-19
39+
cc: clang-19
40+
cxx: clang++-19
41+
os: ubuntu-latest
42+
container: ubuntu:24.04
43+
44+
- name: clang-macOS
45+
cc: clang
46+
cxx: clang++
47+
os: macos-latest
48+
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
if: matrix.name != 'gcc-6'
53+
54+
- name: Checkout (Ubuntu 18.04)
55+
if: matrix.name == 'gcc-6'
56+
# Recent versions of Github's checkout action do not run on older Ubuntu versions because they use a too recent
57+
# Node.js version. Thus, we have to checkout the code manually.
58+
# Doing so is a bit tricky when it comes to PRs from forks (see #249 for details). The general idea here is that
59+
# we access Github's context information for the event triggering the action's execution and use some details on
60+
# the PR's HEAD if given. Otherwise (for executions due to main branch updates), we still use the provided
61+
# environment variables.
62+
run: |
63+
apt-get update
64+
apt-get install -y git
65+
git config --global --add safe.directory '*'
66+
git clone $(awk -v a=${{github.event.pull_request.head.repo.clone_url}} -v b="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" 'BEGIN { if (a == "") { print b } else { print a } }') .
67+
git checkout $GITHUB_HEAD_REF
68+
69+
- name: Setup (macOS)
70+
if: matrix.name == 'clang-macOS'
71+
run: |
72+
brew install bison flex
73+
echo "BISON=$(brew --prefix bison)/bin/bison" >> $GITHUB_ENV
74+
echo "FLEX=$(brew --prefix flex)/bin/flex" >> $GITHUB_ENV
75+
76+
- name: Setup (Ubuntu)
77+
if: matrix.name != 'clang-macOS'
78+
run: |
79+
apt-get update
80+
apt-get install --no-install-recommends -y bison flex ${CC} ${CXX} make valgrind
81+
echo "BISON=bison" >> $GITHUB_ENV
82+
echo "FLEX=flex" >> $GITHUB_ENV
83+
84+
- name: System Information
85+
run: |
86+
awk -v a=$(uname) 'BEGIN { a == "Linux" ? system("cat /etc/issue") : system("sw_vers") }'
87+
${CC} --version
88+
${CXX} --version
89+
${BISON} --version
90+
${FLEX} --version
91+
awk -v a=$(uname) 'BEGIN { if (a == "Linux") system("valgrind --version") }'
92+
93+
- name: Build Parser
94+
run: |
95+
make -j $(nproc)
96+
BISON=${BISON} FLEX=${FLEX} make test
97+
make test_example
98+
99+
- name: Build Parser and Lexer from Scratch
100+
run: |
101+
BISON=${BISON} FLEX=${FLEX} make cleanall
102+
BISON=${BISON} FLEX=${FLEX} make -j $(nproc)
103+
BISON=${BISON} FLEX=${FLEX} make test
104+
make test_example
105+
106+
- name: Build Parser and Lexer from Scratch (Debug)
107+
run: |
108+
BISON=${BISON} FLEX=${FLEX} make cleanall
109+
BISON=${BISON} FLEX=${FLEX} make -j $(nproc) mode=debug ${{matrix.build_options}}
110+
BISON=${BISON} FLEX=${FLEX} make test
111+
make test_example

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ cmake-build-debug/
4848

4949
# macOS compilation dirs
5050
*.dSYM
51+
.DS_STORE
52+
53+
.vscode/*

.travis.yml

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

Makefile

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,30 @@ GMAKE = make mode=$(mode)
3737
NAME := sqlparser
3838
PARSER_CPP = $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
3939
PARSER_H = $(SRCPARSER)/bison_parser.h $(SRCPARSER)/flex_lexer.h
40-
LIB_CFLAGS = -std=c++11 -Wall -Werror $(OPT_FLAG)
40+
LIB_CFLAGS = -std=c++17 $(OPT_FLAG)
41+
42+
relaxed_build ?= "off"
43+
ifeq ($(relaxed_build), on)
44+
$(warning $(NAME) will be built with most compiler warnings deactivated. This is fine if you want to test $(NAME) but will become an issue when you want to contribute code.)
45+
else
46+
LIB_CFLAGS += -Wall -Werror
47+
# Clang: ensure files end with newline. Missing final newlines here triggered
48+
# -Wnewline-eof warnings in downstream projects (e.g., Hyrise).
49+
ifneq (,$(findstring clang,$(shell $(CXX) --version 2>/dev/null)))
50+
LIB_CFLAGS += -Wnewline-eof
51+
endif
52+
endif
4153

4254
static ?= no
4355
ifeq ($(static), yes)
4456
LIB_BUILD = lib$(NAME).a
45-
LIBLINKER = $(AR)
57+
LIBLINKER = $(AR)
4658
LIB_LFLAGS = rs
4759
else
48-
LIB_BUILD = lib$(NAME).so
49-
LIBLINKER = $(CXX)
50-
LIB_CFLAGS += -fPIC
51-
LIB_LFLAGS = -shared -o
60+
LIB_BUILD = lib$(NAME).so
61+
LIBLINKER = $(CXX)
62+
LIB_CFLAGS += -fPIC
63+
LIB_LFLAGS = -shared -o
5264
endif
5365
LIB_CPP = $(sort $(shell find $(SRC) -name '*.cpp' -not -path "$(SRCPARSER)/*") $(PARSER_CPP))
5466
LIB_H = $(shell find $(INCLUDE) -name '*.h' -not -path "$(SRCPARSER)/*") $(PARSER_H)
@@ -60,8 +72,11 @@ library: $(LIB_BUILD)
6072
$(LIB_BUILD): $(LIB_OBJ)
6173
$(LIBLINKER) $(LIB_LFLAGS) $(LIB_BUILD) $(LIB_OBJ)
6274

75+
# The auto-generated code from bison and flex contains some parts the compiler complains about with -Wall.
6376
$(SRCPARSER)/flex_lexer.o: $(SRCPARSER)/flex_lexer.cpp $(SRCPARSER)/bison_parser.cpp
6477
$(CXX) $(LIB_CFLAGS) -c -o $@ $< -Wno-sign-compare -Wno-unneeded-internal-declaration -Wno-register
78+
$(SRCPARSER)/bison_parser.o: $(SRCPARSER)/bison_parser.cpp
79+
$(CXX) $(LIB_CFLAGS) -c -o $@ $< -Wno-unused-but-set-variable
6580

6681
%.o: %.cpp $(PARSER_CPP) $(LIB_H)
6782
$(CXX) $(LIB_CFLAGS) -c -o $@ $<
@@ -120,11 +135,11 @@ $(BM_BUILD): $(BM_ALL) $(LIB_BUILD)
120135
########################################
121136
############ Test & Example ############
122137
########################################
123-
TEST_BUILD = $(BIN)/tests
124-
TEST_CFLAGS = -std=c++11 -Wall -Isrc/ -Iinclude/sqlparser/ -Itest/ -L./ $(OPT_FLAG)
125-
TEST_CPP = $(shell find test/ -name '*.cpp')
126-
TEST_ALL = $(shell find test/ -name '*.cpp') $(shell find test/ -name '*.h')
127-
EXAMPLE_SRC = $(shell find example/ -name '*.cpp') $(shell find example/ -name '*.h')
138+
TEST_BUILD = $(BIN)/tests
139+
TEST_CFLAGS = -std=c++17 -Wall -Werror -Isrc/ -Iinclude/sqlparser/ -Itest/ -L./ $(OPT_FLAG)
140+
TEST_CPP = $(shell find test/ -name '*.cpp')
141+
TEST_ALL = $(shell find test/ -name '*.cpp') $(shell find test/ -name '*.h')
142+
EXAMPLE_SRC = $(shell find example/ -name '*.cpp') $(shell find example/ -name '*.h')
128143

129144
test: $(TEST_BUILD)
130145
bash test/test.sh
@@ -142,17 +157,5 @@ test_format:
142157
@! astyle --options=astyle.options $(LIB_ALL) | grep -q "Formatted"
143158
@! astyle --options=astyle.options $(TEST_ALL) | grep -q "Formatted"
144159

145-
146-
147-
########################################
148-
################# Misc #################
149-
########################################
150-
151160
format:
152-
astyle --options=astyle.options $(LIB_ALL)
153-
astyle --options=astyle.options $(TEST_ALL)
154-
astyle --options=astyle.options $(EXAMPLE_SRC)
155-
156-
log_mode:
157-
@echo $(MODE_LOG)
158-
161+
./format.sh

astyle.options

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

benchmark/queries.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include "queries.h"
22

3-
#include <experimental/filesystem>
3+
#include <filesystem>
44
#include <algorithm>
55
#include <iostream>
66
#include <regex>
77

88
#include "benchmark_utils.h"
99

10-
namespace filesystem = std::experimental::filesystem;
10+
namespace filesystem = std::filesystem;
1111

1212
std::string getQueryName(unsigned i) {
1313
if (sql_queries[i].first.empty()) {

docs/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ Internal Links:
66
* [Developer Documentation](dev-docs.md)
77
* [Supported SQL Queries](syntax-support.md)
88
* [Known Limitations & Missing Features](known-limitations.md)
9+
* [Basic Usage](basic-usage.md)
910

1011

1112
External Resources:
1213

1314
* [Original Dev-Paper (2015)](http://torpedro.com/paper/HyriseSQL-03-2015.pdf)
14-
* [Blog Post about Basic Usage](http://torpedro.github.io/tech/c++/sql/parser/2016/02/27/c++-sql-parser.html)
15-
16-

0 commit comments

Comments
 (0)