Details

    Description

      Reported initially on Node.js connector

      When using COALESCE on BIT fields, results type and value are wrong.

      • Using COALESCE on 2 bit field will be of type BIT, but value will be string encoded, so value 0x01 will be returned as 0x31 (=ascii '1')
      • Using COALESCE on 1 bit field and null will be of type NEWDECIMAL, with text value as well

      Here is how to reproduced :

      CREATE TABLE coalesce_test ( bit_a BIT);
      INSERT INTO coalesce_test (bit_a) VALUES (1);
      SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
      

      Result will be :

      MariaDB [testn]> SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
      Field   1:  `bit_a`
      Org_field:  `bit_a`
      Catalog:    `def`
      Database:   `testn`
      Table:      `coalesce_test`
      Org_table:  `coalesce_test`
      Type:       BIT
      Collation:  binary (63)
      Length:     1
      Max_length: 1
      Decimals:   0
      Flags:      UNSIGNED
       
      Field   2:  `bit_b`
      Org_field:  ``
      Catalog:    `def`
      Database:   ``
      Table:      ``
      Org_table:  ``
      Type:       BIT
      Collation:  binary (63)
      Length:     1
      Max_length: 1
      Decimals:   0
      Flags:      UNSIGNED BINARY
       
      Field   3:  `bit_c`
      Org_field:  ``
      Catalog:    `def`
      Database:   ``
      Table:      ``
      Org_table:  ``
      Type:       NEWDECIMAL
      Collation:  binary (63)
      Length:     2
      Max_length: 1
      Decimals:   0
      Flags:      BINARY NUM
       
       
      +-------+-------+-------+
      | bit_a | bit_b | bit_c |
      +-------+-------+-------+
      |      | 1     |     1 |
      +-------+-------+-------+
      1 row in set (0.000 sec)
      

      expected result would have been 0x01 for bit_b and bit_c. Data type for bit_c is expected to be of BIT type

      Attachments

        Issue Links

          Activity

            diego dupin Diego Dupin created issue -
            diego dupin Diego Dupin made changes -
            Field Original Value New Value
            Description When using COALESCE on BIT fields, results type and value are wrong.

            * Using COALESCE on 2 bit field will be of type BIT, but value will be string encoded, so value 0x01 will be returned as 0x31 (=ascii '1')
            * Using COALESCE on 1 bit field and null will be of type NEWDECIMAL, with text value as well


            Here is how to reproduced :

            {code:sql}
            CREATE TABLE coalesce_test ( bit_a BIT);
            INSERT INTO coalesce_test (bit_a) VALUES (1);
            SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            {code}

            Result will be :

            {code:java}
            MariaDB [testn]> SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            Field 1: `bit_a`
            Org_field: `bit_a`
            Catalog: `def`
            Database: `testn`
            Table: `coalesce_test`
            Org_table: `coalesce_test`
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED

            Field 2: `bit_b`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED BINARY

            Field 3: `bit_c`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: NEWDECIMAL
            Collation: binary (63)
            Length: 2
            Max_length: 1
            Decimals: 0
            Flags: BINARY NUM


            +-------+-------+-------+
            | bit_a | bit_b | bit_c |
            +-------+-------+-------+
            |  | 1 | 1 |
            +-------+-------+-------+
            1 row in set (0.000 sec)
            {code}

            When using COALESCE on BIT fields, results type and value are wrong.

            * Using COALESCE on 2 bit field will be of type BIT, but value will be string encoded, so value 0x01 will be returned as 0x31 (=ascii '1')
            * Using COALESCE on 1 bit field and null will be of type NEWDECIMAL, with text value as well


            Here is how to reproduced :

            {code:sql}
            CREATE TABLE coalesce_test ( bit_a BIT);
            INSERT INTO coalesce_test (bit_a) VALUES (1);
            SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            {code}

            Result will be :

            {code:java}
            MariaDB [testn]> SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            Field 1: `bit_a`
            Org_field: `bit_a`
            Catalog: `def`
            Database: `testn`
            Table: `coalesce_test`
            Org_table: `coalesce_test`
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED

            Field 2: `bit_b`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED BINARY

            Field 3: `bit_c`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: NEWDECIMAL
            Collation: binary (63)
            Length: 2
            Max_length: 1
            Decimals: 0
            Flags: BINARY NUM


            +-------+-------+-------+
            | bit_a | bit_b | bit_c |
            +-------+-------+-------+
            |  | 1 | 1 |
            +-------+-------+-------+
            1 row in set (0.000 sec)
            {code}

            expected result would have been 0x01 for bit_b and bit_c. Data type for bit_c is expected to be of BIT type
            diego dupin Diego Dupin made changes -
            diego dupin Diego Dupin made changes -
            Description When using COALESCE on BIT fields, results type and value are wrong.

            * Using COALESCE on 2 bit field will be of type BIT, but value will be string encoded, so value 0x01 will be returned as 0x31 (=ascii '1')
            * Using COALESCE on 1 bit field and null will be of type NEWDECIMAL, with text value as well


            Here is how to reproduced :

            {code:sql}
            CREATE TABLE coalesce_test ( bit_a BIT);
            INSERT INTO coalesce_test (bit_a) VALUES (1);
            SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            {code}

            Result will be :

            {code:java}
            MariaDB [testn]> SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            Field 1: `bit_a`
            Org_field: `bit_a`
            Catalog: `def`
            Database: `testn`
            Table: `coalesce_test`
            Org_table: `coalesce_test`
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED

            Field 2: `bit_b`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED BINARY

            Field 3: `bit_c`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: NEWDECIMAL
            Collation: binary (63)
            Length: 2
            Max_length: 1
            Decimals: 0
            Flags: BINARY NUM


            +-------+-------+-------+
            | bit_a | bit_b | bit_c |
            +-------+-------+-------+
            |  | 1 | 1 |
            +-------+-------+-------+
            1 row in set (0.000 sec)
            {code}

            expected result would have been 0x01 for bit_b and bit_c. Data type for bit_c is expected to be of BIT type
            report initially [here |https://github.com/mariadb-corporation/mariadb-connector-nodejs/issues/251]

            When using COALESCE on BIT fields, results type and value are wrong.

            * Using COALESCE on 2 bit field will be of type BIT, but value will be string encoded, so value 0x01 will be returned as 0x31 (=ascii '1')
            * Using COALESCE on 1 bit field and null will be of type NEWDECIMAL, with text value as well


            Here is how to reproduced :

            {code:sql}
            CREATE TABLE coalesce_test ( bit_a BIT);
            INSERT INTO coalesce_test (bit_a) VALUES (1);
            SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            {code}

            Result will be :

            {code:java}
            MariaDB [testn]> SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            Field 1: `bit_a`
            Org_field: `bit_a`
            Catalog: `def`
            Database: `testn`
            Table: `coalesce_test`
            Org_table: `coalesce_test`
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED

            Field 2: `bit_b`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED BINARY

            Field 3: `bit_c`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: NEWDECIMAL
            Collation: binary (63)
            Length: 2
            Max_length: 1
            Decimals: 0
            Flags: BINARY NUM


            +-------+-------+-------+
            | bit_a | bit_b | bit_c |
            +-------+-------+-------+
            |  | 1 | 1 |
            +-------+-------+-------+
            1 row in set (0.000 sec)
            {code}

            expected result would have been 0x01 for bit_b and bit_c. Data type for bit_c is expected to be of BIT type
            diego dupin Diego Dupin made changes -
            Description report initially [here |https://github.com/mariadb-corporation/mariadb-connector-nodejs/issues/251]

            When using COALESCE on BIT fields, results type and value are wrong.

            * Using COALESCE on 2 bit field will be of type BIT, but value will be string encoded, so value 0x01 will be returned as 0x31 (=ascii '1')
            * Using COALESCE on 1 bit field and null will be of type NEWDECIMAL, with text value as well


            Here is how to reproduced :

            {code:sql}
            CREATE TABLE coalesce_test ( bit_a BIT);
            INSERT INTO coalesce_test (bit_a) VALUES (1);
            SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            {code}

            Result will be :

            {code:java}
            MariaDB [testn]> SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            Field 1: `bit_a`
            Org_field: `bit_a`
            Catalog: `def`
            Database: `testn`
            Table: `coalesce_test`
            Org_table: `coalesce_test`
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED

            Field 2: `bit_b`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED BINARY

            Field 3: `bit_c`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: NEWDECIMAL
            Collation: binary (63)
            Length: 2
            Max_length: 1
            Decimals: 0
            Flags: BINARY NUM


            +-------+-------+-------+
            | bit_a | bit_b | bit_c |
            +-------+-------+-------+
            |  | 1 | 1 |
            +-------+-------+-------+
            1 row in set (0.000 sec)
            {code}

            expected result would have been 0x01 for bit_b and bit_c. Data type for bit_c is expected to be of BIT type
            Reported initially on [Node.js connector |https://github.com/mariadb-corporation/mariadb-connector-nodejs/issues/251]

            When using COALESCE on BIT fields, results type and value are wrong.

            * Using COALESCE on 2 bit field will be of type BIT, but value will be string encoded, so value 0x01 will be returned as 0x31 (=ascii '1')
            * Using COALESCE on 1 bit field and null will be of type NEWDECIMAL, with text value as well


            Here is how to reproduced :

            {code:sql}
            CREATE TABLE coalesce_test ( bit_a BIT);
            INSERT INTO coalesce_test (bit_a) VALUES (1);
            SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            {code}

            Result will be :

            {code:java}
            MariaDB [testn]> SELECT bit_a, COALESCE(bit_a, bit_a) AS bit_b, COALESCE(bit_a, null) AS bit_c FROM coalesce_test;
            Field 1: `bit_a`
            Org_field: `bit_a`
            Catalog: `def`
            Database: `testn`
            Table: `coalesce_test`
            Org_table: `coalesce_test`
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED

            Field 2: `bit_b`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: BIT
            Collation: binary (63)
            Length: 1
            Max_length: 1
            Decimals: 0
            Flags: UNSIGNED BINARY

            Field 3: `bit_c`
            Org_field: ``
            Catalog: `def`
            Database: ``
            Table: ``
            Org_table: ``
            Type: NEWDECIMAL
            Collation: binary (63)
            Length: 2
            Max_length: 1
            Decimals: 0
            Flags: BINARY NUM


            +-------+-------+-------+
            | bit_a | bit_b | bit_c |
            +-------+-------+-------+
            |  | 1 | 1 |
            +-------+-------+-------+
            1 row in set (0.000 sec)
            {code}

            expected result would have been 0x01 for bit_b and bit_c. Data type for bit_c is expected to be of BIT type
            alice Alice Sherepa made changes -
            alice Alice Sherepa made changes -
            Affects Version/s 10.4 [ 22408 ]
            Affects Version/s 10.5 [ 23123 ]
            Affects Version/s 10.6 [ 24028 ]
            Affects Version/s 10.9 [ 26905 ]
            Affects Version/s 10.10 [ 27530 ]
            Affects Version/s 10.11 [ 27614 ]
            alice Alice Sherepa made changes -
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.9 [ 26905 ]
            Fix Version/s 10.10 [ 27530 ]
            Fix Version/s 10.11 [ 27614 ]
            alice Alice Sherepa made changes -
            Assignee Alexander Barkov [ bar ]
            alice Alice Sherepa made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            bar Alexander Barkov made changes -
            Status Confirmed [ 10101 ] In Progress [ 3 ]
            bar Alexander Barkov made changes -
            Component/s Data types [ 13906 ]
            Fix Version/s 10.4.32 [ 29300 ]
            Fix Version/s 10.5.23 [ 29012 ]
            Fix Version/s 10.6.16 [ 29014 ]
            Fix Version/s 10.10.7 [ 29018 ]
            Fix Version/s 10.11.6 [ 29020 ]
            Fix Version/s 11.0.4 [ 29021 ]
            Fix Version/s 11.1.3 [ 29023 ]
            Fix Version/s 11.2.2 [ 29035 ]
            Fix Version/s 11.3.1 [ 29416 ]
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.9 [ 26905 ]
            Fix Version/s 10.10 [ 27530 ]
            Fix Version/s 10.11 [ 27614 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]

            People

              bar Alexander Barkov
              diego dupin Diego Dupin
              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.