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
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

## description

Calculates an MD5 128-bit checksum for the string
Calculates an MD5 128-bit checksum for the string or binary.

## Syntax

```sql
MD5( <str> )
MD5( <input> )
```

## Parameters

| parameter | description |
| -- | -- |
| `<str>` | The MD5 value to be calculated |
| `<input>` | The MD5 value to be calculated, accept string and binary types |

## Return Value

Expand All @@ -28,13 +28,28 @@ Returns the MD5 value of a string.
## Examples

```sql
select md5("abc");
-- vb (VarBinary) and vc (VarChar) used the same string during insertion.
SELECT * FROM mysql_catalog.binary_test.binary_test;
```

```text
+----------------------------------+
| md5('abc') |
+----------------------------------+
| 900150983cd24fb0d6963f7d28e17f72 |
+----------------------------------+
+------+------------+------+
| id | vb | vc |
+------+------------+------+
| 1 | 0x616263 | abc |
| 2 | 0x78797A | xyz |
| 3 | NULL | NULL |
+------+------------+------+
```

```sql
SELECT MD5(vb), MD5(vc) FROM mysql_catalog.binary_test.binary_test;
```
```text
+----------------------------------+----------------------------------+
| MD5(vb) | MD5(vc) |
+----------------------------------+----------------------------------+
| 900150983cd24fb0d6963f7d28e17f72 | 900150983cd24fb0d6963f7d28e17f72 |
| d16fb36f0911f878998c136191af705e | d16fb36f0911f878998c136191af705e |
| NULL | NULL |
+----------------------------------+----------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ SHA
## Syntax

``` sql
SHA1( <str> )
SHA1( <input> )
```

## Parameters

| parameter | description |
|-----------|-------------|
| `<str>` | The sha1 value to be calculated |
| `<input>` | The sha1 value to be calculated, accept string and binary types |

## Return Value

Expand All @@ -32,13 +32,28 @@ Returns the sha1 value of the input string
## Examples

```sql
select sha("123"), sha1("123");
-- vb (VarBinary) and vc (VarChar) used the same string during insertion.
SELECT * FROM mysql_catalog.binary_test.binary_test;
```
```text
+------+------------+------+
| id | vb | vc |
+------+------------+------+
| 1 | 0x616263 | abc |
| 2 | 0x78797A | xyz |
| 3 | NULL | NULL |
+------+------------+------+
```

```sql
SELECT SHA1(vb), SHA1(vc) FROM mysql_catalog.binary_test.binary_test;
```
```text
+------------------------------------------+------------------------------------------+
| sha1('123') | sha1('123') |
| SHA1(vb) | SHA1(vc) |
+------------------------------------------+------------------------------------------+
| 40bd001563085fc35165329ea1ff5c5ecbdbbeef | 40bd001563085fc35165329ea1ff5c5ecbdbbeef |
| a9993e364706816aba3e25717850c26c9cd0d89d | a9993e364706816aba3e25717850c26c9cd0d89d |
| 66b27417d37e024c46526c2f6d358a754fc552f3 | 66b27417d37e024c46526c2f6d358a754fc552f3 |
| NULL | NULL |
+------------------------------------------+------------------------------------------+
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ The information is digested using SHA2.
## Syntax

```sql
SHA2( <str>, <digest_length>)
SHA2( <input>, <digest_length>)
```

## Parameters

| parameter | description |
|-------------------|----------------------------|
| `<str>` | Content to be encrypted |
| `<input>` | Content to be encrypted, accept string and binary types |
| `<digest_length>` | Summary length, supports 224, 256, 384, 512. must be constant |

## Return Value
Expand Down Expand Up @@ -63,3 +63,30 @@ select sha2(k0, k1) from str;
```text
ERROR 1105 (HY000): errCode = 2, detailMessage = the second parameter of sha2 must be a literal but got: k1
```

```sql
-- vb (VarBinary) and vc (VarChar) used the same string during insertion.
SELECT * FROM mysql_catalog.binary_test.binary_test;
```
```text
+------+------------+------+
| id | vb | vc |
+------+------------+------+
| 1 | 0x616263 | abc |
| 2 | 0x78797A | xyz |
| 3 | NULL | NULL |
+------+------------+------+
```

```sql
SELECT SHA2(vb, 224), SHA2(vc, 224) FROM mysql_catalog.binary_test.binary_test;
```
```text
+----------------------------------------------------------+----------------------------------------------------------+
| SHA2(vb, 224) | SHA2(vc, 224) |
+----------------------------------------------------------+----------------------------------------------------------+
| 23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 | 23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 |
| 30e90f1cd0ceff8eb3dd6a540a605c0666f841d35de63c57e4dd2877 | 30e90f1cd0ceff8eb3dd6a540a605c0666f841d35de63c57e4dd2877 |
| NULL | NULL |
+----------------------------------------------------------+----------------------------------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,44 @@ Calculation SM3 256-bit
## Syntax

```sql
SM3( <str> )
SM3( <input> )
```

## Parameters


| parameter | description |
|-----------|-------------|
| `<str>` | The value of sm3 that needs to be calculated |
| `<input>` | The value of sm3 that needs to be calculated, accept string and binary types |

## Return Value
Returns the sm3 value of the input string

## Examples

```sql
select sm3("abcd");
-- vb (VarBinary) and vc (VarChar) used the same string during insertion.
SELECT * FROM mysql_catalog.binary_test.binary_test;
```

```text
+------------------------------------------------------------------+
| sm3('abcd') |
+------------------------------------------------------------------+
| 82ec580fe6d36ae4f81cae3c73f4a5b3b5a09c943172dc9053c69fd8e18dca1e |
+------------------------------------------------------------------+
+------+------------+------+
| id | vb | vc |
+------+------------+------+
| 1 | 0x616263 | abc |
| 2 | 0x78797A | xyz |
| 3 | NULL | NULL |
+------+------------+------+
```

```sql
SELECT SM3(vb), SM3(vc) FROM mysql_catalog.binary_test.binary_test;
```
```text
+------------------------------------------------------------------+------------------------------------------------------------------+
| SM3(vb) | SM3(vc) |
+------------------------------------------------------------------+------------------------------------------------------------------+
| 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0 | 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0 |
| 869fff440724014a7e086c8b3680f4cfc6a3390670f6e7755a4f0c43c1c31db6 | 869fff440724014a7e086c8b3680f4cfc6a3390670f6e7755a4f0c43c1c31db6 |
| NULL | NULL |
+------------------------------------------------------------------+------------------------------------------------------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@

## Description

Calculate the 32-bit xxhash value of the input string
Calculate the 32-bit xxhash value of the input string or binary.

-Note: When calculating hash values, it is recommended to use `xxhash_32` instead of `murmur_hash3_32`.

## Syntax

```sql
XXHASH_32( <str> [ , <str> ... ] )
XXHASH_32( <input> [ , <input> ... ] )
```

## Parameters

| parameter | description |
|-----------|------------------|
| `<str>` | The 32-bit xxhash value to be calculated |
| `<input>` | The 32-bit xxhash value to be calculated, accept string and binary types |

## Return Value

Expand All @@ -39,4 +39,31 @@ select xxhash_32(NULL), xxhash_32("hello"), xxhash_32("hello", "world");
+-----------------+--------------------+-----------------------------+
| NULL | -83855367 | -920844969 |
+-----------------+--------------------+-----------------------------+
```

```sql
-- vb (VarBinary) and vc (VarChar) used the same string during insertion.
SELECT * FROM mysql_catalog.binary_test.binary_test;
```
```text
+------+------------+------+
| id | vb | vc |
+------+------------+------+
| 1 | 0x616263 | abc |
| 2 | 0x78797A | xyz |
| 3 | NULL | NULL |
+------+------------+------+
```

```sql
SELECT XXHASH_32(vb), XXHASH_32(vc) FROM mysql_catalog.binary_test.binary_test;
```
```text
+---------------+---------------+
| XXHASH_32(vb) | XXHASH_32(vc) |
+---------------+---------------+
| 852579327 | 852579327 |
| -242012205 | -242012205 |
| NULL | NULL |
+---------------+---------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@

## Description

Calculates the 64-bit xxhash value of the input string
Calculates the 64-bit xxhash value of the input string or binary.

-Note: After testing, the performance of `xxhash_64` is about twice that of `murmur_hash3_64`, so when calculating hash values, it is recommended to use `xxhash_64` instead of `murmur_hash3_64`.

## Syntax

```sql
XXHASH_64( <str> [ , <str> ... ] )
XXHASH_64( <input> [ , <input> ... ] )
```

## Parameters

| parameter | description |
|-----------|------------------|
| `<str>` | The 64-bit xxhash value to be calculated |
| `<input>` | The 64-bit xxhash value to be calculated, accept string and binary types |

## Return Value

Expand All @@ -39,4 +39,30 @@ select xxhash_64(NULL), xxhash_64("hello"), xxhash_64("hello", "world");
+-----------------+----------------------+-----------------------------+
| NULL | -7685981735718036227 | 7001965798170371843 |
+-----------------+----------------------+-----------------------------+
```

```sql
-- vb (VarBinary) and vc (VarChar) used the same string during insertion.
SELECT * FROM mysql_catalog.binary_test.binary_test;
```
```text
+------+------------+------+
| id | vb | vc |
+------+------------+------+
| 1 | 0x616263 | abc |
| 2 | 0x78797A | xyz |
| 3 | NULL | NULL |
+------+------------+------+
```
```sql
SELECT XXHASH_64(vb), XXHASH_64(vc) FROM mysql_catalog.binary_test.binary_test;
```
```text
+---------------------+---------------------+
| XXHASH_64(vb) | XXHASH_64(vc) |
+---------------------+---------------------+
| 8696274497037089104 | 8696274497037089104 |
| 7095089596068863775 | 7095089596068863775 |
| NULL | NULL |
+---------------------+---------------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,43 @@
## 语法

```sql
MD5( <str> )
MD5( <input> )
```

## 参数

| 参数 | 说明 |
|---------| -- |
| `<str>` | 需要被计算 MD5 的值 |
| `<input>` | 需要被计算 MD5 的值, 接受字符串和二进制类型 |

## 返回值
返回字符串的 MD5 值。

## 示例

```sql
select md5("abc");
-- vb (VarBinary) 和 vc (VarChar) 插入时使用了相同的字符串.
SELECT * FROM mysql_catalog.binary_test.binary_test;
```
```text
+------+------------+------+
| id | vb | vc |
+------+------------+------+
| 1 | 0x616263 | abc |
| 2 | 0x78797A | xyz |
| 3 | NULL | NULL |
+------+------------+------+
```

```sql
SELECT MD5(vb), MD5(vc) FROM mysql_catalog.binary_test.binary_test;
```
```text
+----------------------------------+
| md5('abc') |
+----------------------------------+
| 900150983cd24fb0d6963f7d28e17f72 |
+----------------------------------+
+----------------------------------+----------------------------------+
| MD5(vb) | MD5(vc) |
+----------------------------------+----------------------------------+
| 900150983cd24fb0d6963f7d28e17f72 | 900150983cd24fb0d6963f7d28e17f72 |
| d16fb36f0911f878998c136191af705e | d16fb36f0911f878998c136191af705e |
| NULL | NULL |
+----------------------------------+----------------------------------+
```
Loading
Loading