[Linux LEAP 15.1] MySQL client version 10.4.3

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

[Linux LEAP 15.1] MySQL client version 10.4.3

Postby hurukan » 20. October 2019 04:00

Greetings,

I'm completly lost :{
I did a demonstration for my students yeeeeaaaars ago and this one always worked untill I upgraded to LEAP 15.1 :{

The demonstration is about a C application (language that we learn at school) that connects to a mariadb database.

This is the part of the main() function
Code: Select all
   setlocale(LC_ALL,"fr_BE.UTF8");
   
  wprintf(L"MySQL client version: %s\n",mysql_get_client_info());
   wprintf(L"Tentative de connexion...");
   MYSQL *connexion = mysql_init(NULL);

  if (connexion == NULL)
  {
      fprintf(stderr, "%s\n", mysql_error(connexion));
      exit(1);
  }

   
   if (mysql_real_connect(connexion, "localhost", "testeur", "toor","CSSMPoste", 0, NULL, 0) == NULL)
  {
     wprintf(L"\t\x1b[31m[ko]\x1b[0m\nErreur à l'ouverture de connexion: %s !!\n",mysql_error(connexion));
     
       exit(1);
  }   
  wprintf(L"\t\x1b[32m[ok]\x1b[0m\n");
 
   if (mysql_query(connexion, "SELECT Nom,CodePostal FROM CodesPostaux,Localités WHERE idCodePostal=Ref_CodesPostaux ORDER BY CodePostal"))
  {
      wprintf(L"(%05d)Erreur lors de l'exécution d'une requête SQL: %s !!\n",mysql_error(connexion),mysql_error(connexion));
     
       exit(1);
  }


Image

The error happened when I try to execute a query with mysql_query() that always worked before, I got some documents showing it was working, I got just to retreive them.
Looking at the output it seems the string is broken as the '\n' is never printed to the terminal :{

What is wrong with mysql_query() that is still documented in the official documentation (refered to refman-5.7-en.a4.pdf) and https://dev.mysql.com/doc/refman/8.0/en/mysql-query.html

The description of the tables involved in the query is:

Image

I do not use binary datas but there is an error that never happened before.
hurukan
 
Posts: 3
Joined: 20. October 2019 03:40
Operating System: Linux LEAP 15.1

Re: [Linux LEAP 15.1] MySQL client version 10.4.3

Postby Nobbie » 21. October 2019 20:03

I think (not 100% sure about this), that MariaDB (not MySQL, Xampp does not install MySQL since many years) does not support mysql_xxxx functions anymore. These functions have been removed in PHP 7 and maybe (i really dont know) it also has been removed totally in the API for MariaDB. In case of PHP, it is recommended to upgrade to the mysqli_xxxx functions instead. I dont know if there is an equivalent C Api likely as for PHP. But it makes sense. In that case, mysql_xxx has been removed for C as well.

Its only a clue.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: [Linux LEAP 15.1] MySQL client version 10.4.3

Postby hurukan » 22. October 2019 13:36

Thank you... I'll try with first replacing those functions with equivalent from the code, and then get back with observations.
hurukan
 
Posts: 3
Joined: 20. October 2019 03:40
Operating System: Linux LEAP 15.1

Re: [Linux LEAP 15.1] MySQL client version 10.4.3

Postby hurukan » 09. December 2019 20:04

Sorry for the delays: I jumped on several forums to obtain help and I lost myself in this mess ^^

The issue seem to be related to the utf8 handling... when I change 'Localités' to 'Localites' (apologizes to be a frenchspeaking teacher ^^) I got no error when executing the C program but the datas
with utf8 encoding ARE NOT DISPLAYED with 1064 error (42000) and log indicating "Got an error reading communication packets"...

Code: Select all
MariaDB [CSSMPosteMieux]> SHOW VARIABLES LIKE 'char%';
+--------------------------+------------------------------+
| Variable_name            | Value                        |
+--------------------------+------------------------------+
| character_set_client     | utf8                         |
| character_set_connection | utf8                         |
| character_set_database   | utf8mb4                      |
| character_set_filesystem | binary                       |
| character_set_results    | utf8                         |
| character_set_server     | utf8                         |
| character_set_system     | utf8                         |
| character_sets_dir       | /usr/share/mariadb/charsets/ |
+--------------------------+------------------------------+


The /etc/my.cnf file contains those directives that I modified but I'm not sure they are correct for what I want to do (list the datas from tables thru a C program using mariadb connector C)

Code: Select all
[client]

default-character-set = utf8

# The MariaDB server
[mysqld]

#default-character-set = utf8
#character-set-client-handshake = FALSE
character-set-server = utf8
#collation-server = utf8


I tried to set the client side default-character-set to utf8mb4 but it behaves the same... :{
hurukan
 
Posts: 3
Joined: 20. October 2019 03:40
Operating System: Linux LEAP 15.1


Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 6 guests