Skip to content

Commit 0642bfa

Browse files
committed
feat: support multiple versions of the plv8 extension
Build multiple versions of the plv8 extension on different PostgreSQL versions. Add test for the extensions and their upgrade on PostgreSQL 15 and 17.
1 parent fb79d32 commit 0642bfa

9 files changed

+632
-162
lines changed

nix/ext/plv8.nix

Lines changed: 0 additions & 160 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
From e473bab9483d937d8cab4313b9b45de0571c20fa Mon Sep 17 00:00:00 2001
2+
From: Jan Tojnar <[email protected]>
3+
Date: Thu, 13 Oct 2022 10:16:32 +0200
4+
Subject: [PATCH] build: Allow using V8 from system
5+
6+
Building V8 is slow and pointless on systems that already provide a recent version like some Linux distros.
7+
With this change, you can build against system V8 with the following:
8+
9+
make USE_SYSTEM_V8=1 SHLIB_LINK=-lv8 V8_OUTDIR=/usr/lib
10+
---
11+
Makefile | 35 +++++++++++++++++++----------------
12+
1 file changed, 19 insertions(+), 16 deletions(-)
13+
14+
diff --git a/Makefile b/Makefile
15+
index 2f1f9f1..cfa50bc 100644
16+
--- a/Makefile
17+
+++ b/Makefile
18+
@@ -20,7 +20,7 @@ OBJS = $(SRCS:.cc=.o)
19+
MODULE_big = plv8-$(PLV8_VERSION)
20+
EXTENSION = plv8
21+
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql $(wildcard upgrade/*.sql)
22+
-
23+
+USE_SYSTEM_V8 = 0
24+
25+
# Platform detection
26+
ifeq ($(OS),Windows_NT)
27+
@@ -41,6 +41,7 @@ PGXS := $(shell $(PG_CONFIG) --pgxs)
28+
PG_VERSION_NUM := $(shell cat `$(PG_CONFIG) --includedir-server`/pg_config*.h \
29+
| perl -ne 'print $$1 and exit if /PG_VERSION_NUM\s+(\d+)/')
30+
31+
+ifeq ($(USE_SYSTEM_V8),0)
32+
AUTOV8_DIR = build/v8
33+
AUTOV8_OUT = build/v8/out.gn/obj
34+
AUTOV8_STATIC_LIBS = -lv8_libplatform -lv8_libbase
35+
@@ -63,21 +64,6 @@ v8:
36+
endif
37+
38+
39+
-# enable direct jsonb conversion by default
40+
-CCFLAGS += -DJSONB_DIRECT_CONVERSION
41+
-
42+
-CCFLAGS += -DV8_COMPRESS_POINTERS=1 -DV8_31BIT_SMIS_ON_64BIT_ARCH=1
43+
-
44+
-CCFLAGS += -I$(AUTOV8_DIR)/include -I$(AUTOV8_DIR)
45+
-
46+
-ifdef EXECUTION_TIMEOUT
47+
- CCFLAGS += -DEXECUTION_TIMEOUT
48+
-endif
49+
-
50+
-ifdef BIGINT_GRACEFUL
51+
- CCFLAGS += -DBIGINT_GRACEFUL
52+
-endif
53+
-
54+
55+
# We're gonna build static link. Rip it out after include Makefile
56+
SHLIB_LINK := $(filter-out -lv8, $(SHLIB_LINK))
57+
@@ -97,6 +83,23 @@ else
58+
SHLIB_LINK += -lrt -std=c++14
59+
endif
60+
endif
61+
+endif
62+
+
63+
+# enable direct jsonb conversion by default
64+
+CCFLAGS += -DJSONB_DIRECT_CONVERSION
65+
+
66+
+CCFLAGS += -DV8_COMPRESS_POINTERS=1 -DV8_31BIT_SMIS_ON_64BIT_ARCH=1
67+
+
68+
+CCFLAGS += -I$(AUTOV8_DIR)/include -I$(AUTOV8_DIR)
69+
+
70+
+ifdef EXECUTION_TIMEOUT
71+
+ CCFLAGS += -DEXECUTION_TIMEOUT
72+
+endif
73+
+
74+
+ifdef BIGINT_GRACEFUL
75+
+ CCFLAGS += -DBIGINT_GRACEFUL
76+
+endif
77+
+
78+
79+
DATA = $(PLV8_DATA)
80+
ifndef DISABLE_DIALECT
81+
--
82+
2.49.0
83+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
From 7523ea5bced10511688e73f6261857c04726a8a9 Mon Sep 17 00:00:00 2001
2+
From: Jan Tojnar <[email protected]>
3+
Date: Thu, 13 Oct 2022 10:16:32 +0200
4+
Subject: [PATCH] build: Allow using V8 from system
5+
6+
Building V8 is slow and pointless on systems that already provide a recent version like some Linux distros.
7+
With this change, you can build against system V8 with the following:
8+
9+
make USE_SYSTEM_V8=1 SHLIB_LINK=-lv8 V8_OUTDIR=/usr/lib
10+
---
11+
Makefile | 36 ++++++++++++++++++++----------------
12+
1 file changed, 20 insertions(+), 16 deletions(-)
13+
14+
diff --git a/Makefile b/Makefile
15+
index 38879cc..a6abae5 100644
16+
--- a/Makefile
17+
+++ b/Makefile
18+
@@ -20,6 +20,7 @@ OBJS = $(SRCS:.cc=.o)
19+
MODULE_big = plv8-$(PLV8_VERSION)
20+
EXTENSION = plv8
21+
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql $(wildcard upgrade/*.sql)
22+
+USE_SYSTEM_V8 = 0
23+
24+
25+
# Platform detection
26+
@@ -41,6 +42,7 @@ PGXS := $(shell $(PG_CONFIG) --pgxs)
27+
PG_VERSION_NUM := $(shell cat `$(PG_CONFIG) --includedir-server`/pg_config*.h \
28+
| perl -ne 'print $$1 and exit if /PG_VERSION_NUM\s+(\d+)/')
29+
30+
+ifeq ($(USE_SYSTEM_V8),0)
31+
AUTOV8_DIR = build/v8
32+
AUTOV8_OUT = build/v8/out.gn/obj
33+
AUTOV8_STATIC_LIBS = -lv8_libplatform -lv8_libbase
34+
@@ -67,22 +69,6 @@ v8:
35+
endif
36+
endif
37+
38+
-# enable direct jsonb conversion by default
39+
-CCFLAGS += -DJSONB_DIRECT_CONVERSION
40+
-
41+
-CCFLAGS += -DV8_COMPRESS_POINTERS=1 -DV8_31BIT_SMIS_ON_64BIT_ARCH=1
42+
-
43+
-CCFLAGS += -I$(AUTOV8_DIR)/include -I$(AUTOV8_DIR)
44+
-
45+
-ifdef EXECUTION_TIMEOUT
46+
- CCFLAGS += -DEXECUTION_TIMEOUT
47+
-endif
48+
-
49+
-ifdef BIGINT_GRACEFUL
50+
- CCFLAGS += -DBIGINT_GRACEFUL
51+
-endif
52+
-
53+
-
54+
# We're gonna build static link. Rip it out after include Makefile
55+
SHLIB_LINK := $(filter-out -lv8, $(SHLIB_LINK))
56+
57+
@@ -101,6 +87,24 @@ else
58+
SHLIB_LINK += -lrt -std=c++14
59+
endif
60+
endif
61+
+endif
62+
+
63+
+
64+
+# enable direct jsonb conversion by default
65+
+CCFLAGS += -DJSONB_DIRECT_CONVERSION
66+
+
67+
+CCFLAGS += -DV8_COMPRESS_POINTERS=1 -DV8_31BIT_SMIS_ON_64BIT_ARCH=1
68+
+
69+
+CCFLAGS += -I$(AUTOV8_DIR)/include -I$(AUTOV8_DIR)
70+
+
71+
+ifdef EXECUTION_TIMEOUT
72+
+ CCFLAGS += -DEXECUTION_TIMEOUT
73+
+endif
74+
+
75+
+ifdef BIGINT_GRACEFUL
76+
+ CCFLAGS += -DBIGINT_GRACEFUL
77+
+endif
78+
+
79+
80+
DATA = $(PLV8_DATA)
81+
ifndef DISABLE_DIALECT
82+
--
83+
2.49.0
84+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From bfe98c83bdcc0f3c33d836e03e6d4cf7199c8d37 Mon Sep 17 00:00:00 2001
2+
From: Jan Tojnar <[email protected]>
3+
Date: Thu, 13 Oct 2022 10:16:32 +0200
4+
Subject: [PATCH] build: Allow using V8 from system
5+
6+
Building V8 is slow and pointless on systems that already provide a recent version like some Linux distros.
7+
With this change, you can build against system V8 with the following:
8+
9+
make USE_SYSTEM_V8=1 SHLIB_LINK=-lv8 V8_OUTDIR=/usr/lib
10+
---
11+
Makefile | 3 +++
12+
1 file changed, 3 insertions(+)
13+
14+
diff --git a/Makefile b/Makefile
15+
index 1180fae..c74b23d 100644
16+
--- a/Makefile
17+
+++ b/Makefile
18+
@@ -13,6 +13,7 @@ OBJS = $(SRCS:.cc=.o)
19+
MODULE_big = plv8-$(PLV8_VERSION)
20+
EXTENSION = plv8
21+
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql
22+
+USE_SYSTEM_V8 = 0
23+
24+
ifeq ($(OS),Windows_NT)
25+
# noop for now
26+
@@ -34,6 +35,7 @@ ifeq ($(NUMPROC),0)
27+
NUMPROC = 1
28+
endif
29+
30+
+ifeq ($(USE_SYSTEM_V8),0)
31+
SHLIB_LINK += -Ldeps/v8-cmake/build
32+
33+
all: v8 $(OBJS)
34+
@@ -48,6 +50,7 @@ deps/v8-cmake/build/libv8_libbase.a: deps/v8-cmake/README.md
35+
@cd deps/v8-cmake && mkdir -p build && cd build && cmake -Denable-fPIC=ON -DCMAKE_BUILD_TYPE=Release ../ && make -j $(NUMPROC)
36+
37+
v8: deps/v8-cmake/build/libv8_libbase.a
38+
+endif
39+
40+
# enable direct jsonb conversion by default
41+
CCFLAGS += -DJSONB_DIRECT_CONVERSION
42+
--
43+
2.49.0
44+

0 commit comments

Comments
 (0)