Skip to content

Commit 5d1a12d

Browse files
committed
build: add PostgreSQL compatibility commands
1 parent 7663f51 commit 5d1a12d

4 files changed

Lines changed: 655 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ run_tests_debug
4242
corpus_test
4343
run_bench
4444
run_bench_compare
45+
pg_compat_17
46+
pg_compat_18
4547
bench/sqlparser_rs_bench/target/

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ MYSQL_CFLAGS = $(shell mysql_config --cflags 2>/dev/null)
77
MYSQL_LIBS = $(shell mysql_config --libs 2>/dev/null)
88
PG_CFLAGS = -I$(shell pg_config --includedir 2>/dev/null || echo /usr/include/postgresql)
99
PG_LIBS = -L$(shell pg_config --libdir 2>/dev/null || echo /usr/lib/x86_64-linux-gnu) -lpq
10+
PG_COMPAT_CACHE ?= /tmp/parsersql-pg-compat
1011

1112
PROJECT_ROOT = .
1213
SRC_DIR = $(PROJECT_ROOT)/src/sql_parser
@@ -121,12 +122,26 @@ ENGINE_STRESS_TARGET = engine_stress_test
121122
MYSQL_SERVER_SRC = $(PROJECT_ROOT)/tools/mysql_server.cpp
122123
MYSQL_SERVER_TARGET = mysql_server
123124

124-
.PHONY: all lib test test-sqlengine test-sqlengine-in-memory test-sqlengine-single test-sqlengine-sharded bench bench-compare bench-distributed build-corpus-test build-sqlengine engine-stress mysql-server clean
125+
.PHONY: all lib test test-sqlengine test-sqlengine-in-memory test-sqlengine-single test-sqlengine-sharded bench bench-compare bench-distributed build-corpus-test build-sqlengine build-pg-compat pg-compat pg-compat-refresh test-pg-compat engine-stress mysql-server clean
125126

126127
build-corpus-test: $(CORPUS_TEST_TARGET)
127128

128129
build-sqlengine: $(SQLENGINE_TARGET)
129130

131+
build-pg-compat: lib
132+
PG_COMPAT_CACHE=$(PG_COMPAT_CACHE) ./scripts/pg_compat/fetch_libpg_query.sh
133+
python3 ./scripts/pg_compat/run_compat.py build --cache $(PG_COMPAT_CACHE)
134+
135+
test-pg-compat: build-pg-compat
136+
PG_COMPAT_RUNNER=$(PG_COMPAT_CACHE)/bin/pg_compat-18 python3 -m unittest discover -s tests/pg_compat -p 'test_*.py' -v
137+
python3 ./scripts/pg_compat/run_compat.py test --cache $(PG_COMPAT_CACHE)
138+
139+
pg-compat: build-pg-compat
140+
python3 ./scripts/pg_compat/run_compat.py full --cache $(PG_COMPAT_CACHE)
141+
142+
pg-compat-refresh: build-pg-compat
143+
python3 ./scripts/pg_compat/run_compat.py refresh --cache $(PG_COMPAT_CACHE)
144+
130145
all: lib test
131146

132147
lib: $(LIB_TARGET)

0 commit comments

Comments
 (0)