Skip to content

Commit

Permalink
Prepare v1.2.5, inc pgrx v0.10.0 and pg16RC1 (#378)
Browse files Browse the repository at this point in the history
These are the updates for the v1.2.5 release, which includes updating to
pgrx v0.10.0 and pg16rc1 support.

---------

Co-authored-by: Brady Bonnette <b_bonnette@tcdi.com>
  • Loading branch information
eeeebbbbrrrr and BradyBonnette authored Sep 6, 2023
1 parent 9f0f459 commit 53bbeea
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 44 deletions.
44 changes: 35 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

strategy:
matrix:
version: ["pg13", "pg14", "pg15"]
version: ["pg13", "pg14", "pg15", "pg16"]
target: ["host", "postgrestd"]
fail-fast: false

Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:

strategy:
matrix:
version: ["pg13", "pg14", "pg15"]
version: ["pg13", "pg14", "pg15", "pg16"]
os: ["ubuntu-latest"]
# it would be nice to other contributors to return "macos-11" to the above array
target: ["host", "postgrestd"]
Expand All @@ -222,7 +222,6 @@ jobs:
- uses: actions/checkout@v3

- name: Set up (Linux) prerequisites and environment
if: matrix.os == 'ubuntu-latest'
run: |
echo ""
Expand Down Expand Up @@ -265,16 +264,10 @@ jobs:
llvm-11 \
make \
pkg-config \
postgresql-$PG_VER \
postgresql-server-dev-$PG_VER \
strace \
zlib1g-dev
echo ""
echo "----- Set up Postgres permissions -----"
sudo chmod a+rwx `/usr/lib/postgresql/$PG_VER/bin/pg_config --pkglibdir` `/usr/lib/postgresql/$PG_VER/bin/pg_config --sharedir`/extension /var/run/postgresql/
echo ""
echo "----- Print env -----"
env
echo ""
Expand All @@ -283,6 +276,39 @@ jobs:
cargo --version
echo ""
- name: Install release version of PostgreSQL
if: matrix.version != 'pg16'
run: |
echo "----- Set up PostgreSQL Apt repository -----"
sudo apt-get install -y wget gnupg
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update -y -qq --fix-missing
echo ""
sudo apt-get install -y \
postgresql-"$PG_VER" \
postgresql-server-dev-"$PG_VER"
- name: Install development version of PostgreSQL
if: matrix.version == 'pg16'
run: |
echo "----- Set up PostgreSQL Apt repository -----"
sudo apt-get install -y wget gnupg
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7FCC7D46ACCC4CF8
sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ $(lsb_release -s -c)-pgdg-snapshot main 16"
sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ $(lsb_release -s -c)-pgdg main 16"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update -y -qq --fix-missing
echo ""
sudo apt-get install -y \
postgresql-"$PG_VER" \
postgresql-server-dev-"$PG_VER"
- name: Set up Postgres permissions
run: sudo chmod a+rwx "$(/usr/lib/postgresql/"$PG_VER"/bin/pg_config --pkglibdir)" "$(/usr/lib/postgresql/"$PG_VER"/bin/pg_config --sharedir)"/extension /var/run/postgresql/

- name: Cache cargo registry
uses: actions/cache@v3
continue-on-error: false
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion plrust-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plrust-tests"
version = "1.2.4"
version = "1.2.5"
edition = "2021"

[lib]
Expand All @@ -11,6 +11,7 @@ default = ["pg13"]
pg13 = ["pgrx/pg13", "pgrx-tests/pg13" ]
pg14 = ["pgrx/pg14", "pgrx-tests/pg14" ]
pg15 = ["pgrx/pg15", "pgrx-tests/pg15" ]
pg16 = ["pgrx/pg16", "pgrx-tests/pg16" ]
pg_test = []
trusted = []

Expand Down
3 changes: 2 additions & 1 deletion plrust-trusted-pgrx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plrust-trusted-pgrx"
version = "1.2.4"
version = "1.2.5"
authors = ["TCDI <opensource@tcdi.com>"]
edition = "2021"
license = "PostgreSQL"
Expand All @@ -15,6 +15,7 @@ crate-type = ["rlib"]
pg13 = ["pgrx/pg13"]
pg14 = ["pgrx/pg14"]
pg15 = ["pgrx/pg15"]
pg16 = ["pgrx/pg16"]

[dependencies]
# changing the pgrx version will likely require at least a minor version bump to this create
Expand Down
3 changes: 2 additions & 1 deletion plrust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plrust"
version = "1.2.4"
version = "1.2.5"
authors = ["TCDI <opensource@tcdi.com>"]
edition = "2021"
license = "PostgreSQL Open Source License"
Expand All @@ -17,6 +17,7 @@ default = ["pg14"]
pg13 = ["pgrx/pg13", "pgrx-tests/pg13"]
pg14 = ["pgrx/pg14", "pgrx-tests/pg14"]
pg15 = ["pgrx/pg15", "pgrx-tests/pg15"]
pg16 = ["pgrx/pg16", "pgrx-tests/pg16"]
# is plrust to be compiled as a "trusted" language handler, meaning it requires postgrestd at runtime
trusted = []
pg_test = []
Expand Down
7 changes: 2 additions & 5 deletions plrust/src/allow_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,8 @@ pub fn load_allowlist() -> eyre::Result<AllowList> {
let path = PathBuf::from_str(
&PLRUST_ALLOWED_DEPENDENCIES
.get()
.map(|cstr| {
cstr.to_str()
.expect("plrust.allowed_dependencies is not valid UTF8")
})
.ok_or(Error::NotConfigured)?,
.ok_or(Error::NotConfigured)?
.to_str()?,
)
.map_err(|_| Error::InvalidPath)?;

Expand Down
32 changes: 18 additions & 14 deletions plrust/src/gucs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@ pub(crate) static PLRUST_COMPILE_LINTS: GucSetting<Option<&'static CStr>> =
GucSetting::<Option<&'static CStr>>::new(Some(DEFAULT_LINTS));
pub(crate) static PLRUST_REQUIRED_LINTS: GucSetting<Option<&'static CStr>> =
GucSetting::<Option<&'static CStr>>::new(None);
pub(crate) static PLRUST_TRUSTED_PGRX_VERSION: GucSetting<Option<&'static CStr>> =
GucSetting::<Option<&'static CStr>>::new(None);

pub(crate) const COMPILED_PGRX_VERSION: &'static str = env!(
"PLRUST_TRUSTED_PGRX_VERSION",
"unknown `plrust-trusted-pgrx` version. `build.rs` must not have run successfully"
const PGRX_VERSION_FROM_BUILD_RS: &'static str = concat!(
env!(
"PLRUST_TRUSTED_PGRX_VERSION",
"unknown `plrust-trusted-pgrx` version. `build.rs` must not have run successfully"
),
"\0" // NULL-terminate the string
);

pub(crate) static PLRUST_TRUSTED_PGRX_VERSION: GucSetting<Option<&'static CStr>> =
GucSetting::<Option<&'static CStr>>::new(Some(unsafe {
CStr::from_bytes_with_nul_unchecked(PGRX_VERSION_FROM_BUILD_RS.as_bytes())
}));

pub(crate) fn init() {
GucRegistry::define_string_guc(
"plrust.work_dir",
Expand Down Expand Up @@ -118,8 +124,9 @@ pub(crate) fn work_dir() -> PathBuf {
PathBuf::from_str(
&PLRUST_WORK_DIR
.get()
.map(|cstr| cstr.to_str().expect("plrust.work_dir is not valid UTF8"))
.expect("plrust.work_dir is not set in postgresql.conf"),
.expect("plrust.work_dir is not set in postgresql.conf")
.to_str()
.expect("plrust.work_dir is not valid UTF8"),
)
.expect("plrust.work_dir is not a valid path")
}
Expand Down Expand Up @@ -147,8 +154,7 @@ pub(crate) fn compilation_targets() -> eyre::Result<(
let other_targets = match PLRUST_COMPILATION_TARGETS.get() {
None => vec![],
Some(targets) => targets
.to_str()
.expect("plrust.compilation_targets is not valid UTF8")
.to_str()?
.split(',')
.map(str::trim)
.filter(|s| s != &std::env::consts::ARCH) // make sure we don't include this architecture in the list of other targets
Expand Down Expand Up @@ -196,11 +202,9 @@ pub(crate) fn get_pgrx_bindings_for_target(target: &CrossCompilationTarget) -> O
pub(crate) fn get_trusted_pgrx_version() -> String {
let version = PLRUST_TRUSTED_PGRX_VERSION
.get()
.map(|cstr| {
cstr.to_str()
.expect("plrust.plrust_trusted_pgrx is not valid UTF8")
})
.unwrap_or(COMPILED_PGRX_VERSION);
.expect("unable to determine `plrust-trusted-pgrx` version") // shouldn't happen since we set a known default
.to_str()
.expect("plrust.plrust_trusted_pgrx_version is not valid UTF8");

// we always want this specific version
format!("={}", version)
Expand Down
2 changes: 1 addition & 1 deletion plrust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const DEFAULT_LINTS: &'static CStr = unsafe {
suspicious_auto_trait_impls, \
where_clauses_object_safety, \
soft_unstable\
\0", // NOTE: This is a null-terminated CString.
\0", // NOTE: This is a null-terminated string as it's used statically as a &CStr
)
};

Expand Down
6 changes: 1 addition & 5 deletions plrust/src/user_crate/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ pub(crate) fn cargo(
fn configure_path(command: &mut Command) -> eyre::Result<()> {
if let Some(path) = PLRUST_PATH_OVERRIDE.get() {
// we were configured with an explicit $PATH to use
command.env(
"PATH",
path.to_str()
.expect("plrust.plrust_path_override is not valid UTF8"),
);
command.env("PATH", path.to_str()?);
} else {
let is_empty = match std::env::var("PATH") {
Ok(s) if s.trim().is_empty() => true,
Expand Down
4 changes: 2 additions & 2 deletions plrust/src/user_crate/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub(crate) fn compile_lints() -> LintSet {
.get()
.unwrap_or_default()
.to_str()
.expect("plrust.plrust_compile_lints is not valid UTF8")
.expect("plrust.compile_lints is not valid UTF8")
.split(',')
.filter(|x| !x.is_empty())
.map(|s| s.trim().into())
Expand Down Expand Up @@ -131,7 +131,7 @@ pub(crate) fn required_lints() -> LintSet {
.get()
.unwrap_or_default()
.to_str()
.expect("plrust.plrust_required_lints is not valid UTF8")
.expect("plrust.required_lints is not valid UTF8")
.split(',')
.filter_map(filter_map)
.collect::<LintSet>();
Expand Down
2 changes: 1 addition & 1 deletion plrustc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plrustc/plrustc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plrustc"
version = "1.2.4"
version = "1.2.5"
edition = "2021"
description = "`rustc_driver` wrapper for plrust"
license = "PostgreSQL"
Expand Down

0 comments on commit 53bbeea

Please sign in to comment.