Re: utf8 column is storing only half of the maximum number of characters
Posted by: Rick James
Date: June 17, 2013 10:40PM

Puzzling.
MySQL will not preallocate any amount of space for VARCHAR(4000), but will truncate any inserts to 4000 _characters_ (not "bytes").
A utf8 character (in MySQL) will occupy 1-3 bytes. Hence, the VARCHAR(4000) will occupy 4002 bytes for 4000 ascii chars; 1202 bytes for 4000 Asian characters. The extra 2 is for length.

Perhaps something else is going on. What are the values for
SHOW VARIABLES LIKE 'char%';
I would hope that most are "utf8", not "latin1".

> I discovered that only the first 2000 characters (i.e. one-half the character limit) are being stored.
How did you discover that? (The technique you used for discovering it may be part of the problem!)

More on charset problems:
http://mysql.rjweb.org/doc.php/charcoll
(But, I am sure it does not have an _explicit_ answer for your problem.)

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: utf8 column is storing only half of the maximum number of characters
1640
June 17, 2013 10:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.