← 输入框|github.com|刷新
Skip to content

Line numbers are wrong with source lines over 4000 bytes #1396

Done

Description

@jgebal

Describe the bug
When reading, scanning and referencing lines of code from (all|dba|user)_source there is a corner case that is not handled correctly right now in utPLSQL.

When a line of source is more than 4000 bytes long, then the source line will actually be stored in two lines of the source view.

The problem was noticed and reported as a fix for ut_metadata.get_source_definition_line function.

But the fix proposed in #1394 only addresses one aspect of the issue.
The aspect that is visible in the expectation result.

To Reproduce

Create the test package with a long line before the expectation result

create or replace package test_package1 is
  --%suite

  --%test
  procedure sp_test;
end;

create or replace package body test_package1 is
  procedure sp_test is
  begin
    /* [comment way over 4000 limit]*********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
    ut.expect(1).to_equal(2);
  end;
end;

Run the tests

begin
    ut.run('test_package1');
end;

The result shows:

Failures:

  1) sp_test
      Actual: 1 (number) was expected to equal: 2 (number)
      at "PMUSER.TEST_PACKAGE1.SP_TEST", line 5 *****************************************************************************************************************************************************************************************************************************************/

Finished in ,008209 seconds
1 tests, 1 failed, 0 errored, 0 disabled, 0 warning(s)

The problem is in the at "PMUSER.TEST_PACKAGE1.SP_TEST", line 5*****...

Expected behavior

The text should be at "PMUSER.TEST_PACKAGE1.SP_TEST", line 5 ut.expect(1).to_equal(2);

Activity

  1. mathewbutler commented on Nov 19, 2026

    @mathewbutler
    Contributor

    I've watched the background to this.

    A really minor comment/suggestion - it's not obvious that the long line has the required length. One way to achieve the same is something like the below. I've not used labels on an anon block before, but doco appears to suggest this works. Unable to test this currently.

    <<create_package_with_long_source_line>>
    declare
      l_body varchar2(32767);
    begin
      -- Build a package body with a comment line over 4,000 bytes.
      l_body :=
           'create or replace package body test_package1 is' || chr(10)
        || '  procedure sp_test is' || chr(10)
        || '  begin' || chr(10)
        || '    /* [a comment way over 4000 character limit] ' || rpad('*', 4000, '*') || ' */' || chr(10)
        || '    ut.expect(1).to_equal(2);' || chr(10)
        || '  end sp_test;' || chr(10)
        || 'end test_package1;';
    
      execute immediate l_body;
    end create_package_with_long_source_line;
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions