Weird issue with some characters in a script

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
tintinux
Junior Boarder
Junior Boarder
Posts: 43
Joined: 19.05.2010, 10:39

Weird issue with some characters in a script

Post by tintinux »

Hi

I'm using 7.2.6 with Lazarus 2.0.10, connected to a MariaDb 10 Database, utf-8 charset selected everywhere.

I get a syntax error when I execute in a ZSqlProcessor this :

Code: Select all

CREATE OR REPLACE TABLE Countries( CountryName VARCHAR(50) NOT NULL)  DEFAULT CHARSET=utf8 ENGINE=InnoDB;

INSERT INTO Countries (CountryName) VALUES ('CAÏMANES, ÎLES');
But with this one (only one "E" has been removed in the country name), for example : no problem !

Code: Select all

CREATE OR REPLACE TABLE Countries(CountryName VARCHAR(50) NOT NULL) DEFAULT CHARSET=utf8 ENGINE=InnoDB;

INSERT INTO Countries (CountryName)  VALUES ('CAÏMANS, ÎLES');
The first script run without error in another SQL client (SquirrelSQL), or when executed in a mysql command line with input from files.

I have attached a zip containing a small project reproducing the problem, and the 2 script files

Any idea about this strange issue ? Could someone try with Delphi ?
You do not have the required permissions to view the files attached to this post.
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 765
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Weird issue with some characters in a script

Post by aehimself »

I remember there were issues on MySQL with the default UTF-8 codepage and everyone advised to use UTF8MB4 instead. I don't know if MariaDB still has this, but it worths to try...?

I converted your application to Delphi and the only error I get is that the table does not exist; so I suppose parsing was successful. This is not going to be too much of a help, as
- I'm using Delphi, you are using Lararus
- I'm using Zeos 8.0, you are using 7.2
- I'm connecting to MySQL while you are connecting to MariaDB...

Anyway, I'd try updating to Zeos 8. I remember @Egonhugeist reworked the character encoding, maybe it will solve your issues too.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: Weird issue with some characters in a script

Post by marsupilami »

Another option might me that the files are read in the wrong encoding. Maybe it is worth a try to see if the SQL loads correctly? Display it in a TMemo or something like that and if it is correct, assign the Memo lines to the TZSqlProcessor SQL:
SqlProcessor.SQL.Assign(Memo.Lines);
Or:
SqlProcessor.SQL. Text := Memo.Lines.Text.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Weird issue with some characters in a script

Post by EgonHugeist »

Hello tintinux,

i hade a look to Classes.pas of FPC3.2. They added an overload for loadfromstream/loadfromfile having a TEncoding overload.
Whithout checking your example it feels correct to add this parameter to our TSQLProcessor.LoadFrom(File/Stream).

See https://sourceforge.net/p/zeoslib/code-0/7316/ Trunk only.
Yet i'm out of time to checkyour example, next week propably. But i'm starting from the premisse your DB is utf8 encoded and the file you use use ansi encoded. Try to add an Ansi-TEncoding to the TSQLProcessor loaders.. Does it help?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Post Reply