troubleshooting Question

WHY IS MYSQL REJECTING ASCII CHARACTER INSERTION INTO CHAR TYPE COLUMN

Avatar of Mike Jacobs
Mike JacobsFlag for United Kingdom of Great Britain and Northern Ireland asked on
MySQL Server
7 Comments1 Solution34 ViewsLast Modified:
I'm getting a rejection error when installing a new record into mysql (from vfp). I suspect it might be mysql being somewhat stricter about data types that vfp.

The data in question is an SHA256 hash value in plain ascii (32 chrs) which I can insert into a VFP table till the cows come home.
Mysql rejects it with the following message - which I do not understand:

[MySQL][ODBC 8.0(w) Driver][mysqld-8.0.19]Incorrect string value: '\xE5}\x1B'\x0A\x0D...' for column 'HASH_SOURCE' at row 1

That looks like a clunky way to express the hex values of the ascii string but that doesn't make sense because the hex version of the string is 0hBEEC0F153832825A8647806E29073BEBD2287C7C03E5F696A9F3EA7123786F62

The initial data type I had set the mysql column to was Varchar (32)

after reading refs in the mysql tooltip text re Varchars, which refers to utf8 chars requiring up to 3 bytes per char, I switched to plain CHAR which reported no such strictures, but I get the same error with that.

To test my hypothesis that it was somehow related to data type, instead of creating an ascii string, I created the hashes in hex and just used the first 32 characters of the 64 byte hex string. That worked a treat. Of course that's no use in the real world and I have no intention of switching to 64 byte fields just so I can use the full hex string because one of my requirements is to keep the whole table as lean as possible and 32 chrs is as lean as we can get with 256 bit hash. So it looks as though the ascii strings are being rejected because they contain one or more non standard characters.

Is that down to an encoding parameter I haven't applied or am I barking up completely the wrong tree?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros