[MDEV-17501] Connect-Storage engine: character set failure Created: 2018-10-19 Updated: 2018-12-08 Resolved: 2018-12-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Connect |
| Affects Version/s: | 10.3.6, 10.3.7, 10.3.8, 10.3.9 |
| Fix Version/s: | 10.3.12 |
| Type: | Bug | Priority: | Major |
| Reporter: | Karsten Budde | Assignee: | Olivier Bertrand |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Environment: |
CentOS7, Oracle 11g, Character Set Oracle WE8ISO8859P1, Character Set MariaDB utf8mb4 |
||
| Description |
|
Hello, in MariaDB 10.2.11 I create a connect-table from mariadb to orcacle with the following statement:
In oracle the character set is WE8ISO8859P1 and in mariadb utf8mb4. Then we update mariadb to 10.3.6. Now the characters as 'ä' or 'Ü' are shown wrong in the connect-table: 'ä' -> 'a' and 'Ü' -> 'U'. Now we use mariadb 10.3.9 and the characters are still wrong. Can you help me? |
| Comments |
| Comment by Olivier Bertrand [ 2018-10-22 ] | ||||||||||||||||||||
|
Do you mean that these characters were shown correct with MariaDB 10.2 (or 1 or 0) and not with the 10.3 version? | ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-10-22 ] | ||||||||||||||||||||
|
Yes, with MariaDB 10.2 these characters were shown correct. | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-10-29 ] | ||||||||||||||||||||
|
Karsten, can you please try the following:
and paste output of the above two scripts. Thanks. | ||||||||||||||||||||
| Comment by Olivier Bertrand [ 2018-10-29 ] | ||||||||||||||||||||
|
I did that and the SELECT command replied:
| ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-10-29 ] | ||||||||||||||||||||
|
Olivier, I think your database uses UTF8 rather than latin1. You can check using this query:
The above script (namely, the INSERT queries) assumes that the Oracle database is configured to use Latin1. | ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-10-29 ] | ||||||||||||||||||||
|
Hello,
In DBeaver the client-charset is utf-8. regards, | ||||||||||||||||||||
| Comment by Olivier Bertrand [ 2018-10-29 ] | ||||||||||||||||||||
|
It replies:
What can I do to use latin1? | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-10-30 ] | ||||||||||||||||||||
|
Karsten, This can be possible if you don't have the NLS_LANG environment variable set properly on the machine running mysqld. Please make sure that NLS_LANG is set to, for example:
so mysqld sees this environment variable at start up time. Please make sure to restart mysqld after changing this variable. Note, using WE8MSWIN1252 (instead of WE8ISO8859P1) is preferrable, because MariaDB's latin1 is in fact cp1252 rather than iso-8859-1. | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-10-30 ] | ||||||||||||||||||||
|
Olivier, I'm afraid there is no a quick way to change the database character set in Oracle. There are some articles on the Internet how to do so, e.g.: | ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-10-30 ] | ||||||||||||||||||||
|
Alexander, I will contact our server administrator for checking and changing the environment variable NLS_LANG. Then I will post the output of the selects here. | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-10-30 ] | ||||||||||||||||||||
|
Karsten, thanks! We'll be waiting for your feedback. Btw, thanks for your previous feedback. I forgot to mention: In my case I have NLS_LANG set to AMERICAN_AMERICA.AL32UTF8. Oracle documentations says: | ||||||||||||||||||||
| Comment by Olivier Bertrand [ 2018-10-30 ] | ||||||||||||||||||||
|
On my machine NLS_LANG was not set.
| ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-11-07 ] | ||||||||||||||||||||
|
Alexander, our server administrator has set the following environment variables I am sorry, but the output of the select in mariadb does not change: MariaDB [(none)]> select * from test.t1;
------
------ | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-07 ] | ||||||||||||||||||||
|
It should be something like this: NLS_LANG=GERMAN_GERMANY.WE8MSWIN1252 Or some other character set known to Oracle: iso885915@euro is a Posix locale character set name, it's not an Oracle character set name. | ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-11-07 ] | ||||||||||||||||||||
|
Now, the server administrator reset NLS_LANG, but the output does not change. [budde@server ~]$ set | grep LANG Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show create table test.t1;
------
------ MariaDB [(none)]> select a, hex(a) from test.t1;
-----
----- | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-07 ] | ||||||||||||||||||||
|
Karsten, can you please try the following: In Oracle:
In MariaDB
What does it return? (please make sure to change the CONNECTION parameter according to your installation). | ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-11-07 ] | ||||||||||||||||||||
|
Alexander, here the output: | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-07 ] | ||||||||||||||||||||
|
On my Fedora box, I have about the same output, but NULL in the CLIENT_DRIVER. Can you please paste fragments of /etc/odbc.ini and /etc/odbcinst.ini, relevant to the Oracle ODBC driver and the data source? Also the output from "rpm -qa|grep odbc" would be helpful. | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-07 ] | ||||||||||||||||||||
|
Karsten, can you also please try one more thing:
and paste output of the above two scripts. Note, it's very similar to what I asked on 2018-10-29, but disables all ConnectSE/MariaDB character set conversion using VARBINARY as the data type and "binary" in both CHARSET and DATA_CHARSET. Thanks. | ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-11-08 ] | ||||||||||||||||||||
|
Alexander, here the parts from the ini-files odbc.ini: [HZO1] odbcinst.ini: [Oracle 12c ODBC driver] [MySQL] and the output from terminal: [budde@server ~]$ rpm -qa|grep odbc | ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-11-08 ] | ||||||||||||||||||||
|
output from sqlplus on windows: SQL> SELECT a, RAWTOHEX(a) FROM t1; A ┼ ã SQL> When I perfom the create statement in mariadb, then I became following output: MariaDB [test]> CREATE TABLE test.t1 ( a VARBINARY(4000) ) ENGINE=CONNECT DEFAULT CHARSET=binary CONNECTION='DSN=HZO1' TABLE_TYPE='ODBC' DATA_CHARSET=binary TABNAME='BUDDE.T1'; I don't know, what is wrong. | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-08 ] | ||||||||||||||||||||
|
Sorry, my fault. The binary keyword must be quoted in back ticks in this context:
| ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-11-08 ] | ||||||||||||||||||||
|
No Problem, here is the output: MariaDB [test]> DROP TABLE IF EXISTS t1; MariaDB [test]> CREATE TABLE t1 ( MariaDB [test]> SELECT a, HEX(a) FROM t1;
-----
----- | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-08 ] | ||||||||||||||||||||
|
What are these lines in the DSN configurations:
I could not find any proves that Oracle's ODBC driver understands these lines. | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-08 ] | ||||||||||||||||||||
|
I have installed the same ODBC driver: oracle-instantclient12.2-odbc-12.2.0.1.0-1.x86_64.
| ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-08 ] | ||||||||||||||||||||
|
After experimenting with the 12.2.0.1.0-1 driver, I found that it works exactly the same with my old driver from Oracle11-XE:
Ä -> A Karsten, please make sure again that mysqld (the MariaDB server binary) is running with NLS_LANG=GERMAN_GERMANY.WE8ISO8859P1 It can be added to /etc/environment, just add this line:
After editing this file, please logout, and login again as root. The do the following. Make sure NLS_LANG is set: Then restart MariaDB server:
| ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-08 ] | ||||||||||||||||||||
|
After restarting the server with a proper NLS_LANG value, please try again the following:
Thanks. | ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-11-08 ] | ||||||||||||||||||||
|
The server administrator set etc/environment as
There are no more entries in this file. Then he log off and on as root. Afterwards I try it in MariaDB again:
| ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-08 ] | ||||||||||||||||||||
|
It appears that a systemd service does not respect /etc/environment. 1. Open /usr/lib/systemd/system/mariadb.service in a text editor 2. Find the section "[Service]" and add the environment variable as follows: [Service] 3. Reload systemd units: systemctl daemon-reload 4. Restart MariaDB server: sudo service mariadb restart 5. Run the test SQL script again:
| ||||||||||||||||||||
| Comment by Karsten Budde [ 2018-11-09 ] | ||||||||||||||||||||
|
Alexander,
Here the output in DBeaver:
Thank you very much for your help. Karsten | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-11-09 ] | ||||||||||||||||||||
|
Karsten, you're welcome. Thank you for cooperation and fast feedback. I think this should be documented. bertrandop, can you please make sure that this is documented in the ConnectSE related manual sections? Thanks! | ||||||||||||||||||||
| Comment by Olivier Bertrand [ 2018-11-09 ] | ||||||||||||||||||||
|
All this seems very specific to Oracle and perhaps some Linux operating systems. Describing character handling with ODBC in general might require a complete book. | ||||||||||||||||||||
| Comment by Alexander Barkov [ 2018-12-08 ] | ||||||||||||||||||||
|
Documented here: |