@@ -14,7 +14,8 @@ use pgrx_pg_sys::PgTryBuilder;
14
14
use std:: panic:: AssertUnwindSafe ;
15
15
16
16
use crate :: memcx;
17
- use crate :: pg_catalog:: pg_proc:: { PgProc , ProArgMode , ProKind } ;
17
+ use crate :: pg_catalog:: PgProc ;
18
+ use crate :: pg_catalog:: { PgProcProargmodes , PgProcProkind } ;
18
19
use crate :: seal:: Sealed ;
19
20
use crate :: {
20
21
direct_function_call, is_a, list:: List , pg_sys, pg_sys:: AsPgCStr , Array , FromDatum , IntoDatum ,
@@ -205,18 +206,22 @@ pub fn fn_call_with_collation<R: FromDatum + IntoDatum>(
205
206
let func_oid = lookup_fn ( fname, args) ?;
206
207
207
208
// lookup the function's pg_proc entry and do some validation
208
- let pg_proc = PgProc :: new ( func_oid) . ok_or ( FnCallError :: UndefinedFunction ) ?;
209
+ let pg_proc = PgProc :: search_procoid ( func_oid) . ok_or ( FnCallError :: UndefinedFunction ) ?;
210
+ let pg_proc = pg_proc. get ( ) . ok_or ( FnCallError :: UndefinedFunction ) ?;
209
211
let retoid = pg_proc. prorettype ( ) ;
210
212
211
213
//
212
214
// do some validation to catch the cases we don't/can't directly call
213
215
//
214
216
215
- if !matches ! ( pg_proc. prokind( ) , ProKind :: Function ) {
217
+ if !matches ! ( pg_proc. prokind( ) , PgProcProkind :: Function ) {
216
218
// It only makes sense to directly call regular functions. Calling aggregate or window
217
219
// functions is nonsensical
218
220
return Err ( FnCallError :: UnsupportedFunctionType ) ;
219
- } else if pg_proc. proargmodes ( ) . iter ( ) . any ( |mode| * mode != ProArgMode :: In ) {
221
+ } else if pg_proc
222
+ . proargmodes ( )
223
+ . map_or ( false , |x| x. iter_deny_null ( ) . any ( |mode| mode != PgProcProargmodes :: In ) )
224
+ {
220
225
// Right now we only know how to support arguments with the IN mode. Perhaps in the
221
226
// future we can support IN_OUT and TABLE return types
222
227
return Err ( FnCallError :: UnsupportedArgumentModes ) ;
@@ -240,7 +245,7 @@ pub fn fn_call_with_collation<R: FromDatum + IntoDatum>(
240
245
. iter ( )
241
246
. enumerate ( )
242
247
. map ( |( i, a) | a. as_datum ( & pg_proc, i) )
243
- . chain ( ( args. len ( ) ..pg_proc. pronargs ( ) ) . map ( |i| create_default_value ( & pg_proc, i) ) )
248
+ . chain ( ( args. len ( ) ..pg_proc. pronargs ( ) as usize ) . map ( |i| create_default_value ( & pg_proc, i) ) )
244
249
. map ( |datum| {
245
250
null |= matches ! ( datum, Ok ( None ) ) ;
246
251
datum
@@ -276,7 +281,7 @@ pub fn fn_call_with_collation<R: FromDatum + IntoDatum>(
276
281
//
277
282
// SAFETY: we allocate enough zeroed space for the base FunctionCallInfoBaseData *plus* the number of arguments
278
283
// we have, and we've asserted that we have the correct number of arguments
279
- assert_eq ! ( nargs, pg_proc. pronargs( ) ) ;
284
+ assert_eq ! ( nargs, pg_proc. pronargs( ) as usize ) ;
280
285
let fcinfo = pg_sys:: palloc0 (
281
286
std:: mem:: size_of :: < pg_sys:: FunctionCallInfoBaseData > ( )
282
287
+ std:: mem:: size_of :: < pg_sys:: NullableDatum > ( ) * nargs,
@@ -433,7 +438,7 @@ fn parse_sql_ident(ident: &str) -> Result<Array<&str>> {
433
438
/// - [`FnCallError::NotDefaultArgument`] if the specified `argnum` does not have a `DEFAULT` clause
434
439
/// - [`FnCallError::DefaultNotConstantExpression`] if the `DEFAULT` clause is one we cannot evaluate
435
440
fn create_default_value ( pg_proc : & PgProc , argnum : usize ) -> Result < Option < pg_sys:: Datum > > {
436
- let non_default_args_cnt = pg_proc. pronargs ( ) - pg_proc. pronargdefaults ( ) ;
441
+ let non_default_args_cnt = ( pg_proc. pronargs ( ) - pg_proc. pronargdefaults ( ) ) as usize ;
437
442
if argnum < non_default_args_cnt {
438
443
return Err ( FnCallError :: NotDefaultArgument ( argnum) ) ;
439
444
}
0 commit comments