Bug #48526 Data type for float and double is incorrectly reported in InnoDB table monitor
Submitted: 4 Nov 10:13 Modified: 2 Dec 9:04
Reporter: Oli Sennhauser
Status: Documenting
Category:Server: InnoDB Severity:S3 (Non-critical)
Version:5.1.40 OS:Any
Assigned to: Satya B Target Version:
Tags: FLOAT, double, innodb_table_monitor
Triage: Triaged: D3 (Medium)

[4 Nov 10:13] Oli Sennhauser
Description:
Having a table with float and double the data types are incorrectly reported in innodb
table monitor.

How to repeat:
CREATE TABLE buggy (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
, f1 INT
, f2 FLOAT
, f3 DOUBLE
, f4 INT
) ENGINE=InnoDB;

enable InnoDB Monitor:

TABLE: name test/buggy, id 0 146, columns 8, indexes 1, appr.rows 0
  COLUMNS:
id: DATA_INT DATA_UNSIGNED DATA_BINARY_TYPE DATA_NOT_NULL len 4;
f1: DATA_INT DATA_BINARY_TYPE len 4;
f2: type 9 DATA_BINARY_TYPE len 4;
f3: type 10 DATA_BINARY_TYPE len 8;
f4: DATA_INT DATA_BINARY_TYPE len 4;
DB_ROW_ID: DATA_SYS prtype 256 len 6;
DB_TRX_ID: DATA_SYS prtype 257 len 6;
DB_ROLL_PTR: DATA_SYS prtype 258 len 7;                      
  INDEX: name PRIMARY, id 0 281, fields 1/7, uniq 1, type 3
   root page 220, appr.key vals 0, leaf pages 1, size pages 1
   FIELDS:  id DB_TRX_ID DB_ROLL_PTR f1 f2 f3 f4

Suggested fix:
Types should be reported correctly as:

#define DATA_FLOAT      9
#define DATA_DOUBLE     10
[9 Nov 8:12] Jimmy Yang
This is due to in function dtype_print(), we have not process the float and double
datatype:

dtype_print() 
{
 switch (mtype) {
        case DATA_VARCHAR:
             fputs("DATA_VARCHAR", stderr);
             break;
 ......
        default:  <==== Double and float get here, thus we have type 9, type 10
             fprintf(stderr, "type %lu", (ulong) mtype);
             break;
}

Fix by adding following type to dtype_print()

#define DATA_FLOAT      9
#define DATA_DOUBLE     10
#define DATA_DECIMAL    11      /* decimal number stored as an ASCII string */
#define DATA_VARMYSQL   12      /* any charset varying length char */
#define DATA_MYSQL      13      /* any charset fixed length char */
                                /* NOTE that 4.1.1 used DATA_MYSQL and
                                DATA_VARMYSQL for all character sets, and the
                                charset-collation for tables created with it
                                can also be latin1_swedish_ci */

Thanks
Jimmy
[9 Nov 8:29] Jimmy Yang
Output after the fix:

Notice column f2 and f3 are of DATA_FLOAT and DATA_DOUBLE now.
--------------------------------------
TABLE: name test/buggy, id 0 13, columns 8, indexes 1, appr.rows 0
  COLUMNS: id: DATA_INT DATA_UNSIGNED DATA_BINARY_TYPE DATA_NOT_NULL len 4; f1: DATA_INT
DATA_BINARY_TYPE len 4; f2: DATA_FLOAT DATA_BINARY_TYPE len 4; f3: DATA_DOUBLE
DATA_BINARY_TYPE len 8; f4: DATA_INT DATA_BINARY_TYPE len 4; DB_ROW_ID: DATA_SYS prtype
256 len 6; DB_TRX_ID: DATA_SYS prtype 257 len 6; DB_ROLL_PTR: DATA_SYS prtype 258 len 7;
  INDEX: name PRIMARY, id 0 15, fields 1/7, uniq 1, type 3
   root page 50, appr.key vals 0, leaf pages 1, size pages 1
   FIELDS:  id DB_TRX_ID DB_ROLL_PTR f1 f2 f3 f4
[30 Nov 9:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/92029

3215 Satya B	2009-11-30
      Applying InnoDB snapshot 5.1-ss6242, part 4. Fixes BUG#48526
      
      1. BUG#48526 - Data type for float and double is incorrectly 
                     reported in InnoDB table monitor
      
      Detailed revision comments:
      
      r6188 | jyang | 2009-11-18 07:14:23 +0200 (Wed, 18 Nov 2009) | 8 lines
      branches/5.1: Fix bug #48526 "Data type for float and
      double is incorrectly reported in InnoDB table monitor".
      Certain datatypes are not printed correctly in
      dtype_print().
      
      rb://204 Approved by Marko.
[30 Nov 14:35] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/92090

3229 Satya B	2009-11-30
      Applying InnoDB Plugin 1.0.6 snapshot, part 9. Fixes BUG#48526, BUG#48317
      
      applied revisions: r6197, r6198, r6199
      r6197 - BUG#48317
      r6199 - BUG#48526
      
      Detailed revision comments:
      
      r6197 | calvin | 2009-11-19 09:32:55 +0200 (Thu, 19 Nov 2009) | 6 lines
      branches/zip: merge the fix of bug#48317 (CMake file)
      
      Due to MySQL changes to the CMake, it is no longer able
      to build InnoDB plugin as a static library on Windows.
      The fix is proposed by Vlad of MySQL.
      
      r6198 | vasil | 2009-11-19 09:44:31 +0200 (Thu, 19 Nov 2009) | 4 lines
      branches/zip:
      
      Add ChangeLog entry for r6197.
      
      r6199 | vasil | 2009-11-19 12:10:12 +0200 (Thu, 19 Nov 2009) | 31 lines
      branches/zip: Merge r6159:6198 from branches/5.1:
      
        ------------------------------------------------------------------------
        r6187 | jyang | 2009-11-18 05:27:30 +0200 (Wed, 18 Nov 2009) | 9 lines
        Changed paths:
           M /branches/5.1/btr/btr0btr.c
        
        branches/5.1: Fix bug #48469 "when innodb tablespace is
        configured too small, crash and corruption!". Function
        btr_create() did not check the return status of fseg_create(),
        and continue the index creation even there is no sufficient
        space.
        
        rb://205 Approved by Marko
        
        
        ------------------------------------------------------------------------
        r6188 | jyang | 2009-11-18 07:14:23 +0200 (Wed, 18 Nov 2009) | 8 lines
        Changed paths:
           M /branches/5.1/data/data0type.c
        
        branches/5.1: Fix bug #48526 "Data type for float and
        double is incorrectly reported in InnoDB table monitor".
        Certain datatypes are not printed correctly in
        dtype_print().
        
        rb://204 Approved by Marko.
        
        
        ------------------------------------------------------------------------
[1 Dec 10:13] Satya B
patch queued to 5.1-bugteam storage/innobase and for the plugin storage/innodb_
plugin.

NULL merged to 6.0 and will be merged to 5.5.*
[2 Dec 9:04] Bugs System
Pushed into 5.1.42 (revid:joro@sun.com-20091202080033-mndu4sxwx19lz2zs) (version source
revid:satya.bn@sun.com-20091130133520-z0m04c2d63wl83bj) (merge vers: 5.1.42) (pib:13)