Bug #111184 Execution plan display error
Submitted: 29 May 2023 12:20 Modified: 29 May 2023 13:17
Reporter: linfeng chen Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Storage Engine API Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[29 May 2023 12:20] linfeng chen
Description:
mysql> CREATE TABLE t1 (p POINT);
Query OK, 0 rows affected (0.65 sec)

mysql> INSERT INTO t1 VALUES (ST_POINTFROMTEXT('POINT(1 2)'));
Query OK, 1 row affected (0.11 sec)

mysql> ALTER TABLE t1 SECONDARY_ENGINE = test;
Query OK, 0 rows affected (0.20 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> SELECT COUNT(*) FROM t1 WHERE p=ST_POINTFROMTEXT('POINT(1 2)');
+----------+
| COUNT(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

mysql> ALTER TABLE t1 SECONDARY_ENGINE = null;
Query OK, 0 rows affected (0.17 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> INSERT INTO t1 VALUES (ST_POINTFROMTEXT('POINT(1 2)'));
Query OK, 1 row affected (0.09 sec)
mysql> EXPLAIN
    -> SELECT COUNT(*) FROM t1 WHERE p=ST_POINTFROMTEXT('POINT(1 2)');
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra       |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
|  1 | SIMPLE      | t1    | NULL       | ALL  | NULL          | NULL | NULL    | NULL |    1 |   100.00 | Using where |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
1 row in set, 1 warning (0.01 sec)

There are two rows of data in the table, but only one row is explicit

mysql>  ANALYZE TABLE t1;
+-----------+---------+----------+----------+
| Table     | Op      | Msg_type | Msg_text |
+-----------+---------+----------+----------+
| testdb.t1 | analyze | status   | OK       |
+-----------+---------+----------+----------+
1 row in set (0.16 sec)

mysql> EXPLAIN  SELECT COUNT(*) FROM t1 WHERE p=ST_POINTFROMTEXT('POINT(1 2)');
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra       |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
|  1 | SIMPLE      | t1    | NULL       | ALL  | NULL          | NULL | NULL    | NULL |    2 |    50.00 | Using where |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
1 row in set, 1 warning (0.00 sec)

How to repeat:
CREATE TABLE t1 (p POINT);
INSERT INTO t1 VALUES (ST_POINTFROMTEXT('POINT(1 2)'));
ALTER TABLE t1 SECONDARY_ENGINE = test;
SELECT COUNT(*) FROM t1 WHERE p=ST_POINTFROMTEXT('POINT(1 2)');
ALTER TABLE t1 SECONDARY_ENGINE = null;
INSERT INTO t1 VALUES (ST_POINTFROMTEXT('POINT(1 2)'));
EXPLAIN SELECT COUNT(*) FROM t1 WHERE p=ST_POINTFROMTEXT('POINT(1 2)');
ANALYZE TABLE t1;
 EXPLAIN  SELECT COUNT(*) FROM t1 WHERE p=ST_POINTFROMTEXT('POINT(1 2)');
[29 May 2023 13:08] MySQL Verification Team
Hi Mr. chen,

Thank you for your bug report.

However, it is not a bug.

Secondary engine syntax is there to add software add-ons that augment the primary engine. So far, it is only used for the RAPID engine, which can be a secondary engine only to InnoDB.

You can read more about it here:

https://dev.mysql.com/doc/heatwave/en/

You are not using this feature correctly, since you have not created any add-on engines, nor are you using our HeatWave secondary engine  .......

Not a bug.
[29 May 2023 13:17] MySQL Verification Team
Hi Mr. chen,

We have decided to verify your bug report.

Simply, there are two problems here.

First of all, secondary engine should be tested whether it is active or not, when the table is altered.

Second, it must check for the  correct interface that is present in it.

Third, this all requires to be documented.

Hence, SECONDARY_ENGINE requires proper documentation and proper checking.

This report is now verified.