Skip to content

Commit 4ee4b8b

Browse files
committed
Introduce a blocklist of "yanked" Postgres versions (#1950)
Due to the out-of-band release set described here: https://www.postgresql.org/about/news/postgresql-172-166-1510-1415-1318-and-1222-released-2965/, we should refuse to compile on the prior point releases mentioned in this press release.
1 parent dd4155c commit 4ee4b8b

File tree

4 files changed

+154
-9
lines changed

4 files changed

+154
-9
lines changed

.github/workflows/package-test.yaml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,73 @@ jobs:
2222
with:
2323
prefix-key: "v1-pgrx--package-test"
2424

25+
- name: Set up prerequisites and environment
26+
run: |
27+
sudo apt-get update -y -qq --fix-missing
28+
29+
echo ""
30+
echo "----- Install sccache -----"
31+
mkdir -p $HOME/.local/bin
32+
curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | tar xz
33+
mv -f sccache-v0.2.15-x86_64-unknown-linux-musl/sccache $HOME/.local/bin/sccache
34+
chmod +x $HOME/.local/bin/sccache
35+
echo "$HOME/.local/bin" >> $GITHUB_PATH
36+
mkdir -p /home/runner/.cache/sccache
37+
echo ""
38+
39+
echo "----- Set up dynamic variables -----"
40+
cat $GITHUB_ENV
41+
echo ""
42+
43+
echo "----- Remove old postgres -----"
44+
sudo apt remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*'
45+
echo ""
46+
47+
echo "----- Install system dependencies -----"
48+
sudo apt-get install -y \
49+
build-essential \
50+
llvm-14-dev libclang-14-dev clang-14 \
51+
gcc \
52+
libssl-dev \
53+
libz-dev \
54+
make \
55+
pkg-config \
56+
strace \
57+
zlib1g-dev
58+
echo ""
59+
60+
"$TOOL_DIR"/rustup.sh
61+
62+
echo "----- Set up cross compilation -----"
63+
sudo apt-get install -y --fix-missing crossbuild-essential-arm64
64+
65+
echo 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc' >> $GITHUB_ENV
66+
# TODO: not all of these should be needed, but for now it's likely fine.
67+
echo 'BINDGEN_EXTRA_CLANG_ARGS_aarch64-unknown-linux-gnu=-target aarch64-unknown-linux-gnu -isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc' >> $GITHUB_ENV
68+
69+
echo "----- Print env -----"
70+
env
71+
echo ""
72+
73+
- name: Setup release Postgres apt repo
74+
run: |
75+
sudo apt-get install -y wget gnupg
76+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
77+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
78+
2579
- name: Install Postgres deps
2680
run: |
2781
sudo apt-get update -y -qq --fix-missing
28-
sudo apt-get install -y postgresql-server-dev-$PG_VER
82+
sudo apt-get install -y postgresql-$PG_VER postgresql-server-dev-$PG_VER
2983
3084
- name: Rustup
3185
run: $TOOL_DIR/rustup.sh nightly
3286

87+
- name: Report version
88+
run: |
89+
cargo --version
90+
pg_config --version
91+
3392
- name: Install cargo pgrx
3493
run: cargo +nightly install --path cargo-pgrx --debug
3594

.github/workflows/runas.yml

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
env:
1010
CARGO_TERM_COLOR: always
1111
RUST_BACKTRACE: 1
12+
TOOL_DIR: ./tools
13+
PG_VER: 14
1214

1315
jobs:
1416
ubuntu:
@@ -20,13 +22,69 @@ jobs:
2022
with:
2123
prefix-key: "v1-cargo-pgrx-test--runas"
2224

25+
- name: Set up prerequisites and environment
26+
run: |
27+
sudo apt-get update -y -qq --fix-missing
28+
29+
echo ""
30+
echo "----- Install sccache -----"
31+
mkdir -p $HOME/.local/bin
32+
curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | tar xz
33+
mv -f sccache-v0.2.15-x86_64-unknown-linux-musl/sccache $HOME/.local/bin/sccache
34+
chmod +x $HOME/.local/bin/sccache
35+
echo "$HOME/.local/bin" >> $GITHUB_PATH
36+
mkdir -p /home/runner/.cache/sccache
37+
echo ""
38+
39+
echo "----- Set up dynamic variables -----"
40+
cat $GITHUB_ENV
41+
echo ""
42+
43+
echo "----- Remove old postgres -----"
44+
sudo apt remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*'
45+
echo ""
46+
47+
echo "----- Install system dependencies -----"
48+
sudo apt-get install -y \
49+
build-essential \
50+
llvm-14-dev libclang-14-dev clang-14 \
51+
gcc \
52+
libssl-dev \
53+
libz-dev \
54+
make \
55+
pkg-config \
56+
strace \
57+
zlib1g-dev
58+
echo ""
59+
60+
"$TOOL_DIR"/rustup.sh
61+
62+
echo "----- Set up cross compilation -----"
63+
sudo apt-get install -y --fix-missing crossbuild-essential-arm64
64+
65+
echo 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc' >> $GITHUB_ENV
66+
# TODO: not all of these should be needed, but for now it's likely fine.
67+
echo 'BINDGEN_EXTRA_CLANG_ARGS_aarch64-unknown-linux-gnu=-target aarch64-unknown-linux-gnu -isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc' >> $GITHUB_ENV
68+
69+
echo "----- Print env -----"
70+
env
71+
echo ""
72+
73+
- name: Setup release Postgres apt repo
74+
run: |
75+
sudo apt-get install -y wget gnupg
76+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
77+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
78+
2379
- name: Install Postgres deps
2480
run: |
2581
sudo apt-get update -y -qq --fix-missing
26-
sudo apt-get install -y postgresql-server-dev-14
82+
sudo apt-get install -y postgresql-$PG_VER postgresql-server-dev-$PG_VER
2783
2884
- name: Report version
29-
run: cargo --version
85+
run: |
86+
cargo --version
87+
pg_config --version
3088
3189
- name: Install cargo pgrx
3290
run: cd cargo-pgrx && cargo install --path . --debug

pgrx-bindgen/src/build.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use bindgen::callbacks::{DeriveTrait, EnumVariantValue, ImplementsTrait, MacroPa
1111
use bindgen::NonCopyUnionStyle;
1212
use eyre::{eyre, WrapErr};
1313
use pgrx_pg_config::{
14-
is_supported_major_version, PgConfig, PgConfigSelector, Pgrx, SUPPORTED_VERSIONS,
14+
is_supported_major_version, PgConfig, PgConfigSelector, PgMinorVersion, PgVersion, Pgrx,
15+
SUPPORTED_VERSIONS,
1516
};
1617
use quote::{quote, ToTokens};
1718
use std::cell::RefCell;
@@ -26,6 +27,20 @@ use syn::{ForeignItem, Item, ItemConst};
2627

2728
const BLOCKLISTED_TYPES: [&str; 3] = ["Datum", "NullableDatum", "Oid"];
2829

30+
// These postgres versions were effectively "yanked" by the community, even tho they still exist
31+
// in the wild. pgrx will refuse to compile against them
32+
const YANKED_POSTGRES_VERSIONS: &[PgVersion] = &[
33+
// this set of releases introduced an ABI break in the [`pg_sys::ResultRelInfo`] struct
34+
// and was replaced by the community on 2024-11-21
35+
// https://www.postgresql.org/about/news/postgresql-172-166-1510-1415-1318-and-1222-released-2965/
36+
PgVersion::new(17, PgMinorVersion::Release(1), None),
37+
PgVersion::new(16, PgMinorVersion::Release(5), None),
38+
PgVersion::new(15, PgMinorVersion::Release(9), None),
39+
PgVersion::new(14, PgMinorVersion::Release(14), None),
40+
PgVersion::new(13, PgMinorVersion::Release(17), None),
41+
PgVersion::new(12, PgMinorVersion::Release(21), None),
42+
];
43+
2944
pub(super) mod clang;
3045
pub(super) mod sym_blocklist;
3146

@@ -209,6 +224,7 @@ pub fn main() -> eyre::Result<()> {
209224
))
210225
}
211226
};
227+
212228
let found_major = found_ver.major;
213229
if let Ok(pg_config) = PgConfig::from_env() {
214230
let major_version = pg_config.major_version()?;
@@ -222,6 +238,17 @@ pub fn main() -> eyre::Result<()> {
222238
vec![(found_ver.major, specific)]
223239
}
224240
};
241+
242+
// make sure we're not trying to build any of the yanked postgres versions
243+
for (_, pg_config) in &pg_configs {
244+
let version = pg_config.get_version()?;
245+
if YANKED_POSTGRES_VERSIONS.contains(&version) {
246+
panic!("Postgres v{}{} is incompatible with \
247+
other versions in this major series and is not supported by pgrx. Please upgrade \
248+
to the latest version in the v{} series.", version.major, version.minor, version.major);
249+
}
250+
}
251+
225252
std::thread::scope(|scope| {
226253
// This is pretty much either always 1 (normally) or 5 (for releases),
227254
// but in the future if we ever have way more, we should consider

pgrx-pg-config/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl PgMinorVersion {
8686
}
8787
}
8888

89-
#[derive(Clone, Debug)]
89+
#[derive(Clone, Debug, Eq, PartialEq)]
9090
pub struct PgVersion {
9191
pub major: u16,
9292
pub minor: PgMinorVersion,
@@ -269,22 +269,23 @@ impl PgConfig {
269269
Ok((major, minor))
270270
}
271271

272-
fn get_version(&self) -> eyre::Result<(u16, PgMinorVersion)> {
272+
pub fn get_version(&self) -> eyre::Result<PgVersion> {
273273
let version_string = self.run("--version")?;
274-
Self::parse_version_str(&version_string)
274+
let (major, minor) = Self::parse_version_str(&version_string)?;
275+
Ok(PgVersion::new(major, minor, None))
275276
}
276277

277278
pub fn major_version(&self) -> eyre::Result<u16> {
278279
match &self.version {
279280
Some(version) => Ok(version.major),
280-
None => Ok(self.get_version()?.0),
281+
None => Ok(self.get_version()?.major),
281282
}
282283
}
283284

284285
fn minor_version(&self) -> eyre::Result<PgMinorVersion> {
285286
match &self.version {
286287
Some(version) => Ok(version.minor),
287-
None => Ok(self.get_version()?.1),
288+
None => Ok(self.get_version()?.minor),
288289
}
289290
}
290291

0 commit comments

Comments
 (0)