Bug #104160 mysql -q option wrong result
Submitted: 30 Jun 2021 6:58 Modified: 9 Dec 2023 23:48
Reporter: 송화 SONGHUA Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:ALL OS:Linux
Assigned to: CPU Architecture:Any

[30 Jun 2021 6:58] 송화 SONGHUA
Description:
the mysql command client -q option have a problem  

How to repeat:
without -q option 

/usr/local/mysql/bin/mysql -S /tmp/mysql3306.sock -uroot -p   --prompt "\u@\p>[\d]>" --database employees
[root@yejr mysql_shell]# /usr/local/mysql/bin/mysql -S /tmp/mysql3306.sock -uroot -poracle   --prompt "\u@\p>[\d]>" --database employees
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 84
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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.

root@mysql3306.sock>[employees]>select '123456789987654321' +0 a ;
+-----------------------+
| a                     |
+-----------------------+
| 1.2345678998765432e17 |
+-----------------------+
1 row in set (0.00 sec)

root@mysql3306.sock>[employees]>desc select '123456789987654321' +0 a ;
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+----------------+
| id | select_type | table | partitions | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra          |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+----------------+
|  1 | SIMPLE      | NULL  | NULL       | NULL | NULL          | NULL | NULL    | NULL | NULL |     NULL | No tables used |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+----------------+
1 row in set, 1 warning (0.00 sec)

root@mysql3306.sock>[employees]>desc select '123456789987654321' +0 a \G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: NULL
   partitions: NULL
         type: NULL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: NULL
     filtered: NULL
        Extra: No tables used
1 row in set, 1 warning (0.00 sec)

with -q option 

[root@yejr mysql_shell]# /usr/local/mysql/bin/mysql -S /tmp/mysql3306.sock -uroot -p  -q   --prompt "\u@\p>[\d]>" --database employees
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 85
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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.

root@mysql3306.sock>[employees]>select '123456789987654321' +0 a ;
+-------------------------+
| a                       |
+-------------------------+
|   1.2345678998765432e17 |
+-------------------------+
1 row in set (0.00 sec)

root@mysql3306.sock>[employees]>desc select '123456789987654321' +0 a \G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: NULL
   partitions: NULL
         type: NULL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: NULL
     filtered: NULL
        Extra: No tables used
1 row in set, 1 warning (0.00 sec)

root@mysql3306.sock>[employees]>desc select '123456789987654321' +0 a ;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
^Z[2]+  Stopped                 /usr/local/mysql/bin/mysql -S /tmp/mysql3306.sock -uroot -p  -q --prompt "\u@\p>[\d]>" --database employees
[30 Jun 2021 12:12] MySQL Verification Team
Hi Mr. SONGHUA,

Thank you so much for your bug report.

We have tested your report on the latest 8.0.25 and on that release, it behaves much worse then what you have reported !!! Simply, delimiters are running out, without ever intended to finish. Your simple test case, which causes that our API function mysql_use_result is utilised instead of mysql_store_result, simply runs for ever, without any attempt to finish.

This bug is verified exactly as reported, We have only increased the severity of this bug to "Serious" !!!!!

Thank you !!!!!
[30 Jun 2021 12:13] MySQL Verification Team
Tested with 5.7 and it behaves the same.
[26 Oct 2023 16:39] MySQL Verification Team
Hi,

This turns out not to be a bug.

You are using an expression involving a string and an integer. Hence, a common denominator is required.

A common denominator for these two incompatible types is a floating point number.

This is described in our Reference Manual.

Not a bug.
[22 Nov 2023 11:39] Georgi Kodinov
Posted by developer:
 
Given that this is expected behavior, I'm converting this to a documentation bug to document the issue with mysql -q and large columns. 
I'd strongly suggest considering some of the more modern EXPLAIN formats instead.
[9 Dec 2023 23:48] Jon Stephens
Fixed documentation issue in mysqldoc rev 77454.

Closed.
[11 Dec 2023 11:11] MySQL Verification Team
Thank you, Jon.