Skip to content

Commit e67b478

Browse files
jfrochesamrose
andauthored
feat: support multiple versions of the pg_jsonschema extension (#1757)
* feat: multiple versions for the pg_jsonschema extension Build multiple versions of the pg_jsonschema extension to on different PostgreSQL versions. Add test for the extensions and their upgrade on PostgreSQL 15 and 17. * fix: centralize bindgen hook override for pgrx extensions Move the bindgen hook fix for ARM NEON vector ABI issues from pg_graphql to mkPgrxExtension, making it available to all pgrx-based extensions. This fix applies to pgrx versions 0.6.1 through 0.11.2 when building on aarch64-linux. * fix: missing dependency on macOS for pg_jsonschema * chore: bump to release --------- Co-authored-by: Sam Rose <[email protected]>
1 parent cdb8609 commit e67b478

File tree

16 files changed

+7825
-124
lines changed

16 files changed

+7825
-124
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ common-nix.vars.pkr.hcl
3030

3131
# pre-commit config is managed in nix
3232
.pre-commit-config.yaml
33-
nixos.qcow2
33+
nixos.qcow2

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ postgres_major:
1010

1111
# Full version strings for each major version
1212
postgres_release:
13-
postgresorioledb-17: 17.5.1.039-orioledb
14-
postgres17: 17.6.1.018
15-
postgres15: 15.14.1.018
13+
postgresorioledb-17: "17.5.1.040-orioledb"
14+
postgres17: "17.6.1.019"
15+
postgres15: "15.14.1.019"
1616

1717
# Non Postgres Extensions
1818
pgbouncer_release: 1.19.0

nix/cargo-pgrx/buildPgrxExtension.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
stdenv,
3535
darwin,
3636
writeShellScriptBin,
37+
defaultBindgenHook,
3738
}:
3839

3940
# The idea behind: Use it mostly like rustPlatform.buildRustPackage and so
@@ -56,7 +57,7 @@
5657
# enable override to generate bindings using bindgenHook.
5758
# Some older versions of cargo-pgrx use a bindgenHook that is not compatible with the
5859
# current clang version present in stdenv
59-
bindgenHook ? rustPlatform.bindgenHook,
60+
bindgenHook ? defaultBindgenHook,
6061
# cargo-pgrx calls rustfmt on generated bindings, this is not strictly necessary, so we avoid the
6162
# dependency here. Set to false and provide rustfmt in nativeBuildInputs, if you need it, e.g.
6263
# if you include the generated code in the output via postInstall.

nix/cargo-pgrx/default.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ let
6060
};
6161
in
6262
{
63+
cargo-pgrx_0_10_2 = mkCargoPgrx {
64+
version = "0.10.2";
65+
hash = "sha256-FqjfbJmSy5UCpPPPk4bkEyvQCnaH9zYtkI7txgIn+ls=";
66+
cargoHash = "sha256-syZ3cQq8qDHBLvqmNDGoxeK6zXHJ47Jwkw3uhaXNCzI=";
67+
};
6368
cargo-pgrx_0_11_3 = mkCargoPgrx {
6469
version = "0.11.3";
6570
hash = "sha256-UHIfwOdXoJvR4Svha6ud0FxahP1wPwUtviUwUnTmLXU=";

nix/cargo-pgrx/mkPgrxExtension.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
pgrxVersion,
55
makeRustPlatform,
66
rust-bin,
7+
system,
78
}:
89
let
910
inherit ((callPackage ./default.nix { inherit rustVersion; })) mkCargoPgrx;
@@ -31,8 +32,28 @@ let
3132
inherit (mapping) hash cargoHash;
3233
version = pgrxVersion;
3334
};
35+
36+
bindgenHook =
37+
# Fix bindgen error on aarch64-linux for versions using pgrx with bindgen 0.68.1
38+
# This affects pgrx 0.6.1 through 0.11.2 which have issues with ARM NEON vector ABI
39+
if (builtins.compareVersions "0.11.3" pgrxVersion > 0) then
40+
let
41+
nixos2211 = (
42+
import (builtins.fetchTarball {
43+
url = "https://channels.nixos.org/nixos-22.11/nixexprs.tar.xz";
44+
sha256 = "1j7h75a9hwkkm97jicky5rhvzkdwxsv5v46473rl6agvq2sj97y1";
45+
}) { inherit system; }
46+
);
47+
in
48+
rustPlatform.bindgenHook.overrideAttrs {
49+
libclang = nixos2211.clang.cc.lib;
50+
clang = nixos2211.clang;
51+
}
52+
else
53+
rustPlatform.bindgenHook;
3454
in
3555
callPackage ./buildPgrxExtension.nix {
3656
inherit rustPlatform;
3757
inherit cargo-pgrx;
58+
defaultBindgenHook = bindgenHook;
3859
}

nix/cargo-pgrx/versions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
"rust": {
3737
"1.70.0": {
3838
"cargoHash": "sha256-syZ3cQq8qDHBLvqmNDGoxeK6zXHJ47Jwkw3uhaXNCzI="
39+
},
40+
"1.76.0": {
41+
"cargoHash": "sha256-syZ3cQq8qDHBLvqmNDGoxeK6zXHJ47Jwkw3uhaXNCzI="
3942
}
4043
}
4144
},

nix/ext/pg_graphql/default.nix

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
postgresql,
88
rust-bin,
99
rsync,
10-
system,
11-
rustPlatform,
1210
}:
1311

1412
let
@@ -104,30 +102,6 @@ let
104102
inherit (postgresql.meta) platforms;
105103
};
106104
}
107-
//
108-
lib.optionalAttrs
109-
(
110-
# Fix bindgen error on aarch64-linux for versions using pgrx with bindgen 0.68.1
111-
# This affects pgrx 0.6.1 through 0.11.2 which have issues with ARM NEON vector ABI
112-
# We apply the fix to all versions up to 1.5.1 (last version before 1.5.4 which uses 0.11.2)
113-
builtins.compareVersions "1.5.4" version > 0
114-
)
115-
{
116-
# Fix bindgen error on aarch64-linux by using an older version of clang
117-
bindgenHook =
118-
let
119-
nixos2211 = (
120-
import (builtins.fetchTarball {
121-
url = "https://channels.nixos.org/nixos-22.11/nixexprs.tar.xz";
122-
sha256 = "1j7h75a9hwkkm97jicky5rhvzkdwxsv5v46473rl6agvq2sj97y1";
123-
}) { inherit system; }
124-
);
125-
in
126-
rustPlatform.bindgenHook.overrideAttrs {
127-
libclang = nixos2211.clang.cc.lib;
128-
clang = nixos2211.clang;
129-
};
130-
}
131105
// lib.optionalAttrs (builtins.compareVersions "1.2.0" version >= 0) {
132106
# Add missing Cargo.lock
133107
patches = [ ./0001-Add-missing-Cargo.lock-${version}.patch ];

nix/ext/pg_jsonschema.nix

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

0 commit comments

Comments
 (0)