Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26843

Inconsistent behavior of ROW_NUMBER upon resignalling from function

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.7
    • 10.11
    • Stored routines
    • None

    Description

      Notes:

      • The test case uses explicit HANDLER / RESIGNAL for more obvious demonstration, but it is really the same without any handler, when the error remains uncaught and gets passed over to the upper level.
      • If you run the test case via MTR, remember to adjust delimiters.

      create or replace function f(a int) returns int return a;
      delimiter $
      create or replace function f2() returns int
      begin
        declare i int default -1;
        declare exit handler for 1318
        begin
          get diagnostics condition 1 @row_number_in_f2= row_number, @msg_in_f2= message_text;
          resignal;
          return -2;
        end;
        select f() into i;
        return i;
      end $
      delimiter ;
       
      --error ER_SP_WRONG_NO_OF_ARGS
      select f2();
       
      get diagnostics condition 1 @row_number_outside= row_number, @msg_outside= message_text;
      select @row_number_in_f2, @msg_in_f2;
      select @row_number_outside, @msg_outside;
       
      # Cleanup
      drop function f2;
      drop function f;
      

      bb-10.7-row_number cb9002be

      MariaDB [test]> select @row_number_in_f2, @msg_in_f2;
      +-------------------+----------------------------------------------------------------------+
      | @row_number_in_f2 | @msg_in_f2                                                           |
      +-------------------+----------------------------------------------------------------------+
      |                 1 | Incorrect number of arguments for FUNCTION test.f; expected 1, got 0 |
      +-------------------+----------------------------------------------------------------------+
      1 row in set (0.000 sec)
       
      MariaDB [test]> select @row_number_outside, @msg_outside;
      +---------------------+----------------------------------------------------------------------+
      | @row_number_outside | @msg_outside                                                         |
      +---------------------+----------------------------------------------------------------------+
      |                   0 | Incorrect number of arguments for FUNCTION test.f; expected 1, got 0 |
      +---------------------+----------------------------------------------------------------------+
      1 row in set (0.000 sec)
      

      So, while the error message is passed over to the caller, the ROW_NUMBER isn't.
      There must be plenty other examples like this.

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.