[CONC-315] can't connect to server when character_set_server is set to UTF16 Created: 2018-03-07  Updated: 2020-08-25  Resolved: 2018-04-18

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 2.3.3, 3.0.3
Fix Version/s: 3.0.4, 2.3.6

Type: Bug Priority: Major
Reporter: Sandhya Sriraj Assignee: Georg Richter
Resolution: Fixed Votes: 1
Labels: None
Environment:

Linux


Attachments: File mysql.cpp    

 Description   

When I am trying to connect to a MySQL server with character_set_server set to utf16, it returns error:
*Variable 'character_set_client' can't be set to the value of 'utf16'. *

I am able to connect to the server using MySQL and MariaDB(10.2.10-MariaDB) command line tools.



 Comments   
Comment by Georg Richter [ 2018-03-07 ]

Sorry, but I don't understand your issue:

Can you please explain how you connect with command line client with client_character_set utf16 ?

Comment by Sandhya Sriraj [ 2018-03-07 ]

Added character_set_server=utf16 in my.cnf file and restarted server to set character_set_server.

From command line:
>mysql -hlocalhost -uusername -p -Pport
it is connecting.

When I use sample program(MariaDB C connector) to connect to the same server it is giving error "Variable 'character_set_client' can't be set to the value of 'utf16".

Comment by Georg Richter [ 2018-03-07 ]

The mysql command line client specifies a default character set before connecting to server:

mysql -uroot -e"SELECT @@character_set_client,@@character_set_server";
+------------------------+------------------------+
| @@character_set_client | @@character_set_server |
+------------------------+------------------------+
| utf8                   | utf16                  |
+------------------------+------------------------+
 
mysql -uroot --default-character-set=utf16;
ERROR 1231 (42000): Variable 'character_set_client' can't be set to the value of 'utf16'

If no client character set was specified, the client will use the server character set. This is of course not possible for several character sets like utf16 or ucs2 and will abort the connection.

Comment by Sandhya Sriraj [ 2018-03-07 ]

I am able to connect to that server using MariaDB client(10.2.10-MariaDB) also. MariaDB 10.2 all client tools use C/C 3.0.x. Is MariaDB client also set default character set before connecting to the server?

Comment by Georg Richter [ 2018-03-07 ]

Command line client use settings from configuration file or if not specified sets the default client character set to utf8 (and in older versions to latin1).

Comment by Sandhya Sriraj [ 2018-03-07 ]

Tried adding default-character-set=utf8 to my.cnf but the issue still persists. Can you please tell me the parameters required to add in my.cnf file so that it will connect to that server programmatically.

Comment by Sandhya Sriraj [ 2018-03-13 ]

Tried with MySQL #[Connector/C 6.1.11 and I am able to connect to the MySQL server. The issue is reproducible only with MariaDB C connector.

Comment by Georg Richter [ 2018-03-13 ]

Hi Sandhya,

thanks for the update. Looks like you forgot to attach the source of your test case.

Comment by Sandhya Sriraj [ 2018-03-14 ]

mysql.cpp

Sample program attached. To reproduce this issue set character_set_server set to utf16 in my.cnf.

Comment by Sandhya Sriraj [ 2018-03-21 ]

Any update on this issue?
Please reopen this issue as it is not solved yet.

Comment by Georg Richter [ 2018-04-18 ]

Fixed in Connector/C 2.3.6 and 3.0.4

Generated at Thu Feb 08 03:04:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.