[MDEV-32816] Make "show collations" data not-nullable Created: 2023-11-15  Updated: 2023-11-24  Resolved: 2023-11-24

Status: Closed
Project: MariaDB Server
Component/s: Protocol
Affects Version/s: None
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Tuomas Hietanen Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-31608 MySQL.Data can not connect to MariaD... Closed
Problem/Incident
is caused by MDEV-27009 Add UCA-14.0.0 collations Closed

 Description   

MariaDb returns some nulls as collation info.
That crashes the .Net MySql driver and Oracle os not willing to fix their driver.

On connect, the driver tries to load collations IDs and cast them to
integers.
However collation is nullable and there are some null-collations, for
example:

+--------------------------------+----------+------+---------+----------+---------+
| Collation                      | Charset  | Id   | Default | Compiled
| Sortlen |
+--------------------------------+----------+------+---------+----------+---------+
 
| uca1400_ai_ci                  | NULL     | NULL | NULL    | Yes     
|       8 |
| uca1400_ai_cs                  | NULL     | NULL | NULL    | Yes     
|       8 |
| uca1400_as_ci                  | NULL     | NULL | NULL    | Yes     
|       8 |
| uca1400_as_cs                  | NULL     | NULL | NULL    | Yes     
|       8 |

So the driver fails to connect the database:
InvalidCast_FromDBNull: Object cannot be cast from DBNull to other
types.

Driver has the following code:

                MySqlCommand mySqlCommand = new MySqlCommand("SHOW COLLATION",
connection);
                try
                {
                        using MySqlDataReader mySqlDataReader =
mySqlCommand.ExecuteReader();
                        CharacterSets = new Dictionary<int, string>();
                        while (mySqlDataReader.Read())
                        {
                                CharacterSets[Convert.ToInt32(mySqlDataReader["id"],
NumberFormatInfo.InvariantInfo)] =
mySqlDataReader.GetString(mySqlDataReader.GetOrdinal("charset"));
                        }
                }
                catch (Exception ex)
                {
                        MySqlTrace.LogError(ThreadID, ex.Message);
                        throw;
                }


See e.g.: https://bugs.mysql.com/bug.php?id=109331



 Comments   
Comment by Daniel Black [ 2023-11-16 ]

Is there a reason the https://github.com/mysql-net/MySqlConnector and MariaDB Connector/J are unacceptable solutions?

Comment by Vladislav Vaintroub [ 2023-11-21 ]

danblack, I do not think we can force anyone to MySqlConnector no matter how good it is, the Oracle's connector remains slightly more popular.
It is not a drop-in, and people may depend on other open source or closed source software, which happened to use Oracle's connector
Also, as we promised client compatibity, I think we should try to keep this promise

I tried to collect some links on the internet for this issue , it is in MDEV-31608 . We broke OnlyOffice, PowerBI, Toad, and some other stuff with NULL collation ids (something that nobody uses, and something that could be put into a dedicated table).

Generated at Thu Feb 08 10:34:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.