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

CONNECT: no error on conversion 0 -> NULL with strict mode

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a Bug
    • Affects Version/s: 10.0.6
    • Fix Version/s: 10.0.5, 10.0.6, 10.0.7, 10.0.8
    • Component/s: None
    • Labels:
      None

      Description

      I don't know if this is really a bug, but this behavior is different from the one we rely on, with this SQL_MODE:

      MariaDB [test]> SELECT @@session.SQL_MODE;
      +-------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | @@session.SQL_MODE                                                                                                                                          |
      +-------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
      +-------------------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.00 sec)
      
      MariaDB [test]> CREATE TABLE t (c INT NULL DEFAULT 0) ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='t.dos';
      Query OK, 0 rows affected (0.09 sec)
      
      MariaDB [test]> INSERT INTO t VALUES (0), (DEFAULT);
      Query OK, 2 rows affected (0.00 sec)
      Records: 2  Duplicates: 0  Warnings: 0
      
      MariaDB [test]> SELECT * FROM t;
      +------+
      | c    |
      +------+
      | NULL |
      | NULL |
      +------+
      2 rows in set (0.00 sec)
      

      Both the DEFAULT 0 clause and the explicit 0 INSERT specify a value that is not supported for this data format. The strict mode is meant to prevent silent data changes. But even without strict mode, maybe a warnings is expected?

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            bertrandop Olivier Bertrand added a comment -

            Indeed CONNECT handles NULL's in a specific way.
            See the CONNECT documentation "NULL handling" chapter page 10.
            Note: I am not sure this was added to the online documentation. You can contact me at:
            bertrandop@gmail.com
            to get the latest documentation in doc or pdf format.

            Show
            bertrandop Olivier Bertrand added a comment - Indeed CONNECT handles NULL's in a specific way. See the CONNECT documentation "NULL handling" chapter page 10. Note: I am not sure this was added to the online documentation. You can contact me at: bertrandop@gmail.com to get the latest documentation in doc or pdf format.
            Hide
            f_razzoli Federico Razzoli added a comment -

            I understand that some text files can't contain NULLs. And this may be a personal opinion.

            When @@sql_mode='STRICT_ALL_TABLES' and I try to insert a 0 in a NULL-able column, I expect an error, and if @@sql_mode='' I expect a warning (it happens with other engines). This seems to me useful, because if I try to explicitly insert a 0, or I specify a DEFAULT 0, it is probably a mistake.

            Show
            f_razzoli Federico Razzoli added a comment - I understand that some text files can't contain NULLs. And this may be a personal opinion. When @@sql_mode='STRICT_ALL_TABLES' and I try to insert a 0 in a NULL-able column, I expect an error, and if @@sql_mode='' I expect a warning (it happens with other engines). This seems to me useful, because if I try to explicitly insert a 0, or I specify a DEFAULT 0, it is probably a mistake.
            Hide
            bertrandop Olivier Bertrand added a comment -

            It is not a mistake but just the fact that CONNECT does not handle nulls like other engines (at least for file based tables)

            Show
            bertrandop Olivier Bertrand added a comment - It is not a mistake but just the fact that CONNECT does not handle nulls like other engines (at least for file based tables)

              People

              • Assignee:
                bertrandop Olivier Bertrand
                Reporter:
                f_razzoli Federico Razzoli
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: