Description:
The following commands return ERROR 1064:
HANDLER mytable READ 'PRIMARY' FIRST;
HANDLER mytable READ 'PRIMARY' > (2);
My secondary key has the same layout and everything works fine:
HANDLER mytable READ skey FIRST;
HANDLER mytable READ skey > (2);
A workaround: Do not create a PRIMARY KEY and instead create a UNIQUE INDEX pkey. But this is a very bad solution.
How to repeat:
mysql> CREATE TABLE mytable (myid INT, PRIMARY KEY (myid), UNIQUE INDEX skey (my
id));
Query OK, 0 rows affected (0.00 sec)
mysql> show columns from mytable;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| myid | int(11) | | PRI | 0 | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)
mysql> show index from mytable;
+---------+------------+----------+--------------+-------------+-----------+----
---------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Car
dinality | Sub_part | Packed | Null | Index_type | Comment |
+---------+------------+----------+--------------+-------------+-----------+----
---------+----------+--------+------+------------+---------+
| mytable | 0 | skey | 1 | myid | A |
3 | NULL | NULL | | BTREE | |
| mytable | 0 | PRIMARY | 1 | myid | A |
3 | NULL | NULL | | BTREE | |
+---------+------------+----------+--------------+-------------+-----------+----
---------+----------+--------+------+------------+---------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM mytable;
+------+
| myid |
+------+
| 1 |
| 2 |
| 3 |
+------+
3 rows in set (0.00 sec)
mysql> HANDLER mytable OPEN;
Query OK, 0 rows affected (0.00 sec)
mysql> HANDLER mytable READ skey FIRST;
+------+
| myid |
+------+
| 1 |
+------+
1 row in set (0.00 sec)
mysql> HANDLER mytable READ skey > (2);
+------+
| myid |
+------+
| 3 |
+------+
1 row in set (0.00 sec)
mysql> HANDLER mytable READ 'PRIMARY' FIRST;
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresp
onds to your MySQL server version for the right syntax to use near ''PRIMARY' FI
RST' at line 1
mysql> HANDLER mytable READ 'PRIMARY' > (2);
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresp
onds to your MySQL server version for the right syntax to use near ''PRIMARY' >
(2)' at line 1