Escape the strings in the execution plan to make it easier to understand
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Enhancement
```sql
create table t1(a varchar(30), index ia(a));
explain select * from t1 where a = '\0';
explain select * from t1 where a = '\n';
explain select * from t1 where a = '\t';
explain select * from t1 where a like '\0%';
explain select * from t1 where a = '"';
create table t2(a varchar(30));
explain select * from t2 where a = '\0';
explain select * from t2 where a = '\n';
explain select * from t2 where a = '\t';
```
Current result:
```sql
> create table t1(a varchar(30), index ia(a));
> explain select * from t1 where a = '\0';
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t1, index:ia(a) | range:[" "," "], keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
> explain select * from t1 where a = '\n';
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t1, index:ia(a) | range:["
","
"], keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
> explain select * from t1 where a = '\t';
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t1, index:ia(a) | range:[" "," "], keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
> explain select * from t1 where a like '\0%';
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| IndexReader_6 | 250.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 250.00 | cop[tikv] | table:t1, index:ia(a) | range:[" ",""), keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
> explain select * from t1 where a = '"';
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
| IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t1, index:ia(a) | range:[""","""], keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------+
> explain select * from t2 where a = '\0';
+-------------------------+----------+-----------+---------------+--------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------+----------+-----------+---------------+--------------------------------+
| TableReader_7 | 10.00 | root | | data:Selection_6 |
| └─Selection_6 | 10.00 | cop[tikv] | | eq(test2.t2.a, " ") |
| └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t2 | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------+
> explain select * from t2 where a = '\n';
+-------------------------+----------+-----------+---------------+--------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------+----------+-----------+---------------+--------------------------------+
| TableReader_7 | 10.00 | root | | data:Selection_6 |
| └─Selection_6 | 10.00 | cop[tikv] | | eq(test2.t2.a, "
") |
| └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t2 | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------+
> explain select * from t2 where a = '\t';
+-------------------------+----------+-----------+---------------+--------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------+----------+-----------+---------------+--------------------------------+
| TableReader_7 | 10.00 | root | | data:Selection_6 |
| └─Selection_6 | 10.00 | cop[tikv] | | eq(test2.t2.a, " ") |
| └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t2 | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------+
```
Expected result:
```sql
> explain select * from t1 where a = '\0';
+------------------------+---------+-----------+-----------------------+-------------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------------+
| IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t1, index:ia(a) | range:["\x00","\x00"], keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------------+
> explain select * from t1 where a = '\n';
+------------------------+---------+-----------+-----------------------+---------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+---------------------------------------------------+
| IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t1, index:ia(a) | range:["\n","\n"], keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+---------------------------------------------------+
> explain select * from t1 where a = '\t';
+------------------------+---------+-----------+-----------------------+---------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+---------------------------------------------------+
| IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t1, index:ia(a) | range:["\t","\t"], keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+---------------------------------------------------+
> explain select * from t1 where a like '\0%';
+------------------------+---------+-----------+-----------------------+-------------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------------+
| IndexReader_6 | 250.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 250.00 | cop[tikv] | table:t1, index:ia(a) | range:["\x00","\x01"), keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+-------------------------------------------------------+
> explain select * from t1 where a = '"';
+------------------------+---------+-----------+-----------------------+---------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+-----------------------+---------------------------------------------------+
| IndexReader_6 | 10.00 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 10.00 | cop[tikv] | table:t1, index:ia(a) | range:["\"","\""], keep order:false, stats:pseudo |
+------------------------+---------+-----------+-----------------------+---------------------------------------------------+
```
Contributor guide
Assessment
This issue has not been assessed yet.