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

Wrong field type for COALESCE with unsigned int

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.1, 10.2, 10.3
    • 10.4
    • Data types
    • None
    • Debian Jessie
      Linux mariadb 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-1 (2016-03-06) x86_64 GNU/Linux

    Description

      It seems that mariadb returns a wrong datatype when dealing with COALESCE and unsigned int/tinyint

      Here are some python tests I ran against our current mysql-5-5.31 and the newer mariadb-1.1.14

      You can see the definition of the fields is exactly the same, but the datatype returned when dealing with unsigned numbers is NEWDECIMAL(246) and not LONG(3) or LONGLONG(8)

      ============                                                                                                                                                                                   
      mysql-5.5.31                                                                                                                                                                                   
      ============                                                                                                                                                                                   
      Field                     Type                 Null  Key  Default  Extra                                                                                                                       
      i_id                      int(11) unsigned     NO    PRI  NULL     auto_increment                                                                                                              
      i_version                 tinyint(4)           NO         1                                                                                                                                    
      active                    tinyint(4) unsigned  NO         1                                                                                                                                    
                                                                                                                                                                                                     
      1-SELECT COALESCE(i_id,NULL) FROM test_table WHERE i_id = 596686
        type = 3 (LONG)
        value = 596686
      2-SELECT COALESCE(i_version,1) FROM test_table WHERE i_id = 596686
        type = 8 (LONGLONG)
        value = 0
      3-SELECT COALESCE(active, 1) FROM test_table WHERE i_id = 596686
        type = 8 (LONGLONG)
        value = 1
                                                                                                                                                                                                     
      ==============                                                                                                                                                                                 
      mariadb-1.1.14                                                                                                                                                                                 
      ==============                                                                                                                                                                                 
      Field                     Type                 Null  Key  Default  Extra                                                                                                                       
      i_id                      int(11) unsigned     NO    PRI  NULL  auto_increment                                                                                                                 
      i_version                 tinyint(4)           NO         1                                                                                                                                    
      active                    tinyint(4) unsigned  NO         1                                                                                                                                    
                                                                                                                                                                                                     
      1-SELECT COALESCE(i_id,NULL) FROM test_table WHERE i_id = 596686
        type = 246 (NEWDECIMAL)
        value = 596686
      2-SELECT COALESCE(i_version,1) FROM test_table WHERE i_id = 596686
        type = 8 (LONGLONG)
        value = 0
      3-SELECT COALESCE(active, 1) FROM test_table WHERE i_id = 596686
        type = 246 (NEWDECIMAL)
        value = 1
      

      Here's the sql to reproduce it:

      create table test_table (
        i_id int(11) unsigned not null auto_increment,
        i_version tinyint(4) not null default 1,
        active tinyint(4) unsigned not null default 1,
        primary key(i_id)
      );
      insert into test_table values ( 596686, 0,1 );
      

      Attachments

        Activity

          People

            bar Alexander Barkov
            javipolo javipolo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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