You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "xuesongxs (via GitHub)" <gi...@apache.org> on 2023/06/28 02:40:36 UTC

[GitHub] [inlong] xuesongxs commented on a diff in pull request #8344: [INLONG-8343][Dashboard] Increase the length of the field for creating MySQL varchar types to 16383

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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org