Description:
According to previous bug with group by clause https://bugs.mysql.com/bug.php?id=106312, same bug way work with order by clause.
MySQL [test]> CREATE TABLE t1 (id int, val varchar(10));
Query OK, 0 rows affected (0.026 sec)
MySQL [test]> INSERT INTO t1 VALUES (1, 'value1');
Query OK, 1 row affected (0.016 sec)
MySQL [test]> INSERT INTO t1 VALUES (2, 'value2');
Query OK, 1 row affected (0.004 sec)
MySQL [test]> SELECT * FROM t1;
+------+--------+
| id | val |
+------+--------+
| 1 | value1 |
| 2 | value2 |
+------+--------+
2 rows in set (0.001 sec)
MySQL [test]> SELECT * FROM t1 order by 1 asc;
+------+--------+
| id | val |
+------+--------+
| 1 | value1 |
| 2 | value2 |
+------+--------+
2 rows in set (0.001 sec)
MySQL [test]> SELECT * FROM t1 order by 1 desc;
+------+--------+
| id | val |
+------+--------+
| 2 | value2 |
| 1 | value1 |
+------+--------+
2 rows in set (0.001 sec)
-- Expected, using the first column in the table t1.
MySQL [test]> SELECT * FROM t1 order by 123;
ERROR 1054 (42S22): Unknown column '123' in 'order clause'
-- Expected
MySQL [test]> SELECT * FROM t1 order by 178234238746328742384353489759873459834759348573948679348634957034957349857934753947539483489579348753498; -- Random big number.
+------+--------+
| id | val |
+------+--------+
| 1 | value1 |
| 2 | value2 |
+------+--------+
2 rows in set, 1 warning (0.001 sec)
MySQL [test]> SELECT * FROM t1 order by 178234238746328742384353489759873459834759348573948679348634957034957349857934753947539483489579348753498 asc; -- Random big number.
+------+--------+
| id | val |
+------+--------+
| 1 | value1 |
| 2 | value2 |
+------+--------+
2 rows in set, 1 warning (0.001 sec)
MySQL [test]> SELECT * FROM t1 order by 178234238746328742384353489759873459834759348573948679348634957034957349857934753947539483489579348753498 desc; -- Random big number.
+------+--------+
| id | val |
+------+--------+
| 1 | value1 |
| 2 | value2 |
+------+--------+
2 rows in set, 1 warning (0.001 sec)
-- Expects error, gets row output instead
How to repeat:
MySQL [test]> CREATE TABLE t1 (id int, val varchar(10));
Query OK, 0 rows affected (0.026 sec)
MySQL [test]> INSERT INTO t1 VALUES (1, 'value1');
Query OK, 1 row affected (0.016 sec)
MySQL [test]> INSERT INTO t1 VALUES (2, 'value2');
Query OK, 1 row affected (0.004 sec)
MySQL [test]> SELECT * FROM t1 order by 178234238746328742384353489759873459834759348573948679348634957034957349857934753947539483489579348753498; -- Random big number.
+------+--------+
| id | val |
+------+--------+
| 1 | value1 |
| 2 | value2 |
+------+--------+
2 rows in set, 1 warning (0.001 sec)
MySQL [test]> SELECT * FROM t1 order by 178234238746328742384353489759873459834759348573948679348634957034957349857934753947539483489579348753498 asc; -- Random big number.
+------+--------+
| id | val |
+------+--------+
| 1 | value1 |
| 2 | value2 |
+------+--------+
2 rows in set, 1 warning (0.001 sec)
MySQL [test]> SELECT * FROM t1 order by 178234238746328742384353489759873459834759348573948679348634957034957349857934753947539483489579348753498 desc; -- Random big number.
+------+--------+
| id | val |
+------+--------+
| 1 | value1 |
| 2 | value2 |
+------+--------+
2 rows in set, 1 warning (0.001 sec)