Skip to content

feat: dbms_output as wrapper of RAISE INFO#971

Closed
rophy wants to merge 4 commits intoIvorySQL:masterfrom
rophy:feat/dbms_output
Closed

feat: dbms_output as wrapper of RAISE INFO#971
rophy wants to merge 4 commits intoIvorySQL:masterfrom
rophy:feat/dbms_output

Conversation

@rophy
Copy link
Copy Markdown
Contributor

@rophy rophy commented Nov 17, 2025

Current version only implements dbms_output.put_line() since that's the most common method in legacy oracle packages.

I hope the commit messages are self-explanary.

Will try implement more methods once I see actual usages.

Summary by CodeRabbit

  • New Features

    • Added DBMS_OUTPUT package exposing put_line, put, new_line, put, enable, and disable for emitting output from DB code.
  • Tests

    • Added comprehensive DBMS_OUTPUT test suite and integrated it into the PL/iSQL test run.
    • Added a test package demonstrating package init-block behavior and verifying output semantics.
  • Style

    • Minor test comment wording updated.

- Implement DBMS_OUTPUT.PUT_LINE and PUT as wrappers for RAISE INFO
- Add hello_pkg test using DBMS_OUTPUT
- Basic implementation without buffering
- Update plisql_nested_subproc2.out: ERROR -> INFO for dbms_output.put_line
- Update comment in plisql_nested_subproc2.sql
- Add plisql_dbms_output test with Oracle API documentation
- Add plisql_dbms_output to Makefile REGRESS list
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 17, 2025

Walkthrough

Adds a SQL-based DBMS_OUTPUT package and registers it in contrib aggregation; introduces tests and Makefile integration; adds a sample package test and a minor test comment change.

Changes

Cohort / File(s) Change Summary
DBMS_OUTPUT module
contrib/ivorysql_ora/ivorysql_ora_merge_sqls, contrib/ivorysql_ora/src/builtin_functions/dbms_output--1.0.sql
Registered and added a new dbms_output package (spec + body) exposing put_line, put, new_line, enable, and disable. Implementation emits output via RAISE INFO; buffering and enable/disable are no-ops.
PL/iSQL tests & Makefile
src/pl/plisql/src/Makefile, src/pl/plisql/src/sql/plisql_dbms_output.sql
Added plisql_dbms_output to REGRESS and introduced comprehensive DBMS_OUTPUT test script covering usage in procedures, functions, and packages and ENABLE/DISABLE behavior.
Oracle test and minor test tweak
src/oracle_test/regress/sql/ora_package.sql, src/pl/plisql/src/sql/plisql_nested_subproc2.sql
Added hello_pkg package with say_hello and init block test; updated a test marker comment in nested subproc test (textual change only).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant DBMS_OUTPUT
    participant Logger as "RAISE INFO"
    participant Session

    Client->>DBMS_OUTPUT: put_line(text)
    DBMS_OUTPUT->>Logger: RAISE INFO with text
    Logger->>Session: emit output

    Client->>DBMS_OUTPUT: put(text)
    DBMS_OUTPUT->>Logger: RAISE INFO with text
    Logger->>Session: emit output

    Client->>DBMS_OUTPUT: new_line()
    DBMS_OUTPUT->>Logger: RAISE INFO with newline/space
    Logger->>Session: emit output

    Client->>DBMS_OUTPUT: enable(size)
    DBMS_OUTPUT-->>Client: no-op (enabled by default)

    Client->>DBMS_OUTPUT: disable()
    DBMS_OUTPUT-->>Client: no-op (still emits)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to:
    • SQL package body correctness and use of RAISE INFO for output.
    • Test script expectations vs actual DBMS_OUTPUT behavior (enable/disable no-ops).
    • Makefile REGRESS integration and test naming.

Suggested reviewers

  • OreoYang
  • NotHimmel

Poem

🐰 I hopped a line into the tree,
put_line sang loud and true to me.
new_line danced, enable stayed light,
disable slept through day and night.
RAISE INFO echoes — a rabbit's delight! 🥕📢

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: implementing dbms_output as a wrapper around RAISE INFO. This directly matches the PR's objective and the changeset's core functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28c7cd3 and 8f59ead.

⛔ Files ignored due to path filters (1)
  • src/pl/plisql/src/expected/plisql_dbms_output.out is excluded by !**/*.out
📒 Files selected for processing (1)
  • src/pl/plisql/src/sql/plisql_dbms_output.sql (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pl/plisql/src/sql/plisql_dbms_output.sql

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
contrib/ivorysql_ora/src/builtin_functions/dbms_output--1.0.sql (1)

1-52: Implementation is functional but minimal - document limitations clearly.

The DBMS_OUTPUT implementation provides basic Oracle compatibility by wrapping RAISE INFO. Key differences from Oracle's implementation:

  1. No buffering: PUT() and PUT_LINE() output immediately rather than buffering
  2. No enable/disable: Output cannot be disabled (procedures are no-ops)
  3. No retrieval: GET_LINE() and GET_LINES() are not implemented

These limitations are acceptable for an initial release and are documented in the header comments. However, ensure users are aware that:

  • Code expecting buffered output behavior may see different timing of messages
  • Applications that rely on enable/disable state will always see output
  • Tools that retrieve output programmatically via GET_LINE/GET_LINES won't work

Consider documenting these limitations in user-facing documentation or release notes. For a future enhancement, implementing actual buffering would improve Oracle compatibility for applications that depend on it.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a43e33 and 28c7cd3.

⛔ Files ignored due to path filters (3)
  • src/oracle_test/regress/expected/ora_package.out is excluded by !**/*.out
  • src/pl/plisql/src/expected/plisql_dbms_output.out is excluded by !**/*.out
  • src/pl/plisql/src/expected/plisql_nested_subproc2.out is excluded by !**/*.out
📒 Files selected for processing (6)
  • contrib/ivorysql_ora/ivorysql_ora_merge_sqls (1 hunks)
  • contrib/ivorysql_ora/src/builtin_functions/dbms_output--1.0.sql (1 hunks)
  • src/oracle_test/regress/sql/ora_package.sql (1 hunks)
  • src/pl/plisql/src/Makefile (1 hunks)
  • src/pl/plisql/src/sql/plisql_dbms_output.sql (1 hunks)
  • src/pl/plisql/src/sql/plisql_nested_subproc2.sql (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-02T10:43:25.257Z
Learnt from: syasirs
Repo: IvorySQL/IvorySQL PR: 858
File: src/Makefile.global.in:513-514
Timestamp: 2025-09-02T10:43:25.257Z
Learning: In IvorySQL Makefile.global.in, $(wildcard t/oracle/*.pl) is used instead of t/oracle/*.pl in Oracle TAP test discovery because the t/oracle directory is optional and may not exist in most builds. The wildcard function safely returns empty string when the directory is missing, preventing shell expansion errors.

Applied to files:

  • src/pl/plisql/src/Makefile
🔇 Additional comments (4)
src/pl/plisql/src/sql/plisql_nested_subproc2.sql (1)

3617-3617: LGTM! Test marker updated to reflect new DBMS_OUTPUT functionality.

The comment change appropriately documents that this section now tests DBMS_OUTPUT rather than raising an error about its absence.

contrib/ivorysql_ora/ivorysql_ora_merge_sqls (1)

3-3: LGTM! Module registration is correct.

The new dbms_output module is properly registered in the build system's module aggregation list.

src/pl/plisql/src/Makefile (1)

59-60: LGTM! Test module properly integrated.

The new plisql_dbms_output test is correctly added to the REGRESS suite with proper formatting and line continuation.

src/oracle_test/regress/sql/ora_package.sql (1)

6097-6134: LGTM! Good test coverage for package initialization and DBMS_OUTPUT integration.

This test case effectively demonstrates:

  1. DBMS_OUTPUT.PUT_LINE usage within package procedures
  2. Package initialization block behavior (should run once per session)
  3. Proper package creation and cleanup

The two consecutive calls to say_hello() will verify that the initialization block (hello_pkg loaded) only executes on the first package reference, which is correct Oracle behavior.

Comment on lines +134 to +142
-- IvorySQL Current Implementation Status:
-- ✓ PUT_LINE(text) - Fully working (uses RAISE INFO)
-- ✗ PUT(text) - Syntax error
-- ✗ NEW_LINE - Syntax error
-- ✗ ENABLE(buffer_size) - Syntax error
-- ✗ DISABLE - Syntax error
-- ✗ GET_LINE(line, status) - Not implemented
-- ✗ GET_LINES(lines, numlines) - Not implemented
--
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Nov 17, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Incorrect implementation status documentation.

The comments indicate that PUT, NEW_LINE, ENABLE, and DISABLE have "syntax errors", but the actual implementation in contrib/ivorysql_ora/src/builtin_functions/dbms_output--1.0.sql shows all these procedures are properly defined and should work:

  • PUT(text) - Implemented (lines 29-33)
  • NEW_LINE - Implemented (lines 35-38)
  • ENABLE(buffer_size) - Implemented as no-op (lines 41-45)
  • DISABLE - Implemented as no-op (lines 47-51)

Update the implementation status to reflect the actual state:

 -- IvorySQL Current Implementation Status:
 -- ✓ PUT_LINE(text)               - Fully working (uses RAISE INFO)
--- ✗ PUT(text)                    - Syntax error
--- ✗ NEW_LINE                     - Syntax error
--- ✗ ENABLE(buffer_size)          - Syntax error
--- ✗ DISABLE                      - Syntax error
+-- ✓ PUT(text)                    - Working (no buffering, outputs immediately)
+-- ✓ NEW_LINE                     - Working (outputs space character)
+-- ✓ ENABLE(buffer_size)          - Working (no-op, output always enabled)
+-- ✓ DISABLE                      - Working (no-op, cannot disable output)
 -- ✗ GET_LINE(line, status)       - Not implemented
 -- ✗ GET_LINES(lines, numlines)   - Not implemented
🤖 Prompt for AI Agents
In src/pl/plisql/src/sql/plisql_dbms_output.sql around lines 134 to 142, the
status comment incorrectly marks PUT, NEW_LINE, ENABLE, and DISABLE as "syntax
error" while the contrib implementation defines them; update the comment block
to reflect that PUT(text), NEW_LINE, ENABLE(buffer_size) and DISABLE are
implemented (ENABLE/DISABLE as no-ops) and adjust the checklist to mark them as
working or implemented and remove the "syntax error" labels so the documentation
matches the actual contrib source.

Copy link
Copy Markdown
Contributor Author

@rophy rophy Nov 17, 2025

Choose a reason for hiding this comment

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

Fixed with commit 8f59ead

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.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the current implementation status documentation in the test file
cat src/pl/plisql/src/sql/plisql_dbms_output.sql | tail -20

Length of output: 1093


@rophy Thanks for fixing this! The documentation now accurately reflects the implementation status. I appreciate that you identified the parser limitation with no-arg procedure calls (NEW_LINE and DISABLE) and documented it clearly. This is helpful context for users who might encounter those syntax errors.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

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.

Fixed with commit 8f59ead

Thanks!

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.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

- Split combined tests into individual test cases per method
- Update implementation status documentation based on test results
- PUT_LINE, PUT, ENABLE work correctly
- NEW_LINE, DISABLE fail (no-arg procedure parser limitation)
@OreoYang
Copy link
Copy Markdown
Collaborator

OreoYang commented Nov 18, 2025

Fixed with commit 8f59ead

Hi rophy,
Could you check the failed regression cases below.

Quick tip: You can manually run the regression test by executing the following command in the directory:
highgo@qd:~/works/test/IvorySQL/src/pl/plisql$ make oracle-check

diff -U3 /home/runner/work/IvorySQL/IvorySQL/src/pl/plisql/src/expected/plisql_dbms_output.out /home/runner/work/IvorySQL/IvorySQL/src/pl/plisql/src/results/plisql_dbms_output.out
--- /home/runner/work/IvorySQL/IvorySQL/src/pl/plisql/src/expected/plisql_dbms_output.out	2025-11-18 00:22:58.425668683 +0000
+++ /home/runner/work/IvorySQL/IvorySQL/src/pl/plisql/src/results/plisql_dbms_output.out	2025-11-18 00:36:29.864620493 +0000
@@ -175,12 +175,14 @@
 -- 7. GET_LINES(lines, numlines)  - Retrieve multiple lines from buffer
 --
 -- IvorySQL Current Implementation Status:
--- ✓ PUT_LINE(text)               - Fully working (uses RAISE INFO)
--- ✗ PUT(text)                    - Syntax error
--- ✗ NEW_LINE                     - Syntax error
--- ✗ ENABLE(buffer_size)          - Syntax error
--- ✗ DISABLE                      - Syntax error
+-- ✓ PUT_LINE(text)               - Works (outputs via RAISE INFO)
+-- ✓ PUT(text)                    - Works (outputs via RAISE INFO)
+-- ✗ NEW_LINE                     - Syntax error (no-arg procedure call)
+-- ✓ ENABLE(buffer_size)          - Works (no-op)
+-- ✗ DISABLE                      - Syntax error (no-arg procedure call)
 -- ✗ GET_LINE(line, status)       - Not implemented
 -- ✗ GET_LINES(lines, numlines)   - Not implemented
 --
--- Note: Current implementation outputs immediately (no buffering)
+-- Note:
+-- - Output is immediate (no buffering)
+-- - NEW_LINE and DISABLE fail due to PL/iSQL parser limitation with no-arg procedures

@rophy
Copy link
Copy Markdown
Contributor Author

rophy commented Nov 18, 2025

sure, will follow up in a day or two

@rophy
Copy link
Copy Markdown
Contributor Author

rophy commented Nov 18, 2025

~/IvorySQL/src/pl/plisql$ make oracle-check
make -C ../../../src/backend generated-headers
make[1]: Entering directory '/home/ivorysql/IvorySQL/src/backend'
......
# +++ ora regress check in src/pl/plisql/src +++
# initializing database system by copying initdb template
# using temp instance on port 65313 with PID 42703
ok 1         - plisql_array                               15 ms
ok 2         - plisql_call                                30 ms
ok 3         - plisql_control                             22 ms
ok 4         - plisql_copy                                10 ms
ok 5         - plisql_domain                              21 ms
ok 6         - plisql_record                              64 ms
ok 7         - plisql_cache                               11 ms
ok 8         - plisql_simple                              16 ms
ok 9         - plisql_transaction                         48 ms
ok 10        - plisql_trap                              1044 ms
ok 11        - plisql_trigger                             10 ms
ok 12        - plisql_varprops                            11 ms
ok 13        - plisql_nested_subproc                   14953 ms
ok 14        - plisql_nested_subproc2                  15028 ms
ok 15        - plisql_out_parameter                       59 ms
ok 16        - plisql_type_rowtype                       548 ms
ok 17        - plisql_dbms_output                         11 ms
1..17
# All 17 tests passed.
make[1]: Leaving directory '/home/ivorysql/IvorySQL/src/pl/plisql/src'

@bigplaice
Copy link
Copy Markdown
Collaborator

Hi, Rophy,thanks for your contribution to IvorySQL!
This dbms_output is quite simple. Do you have plan to implement the missing part?

@rophy
Copy link
Copy Markdown
Contributor Author

rophy commented Nov 26, 2025

Is aliasing to RAISE INFO good enough?

If that is good enough, I can help to fix those methods such as ENABLE, DISABLE, GET_LINE as no-op.

Otherwise I imagine we will need some buffering mechanism to properly mimic dbms_output

@bigplaice
Copy link
Copy Markdown
Collaborator

Hi, Rophy, we expect to be compatible with Oracle as possible as we can, so it would be good to implement buffer mechanism and other procedures as well.

@rophy
Copy link
Copy Markdown
Contributor Author

rophy commented Nov 26, 2025

That's fair. Feel free to drop this pr.
I'll rework on this once I encounter more dbms_output usages in my testing.

@bigplaice
Copy link
Copy Markdown
Collaborator

OK, I'll close this PR. Thanks for your contribution to IvorySQl!

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.

3 participants