Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct broken serialization #828

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions extension/src/stats_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ impl<'input> StatsSummary2D<'input> {

#[pg_extern(immutable, parallel_safe, strict)]
pub fn stats1d_trans_serialize(state: Internal) -> bytea {
let ser: &StatsSummary1DData = unsafe { state.get().unwrap() };
let ser: &StatsSummary1D = unsafe { state.get().unwrap() };
let ser: &StatsSummary1DData = &ser.0;
crate::do_serialize!(ser)
}

Expand All @@ -125,7 +126,8 @@ pub fn stats1d_trans_deserialize_inner(bytes: bytea) -> Inner<StatsSummary1D<'st

#[pg_extern(immutable, parallel_safe, strict)]
pub fn stats2d_trans_serialize(state: Internal) -> bytea {
let ser: &StatsSummary2DData = unsafe { state.get().unwrap() };
let ser: &StatsSummary2D = unsafe { state.get().unwrap() };
let ser: &StatsSummary2DData = &ser.0;
crate::do_serialize!(ser)
}

Expand Down Expand Up @@ -1654,9 +1656,9 @@ mod tests {
let state = stats1d_trans_inner(state, Some(39.42), ptr::null_mut());
let state = stats1d_trans_inner(state, Some(-43.0), ptr::null_mut());

let control = state.unwrap();
let control = (*state.unwrap()).clone();
let buffer = stats1d_trans_serialize(Inner::from(control.clone()).internal().unwrap());
let buffer = pgrx::varlena::varlena_to_byte_slice(buffer.0.cast_mut_ptr());
let buffer = varlena_to_byte_slice(buffer.0.cast_mut_ptr());

let expected = [
1, 1, 1, 5, 0, 0, 0, 0, 0, 0, 0, 144, 194, 245, 40, 92, 143, 73, 64, 100, 180, 142,
Expand All @@ -1669,7 +1671,7 @@ mod tests {
let new_state =
stats1d_trans_deserialize_inner(bytea(pg_sys::Datum::from(expected.as_ptr())));

assert_eq!(&*new_state, &*control);
assert_eq!(*new_state, control);
}
}

Expand Down
4 changes: 2 additions & 2 deletions extension/src/time_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ pub fn arrow_timevector_unnest<'a>(

#[pg_extern(immutable, parallel_safe, strict)]
pub fn timevector_serialize(state: Internal) -> bytea {
// FIXME: This might duplicate the version and padding bits
let state: &Timevector_TSTZ_F64Data = unsafe { state.get().unwrap() };
let state: &Timevector_TSTZ_F64 = unsafe { state.get().unwrap() };
let state: &Timevector_TSTZ_F64Data = &state.0;
crate::do_serialize!(state)
}

Expand Down
Loading