From b4c552dddefc5c75a818a9f2ff84cefa36856581 Mon Sep 17 00:00:00 2001 From: Andrew Jackson <46945903+AndrewJackson2020@users.noreply.github.com> Date: Fri, 14 Feb 2025 10:08:31 -0600 Subject: [PATCH] Add postgres version check in makefile (#605) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds a version check to the makefile. I know the versions are specified in the docs but is a bit more user friendly to have the build failed with an error message. Behavior with this patch ```console $ PATH=/path/to/postgres/18/bin:$PATH make Makefile.global:11: *** maximum version of PostgreSQL required is 17 (but have 18). Stop. ``` Behavior without this patch ```bash $ PATH=path/to/pg18/bin:$PATH make g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -O2 -std=c++17 -Wno-sign-compare -Wshadow -Wswitch -Wunused-parameter -Wunreachable-code -Wno-unknown-pragmas -Wall -Wextra -Wno-register -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Iinclude -isystem third_party/duckdb/src/include -isystem third_party/duckdb/third_party/re2 -isystem path/to/pg18/include/server -Wno-sign-compare -Wshadow -Wswitch -Wunused-parameter -Wunreachable-code -Wno-unknown-pragmas -Wall -Wextra -I. -I./ -Ipath/to/pg18/include/server -Ipath/to/pg18/include/internal -D_GNU_SOURCE -c -o src/pgduckdb_background_worker.o src/pgduckdb_background_worker.cpp -MMD -MP -MF .deps/pgduckdb_background_worker.Po g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -O2 -std=c++17 -Wno-sign-compare -Wshadow -Wswitch -Wunused-parameter -Wunreachable-code -Wno-unknown-pragmas -Wall -Wextra -Wno-register -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Iinclude -isystem third_party/duckdb/src/include -isystem third_party/duckdb/third_party/re2 -isystem path/to/pg18/include/server -Wno-sign-compare -Wshadow -Wswitch -Wunused-parameter -Wunreachable-code -Wno-unknown-pragmas -Wall -Wextra -I. -I./ -Ipath/to/pg18/include/server -Ipath/to/pg18/include/internal -D_GNU_SOURCE -c -o src/pgduckdb.o src/pgduckdb.cpp -MMD -MP -MF .deps/pgduckdb.Po g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -O2 -std=c++17 -Wno-sign-compare -Wshadow -Wswitch -Wunused-parameter -Wunreachable-code -Wno-unknown-pragmas -Wall -Wextra -Wno-register -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Iinclude -isystem third_party/duckdb/src/include -isystem third_party/duckdb/third_party/re2 -isystem path/to/pg18/include/server -Wno-sign-compare -Wshadow -Wswitch -Wunused-parameter -Wunreachable-code -Wno-unknown-pragmas -Wall -Wextra -I. -I./ -Ipath/to/pg18/include/server -Ipath/to/pg18/include/internal -D_GNU_SOURCE -c -o src/pgduckdb_ddl.o src/pgduckdb_ddl.cpp -MMD -MP -MF .deps/pgduckdb_ddl.Po src/pgduckdb_ddl.cpp: In function ‘void DuckdbHandleDDL(PlannedStmt*, const char*, ParamListInfo)’: src/pgduckdb_ddl.cpp:186:49: error: cannot convert ‘Node*’ to ‘Query*’ in assignment 186 | stmt->into->viewQuery = (Node *)copyObjectImpl(stmt->query); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | Node* make: *** [Makefile.global:38: src/pgduckdb_ddl.o] Error 1 ``` --------- Co-authored-by: Jelte Fennema-Nio --- Makefile.global | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Makefile.global b/Makefile.global index fd08f4ae..03b91ea8 100644 --- a/Makefile.global +++ b/Makefile.global @@ -1,5 +1,17 @@ PG_CONFIG ?= pg_config +PG_MIN_VER = 14 +PG_VER = $(shell $(PG_CONFIG) --version | sed "s/^[^ ]* \([0-9]*\).*$$/\1/" 2>/dev/null) +ifeq ($(shell expr "$(PG_MIN_VER)" \<= "$(PG_VER)"), 0) +$(error Minimum version of PostgreSQL required is $(PG_MIN_VER) (but have $(PG_VER))) +endif + +# If you want to test with an unsupported PG version you can pass a different value to make +PG_MAX_VER ?= 17 +ifeq ($(shell expr "$(PG_MAX_VER)" \>= "$(PG_VER)"), 0) +$(error Maximum supported version of PostgreSQL is $(PG_MAX_VER) (but have $(PG_VER))) +endif + PGXS := $(shell $(PG_CONFIG) --pgxs) PG_LIB := $(shell $(PG_CONFIG) --pkglibdir) PG_LIBDIR := $(shell $(PG_CONFIG) --libdir)