Skip to content

Commit 0189c69

Browse files
Make PgRelation::heap_relation unsafe (pgcentralfoundation#2176)
Partially addresses the unsoundness mentioned in pgcentralfoundation#2140
1 parent 6db42c0 commit 0189c69

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

pgrx/src/rel.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ impl PgRelation {
191191

192192
/// If this `PgRelation` represents an index, return the `PgRelation` for the heap
193193
/// relation to which it is attached
194-
pub fn heap_relation(&self) -> Option<PgRelation> {
194+
///
195+
/// # Safety
196+
///
197+
/// This does not perform locking, even though Postgres requires it.
198+
/// Callers must first call `with_lock` before calling this.
199+
pub unsafe fn heap_relation(&self) -> Option<PgRelation> {
195200
// SAFETY: we know self.boxed and its members are correct as we created it
196201
let rd_index: PgBox<pg_sys::FormData_pg_index> =
197202
unsafe { PgBox::from_pg(self.boxed.rd_index) };

0 commit comments

Comments
 (0)