@@ -375,20 +375,24 @@ export function transformIdentityCastLiteral(
375375 return QuoteUtils . quoteIdentifier ( newName ) ;
376376 }
377377
378- const qualified = QUALIFIED_IDENTITY_RE . exec ( sval ) ;
379- if ( ! qualified ) return sval ;
378+ // `regprocedure` and `regoperator` carry an argument list after the name, and
379+ // an argument type can itself be schema-qualified
380+ // (`fn("my-schema".row_type)`), so the list is routed as ordinary schema refs.
381+ const argsAt = sval . indexOf ( '(' ) ;
382+ const head = argsAt === - 1 ? sval : sval . slice ( 0 , argsAt ) ;
383+ const args =
384+ argsAt === - 1 ? '' : transformSchemaRefsInString ( sval . slice ( argsAt ) , router , result ) ;
385+
386+ const qualified = QUALIFIED_IDENTITY_RE . exec ( head ) ;
387+ if ( ! qualified ) return `${ head } ${ args } ` ;
380388 const schemaName = unquoteIdentifier ( qualified [ 1 ] ) ;
381- const remainder = qualified [ 2 ] ;
382- // `regprocedure` and `regoperator` carry an argument list after the name.
383- const argsAt = remainder . indexOf ( '(' ) ;
384- const objName = unquoteIdentifier ( ( argsAt === - 1 ? remainder : remainder . slice ( 0 , argsAt ) ) . trim ( ) ) ;
385- const args = argsAt === - 1 ? '' : remainder . slice ( argsAt ) ;
389+ const objName = unquoteIdentifier ( qualified [ 2 ] . trim ( ) ) ;
386390
387391 const target = router . resolveObject ( schemaName , objName , ns ) ;
388- if ( ! target ) return sval ;
392+ if ( ! target ) return ` ${ head } ${ args } ` ;
389393 const rebound = target . name !== undefined && target . name !== objName ;
390394 const requalified = target . schema === null || ( ! ! target . schema && target . schema !== schemaName ) ;
391- if ( ! rebound && ! requalified ) return sval ;
395+ if ( ! rebound && ! requalified ) return ` ${ head } ${ args } ` ;
392396
393397 result . schemasFound . add ( schemaName ) ;
394398 const nameToken = QuoteUtils . quoteIdentifier ( rebound ? target . name ! : objName ) ;
0 commit comments