Skip to content

dbms_utility: fix backtrace/call-stack qualification for package members - #1471

Merged
gaoxueyu merged 1 commit into
IvorySQL:masterfrom
db-nikhil:nikkhils/dbms_utility_fix
Aug 17, 2026
Merged

gaoxueyu merged 1 commit into
IvorySQL:masterfrom
db-nikhil:nikkhils/dbms_utility_fix

Conversation

@db-nikhil

@db-nikhil db-nikhil commented Jul 28, 2026 •

Copy link
Copy Markdown

Fixes #1472

FORMAT_ERROR_BACKTRACE unconditionally prepended a hardcoded "PUBLIC." prefix to every frame name, including package member frames whose context line already carries the full schema.package.routine path produced by plisql_package_qualified_signature(). Two bugs resulted:

Package members lost the package component: "PUBLIC.PKG_ERROR" instead of "PUBLIC.TEST_PKG.PKG_ERROR". Schema-qualified standalone routines got an extra prefix: "PUBLIC. TEST_SCHEMA.SCHEMA_ERROR" instead of "TEST_SCHEMA.SCHEMA_ERROR".

Add test 18 to dbms_utility.sql to cover FORMAT_CALL_STACK from inside a package procedure and assert the frame is schema/package-qualified.

Summary by CodeRabbit

Summary

  • Bug Fixes

    • Corrected DBMS_UTILITY formatting for FORMAT_ERROR_BACKTRACE and FORMAT_CALL_STACK so schema/package-qualified routine names render correctly, and eliminates unintended PUBLIC. prefixes in frames/lines.
  • Tests

    • Added regression coverage for FORMAT_CALL_STACK using a package procedure.
    • Added regression coverage for FORMAT_ERROR_BACKTRACE using schema-qualified routines.
    • Updated expected outputs for utl_encode and utl_file context lines to reflect fully qualified routine names.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

PL/iSQL now resolves package ownership when formatting error contexts and call stacks. DBMS_UTILITY avoids adding PUBLIC to already-qualified routines. Regression tests and expected outputs cover package members, schema-qualified procedures, and system package functions.

Changes

Package-qualified diagnostics

Layer / File(s) Summary
PL/iSQL package signature propagation
src/pl/plisql/src/pl_exec.c
Package metadata lookup now produces schema/package-qualified signatures for PL/iSQL error contexts and call-stack frames.
Qualified backtrace formatting
contrib/ivorysql_ora/src/builtin_packages/dbms_utility/dbms_utility.c
Already-qualified routine names are emitted unchanged, while unqualified names retain the PUBLIC prefix.
Diagnostic regression coverage
contrib/ivorysql_ora/sql/dbms_utility.sql, contrib/ivorysql_ora/expected/dbms_utility.out, contrib/ivorysql_ora/expected/utl_encode.out, contrib/ivorysql_ora/expected/utl_file.out
Adds package call-stack and schema-qualified backtrace tests, and updates expected diagnostic names for package and system routines.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant test_call_stack_pkg
  participant DBMS_UTILITY
  participant plisql_get_call_stack
  participant pg_package
  test_call_stack_pkg->>DBMS_UTILITY: FORMAT_CALL_STACK
  DBMS_UTILITY->>plisql_get_call_stack: format PL/iSQL frames
  plisql_get_call_stack->>pg_package: resolve package metadata
  pg_package-->>plisql_get_call_stack: schema and package names
  plisql_get_call_stack-->>DBMS_UTILITY: qualified stack frames
  DBMS_UTILITY-->>test_call_stack_pkg: formatted call stack
Loading

Possibly related PRs

Suggested reviewers: hs-liuxh, oreoyang

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also updates utl_encode.out and utl_file.out, which are unrelated to #1472’s DBMS_UTILITY scope. Move the utl_encode and utl_file expectation changes into a separate PR or justify them as required follow-up coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main fix to DBMS_UTILITY frame qualification for package members.
Linked Issues check ✅ Passed The changes address both package-member qualification and schema-qualified routine prefixes required by #1472.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contrib/ivorysql_ora/sql/dbms_utility.sql`:
- Around line 442-468: Update the Test 18 package-stack test around
test_call_stack_pkg to create and invoke the package under a dedicated
non-public schema, then require the exact schema-qualified prefix in the
FORMAT_CALL_STACK result instead of accepting any prefix. Adjust setup,
invocation, cleanup, and expected output to match the dedicated schema while
preserving the package qualification assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f6246d3-3669-476f-a77e-784634252007

📥 Commits

Reviewing files that changed from the base of the PR and between a88132c and 060bcf9.

📒 Files selected for processing (4)
  • contrib/ivorysql_ora/expected/dbms_utility.out
  • contrib/ivorysql_ora/sql/dbms_utility.sql
  • contrib/ivorysql_ora/src/builtin_packages/dbms_utility/dbms_utility.c
  • src/pl/plisql/src/pl_exec.c

@db-nikhil
db-nikhil force-pushed the nikkhils/dbms_utility_fix branch from 060bcf9 to 687d722 Compare July 28, 2026 17:08
@hanjianqiao

Copy link
Copy Markdown
Collaborator

Thanks so much for the contribution! Could you add some more details in #1472.

@db-nikhil
db-nikhil force-pushed the nikkhils/dbms_utility_fix branch from 687d722 to d5c3b8f Compare July 29, 2026 08:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contrib/ivorysql_ora/sql/dbms_utility.sql`:
- Line 460: Strengthen the wildcard assertions in the relevant stack-validation
tests: update the Test 19 check around the
CALLSTACK_NS.TEST_CALL_STACK_PKG.STACK_CALLER frame to assert the complete
ORA-06512 frame, and update Test 18 around the BUG_SCHEMA.SCHEMA_ERROR check to
explicitly reject the PUBLIC.CALLSTACK_NS... prefixed form. Preserve the
existing valid-frame assertions while ensuring residual leading PUBLIC.
qualifiers fail.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 69f47c93-3afe-4ad3-9c56-51a2b0c7e668

📥 Commits

Reviewing files that changed from the base of the PR and between 687d722 and d5c3b8f.

📒 Files selected for processing (6)
  • contrib/ivorysql_ora/expected/dbms_utility.out
  • contrib/ivorysql_ora/expected/utl_encode.out
  • contrib/ivorysql_ora/expected/utl_file.out
  • contrib/ivorysql_ora/sql/dbms_utility.sql
  • contrib/ivorysql_ora/src/builtin_packages/dbms_utility/dbms_utility.c
  • src/pl/plisql/src/pl_exec.c
🚧 Files skipped from review as they are similar to previous changes (2)
  • contrib/ivorysql_ora/src/builtin_packages/dbms_utility/dbms_utility.c
  • src/pl/plisql/src/pl_exec.c

@db-nikhil
db-nikhil force-pushed the nikkhils/dbms_utility_fix branch 3 times, most recently from 676690f to 2773838 Compare July 29, 2026 14:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pl/plisql/src/pl_exec.c`:
- Around line 10222-10227: Update the current line selection in the call-stack
formatting path to match plisql_exec_error_callback(): check estate->err_var
before estate->err_stmt, preserving the existing fallback behavior when either
field is unavailable.
- Around line 1450-1460: Update plisql_exec_error_callback() and
plisql_get_call_stack() in src/pl/plisql/src/pl_exec.c at lines 1486-1488 and
10235-10237 to store plisql_package_qualified_signature() results in temporary
variables, then pfree() them after errcontext() formatting and
appendStringInfo() insertion. In plisql_package_qualified_signature() at lines
1450-1460, ensure the intermediate nspname and pkgqual allocations are freed
before returning the final signature while preserving the existing returned
string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 354c8449-b2d2-4691-bfe4-b1f85b9e5637

📥 Commits

Reviewing files that changed from the base of the PR and between ace8b99 and 676690f.

📒 Files selected for processing (6)
  • contrib/ivorysql_ora/expected/dbms_utility.out
  • contrib/ivorysql_ora/expected/utl_encode.out
  • contrib/ivorysql_ora/expected/utl_file.out
  • contrib/ivorysql_ora/sql/dbms_utility.sql
  • contrib/ivorysql_ora/src/builtin_packages/dbms_utility/dbms_utility.c
  • src/pl/plisql/src/pl_exec.c
🚧 Files skipped from review as they are similar to previous changes (5)
  • contrib/ivorysql_ora/expected/utl_file.out
  • contrib/ivorysql_ora/expected/utl_encode.out
  • contrib/ivorysql_ora/sql/dbms_utility.sql
  • contrib/ivorysql_ora/src/builtin_packages/dbms_utility/dbms_utility.c
  • contrib/ivorysql_ora/expected/dbms_utility.out

Comment thread src/pl/plisql/src/pl_exec.c Resolved
Comment thread src/pl/plisql/src/pl_exec.c Resolved
@db-nikhil
db-nikhil force-pushed the nikkhils/dbms_utility_fix branch 4 times, most recently from da52181 to 9298c08 Compare August 3, 2026 09:59
@hanjianqiao hanjianqiao self-assigned this Aug 3, 2026
@db-nikhil
db-nikhil force-pushed the nikkhils/dbms_utility_fix branch from 9298c08 to 1ef6f2b Compare August 4, 2026 06:32
@hanjianqiao

Copy link
Copy Markdown
Collaborator

@db-nikhil I found an obvious mistake: INTERCHANGE mode doesn't actually mean uppercase — see the docs for details: https://docs.ivorysql.org/en/ivorysql-doc/master/oracle_compatibility/compat_case_conversion

Either way works for me — would you prefer to fix this within this PR, or track it in a follow-up PR?

Thanks!

@db-nikhil
db-nikhil force-pushed the nikkhils/dbms_utility_fix branch from 1ef6f2b to f4703af Compare August 7, 2026 11:47
@db-nikhil

Copy link
Copy Markdown
Author

@db-nikhil I found an obvious mistake: INTERCHANGE mode doesn't actually mean uppercase — see the docs for details: https://docs.ivorysql.org/en/ivorysql-doc/master/oracle_compatibility/compat_case_conversion

Either way works for me — would you prefer to fix this within this PR, or track it in a follow-up PR?

Thanks!

@hanjianqiao thanks for the pointer to the documentation! I have updated this PR based on it.

FORMAT_ERROR_BACKTRACE unconditionally prepended a hardcoded "PUBLIC."
prefix to every frame name, including package member frames whose context
line already carries the full schema.package.routine path produced by
plisql_package_qualified_signature(). Two bugs resulted:

Package members lost the package component: "PUBLIC.PKG_ERROR" instead
of "PUBLIC.TEST_PKG.PKG_ERROR".  Schema-qualified standalone routines
got an extra prefix: "PUBLIC. TEST_SCHEMA.SCHEMA_ERROR" instead of
"TEST_SCHEMA.SCHEMA_ERROR".

Add test 18 to dbms_utility.sql to cover FORMAT_CALL_STACK from inside a
package procedure and assert the frame is schema/package-qualified.
@db-nikhil
db-nikhil force-pushed the nikkhils/dbms_utility_fix branch from f4703af to a0b521e Compare August 7, 2026 12:30

@jiaoshuntian jiaoshuntian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@db-nikhil

Copy link
Copy Markdown
Author

is there anything else pending here from my side?

@hanjianqiao

hanjianqiao commented Aug 16, 2026 •

Copy link
Copy Markdown
Collaborator

@db-nikhil Thanks again for the contribution, and sorry for the slow turnaround!

This looks good to me. It still needs to clear our internal review process, though, and we've had a high volume of PRs come in recently, so things are moving slower than usual — I'd expect to have an update for you within the next week.

@gaoxueyu
gaoxueyu merged commit b7d9f4e into IvorySQL:master Aug 17, 2026
7 checks passed
@db-nikhil
db-nikhil deleted the nikkhils/dbms_utility_fix branch August 18, 2026 05:41
hs-liuxh pushed a commit to hs-liuxh/IvorySQL that referenced this pull request Sep 2, 2026
…_fix

dbms_utility: fix backtrace/call-stack qualification for package members

(cherry picked from commit b7d9f4e)
hs-liuxh pushed a commit to hs-liuxh/IvorySQL that referenced this pull request Sep 2, 2026
…_fix

dbms_utility: fix backtrace/call-stack qualification for package members

(cherry picked from commit b7d9f4e)
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.

DBMS_UTILITY.FORMAT_ERROR_BACKTRACE / FORMAT_CALL_STACK produce wrong frame names for package members and schema-qualified routines

4 participants