From 31950b950daa729706eb13e180bab8941ee71bb3 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Thu, 26 Oct 2023 22:32:08 -0700 Subject: [PATCH 1/2] yeet IntoDatum for u32 impl from when `pg_sys::Oid` was not a newtype but an alias. now unnecessary. --- pgrx/src/datum/into.rs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/pgrx/src/datum/into.rs b/pgrx/src/datum/into.rs index 41c0d2b823..52c75744fd 100644 --- a/pgrx/src/datum/into.rs +++ b/pgrx/src/datum/into.rs @@ -172,25 +172,6 @@ impl IntoDatum for i32 { } } -/// for oid -impl IntoDatum for u32 { - #[inline] - fn into_datum(self) -> Option { - Some(pg_sys::Datum::from(self)) - } - - fn type_oid() -> pg_sys::Oid { - pg_sys::OIDOID - } - - fn is_compatible_with(other: pg_sys::Oid) -> bool { - Self::type_oid() == other - || i8::type_oid() == other - || i16::type_oid() == other - || i32::type_oid() == other - } -} - /// for bigint impl IntoDatum for i64 { #[inline] From 55caa631ea4ebda1fdd9b8ac95af8c7d8f0552c4 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Thu, 26 Oct 2023 22:44:37 -0700 Subject: [PATCH 2/2] Fix doctests that use u32 in Spi --- pgrx/src/spi/cursor.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pgrx/src/spi/cursor.rs b/pgrx/src/spi/cursor.rs index f9a7fbf7e5..4e18153411 100644 --- a/pgrx/src/spi/cursor.rs +++ b/pgrx/src/spi/cursor.rs @@ -34,9 +34,9 @@ type CursorName = String; /// # fn foo() -> spi::Result<()> { /// Spi::connect(|mut client| { /// let mut cursor = client.open_cursor("SELECT * FROM generate_series(1, 5)", None); -/// assert_eq!(Some(1u32), cursor.fetch(1)?.get_one::()?); -/// assert_eq!(Some(2u32), cursor.fetch(2)?.get_one::()?); -/// assert_eq!(Some(3u32), cursor.fetch(3)?.get_one::()?); +/// assert_eq!(Some(1), cursor.fetch(1)?.get_one::()?); +/// assert_eq!(Some(2), cursor.fetch(2)?.get_one::()?); +/// assert_eq!(Some(3), cursor.fetch(3)?.get_one::()?); /// Ok::<_, pgrx::spi::Error>(()) /// // <--- all three SpiTupleTable get freed by Spi::connect at this point /// }) @@ -49,13 +49,13 @@ type CursorName = String; /// # fn foo() -> spi::Result<()> { /// let cursor_name = Spi::connect(|mut client| { /// let mut cursor = client.open_cursor("SELECT * FROM generate_series(1, 5)", None); -/// assert_eq!(Ok(Some(1u32)), cursor.fetch(1)?.get_one::()); +/// assert_eq!(Ok(Some(1)), cursor.fetch(1)?.get_one::()); /// Ok::<_, spi::Error>(cursor.detach_into_name()) // <-- cursor gets dropped here /// // <--- first SpiTupleTable gets freed by Spi::connect at this point /// })?; /// Spi::connect(|mut client| { /// let mut cursor = client.find_cursor(&cursor_name)?; -/// assert_eq!(Ok(Some(2u32)), cursor.fetch(1)?.get_one::()); +/// assert_eq!(Ok(Some(2)), cursor.fetch(1)?.get_one::()); /// drop(cursor); // <-- cursor gets dropped here /// // ... more code ... /// Ok(())