Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions functions-and-operators/bit-functions-and-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TiDB supports all of the [bit functions and operators](https://dev.mysql.com/doc
| [`<<`](#-left-shift) | Left shift |
| [`>>`](#-right-shift) | Right shift |

## [`BIT_COUNT()`](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#function_bit-count)
## `BIT_COUNT()`

The `BIT_COUNT(expr)` function returns the number of bits that are set as 1 in `expr`.

Expand Down Expand Up @@ -71,7 +71,7 @@ SELECT BIT_COUNT(INET_ATON('255.255.255.0'));
1 row in set (0.00 sec)
```

## [`&` (bitwise AND)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-and)
## `&` (bitwise AND)

The `&` operator performs a bitwise AND operation. It compares the corresponding bits of two numbers: if both corresponding bits are 1, the corresponding bit of the result is 1; otherwise, it is 0.

Expand Down Expand Up @@ -129,7 +129,7 @@ SELECT INET_NTOA(INET_ATON('192.168.1.2') & INET_ATON('255.255.255.0'));
1 row in set (0.00 sec)
```

## [`~` (bitwise inversion)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-invert)
## `~` (bitwise inversion)

The `~` operator performs a bitwise inversion (or bitwise NOT) operation on a given value. It inverts each bit of the given value: bits that are 0 become 1, and bits that are 1 become 0.

Expand Down Expand Up @@ -169,7 +169,7 @@ SELECT CONV(~ b'1111111111111111111111111111111111111111111111110000111100001111
1 row in set (0.00 sec)
```

## [`|` (bitwise OR)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-or)
## `|` (bitwise OR)

The `|` operator performs a bitwise OR operation. It compares the corresponding bits of two numbers: if at least one of the corresponding bits is 1, the corresponding bit in the result is 1.

Expand Down Expand Up @@ -197,7 +197,7 @@ SELECT CONV(b'1010' | b'1100',10,2);
1 row in set (0.00 sec)
```

## [`^` (bitwise XOR)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_bitwise-xor)
## `^` (bitwise XOR)

The `^` operator performs a bitwise XOR (exclusive OR) operation. It compares the corresponding bits of two numbers: if the corresponding bits are different, the corresponding bit in the result is 1.

Expand Down Expand Up @@ -227,7 +227,7 @@ SELECT CONV(b'1010' ^ b'1100',10,2);

Note that the result is shown as `110` instead of `0110` because the leading zero is removed.

## [`<<` (left shift)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_left-shift)
## `<<` (left shift)

The `<<` operator performs a left shift operation, which shifts the bits of a number to the left by a specified number of positions, filling the vacated bits with zeros on the right.

Expand Down Expand Up @@ -261,7 +261,7 @@ SELECT n,1<<n,LPAD(CONV(1<<n,10,2),11,0) FROM cte;
11 rows in set (0.00 sec)
```

## [`>>` (right shift)](https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html#operator_right-shift)
## `>>` (right shift)

The `>>` operator performs a right shift operation, which shifts the bits of a number to the right by a specified number of positions, filling the vacated bits with zeros on the left.

Expand Down
24 changes: 12 additions & 12 deletions functions-and-operators/encryption-and-compression-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TiDB supports most of the [encryption and compression functions](https://dev.mys
| [`UNCOMPRESSED_LENGTH()`](#uncompressed_length) | Return the length of a string before compression |
| [`VALIDATE_PASSWORD_STRENGTH()`](#validate_password_strength) | Validate the password strength |

### [`AES_DECRYPT()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-decrypt)
### `AES_DECRYPT()`

The `AES_DECRYPT(data, key [,iv])` function decrypts `data` that was previously encrypted using the [`AES_ENCRYPT()`](#aes_encrypt) function with the same `key`.

Expand All @@ -47,7 +47,7 @@ SELECT AES_DECRYPT(0x28409970815CD536428876175F1A4923, 'secret');
1 row in set (0.00 sec)
```

### [`AES_ENCRYPT()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_aes-encrypt)
### `AES_ENCRYPT()`

The `AES_ENCRYPT(data, key [,iv])` function encrypts `data` with `key` using the [Advanced Encryption Standard (AES)](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) algorithm.

Expand All @@ -68,7 +68,7 @@ SELECT AES_ENCRYPT(0x616263,'secret');
1 row in set (0.00 sec)
```

### [`COMPRESS()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_compress)
### `COMPRESS()`

The `COMPRESS(expr)` function returns a compressed version of the input data `expr`.

Expand Down Expand Up @@ -122,7 +122,7 @@ SELECT LENGTH(a),LENGTH(COMPRESS(a)) FROM x;
1 row in set (0.00 sec)
```

### [`MD5()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_md5)
### `MD5()`

The `MD5(expr)` function calculates a 128-bit [MD5](https://en.wikipedia.org/wiki/MD5) hash for the given argument `expr`.

Expand All @@ -139,7 +139,7 @@ SELECT MD5('abc');
1 row in set (0.00 sec)
```

### [`PASSWORD()`](https://dev.mysql.com/doc/refman/5.7/en/encryption-functions.html#function_password)
### `PASSWORD()`

> **Warning:**
>
Expand All @@ -162,7 +162,7 @@ SELECT PASSWORD('secret');
Warning (Code 1681): PASSWORD is deprecated and will be removed in a future release.
```

### [`RANDOM_BYTES()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_random-bytes)
### `RANDOM_BYTES()`

The `RANDOM_BYTES(n)` function returns `n` random bytes.

Expand All @@ -179,11 +179,11 @@ SELECT RANDOM_BYTES(3);
1 row in set (0.00 sec)
```

### [`SHA()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1)
### `SHA()`

The `SHA()` function is an alias for [`SHA1`](#sha1).

### [`SHA1()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha1)
### `SHA1()`

The `SHA1(expr)` function calculates a 160-bit [SHA-1](https://en.wikipedia.org/wiki/SHA-1) hash for the given argument `expr`.

Expand All @@ -200,7 +200,7 @@ SELECT SHA1('abc');
1 row in set (0.00 sec)
```

### [`SHA2()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_sha2)
### `SHA2()`

The `SHA2(str, n)` function calculates a hash using an algorithm from the [SHA-2](https://en.wikipedia.org/wiki/SHA-2) family. The `n` argument is used to select the algorithm. `SHA2()` returns `NULL` if any of the arguments are `NULL` or if the algorithm selected by `n` is unknown or unsupported.

Expand Down Expand Up @@ -248,7 +248,7 @@ SELECT SM3('abc');
1 row in set (0.00 sec)
```

### [`UNCOMPRESS()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompress)
### `UNCOMPRESS()`

The `UNCOMPRESS(data)` function decompresses the data that was compressed with the [`COMPRESS()`](#compress) function.

Expand All @@ -265,7 +265,7 @@ SELECT UNCOMPRESS(0x03000000789C72747206040000FFFF018D00C7);
1 row in set (0.00 sec)
```

### [`UNCOMPRESSED_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_uncompressed-length)
### `UNCOMPRESSED_LENGTH()`

The `UNCOMPRESSED_LENGTH(data)` function returns the first 4 bytes of the compressed data, which store the length that the compressed string had before being compressed with the [`COMPRESS()`](#compress) function.

Expand All @@ -282,7 +282,7 @@ SELECT UNCOMPRESSED_LENGTH(0x03000000789C72747206040000FFFF018D00C7);
1 row in set (0.00 sec)
```

### [`VALIDATE_PASSWORD_STRENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_validate-password-strength)
### `VALIDATE_PASSWORD_STRENGTH()`

<CustomContent platform="tidb">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ summary: Learn about JSON functions that aggregate JSON values.

The functions listed on this page are part of the [aggregate functions](/functions-and-operators/aggregate-group-by-functions.md) that TiDB supports, but are specific to working with JSON.

## [JSON_ARRAYAGG()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-arrayagg)
TiDB supports the [two aggregate JSON functions](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html) available in MySQL 8.0.

## `JSON_ARRAYAGG()`

The `JSON_ARRAYAGG(key)` function aggregates values of keys into a JSON array according to the given `key`. `key` is typically an expression or a column name.

Expand All @@ -28,7 +30,7 @@ SELECT JSON_ARRAYAGG(v) FROM (SELECT 1 'v' UNION SELECT 2);
1 row in set (0.00 sec)
```

## [JSON_OBJECTAGG()](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-objectagg)
## `JSON_OBJECTAGG()`

The `JSON_OBJECTAGG(key,value)` function aggregates keys and values of keys into a JSON object according to the given `key` and `value`. Both `key` or `value` are typically an expression or a column name.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ summary: Learn about JSON functions that create JSON values.

# JSON Functions That Create JSON Values

This document describes JSON functions that create JSON values.
TiDB supports all the [JSON functions that create JSON values](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html) available in MySQL 8.0.

## [JSON_ARRAY()](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-array)
## `JSON_ARRAY()`

The `JSON_ARRAY([val[, val] ...])` function evaluates a (possibly empty) list of values and returns a JSON array containing those values.

Expand All @@ -24,7 +24,7 @@ SELECT JSON_ARRAY(1,2,3,4,5), JSON_ARRAY("foo", "bar");
1 row in set (0.00 sec)
```

## [JSON_OBJECT()](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-object)
## `JSON_OBJECT()`

The `JSON_OBJECT([key, val[, key, val] ...])` function evaluates a (possibly empty) list of key-value pairs and returns a JSON object containing those pairs.

Expand All @@ -41,7 +41,7 @@ SELECT JSON_OBJECT("database", "TiDB", "distributed", TRUE);
1 row in set (0.00 sec)
```

## [JSON_QUOTE()](https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-quote)
## `JSON_QUOTE()`

The `JSON_QUOTE(str)` function returns a string as a JSON value with quotes.

Expand Down
24 changes: 12 additions & 12 deletions functions-and-operators/json-functions/json-functions-modify.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ summary: Learn about JSON functions that modify JSON values.

# JSON Functions That Modify JSON Values

This document describes JSON functions that modify JSON values.
TiDB supports all the [JSON functions that modify JSON values](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html) available in MySQL 8.0.

## [JSON_APPEND()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-append)
## `JSON_APPEND()`

An alias to [`JSON_ARRAY_APPEND()`](#json_array_append).

## [JSON_ARRAY_APPEND()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-array-append)
## `JSON_ARRAY_APPEND()`

The `JSON_ARRAY_APPEND(json_array, path, value [,path, value] ...)` function appends values to the end of the indicated arrays within a JSON document at the specified `path` and returns the result.

Expand Down Expand Up @@ -49,7 +49,7 @@ SELECT JSON_ARRAY_APPEND('{"transport_options": ["Car", "Boat", "Train"]}', '$.t
1 row in set (0.00 sec)
```

## [JSON_ARRAY_INSERT()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-array-insert)
## `JSON_ARRAY_INSERT()`

The `JSON_ARRAY_INSERT(json_array, path, value [,path, value] ...)` function inserts a `value` into the specified position of the `json_array` in the `path` and returns the result.

Expand Down Expand Up @@ -87,7 +87,7 @@ SELECT JSON_ARRAY_INSERT('["Car", "Boat", "Train"]', '$[1]', "Airplane") AS "Tra
1 row in set (0.00 sec)
```

## [JSON_INSERT()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-insert)
## `JSON_INSERT()`

The `JSON_INSERT(json_doc, path, value [,path, value] ...)` function inserts one or more values into a JSON document and returns the result.

Expand Down Expand Up @@ -125,7 +125,7 @@ SELECT JSON_INSERT('{"a": 61, "b": 62}', '$.a', 41, '$.c', 63);
1 row in set (0.00 sec)
```

## [JSON_MERGE_PATCH()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge-patch)
## `JSON_MERGE_PATCH()`

The `JSON_MERGE_PATCH(json_doc, json_doc [,json_doc] ...)` function merges two or more JSON documents into a single JSON document, without preserving values of duplicate keys. For `json_doc` arguments with duplicated keys, only the values from the later specified `json_doc` argument are preserved in the merged result.

Expand All @@ -150,7 +150,7 @@ SELECT JSON_MERGE_PATCH(
1 row in set (0.00 sec)
```

## [JSON_MERGE_PRESERVE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge-preserve)
## `JSON_MERGE_PRESERVE()`

The `JSON_MERGE_PRESERVE(json_doc, json_doc [,json_doc] ...)` function merges two or more JSON documents while preserving all values associated with each key and returns the merged result.

Expand All @@ -171,15 +171,15 @@ SELECT JSON_MERGE_PRESERVE('{"a": 1, "b": 2}','{"a": 100}', '{"c": 300}');
1 row in set (0.00 sec)
```

## [JSON_MERGE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-merge)
## `JSON_MERGE()`

> **Warning:**
>
> This function is deprecated.

A deprecated alias for [`JSON_MERGE_PRESERVE()`](#json_merge_preserve).

## [JSON_REMOVE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-remove)
## `JSON_REMOVE()`

The `JSON_REMOVE(json_doc, path [,path] ...)` function removes data of the specified `path` from a JSON document and returns the result.

Expand Down Expand Up @@ -215,7 +215,7 @@ SELECT JSON_REMOVE('{"a": 61, "b": 62, "c": 63}','$.b','$.c');
1 row in set (0.00 sec)
```

## [JSON_REPLACE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-replace)
## `JSON_REPLACE()`

The `JSON_REPLACE(json_doc, path, value [, path, value] ...)` function replaces values in specified paths of a JSON document and returns the result. If a specified path does not exist, the value corresponding to the path is not added to the result.

Expand Down Expand Up @@ -253,7 +253,7 @@ SELECT JSON_REPLACE('{"a": 41, "b": 62}','$.b',42,'$.c',43);
1 row in set (0.00 sec)
```

## [JSON_SET()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-set)
## `JSON_SET()`

The `JSON_SET(json_doc, path, value [,path, value] ...)` function inserts or updates data in a JSON document and returns the result.

Expand Down Expand Up @@ -291,7 +291,7 @@ SELECT JSON_SET('{"version": 1.1, "name": "example"}','$.version',1.2,'$.branch'
1 row in set (0.00 sec)
```

## [JSON_UNQUOTE()](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-unquote)
## `JSON_UNQUOTE()`

The `JSON_UNQUOTE(json)` function unquotes a JSON value and returns the result as a string. This is the opposite of the [`JSON_QUOTE()`](/functions-and-operators/json-functions/json-functions-create.md#json_quote) function.

Expand Down
10 changes: 5 additions & 5 deletions functions-and-operators/json-functions/json-functions-return.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ summary: Learn about JSON functions that return JSON values.

# JSON Functions That Return JSON Values

This document describes JSON functions that return JSON values.
TiDB supports all the [JSON functions that return JSON value attributes](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html) available in MySQL 8.0.

## [JSON_DEPTH()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-depth)
## `JSON_DEPTH()`

The `JSON_DEPTH(json_doc)` function returns the maximum depth of a JSON document.

Expand All @@ -32,7 +32,7 @@ SELECT JSON_DEPTH('{"weather": {"current": "sunny"}}');
1 row in set (0.00 sec)
```

## [JSON_LENGTH()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-length)
## `JSON_LENGTH()`

The `JSON_LENGTH(json_doc [,path])` function returns the length of a JSON document. If a `path` argument is given, it returns the length of the value within the path.

Expand Down Expand Up @@ -68,7 +68,7 @@ SELECT JSON_LENGTH('{"weather": {"current": "sunny", "tomorrow": "cloudy"}}','$.
1 row in set (0.01 sec)
```

## [JSON_TYPE()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-type)
## `JSON_TYPE()`

The `JSON_TYPE(json_val)` function returns a string indicating [the type of a JSON value](/data-type-json.md#json-value-types).

Expand Down Expand Up @@ -132,7 +132,7 @@ SELECT JSON_TYPE('"2025-06-14"'),JSON_TYPE(CAST(CAST('2025-06-14' AS date) AS js
1 row in set (0.00 sec)
```

## [JSON_VALID()](https://dev.mysql.com/doc/refman/8.0/en/json-attribute-functions.html#function_json-valid)
## `JSON_VALID()`

The `JSON_VALID(str)` function checks if the argument is valid JSON. This can be useful for checking a column before converting it to the `JSON` type.

Expand Down
Loading