The behavior of `json_search` is incompatible with MySQL for `NULL` value
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
Run SQL `SELECT JSON_SEARCH(NULL, 'one', 1);`
### 2. What did you expect to see? (Required)
```sql
mysql> SELECT JSON_SEARCH(NULL, 'one', 1);
+-----------------------------+
| JSON_SEARCH(NULL, 'one', 1) |
+-----------------------------+
| NULL |
+-----------------------------+
1 row in set (0.01 sec)
```
### 3. What did you see instead (Required)
```sql
mysql> SELECT JSON_SEARCH(NULL, 'one', 1);
ERROR 3146 (22032): Invalid data type for JSON data in argument 1 to function json_search; a JSON string or JSON type is required.
```
### 4. What is your TiDB version? (Required)
```
mysql> SELECT tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.0
Edition: Community
Git Commit Hash: d13e52ed6e22cc5789bed7c64c861578cd2ed55b
Git Branch: HEAD
UTC Build Time: 2024-12-18 02:27:10
GoVersion: go1.23.2
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
Contributor guide
Assessment
This issue has not been assessed yet.