Skip to content

Commit

Permalink
fix: Mark PgTupleDesk::from_pg_copy unsafe (#224)
Browse files Browse the repository at this point in the history
Signed-off-by: Ana Hobden <operator@hoverbear.org>
  • Loading branch information
Hoverbear committed Sep 24, 2021
1 parent 1a717ae commit c6d699f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pgx/src/tupdesc.rs
Expand Up @@ -70,10 +70,15 @@ impl<'a> PgTupleDesc<'a> {
/// allocated in the `CurrentMemoryContext`
///
/// When this instance is dropped, the copied TupleDesc is `pfree()`'d
pub fn from_pg_copy<'b>(ptr: pg_sys::TupleDesc) -> PgTupleDesc<'b> {
///
/// ## Safety
///
/// This method is unsafe as we cannot validate that the provided `pg_sys::TupleDesc` is valid
/// or requires reference counting.
pub unsafe fn from_pg_copy<'b>(ptr: pg_sys::TupleDesc) -> PgTupleDesc<'b> {
PgTupleDesc {
// SAFETY: pg_sys::CreateTupleDescCopyConstr will be returning a valid pointer
tupdesc: unsafe { PgBox::from_pg(pg_sys::CreateTupleDescCopyConstr(ptr)) },
tupdesc: PgBox::from_pg(pg_sys::CreateTupleDescCopyConstr(ptr)),
parent: None,
data: None,
need_release: false,
Expand Down

0 comments on commit c6d699f

Please sign in to comment.