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

SQL_SELECT_LIMIT and FOUND_ROWS() are not handled correctly by the INFORMATION_SCHEMA.TABLES fast path

    XMLWordPrintable

Details

    • Not for Release Notes

    Description

      SQL_SELECT_LIMIT and FOUND_ROWS() are not handled correctly by the INFORMATION_SCHEMA.TABLES fast path. sql_select_limit=2 returns all 3 rows instead of 2, while FOUND_ROWS() returns the previous statement's row count instead of the 3 rows returned by the I_S query.

      CREATE TABLE t1(i INT);
      CREATE TABLE t2(i INT);
      CREATE TABLE t3(i INT);
       
      -- (a) @@sql_select_limit is ignored by the fast path.
      SET @@session.sql_select_limit=2;
      SELECT TABLE_CATALOG FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'; -- expected 2 rows, but it returns 3
      SET @@session.sql_select_limit=DEFAULT;
       
      -- (b) FOUND_ROWS() after a fast-path query is wrong.
      SELECT 1; -- 1 row
      SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
      SELECT FOUND_ROWS(); -- expected 3, but it returns 1
      

      CLI Output

      13.1.0-opt>CREATE TABLE t1(i INT);
      Query OK, 0 rows affected (0.010 sec)
       
      13.1.0-opt>CREATE TABLE t2(i INT);
      Query OK, 0 rows affected (0.006 sec)
       
      13.1.0-opt>CREATE TABLE t3(i INT);
      Query OK, 0 rows affected (0.005 sec)
       
      13.1.0-opt>
      13.1.0-opt>
      13.1.0-opt>SET @@session.sql_select_limit=2;
      Query OK, 0 rows affected (0.000 sec)
       
      13.1.0-opt>SELECT TABLE_CATALOG FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'; -- expected 2 rows, but it returns 3
      +---------------+
      | TABLE_CATALOG |
      +---------------+
      | def           |
      | def           |
      | def           |
      +---------------+
      3 rows in set (0.000 sec)
       
      13.1.0-opt>SET @@session.sql_select_limit=DEFAULT;
      Query OK, 0 rows affected (0.000 sec)
       
      13.1.0-opt>
      13.1.0-opt>SELECT 1; -- 1 row
      +---+
      | 1 |
      +---+
      | 1 |
      +---+
      1 row in set (0.000 sec)
       
      13.1.0-opt>
      13.1.0-opt>SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
      +------------+
      | TABLE_NAME |
      +------------+
      | t2         |
      | t1         |
      | t3         |
      +------------+
      3 rows in set (0.000 sec)
       
      13.1.0-opt>SELECT FOUND_ROWS(); -- expected 3, but it returns 1
      +--------------+
      | FOUND_ROWS() |
      +--------------+
      |            1 |
      +--------------+
      1 row in set (0.000 sec)
       
      13.1.0-opt>
      

      Attachments

        Issue Links

          Activity

            People

              janlindstrom Jan Lindström
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0.5h Original Estimate - 0.5h
                  0.5h
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 1h 25m
                  1h 25m

                  Git Integration

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