Bug #57103 �(65533) symbols
Submitted: 29 Sep 2010 15:14 Modified: 3 Sep 2021 8:28
Reporter: ruslan shv Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.13 OS:Linux
Assigned to: Alexander Soklakov CPU Architecture:Any
Tags: 65533

[29 Sep 2010 15:14] ruslan shv
Description:
i connect to mysql with connectionString=jdbc:mysql://host/db?user=user&password=password&characterEncoding=utf8&useOldAliasMetadataBehavior=true
execute simple query 

SELECT ifnull(SUM(CASE a WHEN 2 THEN 2 ELSE null END),'текст') FROM table1 GROUP BY b;

and see ���������� symbols

How to repeat:
create table table1(`a`bigint(20), `b`bigint(20));
insert into table1 values (1,1);
SELECT ifnull(SUM(CASE a WHEN 2 THEN 2 ELSE null END),'текст') FROM table1 GROUP BY b;
[29 Sep 2010 16:36] Peter Laursen
I think the client you use added those as a 'placeholder' because the font used does not have all glyphs.

Peter
(not a MySQL person)
[29 Sep 2010 18:01] Valeriy Kravchuk
Please, send the results of

echo $LANG

from OS command line and

show session variables like 'char%';

from mysql command line.

I think the result may depend on the settings above or font used, as Peter noted. 

Look:

macbook-pro:5.5 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.5.7-rc-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create table table1(`a`bigint(20), `b`bigint(20));
Query OK, 0 rows affected (0.06 sec)

mysql> insert into table1 values (1,1);
Query OK, 1 row affected (0.00 sec)

mysql> SELECT ifnull(SUM(CASE a WHEN 2 THEN 2 ELSE null END),'текст')
    -> FROM table1 GROUP BY b;
+--------------------------------------------------------------+
| ifnull(SUM(CASE a WHEN 2 THEN 2 ELSE null END),'текст')      |
+--------------------------------------------------------------+
| текст                                                        |
+--------------------------------------------------------------+
1 row in set (0.07 sec)

mysql> show variables like 'char%';
+--------------------------+---------------------------------------------+
| Variable_name            | Value                                       |
+--------------------------+---------------------------------------------+
| character_set_client     | utf8                                        |
| character_set_connection | utf8                                        |
| character_set_database   | latin1                                      |
| character_set_filesystem | binary                                      |
| character_set_results    | utf8                                        |
| character_set_server     | latin1                                      |
| character_set_system     | utf8                                        |
| character_sets_dir       | /Users/openxs/dbs/5.5/share/mysql/charsets/ |
+--------------------------+---------------------------------------------+
8 rows in set (0.00 sec)

mysql> exit
Bye
macbook-pro:5.5 openxs$ echo $LANG
uk_UA.UTF-8
[30 Sep 2010 4:58] ruslan shv
echo $LANG                                                                                                                                                      [8:52]
en_US.utf8

[08:51:27] localhost:(none)> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

if i run this query in command line mysql client i have correct result 
+--------------------------------------------------------------+
| ifnull(SUM(CASE a WHEN 2 THEN 2 ELSE null END),'текст')      |
+--------------------------------------------------------------+
| текст                                                        |
+--------------------------------------------------------------+

bug occurs when i run this query in my Java application.
but if i run something like this 

SELECT ifnull(null,'текст') FROM table1;

i have everywhere correct
+---------------------------+
| ifnull(null,'текст')      |
+---------------------------+
| текст                     |
+---------------------------+
[30 Sep 2010 6:11] Valeriy Kravchuk
What Connector/J version and JDBC URL/configuration properties do you use?
[30 Sep 2010 6:27] ruslan shv
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbcp.PoolingDataSource;
import org.apache.commons.pool.impl.GenericObjectPool;

String connectionString="jdbc:mysql://host/db?user=user&password=password&characterEncoding=utf8&useOldAliasMetadataBehavior=true";
GenericObjectPool connectionPool = new GenericObjectPool(null);
PoolingDataSource ds = new PoolingDataSource (connectionString, connectionPool);
QueryRunner queryRunner = new QueryRunner(ds);

queryRunner.query(query, mapListHandler);
[30 Sep 2010 9:10] Valeriy Kravchuk
What about the exact Connector/J version used?
[30 Sep 2010 10:03] ruslan shv
Connector/J 5.1.10
[30 Sep 2010 10:56] Sveta Smirnova
Thank you for the feedback.

Verified as described.

Test case for c/J test suite:

import testsuite.BaseTestCase;
import java.sql.*;

public class bug57103 extends BaseTestCase {
	
	public bug57103(String name) {
		super(name);
	}

	public static void main(String[] args) {
		junit.textui.TestRunner.run(bug57103.class);
	}

	public void testbug57103() throws Exception {
		try {
			this.stmt.executeUpdate("drop table if exists table1");
			this.stmt.executeUpdate("create table table1(`a`bigint(20), `b`bigint(20))");
			this.stmt.executeUpdate("insert into table1 values (1,1)");
			
			this.rs = this.stmt.executeQuery("SELECT ifnull(SUM(CASE a WHEN 2 THEN 2 ELSE null END),'текст') FROM table1 GROUP BY b");
			while (this.rs.next()) {
				assertTrue("Values are not equals", this.rs.getString(1).contentEquals("текст"));
			}

		} finally {
	    	closeMemberJDBCResources();
		}
	}
	
}
[3 Sep 2021 8:28] Alexander Soklakov
Posted by developer:
 
This bug is not reproducible with the latest Connector/J 8.0.

Connector/J 5.1 series came to EOL on Feb 9th, 2021, see https://www.mysql.com/support/eol-notice.html, so this bug will not be fixed there.