-
Notifications
You must be signed in to change notification settings - Fork 156
Fix type coercion failure with mixed positional/named parameters in packages and subprocedures #1132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Add test cases for mixed positional and named parameters when calling package procedures with variables and default parameters. Tests cover: - All positional parameters - All named parameters with variables - Mixed positional and named with literals - Mixed positional and named with variables (the bug case) - Multiple variables with mixed notation Related: IvorySQL#1006
When calling package procedures with mixed positional and named parameters, the argument list gets reordered by LookupPkgFunc to match the procedure's parameter order and fill in default values. However, the actual_arg_types array was not updated to match this reordering, causing type coercion to fail with "failed to find conversion function from unknown to varchar2" when variables were used as named parameter values. This fix rebuilds the actual_arg_types array after package function resolution to ensure it matches the reordered fargs list. Fixes: IvorySQL#1006
Add test cases for mixed positional and named parameters when calling subprocedures with variables. This extends the package procedure tests to cover subprocedures as well. Tests cover: - Mixed positional + named with variable (varchar arg) - Mixed positional + named with variable (number arg) - Named parameters in different order than declared - All named with variables - Subprocedure overloading with named parameters Without the fix, Case 3 (named params in different order) causes a server crash due to misaligned type arrays after argument reordering. Related: IvorySQL#1006
When calling subprocedures with mixed positional and named parameters, the fargs list gets reordered to declared order, but true_typeids (which becomes declared_arg_types) remained in call order. This caused type coercion in make_fn_arguments() to fail, leading to server crash. The fix has two parts: 1. Extend parse_func.c fix to also handle FUNC_FROM_SUBPROCFUNC 2. In pl_subproc_function.c, rebuild true_typeids in declared order after fargs is reordered This preserves overload resolution (which uses call-order types before reordering) while fixing type coercion (which needs declared-order types after reordering). Fixes: IvorySQL#1006
WalkthroughThe changes fix a type resolution bug in PL/SQL where mixed positional and named parameters with variable values failed to resolve correctly. Two core modules were updated to reconstruct type arrays (actual_arg_types and true_typeids) after argument reordering to ensure they match the declared parameter order. Comprehensive tests validate the fix across various call patterns and parameter combinations. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings🧬 Code graph analysis (1)src/backend/parser/parse_func.c (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #1006
Problem
Calling package procedures or subprocedures with mixed positional and named parameters using variables as named argument values fails with:
The root cause is that after
plisql_expand_and_reorder_functionargs()reordersfargsto declared parameter order, the type arrays (actual_arg_typesanddeclared_arg_types) remain in call order, causing type coercion to fail.Solution
Rebuild type arrays in declared order after argument reordering:
actual_arg_typesinparse_func.cdeclared_arg_typesinpl_subproc_function.cBoth fixes are applied after overload resolution completes, preserving correct function matching.
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.