Bug #99134 select * from (SELECT NULL) t returns misunderstanding result
Submitted: 31 Mar 2020 16:07 Modified: 20 Jul 2020 8:46
Reporter: Feng Liyuan Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.19 OS:Any
Assigned to: CPU Architecture:Any

[31 Mar 2020 16:07] Feng Liyuan
Description:
mysql> select * from (SELECT NULL) t;
+------------+
| NULL    |
+------------+
| 0x     |
+------------+
1 row in set (0.00 sec)

mysql> SELECT NULL;
+------+
| NULL |
+------+
| NULL |
+------+
1 row in set (0.00 sec)

How to repeat:
select * from (SELECT NULL) t;
[31 Mar 2020 16:40] MySQL Verification Team
Thank you for the bug report.

c:\dbs>c:\dbs\5.6\bin\mysql -uroot --local-infile --port=3560 -p --prompt="mysql 5.6 > " --column-type-info
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.49-log Source distribution BUILT: 2020-MAR-28

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.6 > select * from (SELECT NULL) t;

+------+
| NULL |
+------+
| NULL |
+------+
1 row in set (0.00 sec)

mysql 5.6 >

c:\dbs>c:\dbs\5.7\bin\mysql -uroot --port=3570 -p  --prompt="mysql 5.7 > " --default-character-set=latin1
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.31-log Source distribution BUILT: 2020-MAR-28

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.7 > select * from (SELECT NULL) t;
+------+
| NULL |
+------+
| NULL |
+------+
1 row in set (0.01 sec)

mysql 5.7 >

c:\dbs>c:\dbs\8.0\bin\mysql -uroot --port=3580 -p --local-infile=1 --prompt="mysql 8.0 > " --default-character-set=latin1
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.21 Source distribution BUILT: 2020-MAR-28

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 8.0 > select * from (SELECT NULL) t;
+------------+
| NULL       |
+------------+
| 0x         |
+------------+
1 row in set (0.00 sec)

mysql 8.0 >
[20 Jul 2020 8:46] Erlend Dahl
Posted by developer Bharathy X Satish:
======================================

WL#13038 enables --binary-as-hex option to true for interactive clients. Thus
NULL is converted to hex before being displayed.
To get the NULL value set --binary-to-hex=false
 
 
./bin/mysql --user=root --socket=/tmp/mysqld47.sock --binary-as-hex=false
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 41
Server version: 8.0.22-tr-debug Source distribution
 
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.
 
mysql> select * from (SELECT NULL) t;
+------+
| NULL |
+------+
| NULL |
+------+
1 row in set (0.00 sec)
 
IMHO this is an expected behaviour.