Bug #23749 | VarChar field size over 255 causes a System.OverflowException | ||
---|---|---|---|
Submitted: | 29 Oct 2006 12:28 | Modified: | 6 Nov 2006 17:46 |
Reporter: | simon bosanquet | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S1 (Critical) |
Version: | 1.0.8 RC | OS: | Windows (WinXP SP2) |
Assigned to: | Reggie Burnett | CPU Architecture: | Any |
[29 Oct 2006 12:28]
simon bosanquet
[29 Oct 2006 12:40]
simon bosanquet
The documentation states that it can have a value up to 65,532 in versions after MySQL 5.0.3. "Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions. (The maximum effective length of a VARCHAR in MySQL 5.0.3 and later is determined by the maximum row size and the character set used. The maximum column length is subject to a row size of 65,532 bytes.)"
[29 Oct 2006 13:15]
simon bosanquet
Example Project
Attachment: LARGE_VARCHAR_EXAMPLE.zip (application/x-zip-compressed, text), 21.77 KiB.
[29 Oct 2006 13:16]
simon bosanquet
SQL Example File
Attachment: LargeVarcharExample.sql (application/octet-stream, text), 1.35 KiB.
[29 Oct 2006 13:49]
simon bosanquet
I have just been looking at the 5.0.1 source and i see you have modified the ParseType function [now contained in ISSchemaProvider.cs]. This seems to be a better implementation. Resolution: ________________________________________________________________________________ Old Code: private void ParseType(string type, string sql_mode, MySqlParameter p) { string typeName, flags = String.Empty, size; int end; type = type.ToLower(CultureInfo.InvariantCulture).Trim(); int start = type.IndexOf("("); if (start != -1) end = type.IndexOf(')', start + 1); else end = start = type.IndexOf(' '); if (start == -1) start = type.Length; typeName = type.Substring(0, start); if (end != -1) flags = type.Substring(end + 1); bool unsigned = flags.IndexOf("unsigned") != -1; bool real_as_float = sql_mode.IndexOf("REAL_AS_FLOAT") != -1; p.MySqlDbType = GetTypeFromName(typeName, unsigned, real_as_float); if (end > start && p.MySqlDbType != MySqlDbType.Set) { size = type.Substring(start + 1, end - (start + 1)); string[] parts = size.Split(new char[] { ',' }); p.Size = p.Precision = Byte.Parse(parts[0]); if (parts.Length > 1) p.Scale = Byte.Parse(parts[1]); } } ________________________________________________________________________________ New Code: private void ParseType(string type, string sql_mode, MySqlParameter p) { string typeName, flags = String.Empty, size; int end; type = type.ToLower(CultureInfo.InvariantCulture).Trim(); int start = type.IndexOf("("); if (start != -1) end = type.IndexOf(')', start + 1); else end = start = type.IndexOf(' '); if (start == -1) start = type.Length; typeName = type.Substring(0, start); if (end != -1) flags = type.Substring(end + 1); bool unsigned = flags.IndexOf("unsigned") != -1; bool real_as_float = sql_mode.IndexOf("REAL_AS_FLOAT") != -1; p.MySqlDbType = GetTypeFromName(typeName, unsigned, real_as_float); if (end > start && p.MySqlDbType != MySqlDbType.Set) { size = type.Substring(start + 1, end - (start + 1)); string[] parts = size.Split(new char[] { ',' }); if (typeName == "varchar" || typeName == "char") p.Size = Int32.Parse(parts[0]); else { p.Precision = Byte.Parse(parts[0]); if (parts.Length > 1) p.Scale = Int32.Parse(parts[1]); } } }
[30 Oct 2006 15:36]
Tonci Grgin
Hi Simon and thanks for your complete bug report. Verified as described by reporter on: - MySQL server 5.0.27BK on WinXP Pro SP2 localhost - c/NET 1.0.8RC SVN - Net FW 2.0 StoredProcedure.cs, line 368 if (end > start && p.MySqlDbType != MySqlDbType.Set) { size = type.Substring(start + 1, end - (start + 1)); string[] parts = size.Split(new char[] { ',' }); p.Size = p.Precision = Byte.Parse(parts[0]); if (parts.Length > 1) p.Scale = Byte.Parse(parts[1]); }
[30 Oct 2006 16:48]
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/14574
[30 Oct 2006 16:50]
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/14575
[6 Nov 2006 14:11]
MC Brown
A note has been added to the 1.0.9 changelog.
[6 Nov 2006 17:46]
simon bosanquet
You say 1.0.9 change log. Does this mean it wont be in 1.0.8 final?
[6 Nov 2006 17:56]
Reggie Burnett
1.0.8 is an RC. 1.0.9 Final will be the very next release.