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

Datetime order by and limit offset not working

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Not a Bug
    • 10.5.12, 10.7.1
    • N/A
    • Server
    • None
    • from docker image : docker run --rm -e MYSQL_ROOT_PASSWORD=azerty -e TZ=Europe\Paris -it mariadb:10.7.1

    Description

      Example :

      CREATE TABLE test (a VARCHAR(255), b datetime);
      insert into test values('1', '2021-11-03 11:21:21');
      insert into test values('2', '2021-11-03 11:22:21');
      insert into test values('3', '2021-11-04');
      insert into test values('5', '2021-11-05');
      insert into test values('6', '2040-01-01 10:10');
       
      MariaDB [toto]> select * from test;
      +------+---------------------+
      | a    | b                   |
      +------+---------------------+
      | 1    | 2021-11-03 11:21:21 |
      | 2    | 2021-11-03 11:22:21 |
      | 3    | 2021-11-04 00:00:00 |
      | 5    | 2021-11-05 00:00:00 |
      | 6    | 2040-01-01 10:10:00 |
      +------+---------------------+
      5 rows in set (0.000 sec)
       
      MariaDB [toto]> select * from test order by b;
      +------+---------------------+
      | a    | b                   |
      +------+---------------------+
      | 1    | 2021-11-03 11:21:21 |
      | 2    | 2021-11-03 11:22:21 |
      | 3    | 2021-11-04 00:00:00 |
      | 5    | 2021-11-05 00:00:00 |
      | 6    | 2040-01-01 10:10:00 |
      +------+---------------------+
      5 rows in set (0.000 sec)
       
      MariaDB [toto]> select * from test order by b limit 3 offset 0;
      +------+---------------------+
      | a    | b                   |
      +------+---------------------+
      | 1    | 2021-11-03 11:21:21 |
      | 2    | 2021-11-03 11:22:21 |
      | 3    | 2021-11-04 00:00:00 |
      +------+---------------------+
      3 rows in set (0.000 sec)
       
      MariaDB [toto]> select * from test order by b limit 3 offset 1;
      +------+---------------------+
      | a    | b                   |
      +------+---------------------+
      | 2    | 2021-11-03 11:22:21 | <= ERROR
      | 3    | 2021-11-04 00:00:00 | <= ERROR
      | 5    | 2021-11-05 00:00:00 |
      +------+---------------------+
      3 rows in set (0.000 sec)
       
      MariaDB [toto]> select * from test order by b DESC;
      +------+---------------------+
      | a    | b                   |
      +------+---------------------+
      | 6    | 2040-01-01 10:10:00 |
      | 5    | 2021-11-05 00:00:00 |
      | 3    | 2021-11-04 00:00:00 |
      | 2    | 2021-11-03 11:22:21 |
      | 1    | 2021-11-03 11:21:21 |
      +------+---------------------+
      5 rows in set (0.000 sec)
       
      MariaDB [toto]> select * from test order by b DESC limit 3 offset 0;
      +------+---------------------+
      | a    | b                   |
      +------+---------------------+
      | 6    | 2040-01-01 10:10:00 |
      | 5    | 2021-11-05 00:00:00 |
      | 3    | 2021-11-04 00:00:00 |
      +------+---------------------+
      3 rows in set (0.000 sec)
       
      MariaDB [toto]> select * from test order by b DESC limit 3 offset 1;
      +------+---------------------+
      | a    | b                   |
      +------+---------------------+
      | 5    | 2021-11-05 00:00:00 |  <= ERROR
      | 3    | 2021-11-04 00:00:00 |  <= ERROR
      | 2    | 2021-11-03 11:22:21 |
      +------+---------------------+
      3 rows in set (0.001 sec)
      

      Attachments

        Activity

          People

            serg Sergei Golubchik
            salorium Geoffrey Saleur
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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