Skip to content

Commit

Permalink
Update to pgrx 0.12.8; add some comments; cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zilder committed Nov 4, 2024
1 parent 569e55b commit 74a96a9
Show file tree
Hide file tree
Showing 9 changed files with 680 additions and 442 deletions.
1,082 changes: 666 additions & 416 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ sudo apt-get install make gcc pkg-config clang postgresql-server-dev-14 libssl-d
Next you need [cargo-pgrx](https://github.com/tcdi/pgrx), which can be installed with

```bash
cargo install --version '=0.12.7' --force cargo-pgrx
cargo install --version '=0.12.8' --force cargo-pgrx
```

You must reinstall cargo-pgrx whenever you update your Rust compiler, since cargo-pgrx needs to be built with the same compiler as Toolkit.
Expand Down
8 changes: 4 additions & 4 deletions extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pg_test = ["approx"]
[dependencies]
# Keep synchronized with `cargo install --version N.N.N cargo-pgrx` in Readme.md and docker/ci/Dockerfile
# Also `pgrx-tests` down below in `dev-dependencies`.
pgrx = "=0.12.7"
pgrx-macros = "=0.12.7"
pgrx-sql-entity-graph = "=0.12.7"
pgrx = "=0.12.8"
pgrx-macros = "=0.12.8"
pgrx-sql-entity-graph = "=0.12.8"
encodings = {path="../crates/encodings"}
flat_serialize = {path="../crates/flat_serialize/flat_serialize"}
flat_serialize_macro = {path="../crates/flat_serialize/flat_serialize_macro"}
Expand Down Expand Up @@ -62,5 +62,5 @@ spfunc = "0.1.0"
statrs = "0.15.0"

[dev-dependencies]
pgrx-tests = "=0.12.7"
pgrx-tests = "=0.12.8"
approx = "0.4.0"
2 changes: 0 additions & 2 deletions extension/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ unsafe impl pgrx::callconv::BoxRet for bytea {
unsafe fn box_into<'fcx>(self, fcinfo: &mut pgrx::callconv::FcInfo<'fcx>)
-> pgrx::datum::Datum<'fcx>
{
// self.0
unsafe { fcinfo.return_raw_datum(self.0) }
}
}
Expand Down Expand Up @@ -152,7 +151,6 @@ unsafe impl pgrx::callconv::BoxRet for Interval {
unsafe fn box_into<'fcx>(self, fcinfo: &mut pgrx::callconv::FcInfo<'fcx>)
-> pgrx::datum::Datum<'fcx>
{
// self.0
unsafe { fcinfo.return_raw_datum(self.0) }
}
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/serialization.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use self::collations::PgCollationId;
pub use self::functions::PgProcId;
pub use self::types::{PgTypId, ShortTypeId};
pub use self::types::ShortTypeId;
use std::{
convert::TryInto,
os::raw::{c_char, c_int},
Expand Down
9 changes: 2 additions & 7 deletions extension/src/time_vector/pipeline/lambda/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,16 @@ where
//
// https://github.com/rust-lang/rust/issues/116831
//
// For now it seems OK to suppress these warnings here and below with
// For now it seems OK to suppress these warnings here with
// #[allow(improper_ctypes)]
#[allow(improper_ctypes)]
extern "C" {
#[allow(improper_ctypes)]
fn interval_pl(fcinfo: pg_sys::FunctionCallInfo) -> pg_sys::Datum;
#[allow(improper_ctypes)]
fn interval_mi(fcinfo: pg_sys::FunctionCallInfo) -> pg_sys::Datum;
#[allow(improper_ctypes)]
fn interval_mul(fcinfo: pg_sys::FunctionCallInfo) -> pg_sys::Datum;
#[allow(improper_ctypes)]
fn interval_div(fcinfo: pg_sys::FunctionCallInfo) -> pg_sys::Datum;

#[allow(improper_ctypes)]
fn timestamptz_pl_interval(fcinfo: pg_sys::FunctionCallInfo) -> pg_sys::Datum;
#[allow(improper_ctypes)]
fn timestamptz_mi_interval(fcinfo: pg_sys::FunctionCallInfo) -> pg_sys::Datum;
}

Expand Down
10 changes: 5 additions & 5 deletions extension/src/type_builder.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#[derive(Copy, Clone, Debug, serde::Serialize)]
pub enum CachedDatum<'r> {
// pub enum CachedDatum {
None,
FromInput(&'r [u8]),
Flattened(&'r [u8]),
// FromInput(pgrx::pgbox::PgBox<[u8]>),
// Flattened(pgrx::pgbox::PgBox<[u8]>),
}

impl PartialEq for CachedDatum<'_> {
Expand All @@ -14,12 +11,16 @@ impl PartialEq for CachedDatum<'_> {
}
}

// XXX Required by [`pgrx::PostgresType`] for default [`pgrx::FromDatum`]
// implementation but isn't used since we implement [`pgrx::FromDatum`]
// ourselves. We need a custom implementation because with the default one the
// compiler complains that `'input` and `'de` lifetimes are incompatible.
impl<'de> serde::Deserialize<'de> for CachedDatum<'_> {
fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
where
D: serde::de::Deserializer<'de>,
{
Ok(CachedDatum::None)
unimplemented!();
}
}

Expand Down Expand Up @@ -134,7 +135,6 @@ macro_rules! pg_type_impl {
pub fn [<$name:lower _in>](input: Option<&::core::ffi::CStr>) -> Option<$name<'static>> {
input.map_or_else(|| {
while let Some(m) = <$name as ::pgrx::inoutfuncs::InOutFuncs>::NULL_ERROR_MESSAGE {
// for m in <$name as ::pgrx::inoutfuncs::InOutFuncs>::NULL_ERROR_MESSAGE {
::pgrx::pg_sys::error!("{m}");
}
None
Expand Down
5 changes: 0 additions & 5 deletions extension/src/uddsketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ impl SerializedUddSketch {

// PG object for the sketch.
pg_type! {
//#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[derive(Debug)]
struct UddSketch<'input> {
// struct UddSketch {
alpha: f64,
max_buckets: u32,
num_buckets: u32,
Expand Down Expand Up @@ -265,7 +263,6 @@ impl<'a, 'b> From<&'a ReadableUddSketch> for UddSketch<'b> {
}

impl<'input> InOutFuncs for UddSketch<'input> {
// impl InOutFuncs for UddSketch {
fn output(&self, buffer: &mut StringInfo) {
use crate::serialization::{str_to_db_encoding, EncodedStr::*};

Expand All @@ -289,7 +286,6 @@ impl<'input> InOutFuncs for UddSketch<'input> {
}

impl<'input> UddSketch<'input> {
// impl UddSketch {
fn keys(&self) -> impl Iterator<Item = SketchHashKey> + '_ {
// FIXME does this really need a slice?
decompress_keys(
Expand Down Expand Up @@ -354,7 +350,6 @@ impl<'input> UddSketch<'input> {
}

impl<'input> FromIterator<f64> for UddSketch<'input> {
// impl FromIterator<f64> for UddSketch {
fn from_iter<T: IntoIterator<Item = f64>>(iter: T) -> Self {
let mut sketch = UddSketchInternal::new(
PERCENTILE_AGG_DEFAULT_SIZE.into(),
Expand Down
2 changes: 1 addition & 1 deletion tools/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TSDB_PG_VERSIONS='12 13 14 15 16 17'
CARGO_EDIT=0.11.2

# Keep synchronized with extension/Cargo.toml and `cargo install --version N.N.N cargo-pgrx` in Readme.md .
PGRX_VERSION=0.12.7
PGRX_VERSION=0.12.8

RUST_TOOLCHAIN=1.82.0
RUST_PROFILE=minimal
Expand Down

0 comments on commit 74a96a9

Please sign in to comment.