From 5d5a7aade91b1a2c14d93d3747403355dd1d8e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Wed, 3 Apr 2024 14:01:32 +0200 Subject: [PATCH 1/6] Add example for QUOTE() --- functions-and-operators/string-functions.md | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/functions-and-operators/string-functions.md b/functions-and-operators/string-functions.md index d6c9f6bf1ad7b..59ccafaf8cf3e 100644 --- a/functions-and-operators/string-functions.md +++ b/functions-and-operators/string-functions.md @@ -1188,7 +1188,7 @@ Return a string containing octal representation of a number. ### [`OCTET_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_octet-length) -Synonym for `LENGTH()`. +Synonym for [`LENGTH()`](#length). ### [`ORD()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ord) @@ -1196,12 +1196,31 @@ Return character code for leftmost character of the argument. ### [`POSITION()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_position) -Synonym for `LOCATE()`. +Synonym for [`LOCATE()`](#locate). ### [`QUOTE()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_quote) Escape the argument for use in an SQL statement. +If the argument is NULL then the function returns NULL. + +Examples: + +In this example you can see that ASCII NUL gets escaped as `\0` and `'` gets escaped as `\'`. + +```sql +SELECT QUOTE(0x002774657374); +``` + +``` ++-----------------------+ +| QUOTE(0x002774657374) | ++-----------------------+ +| '\0\'test' | ++-----------------------+ +1 row in set (0.00 sec) +``` + ### [`REGEXP`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp) Pattern matching using regular expressions. @@ -1240,7 +1259,7 @@ Return the specified rightmost number of characters. ### [`RLIKE`](https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp) -Synonym for `REGEXP`. +Synonym for [`REGEXP`](#regexp). ### [`RPAD()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_rpad) From 5e69e6d5d3fbde8935e084ead813a899d7c728d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Sun, 7 Apr 2024 10:48:44 +0200 Subject: [PATCH 2/6] Update functions-and-operators/string-functions.md Co-authored-by: Aolin --- functions-and-operators/string-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions-and-operators/string-functions.md b/functions-and-operators/string-functions.md index 59ccafaf8cf3e..df7db260a4ec9 100644 --- a/functions-and-operators/string-functions.md +++ b/functions-and-operators/string-functions.md @@ -1202,11 +1202,11 @@ Synonym for [`LOCATE()`](#locate). Escape the argument for use in an SQL statement. -If the argument is NULL then the function returns NULL. +If the argument is `NULL`, the function returns `NULL`. Examples: -In this example you can see that ASCII NUL gets escaped as `\0` and `'` gets escaped as `\'`. +The following example shows that the ASCII NULL character is escaped as `\0` and the single quote character `'` is escaped as `\'`: ```sql SELECT QUOTE(0x002774657374); From 7b60be00cac8975f0840be126eeed6bdd58adf93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 9 Apr 2024 09:45:38 +0200 Subject: [PATCH 3/6] Update based on review --- functions-and-operators/string-functions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions-and-operators/string-functions.md b/functions-and-operators/string-functions.md index df7db260a4ec9..33b44ecad947d 100644 --- a/functions-and-operators/string-functions.md +++ b/functions-and-operators/string-functions.md @@ -1206,6 +1206,8 @@ If the argument is `NULL`, the function returns `NULL`. Examples: +For this example you need to use the `--skip-binary-as-hex` option as otherwise it would display the result as hex-encoded instead of directly displaying it. + The following example shows that the ASCII NULL character is escaped as `\0` and the single quote character `'` is escaped as `\'`: ```sql From c0e86e3b46170110e0516c7794644cc0284ae2ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 9 Apr 2024 10:01:46 +0200 Subject: [PATCH 4/6] Update functions-and-operators/string-functions.md Co-authored-by: Aolin --- functions-and-operators/string-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions-and-operators/string-functions.md b/functions-and-operators/string-functions.md index 33b44ecad947d..d7a11d705674f 100644 --- a/functions-and-operators/string-functions.md +++ b/functions-and-operators/string-functions.md @@ -1206,7 +1206,7 @@ If the argument is `NULL`, the function returns `NULL`. Examples: -For this example you need to use the `--skip-binary-as-hex` option as otherwise it would display the result as hex-encoded instead of directly displaying it. +To display the result as a hexadecimal-encoded value instead of showing it directly, you need to start the MySQL client with the [`--skip-binary-as-hex`](https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-hex) option. The following example shows that the ASCII NULL character is escaped as `\0` and the single quote character `'` is escaped as `\'`: From 8f56660547beed0598b93fd1d4e0d4b279c930e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 9 Apr 2024 17:25:36 +0200 Subject: [PATCH 5/6] Update based on review --- functions-and-operators/string-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions-and-operators/string-functions.md b/functions-and-operators/string-functions.md index d7a11d705674f..07ea02adaef16 100644 --- a/functions-and-operators/string-functions.md +++ b/functions-and-operators/string-functions.md @@ -1206,7 +1206,7 @@ If the argument is `NULL`, the function returns `NULL`. Examples: -To display the result as a hexadecimal-encoded value instead of showing it directly, you need to start the MySQL client with the [`--skip-binary-as-hex`](https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-hex) option. +To display the result directly instead of showing a hexadecimal-encoded value, you need to start the MySQL client with the [`--skip-binary-as-hex`](https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-hex) option. The following example shows that the ASCII NULL character is escaped as `\0` and the single quote character `'` is escaped as `\'`: From 3421d4c86d62944baca063c8317ed94992544423 Mon Sep 17 00:00:00 2001 From: Lilian Lee Date: Wed, 10 Apr 2024 11:22:41 +0800 Subject: [PATCH 6/6] Update wording --- functions-and-operators/string-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions-and-operators/string-functions.md b/functions-and-operators/string-functions.md index 07ea02adaef16..b1c705990b5f6 100644 --- a/functions-and-operators/string-functions.md +++ b/functions-and-operators/string-functions.md @@ -1204,7 +1204,7 @@ Escape the argument for use in an SQL statement. If the argument is `NULL`, the function returns `NULL`. -Examples: +Example: To display the result directly instead of showing a hexadecimal-encoded value, you need to start the MySQL client with the [`--skip-binary-as-hex`](https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-hex) option.