xuesongxs commented on code in PR #8344:
URL: https://github.com/apache/inlong/pull/8344#discussion_r1244596351


##########
inlong-dashboard/src/plugins/sinks/defaults/MySQL.ts:
##########
@@ -47,7 +47,7 @@ const fieldTypesConf = {
   TIME: () => '',
   DATETIME: () => '',
   CHAR: (m, d) => (1 <= m && m <= 255 ? '' : '1<=M<=255'),
-  VARCHAR: (m, d) => (1 <= m && m <= 255 ? '' : '1<=M<=255'),
+  VARCHAR: (m, d) => (1 <= m && m <= 16383 ? '' : '1<=M<=16383'),

Review Comment:
   > Excuse me, how do you get the result of 16383 here?
   > 
   > If you consider the utf8mb4 character set, it takes up to 4 bytes to 
represent 1 character, so 65535 / 4 = 16383, then the maximum length of the 
char above is 255, which is also inaccurate.
   
   What is the maximum length of the varchar field in MySQL version 5.7? Under 
different character sets, the disk space occupied by a character varies, so:
   
   Under the Litan1 character set, varchar can store up to 65535-2-1=65532 
characters. If it is a non empty varchar field, it can store 65535-2=65533 
characters.
   
   Under the utf8 character set, varchar can store up to floor 
((65535-2-1)/3)=21844 characters. If it is a non empty varchar field, it can 
store floor ((65535-2)/3)=21844, and after rounding down, it is also 21844 
characters
   
   Under the utf8mb4 character set, varchar can store up to floor 
(65535-2-1)/4)=16383 characters. If it is a non empty varchar field, it can 
store 16383 characters as well.
   
![13d831694265891853e93a00eaa2e53](https://github.com/apache/inlong/assets/54351417/dc57cacb-561a-4fd7-8254-a0db715f2605)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to