Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-720

CallableStatements with Boolean OUT parameter

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Fix
    • 2.2.5, 2.4.2
    • N/A
    • MySQL compatibility
    • None
    • MySQL 5.6 database

    Description

      We observed an inconsistent behaviour from MySQL Connector/J to MariaDB Connector/J.

      Steps to reproduce:

      1) Create a SP that always returns 0 (false)

      create procedure FalseFunc (OUT o_duplicate BIT(1)) begin set o_duplicate = 0; end
      

      2) Create a Test case that calls the stored procedure

      @Test
      public void test_sp() throws SQLException {
      Connection con = DriverManager.getConnection("jdbc:mysql://localhost/mydb", "root", null);
      CallableStatement cs = con.prepareCall("{call FalseFunc(?) }");
      cs.registerOutParameter(1, Types.BOOLEAN);
      cs.executeQuery();
       
      boolean value = cs.getBoolean(1);
       
      assertFalse(value);
       
      con.close();
      }
      

      3) Calls the test case with the mariadb-java-client-2.2.5 and mysql-connector-java-5.1.47

      4) The test case works with the MySQL JDBC Driver but fails with MariaDB JDBC Driver. It always returns true, even though it should return false.

      Attachments

        Issue Links

          Activity

            If we change the OUT parameter to TINYINT(1) it works, it does not work with BIT(1).

            raupach Björn Raupach added a comment - If we change the OUT parameter to TINYINT(1) it works, it does not work with BIT(1).

            Not sure if it helps, but if I look into BinaryRowProtocol.java and the method getInternalBoolean it checks if parseBit() != 0. I can only see parseBit returning 48 false and 49 true. Not 0. However I have no knowledge of the MySQL wire protocol. Just guessing.

            raupach Björn Raupach added a comment - Not sure if it helps, but if I look into BinaryRowProtocol.java and the method getInternalBoolean it checks if parseBit() != 0 . I can only see parseBit returning 48 false and 49 true. Not 0. However I have no knowledge of the MySQL wire protocol. Just guessing.
            diego dupin Diego Dupin added a comment - - edited

            I've created an issue server-side (MDEV-20212),
            There is an issue for BIT parameter output when using a specific "binary" protocol that MariaDB driver use.
            for your example parseBit() != 0 return false because, server return '0' ( = 0x30 = 48 ) not 0 (0x00).

            A workaround is to use TINYINT(1) as you indicate.

            Just for information:
            mysql driver and MariaDB driver doesn't behave the same way at all for stored procedure with OUT parameter.

            MariaDB connector will execute

            call other128(?,?)
            

            MySQL under the hood will do more queries :

            SHOW CREATE PROCEDURE `testj`.`other128`
            CALL other128(@com_mysql_jdbc_outparam_o_duplicate,@com_mysql_jdbc_outparam_o2) 
            SELECT @com_mysql_jdbc_outparam_o_duplicate,@com_mysql_jdbc_outparam_o2
            

            diego dupin Diego Dupin added a comment - - edited I've created an issue server-side ( MDEV-20212 ), There is an issue for BIT parameter output when using a specific "binary" protocol that MariaDB driver use. for your example parseBit() != 0 return false because, server return '0' ( = 0x30 = 48 ) not 0 (0x00). A workaround is to use TINYINT(1) as you indicate. Just for information: mysql driver and MariaDB driver doesn't behave the same way at all for stored procedure with OUT parameter. MariaDB connector will execute call other128(?,?) MySQL under the hood will do more queries : SHOW CREATE PROCEDURE `testj`.`other128` CALL other128( @com_mysql_jdbc_outparam_o_duplicate , @com_mysql_jdbc_outparam_o2 ) SELECT @com_mysql_jdbc_outparam_o_duplicate , @com_mysql_jdbc_outparam_o2
            diego dupin Diego Dupin added a comment -

            won't fix in connector, waiting for MDEV-20212

            diego dupin Diego Dupin added a comment - won't fix in connector, waiting for MDEV-20212

            People

              diego dupin Diego Dupin
              raupach Björn Raupach
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.