Skip to content

fix: prevent segfault when package has subproc with param-initialized…#1173

Merged
gaoxueyu merged 1 commit intoIvorySQL:IVORY_REL_5_STABLEfrom
jiaoshuntian:ivy5_bp_1123
Jan 29, 2026
Merged

fix: prevent segfault when package has subproc with param-initialized…#1173
gaoxueyu merged 1 commit intoIvorySQL:IVORY_REL_5_STABLEfrom
jiaoshuntian:ivy5_bp_1123

Conversation

@jiaoshuntian
Copy link
Copy Markdown
Collaborator

@jiaoshuntian jiaoshuntian commented Jan 27, 2026

… local var (#1005)

Summary by CodeRabbit

  • Bug Fixes

    • Resolved variable initialization handling in nested subprocedures that could trigger invalid references during the initialization phase.
  • Tests

    • Added comprehensive test coverage for nested subprocedure scenarios, including package procedures, standalone functions with nested helpers, and parameter-initialized local variables.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

This PR introduces a helper function plisql_datum_belongs_to_subproc() to prevent initializing datums that belong to nested subprocedures. The function filters out subproc datums during initialization in plisql_add_initdatums(). Comprehensive tests for issue #1005 are added.

Changes

Cohort / File(s) Summary
Core Implementation
src/pl/plisql/src/pl_comp.c
Adds plisql_datum_belongs_to_subproc() helper to identify datums within subprocedure ranges; integrates it into plisql_add_initdatums() to skip subproc datums during initialization in both the counting loop and varnos array construction.
Test Suite
src/pl/plisql/src/sql/plisql_nested_subproc.sql
Appends comprehensive test suite for issue #1005 covering package-based procedures, nested functions with param-initialized locals, and standalone functions with nested helpers; test suite is duplicated in sequence.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • OreoYang
  • bigplaice

Poem

🐰 A datum skips its parent's care,
When subprocs claim their nested share,
No double-init shall occur,
The bounds checked clean, the tests concur!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly describes the main fix: preventing segfault when a package has a subprocedure with parameter-initialized local variables, which aligns with the core change in pl_comp.c.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gaoxueyu gaoxueyu merged commit 27a4011 into IvorySQL:IVORY_REL_5_STABLE Jan 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants