Search found 8 matches

by robert84
Thu 15 Sep 2022 20:56
Forum: MySQL Data Access Components
Topic: 'utf8' charset is now deprecated
Replies: 8
Views: 10786

Re: 'utf8' charset is now deprecated

pavelpd wrote: Thu 15 Sep 2022 07:31 Please note that if you set the Charset property to 'utf8mb4' and share the enabled UseUnicode=true parameter, then the Charset property will not be ignored and a request like "SET NAMES 'utf8mb4'" will be sent to the server, in all other cases when using UseUnicode=true, the Charset property is ignored and a "SET NAMES 'utf8'" request is sent to the server.

We will correct this inaccuracy in the documentation in the near future.
Great. Finally it will be possible for me to use utf8mb4_0900_ai_ci collation.

Thanks for the tip, this was quite useful.
by robert84
Wed 31 Aug 2022 18:44
Forum: SecureBridge
Topic: Unable to set IsSecure with TLSv1.3
Replies: 2
Views: 41761

Re: Unable to set IsSecure with TLSv1.3

Test case for Lazarus (tested on win32):

https://oshi.at/Gciz
by robert84
Mon 29 Aug 2022 16:43
Forum: MySQL Data Access Components
Topic: 'utf8' charset is now deprecated
Replies: 8
Views: 10786

Re: 'utf8' charset is now deprecated

davidmarcus wrote: Mon 29 Aug 2022 16:34 My Delphi app is using Unicode. I have Options.UseUnicode = True and Options.CharSet = 'utf8mb4'. I think my app is working. I did test it back then. But, if your app is using Latin 1, then I don't know what happens.
Hi David

As I said in my previous post, when you enable UseUnicode the Charset field is ignored (this behaviour is documented here). So you aren't really using utf8mb4 but utf8/utf8mb3 (the non-standard version which has now been deprecated). You can easily verify this by enabling the general_log in MySQL server and inspecting the commands sent by MyDAC.

If you really want to force charset to utf8mb4 you have to issue a SET NAMES command, e.g.

Code: Select all

MyConnection1.ExecSQL('SET NAMES utf8mb4');
but this is potentially dangerous and could even lead to data corruption as you're changing charset behind MyDAC's back, and MyDAC could well be making the assumption that utf8/utf8mb3 is still in place.

This is why I'm asking for advice from MyDAC devs as they're the ones who know if this would be a problem (it likely would) and have the ability to fix it.
by robert84
Mon 29 Aug 2022 16:30
Forum: MySQL Data Access Components
Topic: Changing from latin1 to utf8mb4
Replies: 26
Views: 157935

Re: Changing from latin1 to utf8mb4

davidmarcus wrote: Wed 13 Jan 2016 00:36 That works better. I tried some Japanese in the Basic Multilingual Plane, and it worked. But, when I tried a Japanese character not in the Basic Multilingual Plane, I got
#HY000Incorrect string value: '\xF0\xA0\x80\x81' for column 'Name' at row 1
Do you know if it should work for such characters?
If you have enabled UseUnicode, MyDAC uses 'utf8' internally which means only BMP characters will be supported. For full UTF-8 support you need 'utf8mb4'.

Unfortunately It's not clear if you can use 'utf8mb4' in combination with UseUnicode (I recently started a thread regarding this). I'm waiting for some clarification from MyDAC devs on this matter.
by robert84
Mon 29 Aug 2022 16:26
Forum: MySQL Data Access Components
Topic: 'utf8' charset is now deprecated
Replies: 8
Views: 10786

Re: 'utf8' charset is now deprecated

davidmarcus wrote: Mon 29 Aug 2022 15:09 I think utf8mb4 works with MyDAC. See viewtopic.php?f=7&t=31291
Thanks David. That post discusses something different. Setting Charset to 'utf8mb4' would make MyDAC simply request utf8mb4 from server and not do any conversions locally. This doesn't work in my case as I'm still stuck with Delphi 7 and hence the VCL expects windows-1252 / latin1.

My concern is with UseUnicode = True mode, which makes MyDAC convert between charsets in the client side. As described here, when UseUnicode is enabled the Charset property is ignored (and 'utf8' is used behind the scenes, which is the issue at hand here).
by robert84
Sun 28 Aug 2022 20:11
Forum: SecureBridge
Topic: Unable to set IsSecure with TLSv1.3
Replies: 2
Views: 41761

Unable to set IsSecure with TLSv1.3

Hi

I'm having some trouble setting IsSecure on TLSv1.3. When I attempt so I get a EScError exception with message: 'The other side has sent a failure alert: [47]'

The code to trigger it is very simple, it is basically:

Code: Select all

    Protocols := [spTls13];
    Connect;
    IsSecure := True;
I'm providing a complete ZIP including:

- stunnel config file to run as server side
- Delphi 7 test project

It can be downloaded from: https://oshi.at/XDZf

In order to reproduce:

1. Start stunnel with:

Code: Select all

sudo stunnel test.conf
2. Build Project1.dpr and run it.

3. Press on button labeled 'TLSv1.2'. You'll see that a successful connection is logged on stunnel:

Code: Select all

2022.08.28 21:59:53 LOG5[0]: Service [test] accepted connection from 127.0.0.1:42950
2022.08.28 21:59:53 LOG6[0]: Peer certificate not required
2022.08.28 21:59:53 LOG6[0]: No peer certificate received
2022.08.28 21:59:53 LOG6[0]: Session id: XXXX
2022.08.28 21:59:53 LOG6[0]: TLS accepted: new session negotiated
2022.08.28 21:59:53 LOG6[0]: TLSv1.2 ciphersuite: ECDHE-RSA-AES256-GCM-SHA384 (256-bit encryption)
2022.08.28 21:59:53 LOG6[0]: Local mode child started (PID=1089023)
4. Now press button labeled 'TLSv1.3'. The app will raise EScError exception, and stunnel will display this:

Code: Select all

2022.08.28 22:02:35 LOG5[0]: Service [test] accepted connection from 127.0.0.1:42952
2022.08.28 22:02:35 LOG6[0]: Peer certificate not required
2022.08.28 22:02:35 LOG3[0]: SSL_accept: ../ssl/statem/extensions_srvr.c:697: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share
2022.08.28 22:02:35 LOG5[0]: Connection reset: 0 byte(s) sent to TLS, 0 byte(s) sent to socket
by robert84
Sun 28 Aug 2022 17:20
Forum: MySQL Data Access Components
Topic: AV on trigger
Replies: 4
Views: 54689

Re: AV on trigger

Hi

Although I don't fully understand the problem, I notice you have a mix of charsets (utf8mb3 vs utf8mb4) which is an almost guaranteed recipe for trouble. So I would fix that before anything else. It may well be the cause of your problem.

Note that if you're using UseUnicode, MyDAC defaults to 'utf8' (aka 'utf8mb3'). See my other post which is somewhat related. In this situation, unless you consistently use utf8mb3 everywhere else it is likely you run into charset mismatch or collation mismatch issues.

I suggest you do one of the following:
  • Disable UseUnicode
  • Migrate all your charsets to utf8mb3 to match with MyDAC
  • Wait for MyDAC to be upgraded to utf8mb4
  • Force MyDAC to use utf8mb4 by issuing your own SET NAMES command (potentially dangerous!)
by robert84
Sun 28 Aug 2022 17:10
Forum: MySQL Data Access Components
Topic: 'utf8' charset is now deprecated
Replies: 8
Views: 10786

'utf8' charset is now deprecated

Hi

I have noticed that when UseUnicode is enabled, MyDAC sends this command to server right after starting its connection:

Code: Select all

SET NAMES 'utf8'
Note that as of MySQL 8.0, this charset identifier is deprecated and is expected to be removed in future releases. The MySQL developers recommend that applications use utf8mb4 instead.

utf8mb4 is a much better alternative, since unlike its predecessor it is standards-compliant. It is also a requirement if you want to use some of the newer collations (such as utf8mb4_0900_ai_ci).

It's fairly simple for the application developer to override MyDAC SET NAMES string by sending a new one afterwards, e.g.

Code: Select all

MyConnection1.ExecSQL('SET NAMES utf8mb4');
However messing with charset connection settings behind MyDAC's back seems somewhat dangerous so I'm hesitant to use this on production environments. Has someone tried this? (I've tested it in a small application and couldn't find any issues).

Would be great if the MyDAC developers could confirm if utf8mb4 can be used or -even better!- upgrade the SET NAMES string in MyDAC.