Skip to content

Commit

Permalink
Narrow down unsafe blocks (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspermarstal authored Mar 7, 2024
1 parent bb2ccd1 commit d91da42
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plprql/src/plprql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,22 @@ extension_sql!(
returns language_handler
language C as 'MODULE_PATHNAME', '@FUNCTION_NAME@';
")]
unsafe fn plprql_call_handler(function_call_info: pg_sys::FunctionCallInfo) -> PlprqlResult<pg_sys::Datum> {
fn plprql_call_handler(function_call_info: pg_sys::FunctionCallInfo) -> PlprqlResult<pg_sys::Datum> {
let function = Function::from_call_info(function_call_info)?;

let datum = match function.return_mode() {
Return::Table => TableIterator::srf_next(function.call_info, call_table_iterator(&function)),
Return::SetOf => SetOfIterator::srf_next(function.call_info, call_setof_iterator(&function)),
Return::Scalar => call_scalar(&function),
let datum = unsafe {
match function.return_mode() {
Return::Table => TableIterator::srf_next(function.call_info, call_table_iterator(&function)),
Return::SetOf => SetOfIterator::srf_next(function.call_info, call_setof_iterator(&function)),
Return::Scalar => call_scalar(&function),
}
};

Ok(datum)
}

#[pg_extern]
unsafe fn plprql_call_validator(_function_id: pg_sys::Oid, _function_call_info: pg_sys::FunctionCallInfo) {
fn plprql_call_validator(_function_id: pg_sys::Oid, _function_call_info: pg_sys::FunctionCallInfo) {
// TODO
}

Expand Down

0 comments on commit d91da42

Please sign in to comment.