String Functions
When GaussDB uses the SQL_ASCII, the server interprets byte values 0 to 127 according to the ASCII standard, and byte values 128 to 255 are regarded as characters that cannot be parsed. If the input and output of the function contain any non-ASCII data, the database cannot convert or verify non-ASCII characters. As a result, the behavior of the function is greatly different from that of MySQL.
Function |
Differences Compared with MySQL |
---|---|
ASCII() |
- |
BIT_LENGTH() |
- |
CHAR_LENGTH() |
If the database character set is SQL_ASCII, this function returns the number of bytes instead of the number of characters. |
CHARACTER_LENGTH() |
|
CONCAT() |
- |
CONCAT_WS() |
- |
HEX() |
- |
LENGTH() |
- |
LPAD() |
The default maximum padding length in MySQL is 1398101, and that in GaussDB is 1048576. The maximum padding length varies depending on the character set. For example, if the character set is GBK, the default maximum padding length in GaussDB is 2097152. |
RPAD() |
|
MD5() |
When the length of the inserted string of the BINARY type is less than the target length, the padding characters in GaussDB are different from those in MySQL. Therefore, when the input parameter is of the BINARY type, the function result in GaussDB is different from that in MySQL. |
RANDOM_BYTES() |
Both GaussDB and MySQL use OpenSSL to generate random character strings. GaussDB uses OpenSSL 3.x.x to generate random character strings. Compared with MySQL using OpenSSL 1.x.x, the performance in GaussDB may deteriorate. |
REPEAT() |
- |
REPLACE() |
If the third input parameter is null and the string length of the second input parameter is not 0, GaussDB returns NULL and MySQL may return the characters of the first parameter. For example: -- Behavior in GaussDB: m_db=# select replace('1.23', binary(1.1), null); replace --------- (1 row) -- Behavior in MySQL: mysql> select replace('1.23', binary(1.1), null); +------------------------------------+ | replace('1.23', binary(1.1), null) | +------------------------------------+ | 1.23 | +------------------------------------+ 1 row in set (0.00 sec) |
SHA()/SHA1() |
- |
SHA2() |
- |
SPACE() |
- |
STRCMP() |
- |
FIND_IN_SET() |
- |
LCASE() |
- |
LEFT() |
- |
LOWER() |
- |
LTRIM() |
- |
REVERSE() |
- |
RIGHT() |
- |
RTRIM() |
- |
SUBSTR() |
When the collation returned by the first input parameter node is BINARY, MySQL may still use different collation logic (depending on the nested function), but GaussDB processes functions based on BINARY collation. As a result, the length of truncated bytes is different. |
SUBSTRING() |
|
SUBSTRING_INDEX() |
|
TRIM() |
- |
UCASE() |
- |
UPPER() |
- |
UNHEX() |
- |
FIELD() |
- |
COMPRESS() |
- |
UNCOMPRESS() |
- |
UNCOMPRESS_LENGTH() |
- |
EXPORT_SET() |
- |
POSITION() |
- |
LOCATE() |
- |
CHAR() |
|
ELT() |
In MySQL, the number of input parameters of the ELT function is not limited. In GaussDB, the number of input parameters of the function cannot exceed 8192. |
FORMAT() |
- |
BIN() |
- |
MAKE_SET() |
In MySQL 5.7, if the first parameter selected by the MAKE_SET function is of the integer, floating-point, or fixed-point type and the returned result contains non-ASCII characters, garbled characters may be displayed. In GaussDB, the displayed result is normal, which is the same as that in MySQL 8.0. |
TO_BASE64() |
- |
FROM_BASE64() |
- |
ORD() |
- |
MID() |
- |
QUOTE() |
|
INSERT() |
- |
INSTR() |
- |
OCTET_LENGTH() |
- |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot