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

yeet IntoDatum for u32 #1354

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
19 changes: 0 additions & 19 deletions pgrx/src/datum/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,6 @@ impl IntoDatum for i32 {
}
}

/// for oid
impl IntoDatum for u32 {
#[inline]
fn into_datum(self) -> Option<pg_sys::Datum> {
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]
Expand Down
10 changes: 5 additions & 5 deletions pgrx/src/spi/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u32>()?);
/// assert_eq!(Some(2u32), cursor.fetch(2)?.get_one::<u32>()?);
/// assert_eq!(Some(3u32), cursor.fetch(3)?.get_one::<u32>()?);
/// assert_eq!(Some(1), cursor.fetch(1)?.get_one::<i32>()?);
/// assert_eq!(Some(2), cursor.fetch(2)?.get_one::<i32>()?);
/// assert_eq!(Some(3), cursor.fetch(3)?.get_one::<i32>()?);
/// Ok::<_, pgrx::spi::Error>(())
/// // <--- all three SpiTupleTable get freed by Spi::connect at this point
/// })
Expand All @@ -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::<u32>());
/// assert_eq!(Ok(Some(1)), cursor.fetch(1)?.get_one::<i32>());
/// 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::<u32>());
/// assert_eq!(Ok(Some(2)), cursor.fetch(1)?.get_one::<i32>());
/// drop(cursor); // <-- cursor gets dropped here
/// // ... more code ...
/// Ok(())
Expand Down