Skip to content

Commit

Permalink
fix: pg13
Browse files Browse the repository at this point in the history
  • Loading branch information
usamoi committed Nov 11, 2024
1 parent 1d11513 commit 5797576
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ path = "./src/bin/pgrx_embed.rs"

[features]
default = []
pg12 = ["pgrx/pg12"]
pg13 = ["pgrx/pg13"]
pg14 = ["pgrx/pg14"]
pg15 = ["pgrx/pg15"]
Expand Down
2 changes: 1 addition & 1 deletion src/gucs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub unsafe fn init() {
executing::init();
prewarm::init();
prewarm::prewarm();
#[cfg(any(feature = "pg12", feature = "pg13", feature = "pg14"))]
#[cfg(any(feature = "pg13", feature = "pg14"))]
pgrx::pg_sys::EmitWarningsOnPlaceholders(c"rabbithole".as_ptr());
#[cfg(any(feature = "pg15", feature = "pg16", feature = "pg17"))]
pgrx::pg_sys::MarkGUCPrefixReserved(c"rabbithole".as_ptr());
Expand Down
33 changes: 33 additions & 0 deletions src/index/am.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,39 @@ pub unsafe extern "C" fn ambuildempty(_index: pgrx::pg_sys::Relation) {
pgrx::error!("Unlogged indexes are not supported.");
}

#[cfg(feature = "pg13")]
#[pgrx::pg_guard]
pub unsafe extern "C" fn aminsert(
index: pgrx::pg_sys::Relation,
values: *mut Datum,
is_null: *mut bool,
heap_tid: pgrx::pg_sys::ItemPointer,
_heap: pgrx::pg_sys::Relation,
_check_unique: pgrx::pg_sys::IndexUniqueCheck::Type,
_index_info: *mut pgrx::pg_sys::IndexInfo,
) -> bool {
use base::vector::OwnedVector;
let opfamily = unsafe { am_options::opfamily(index) };
let vector = unsafe { opfamily.datum_to_vector(*values.add(0), *is_null.add(0)) };
if let Some(vector) = vector {
let vector = match opfamily.preprocess(vector.as_borrowed()) {
OwnedVector::Vecf32(x) => x,
OwnedVector::Vecf16(_) => unreachable!(),
OwnedVector::SVecf32(_) => unreachable!(),
OwnedVector::BVector(_) => unreachable!(),
};
let pointer = ctid_to_pointer(unsafe { heap_tid.read() });
algorithm::insert::insert(
unsafe { Relation::new(index) },
pointer,
vector.into_vec(),
opfamily.distance_kind(),
);
}
false
}

#[cfg(any(feature = "pg14", feature = "pg15", feature = "pg16", feature = "pg17"))]
#[pgrx::pg_guard]
pub unsafe extern "C" fn aminsert(
index: pgrx::pg_sys::Relation,
Expand Down

0 comments on commit 5797576

Please sign in to comment.