Bug #37301 Length and Max_length differ with no obvious reason

Submitted: 10 Jun 2008 8:10 Modified: 3 Dec 2008 19:52
Reporter: Tonci Grgin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S2 (Serious)
Version:5.0.56entSP1, 5.0.64pb, 5.1.26rc-pb OS:Windows (XP SP2)
Assigned to: Sergei Glukhov CPU Architecture:Any

[10 Jun 2008 8:10] Tonci Grgin
Description:
Length and Max_length differ with no obvious reason for "SHOW CREATE TABLE..." This occur somewhere after 5.0.44, all later versions affected.

How to repeat:
CREATE TABLE `new_bug` (
 `Codigo` int(10) unsigned NOT NULL auto_increment,
 `Nombre` varchar(255) default NULL,
 `Telefono` varchar(255) default NULL,
 `Observaciones` longtext,
 `Direccion` varchar(255) default NULL,
 `Dni` varchar(255) default NULL,
 `CP` int(11) default NULL,
 `Provincia` varchar(255) default NULL,
 `Poblacion` varchar(255) default NULL,
 PRIMARY KEY  (`Codigo`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

mysql> show create table a;
Field   1:  `Table`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  cp1251_general_ci (51)
Length:     21
Max_length: 1
Decimals:   31
Flags:      NOT_NULL

Field   2:  `Create Table`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  cp1251_general_ci (51)
Length:     341  <<<
Max_length: 445  <<<
Decimals:   31
Flags:      NOT_NULL 

Suggested fix:
This has been spotted working on Bug#24131. Thanks to Lawrin & JimW for following up.
[19 Jun 2008 9:49] 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/48153

2640 Sergey Glukhov	2008-06-19
      Bug#37301 Length and Max_length differ with no obvious reason
      Length value is the length of the field,
      Max_length is the length of the field value.
      So Max_length can not be more than Length.
      The fix: fixed calculation of the Item_empty_string item length
[19 Jun 2008 10:45] Alexey Botchkov
I'd recommend not to do the assignement in the constructor call. Seems a bit risky. Use collation.collation member instead.
[19 Jun 2008 10:59] 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/48161

2640 Sergey Glukhov	2008-06-19
      Bug#37301 Length and Max_length differ with no obvious reason(2nd version)
      Length value is the length of the field,
      Max_length is the length of the field value.
      So Max_length can not be more than Length.
      The fix: fixed calculation of the Item_empty_string item length
[15 Aug 2008 20:13] 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/51781

2665 Chad MILLER	2008-08-15
      Bug#37301 Length and Max_length differ with no obvious reason(2nd version)
      Length value is the length of the field,
      Max_length is the length of the field value.
      So Max_length can not be more than Length.
      The fix: fixed calculation of the Item_empty_string item length
      
      (Patch applied and queued on demand of Trudy/Davi.)
[15 Aug 2008 21:34] 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/51786

2665 Chad MILLER	2008-08-15
      Bug#37301 Length and Max_length differ with no obvious reason(2nd version)
      Length value is the length of the field,
      Max_length is the length of the field value.
      So Max_length can not be more than Length.
      The fix: fixed calculation of the Item_empty_string item length
      
      (Patch applied and queued on demand of Trudy/Davi.)
[15 Aug 2008 21:35] Chad MILLER
Queued to 5.0-bugteam, 5.1-bugteam, and 6.0-bugteam on demand of Trudy/Davi.
[20 Aug 2008 8:24] 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/52016

2713 Sergey Glukhov	2008-08-20
      after merge fix, related to bug#37301 changes
[20 Aug 2008 8:32] 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/52017

2713 Sergey Glukhov	2008-08-20
      after merge fix, related to bug#37301 changes
[21 Aug 2008 18:04] Bugs System
Pushed into 5.1.28  (revid:gluh@mysql.com-20080820081542-i187hhlx4oxxnan2) (version source revid:gluh@mysql.com-20080820081542-i187hhlx4oxxnan2) (pib:3)
[21 Aug 2008 19:28] Paul DuBois
Noted in 5.1.28 changelog.

The max_length result set metadata value was calculated incorrectly 
under some circumstances.

Setting report to Patch Queued pending push of fix to 5.0.x/6.0.x.
[14 Sep 2008 2:48] Bugs System
Pushed into 6.0.7-alpha  (revid:gluh@mysql.com-20080820081542-i187hhlx4oxxnan2) (version source revid:sven@mysql.com-20080818175803-c1nutd5773r6b4gd) (pib:3)
[15 Sep 2008 18:37] Paul DuBois
Noted in 6.0.7 changelog.

Setting report to NDI pending push into 5.0.x.
[3 Dec 2008 19:52] Paul DuBois
Noted in 5.0.70 changelog.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.