Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-3839

Count as a window function doesn't work with NULLs

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.2.5
    • 1.4.4, 1.5.1
    • None
    • None

    Description

      MariaDB [smtp_email_validator]> select count(null) over () from logs where timestamp > now() - interval 1 hour; 
      ERROR 1815 (HY000): Internal error: InetStreamSocket::readToMagic: Remote is closed
      MariaDB [smtp_email_validator]> show warnings\G
      *************************** 1. row ***************************
        Level: Error
         Code: 1815
      Message: Internal error: InetStreamSocket::readToMagic: Remote is closed
      *************************** 2. row ***************************
        Level: Error
         Code: 1030
      Message: Got error 1815 "Unknown error 1815" from storage engine InfiniDB
      *************************** 3. row ***************************
        Level: Error
         Code: 1815
      Message: Internal error: /data/buildbot/bb-worker/centos7/mariadb-columnstore-engine/dbcon/execplan/clientrotator.cpp: Could not get a connection to a ExeMgr
      3 rows in set (0.000 sec)
      

      If we use an expression as a `count ` argument, it counts all rows including the ones containing NULLs

      Attachments

        Activity

          One may be tempted to ask why anyone would write count(NULL). Automated systems do.

          David.Hall David Hall (Inactive) added a comment - One may be tempted to ask why anyone would write count(NULL). Automated systems do.

          Looking at colIn == -1 to check for NULL has the incorrect assumption that the -1 is caused by a NULL parameter. What is actually happening is that because the parameter is a constant, the field index is -1. Any constant will do this.
          This solution results in any constant parameter being treated as NULL, which is incorrect.
          A more correct solution is to look at the value of fConstantColumns[0] for the constant value. Unfortunately, the value inserted here for NULL is 0 (incorrect). Perhaps adding a line in ConstantColumn.cpp after if (fType == ConstantColumn::NULLDATA) to push the actual NULL value in would work.

          David.Hall David Hall (Inactive) added a comment - Looking at colIn == -1 to check for NULL has the incorrect assumption that the -1 is caused by a NULL parameter. What is actually happening is that because the parameter is a constant, the field index is -1. Any constant will do this. This solution results in any constant parameter being treated as NULL, which is incorrect. A more correct solution is to look at the value of fConstantColumns [0] for the constant value. Unfortunately, the value inserted here for NULL is 0 (incorrect). Perhaps adding a line in ConstantColumn.cpp after if (fType == ConstantColumn::NULLDATA) to push the actual NULL value in would work.

          I have updated change to work for other constants as well as NULLs.

          jrojas Jose Rojas (Inactive) added a comment - I have updated change to work for other constants as well as NULLs.

          Build verified: 1.4.4-1m 1.5.0-1 source

          1.4.4-1

          /root/ColumnStore/buildColumnstoreFromGithubSource/server
          commit d8ff39957275afc7a870487631cd3b3be5eb8818
          Author: Rasmus Johansson <razze@iki.fi>
          Date: Mon May 4 10:10:07 2020 +0000

          MDEV-22273 jUnit patch: xml test result differs from MTR output in case if retry

          /root/ColumnStore/buildColumnstoreFromGithubSource/server/engine
          commit 4c275557633edb60905faa500990d55a6834951d
          Merge: aa054a9 47f2933
          Author: David.Hall <david.hall@mariadb.com>
          Date: Tue May 5 12:34:03 2020 -0500

          Merge pull request #1179 from pleblanc1976/update-libs3-ref

          Updated the s3 lib.

          1.5.0-1

          /root/ColumnStore/buildColumnstoreFromGithubSource/server
          commit 43b7e5d29a5480214cee8317a4625b749ccffbaf
          Author: Rasmus Johansson <razze@iki.fi>
          Date: Mon May 4 10:10:07 2020 +0000

          MDEV-22273 jUnit patch: xml test result differs from MTR output in case if retry

          /root/ColumnStore/buildColumnstoreFromGithubSource/server/engine
          commit 368c4fac059d5cf4f1596e56ea7b1e729e29ec49
          Merge: 15a9efa 4bc408c
          Author: David.Hall <david.hall@mariadb.com>

          Date: Tue May 5 12:35:14 2020 -0500

          Merge pull request #1178 from pleblanc1976/update-libs3-ref-1.5

          Updated s3 lib ref

          Reproduced the issue in 1.2.5-1

          MariaDB [mytest]> select count(null) over () from orders where o_orderdate > '1997-05-17' - interval 1 hour;
          ERROR 1815 (HY000): Internal error: InetStreamSocket::readToMagic: Remote is closed

          MariaDB [mytest]> select count(null) over () from orders where o_orderdate > '1998-08-02' - interval 1 hour;
          ---------------------

          count(null) over ()

          ---------------------

          0

          .
          .
          .

          0
          0

          ---------------------
          581 rows in set (0.070 sec)

          MariaDB [mytest]> select count from orders where o_orderdate = '1998-08-02';
          ----------

          count

          ----------

          581

          ----------
          1 row in set (0.057 sec)

          dleeyh Daniel Lee (Inactive) added a comment - Build verified: 1.4.4-1m 1.5.0-1 source 1.4.4-1 /root/ColumnStore/buildColumnstoreFromGithubSource/server commit d8ff39957275afc7a870487631cd3b3be5eb8818 Author: Rasmus Johansson <razze@iki.fi> Date: Mon May 4 10:10:07 2020 +0000 MDEV-22273 jUnit patch: xml test result differs from MTR output in case if retry /root/ColumnStore/buildColumnstoreFromGithubSource/server/engine commit 4c275557633edb60905faa500990d55a6834951d Merge: aa054a9 47f2933 Author: David.Hall <david.hall@mariadb.com> Date: Tue May 5 12:34:03 2020 -0500 Merge pull request #1179 from pleblanc1976/update-libs3-ref Updated the s3 lib. 1.5.0-1 /root/ColumnStore/buildColumnstoreFromGithubSource/server commit 43b7e5d29a5480214cee8317a4625b749ccffbaf Author: Rasmus Johansson <razze@iki.fi> Date: Mon May 4 10:10:07 2020 +0000 MDEV-22273 jUnit patch: xml test result differs from MTR output in case if retry /root/ColumnStore/buildColumnstoreFromGithubSource/server/engine commit 368c4fac059d5cf4f1596e56ea7b1e729e29ec49 Merge: 15a9efa 4bc408c Author: David.Hall <david.hall@mariadb.com> Date: Tue May 5 12:35:14 2020 -0500 Merge pull request #1178 from pleblanc1976/update-libs3-ref-1.5 Updated s3 lib ref Reproduced the issue in 1.2.5-1 MariaDB [mytest] > select count(null) over () from orders where o_orderdate > '1997-05-17' - interval 1 hour; ERROR 1815 (HY000): Internal error: InetStreamSocket::readToMagic: Remote is closed MariaDB [mytest] > select count(null) over () from orders where o_orderdate > '1998-08-02' - interval 1 hour; --------------------- count(null) over () --------------------- 0 . . . 0 0 --------------------- 581 rows in set (0.070 sec) MariaDB [mytest] > select count from orders where o_orderdate = '1998-08-02'; ---------- count ---------- 581 ---------- 1 row in set (0.057 sec)

          People

            dleeyh Daniel Lee (Inactive)
            patricksafarov Patrick Safarov
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.