Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON_REPLACE/JSON_REMOVE etc does not return error for invalid path expressions #34959

Closed
Tracked by #36993
morgo opened this issue May 25, 2022 · 0 comments · Fixed by #37074
Closed
Tracked by #36993

JSON_REPLACE/JSON_REMOVE etc does not return error for invalid path expressions #34959

morgo opened this issue May 25, 2022 · 0 comments · Fixed by #37074
Assignees

Comments

@morgo
Copy link
Contributor

morgo commented May 25, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

SET @json = '{"advertise-address": "123456","alter-primary-key": false,"ballast-object-size": 0,"performance": {"bind-info-lease": "3s","cross-join": true,"distinct-agg-push-down": false,"enable-stats-cache-mem-quota": false,"enforce-mpp": false,"feedback-probability": 0,"txn-entry-size-limit": 104857600,"txn-total-size-limit": 1048576000}}';
SELECT json_pretty(@json);

SELECT JSON_PRETTY(JSON_REPLACE(@json, '$.performance.txn-entry-size-limit', 'newValue'));
SELECT JSON_PRETTY(JSON_REPLACE(@json, '$."performance".txn-entry-size-limit', 'newValue'));
SELECT JSON_PRETTY(JSON_REPLACE(@json, '$."performance."txn-entry-size-limit', 'newValue'));
SELECT JSON_PRETTY(JSON_REPLACE(@json, '$."performance."txn-entry-size-limit"', 'newValue'));

SELECT JSON_PRETTY(JSON_REMOVE(@json, '$.performance.txn-entry-size-limit'));
SELECT JSON_PRETTY(JSON_REMOVE(@json, '$."performance".txn-entry-size-limit'));
SELECT JSON_PRETTY(JSON_REMOVE(@json, '$."performance."txn-entry-size-limit'));
SELECT JSON_PRETTY(JSON_REMOVE(@json, '$."performance."txn-entry-size-limit"'));

2. What did you expect to see? (Required)

mysql [localhost:8028] {msandbox} (test) > SET @json = '{"advertise-address": "123456","alter-primary-key": false,"ballast-object-size": 0,"performance": {"bind-info-lease": "3s","cross-join": true,"distinct-agg-push-down": false,"enable-stats-cache-mem-quota": false,"enforce-mpp": false,"feedback-probability": 0,"txn-entry-size-limit": 104857600,"txn-total-size-limit": 1048576000}}';
Query OK, 0 rows affected (0.00 sec)

mysql [localhost:8028] {msandbox} (test) > SELECT json_pretty(@json);
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| json_pretty(@json)                                                                                                                                                                                                                                                                                                                                                                                |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "performance": {
    "cross-join": true,
    "enforce-mpp": false,
    "bind-info-lease": "3s",
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false
  },
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql [localhost:8028] {msandbox} (test) > 
mysql [localhost:8028] {msandbox} (test) > SELECT JSON_PRETTY(JSON_REPLACE(@json, '$.performance.txn-entry-size-limit', 'newValue'));
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 34.
mysql [localhost:8028] {msandbox} (test) > SELECT JSON_PRETTY(JSON_REPLACE(@json, '$."performance".txn-entry-size-limit', 'newValue'));
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 36.
mysql [localhost:8028] {msandbox} (test) > SELECT JSON_PRETTY(JSON_REPLACE(@json, '$."performance."txn-entry-size-limit', 'newValue'));
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 16.
mysql [localhost:8028] {msandbox} (test) > SELECT JSON_PRETTY(JSON_REPLACE(@json, '$."performance."txn-entry-size-limit"', 'newValue'));
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 16.
mysql [localhost:8028] {msandbox} (test) > 
mysql [localhost:8028] {msandbox} (test) > SELECT JSON_PRETTY(JSON_REMOVE(@json, '$.performance.txn-entry-size-limit'));
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 34.
mysql [localhost:8028] {msandbox} (test) > SELECT JSON_PRETTY(JSON_REMOVE(@json, '$."performance".txn-entry-size-limit'));
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 36.
mysql [localhost:8028] {msandbox} (test) > SELECT JSON_PRETTY(JSON_REMOVE(@json, '$."performance."txn-entry-size-limit'));
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 16.
mysql [localhost:8028] {msandbox} (test) > SELECT JSON_PRETTY(JSON_REMOVE(@json, '$."performance."txn-entry-size-limit"'));
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 16.

3. What did you see instead (Required)

tidb> SET @json = '{"advertise-address": "123456","alter-primary-key": false,"ballast-object-size": 0,"performance": {"bind-info-lease": "3s","cross-join": true,"distinct-agg-push-down": false,"enable-stats-cache-mem-quota": false,"enforce-mpp": false,"feedback-probability": 0,"txn-entry-size-limit": 104857600,"txn-total-size-limit": 1048576000}}';
Query OK, 0 rows affected (0.00 sec)

tidb> SELECT json_pretty(@json);
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| json_pretty(@json)                                                                                                                                                                                                                                                                                                                                                                                |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0,
  "performance": {
    "bind-info-lease": "3s",
    "cross-join": true,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false,
    "enforce-mpp": false,
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000
  }
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

tidb> 
tidb> SELECT JSON_PRETTY(JSON_REPLACE(@json, '$.performance.txn-entry-size-limit', 'newValue'));
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(JSON_REPLACE(@json, '$.performance.txn-entry-size-limit', 'newValue'))                                                                                                                                                                                                                                                                                                                |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0,
  "performance": {
    "bind-info-lease": "3s",
    "cross-join": true,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false,
    "enforce-mpp": false,
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000
  }
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

tidb> SELECT JSON_PRETTY(JSON_REPLACE(@json, '$."performance".txn-entry-size-limit', 'newValue'));
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(JSON_REPLACE(@json, '$."performance".txn-entry-size-limit', 'newValue'))                                                                                                                                                                                                                                                                                                              |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0,
  "performance": {
    "bind-info-lease": "3s",
    "cross-join": true,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false,
    "enforce-mpp": false,
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000
  }
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

tidb> SELECT JSON_PRETTY(JSON_REPLACE(@json, '$."performance."txn-entry-size-limit', 'newValue'));
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(JSON_REPLACE(@json, '$."performance."txn-entry-size-limit', 'newValue'))                                                                                                                                                                                                                                                                                                              |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0,
  "performance": {
    "bind-info-lease": "3s",
    "cross-join": true,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false,
    "enforce-mpp": false,
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000
  }
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

tidb> SELECT JSON_PRETTY(JSON_REPLACE(@json, '$."performance."txn-entry-size-limit"', 'newValue'));
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(JSON_REPLACE(@json, '$."performance."txn-entry-size-limit"', 'newValue'))                                                                                                                                                                                                                                                                                                             |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0,
  "performance": {
    "bind-info-lease": "3s",
    "cross-join": true,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false,
    "enforce-mpp": false,
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000
  }
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

tidb> 
tidb> SELECT JSON_PRETTY(JSON_REMOVE(@json, '$.performance.txn-entry-size-limit'));
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(JSON_REMOVE(@json, '$.performance.txn-entry-size-limit'))                                                                                                                                                                                                                                                                                                                             |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0,
  "performance": {
    "bind-info-lease": "3s",
    "cross-join": true,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false,
    "enforce-mpp": false,
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000
  }
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

tidb> SELECT JSON_PRETTY(JSON_REMOVE(@json, '$."performance".txn-entry-size-limit'));
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(JSON_REMOVE(@json, '$."performance".txn-entry-size-limit'))                                                                                                                                                                                                                                                                                                                           |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0,
  "performance": {
    "bind-info-lease": "3s",
    "cross-join": true,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false,
    "enforce-mpp": false,
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000
  }
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

tidb> SELECT JSON_PRETTY(JSON_REMOVE(@json, '$."performance."txn-entry-size-limit'));
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(JSON_REMOVE(@json, '$."performance."txn-entry-size-limit'))                                                                                                                                                                                                                                                                                                                           |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0,
  "performance": {
    "bind-info-lease": "3s",
    "cross-join": true,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false,
    "enforce-mpp": false,
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000
  }
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

tidb> SELECT JSON_PRETTY(JSON_REMOVE(@json, '$."performance."txn-entry-size-limit"'));
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(JSON_REMOVE(@json, '$."performance."txn-entry-size-limit"'))                                                                                                                                                                                                                                                                                                                          |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "advertise-address": "123456",
  "alter-primary-key": false,
  "ballast-object-size": 0,
  "performance": {
    "bind-info-lease": "3s",
    "cross-join": true,
    "distinct-agg-push-down": false,
    "enable-stats-cache-mem-quota": false,
    "enforce-mpp": false,
    "feedback-probability": 0,
    "txn-entry-size-limit": 104857600,
    "txn-total-size-limit": 1048576000
  }
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

tidb> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.1.0-alpha-503-gdd30e19f3
Edition: Community
Git Commit Hash: dd30e19f35677aedbbf28051f2ec674b019833ad
Git Branch: remove-deprecated-config
UTC Build Time: 2022-05-25 18:33:53
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants