Bug #26993 String agrregrate case returns unexpected data

Submitted: 9 Mar 2007 10:51 Modified: 3 Feb 2009 1:58
Reporter: Jared S (Silver Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:5.0.5.0 OS:Windows (WinXP)
Assigned to: CPU Architecture:Any
Tags: case, Data Type, qc, return

[9 Mar 2007 10:51] Jared S
Description:
I get unexpected results when I parse a unusual SQL statement.

How to repeat:
1. Execute a reader

CMD0 = New MySql.Data.MySqlClient.MySqlCommand("SELECT CASE 1 WHEN 0 THEN '1' ELSE 0 END as Ex1", CON0)
DTR0 = CMD0.ExecuteReader

2. Look at the result

DTR0.Read()
Trace.WriteLine(DTR0.Item("Ex1"))
DTR0.Close()

3. immediate windows returns> System.Byte[]
[15 Mar 2007 10:11] Tonci Grgin
Hi Jared and thanks for your report. I have several issues with it. Lets start with easy one:
 - Trace.WriteLine(DTR0.Item("Ex1")) does not compile nor does DataReader have property by the name "Item"

Now I don't understand what this report is about:
C:\mysql507\bin>mysql -T -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.38-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SELECT CASE 1 WHEN 0 THEN '1' ELSE 0 END as Ex1;
Field   1:  `Ex1`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  binary (63)
Length:     1
Max_length: 1
Decimals:   31
Flags:      NOT_NULL BINARY

+-----+
| Ex1 |
+-----+
| 0   |
+-----+
1 row in set (0.00 sec)

mysql>

As you can see, server is returning VARBINARY type for your statement and c/NET respects that:
	MySqlDbType	VarBinary	MySql.Data.MySqlClient.MySqlDbType

+	SystemType	{Name = "Byte[]" FullName = "System.Byte[]"}	System.Type {System.RuntimeType}

So, where's the problem? In server returned metadata?

Quick test case:
            MySqlConnection conn = new MySqlConnection();
            conn.ConnectionString = "DataSource=localhost;Database=test;UserID=root;Password=;PORT=3306";
            conn.Open();

            MySqlCommand command = new MySqlCommand();
            command.CommandText = "SELECT CASE 1 WHEN 0 THEN '1' ELSE 0 END as Ex1";
            command.CommandType = CommandType.Text;
            command.Connection = (MySqlConnection)conn;
            command.CommandTimeout = 0;

            MySqlDataReader dr = command.ExecuteReader();
            dr.Read();
            dr.Close();
            MessageBox.Show("Ready");
            command.Dispose();
            conn.Close();
[15 Mar 2007 15:30] Tonci Grgin
Probably caused by Bug#10491.
[15 Mar 2007 21:37] Jared S
MySqlConnection conn = new MySqlConnection();

	conn.ConnectionString = "DataSource=localhost;Database=test;UserID=root;Password=;PORT=3306";
	conn.Open();

	MySqlCommand Command = new MySqlCommand();
	Command.CommandText = "SELECT CASE 1 WHEN 0 THEN '1' ELSE 0 END as Ex1";
	Command.CommandType = CommandType.Text;
	Command.Connection = conn;
	Command.CommandTimeout = 0;

	MySqlDataReader dr = Command.ExecuteReader();
	dr.Read();
	MessageBox.Show("Ex1:" + dr[0].ToString());
	dr.Close();
	Command.Dispose();
	conn.Close();

\\ Code above is valid C# example generated from Instant C# converter
[19 Mar 2007 14:43] Tonci Grgin
Jared, this is not a connector bug. This is, by my opinion, a duplicate of Bug#10491 which is a server bug. We'll see if connectors lead will decide to work around this problem or not.
[3 Feb 2009 1:40] Jared S
Still getting  'System.Byte[]' instead of utf8 text.  Duplicate bug was pushed to 5.1.21 and I tested against 5.2.30.
[3 Feb 2009 1:58] Jared S
[CS] dr.GetString(0)     | Succeeds
[VB] dr.GetString(0)     | Succeeds
[VB] dr.Item(0).ToString | Fails

Looks likes some sort of IEnumerate flaw NET.  Although C# doesn't expose 'Item' property so it is hard to log a bug.

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

Page generated in 0.060 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.