--- Begin Message ---
- To: submit@bugs.debian.org
- Subject: mytop error when using MySQL ANSI_QUOTES mode: Use of uninitialized value in string ne at /usr/bin/mytop line 1063.
- From: Michael Wood <esiotrot@gmail.com>
- Date: Fri, 6 Jul 2018 12:29:31 +0200
- Message-id: <CAP6d-HX9v=Hmv=fD1Qe+Nad1pvSmu0nAm=u1hu49nA4g7om5RA@mail.gmail.com>
Package: mytop
Version: 1.9.1-4
Perl version: 5.18.2-2ubuntu1.6
I encountered this bug in the Ubuntu package and reported it here:
https://bugs.launchpad.net/bugs/1778745
I have verified that the problem also exists in Debian unstable.
Output when run on a system with sql-mode including ANSI_QUOTES:
MySQL on localhost (5.6.33) load 0.39 0.54 0.58 2/1749 31690 up
124+10:33:39 [10:20:13]
Queries: 6.7M qps: 1 Slow: 107.0 Se/In/Up/De(%):
87/00/11/00
Sorts: 0 qps now: 1 Slow qps: 0.0 Threads: 3 ( 1/ 3)
00/00/00/00
Key Efficiency: 99.9% Bps in/out: 274.6/205.3 Now in/out: 22.6/ 2.4k
Use of uninitialized value in string ne at /usr/bin/mytop line 1063.
ReadOnly
Id User Host/IP DB Time Cmd State Query
-- ---- ------- -- ---- ---
----- ----------
1007 root localhost 0 Query init show f
I'm running MySQL with the following sql-mode in my.cnf:
sql-mode = "STRICT_TRANS_TABLES,ANSI_QUOTES,NO_ENGINE_SUBSTITUTION"
By default MySQL treats single and double quotes interchangeably and
uses backticks for escaping table/column names.
The "ANSI_QUOTES" option causes MySQL to use ANSI standard quoting
(double quotes), so it no longer allows double quotes for string
literals.
Line 1063 of mytop is:
my($data) = Hashes('show global variables like "read_only"');
Attempting to execute that statement results in the following error from MySQL:
mysql> show global variables like "read_only";
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '"read_only"' at line 1
Whereas using single quotes works as expected:
mysql> show global variables like 'read_only';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| read_only | OFF |
+---------------+-------+
1 row in set (0,00 sec)
When MySQL's sql-mode is set to include ANSI_QUOTES mytop spits out
the following in the header:
Use of uninitialized value in string ne at /usr/bin/mytop line 1063.
ReadOnly
Changing line 1063 to use single quotes in the SQL statement sent to
MySQL resolves the problem.
The fix is just to swap the single quotes to double quotes in that
line, and vice versa as in the attached patch.
--
Michael Wood <esiotrot@gmail.com>
Description: fix quoting when in ANSI_QUOTES mode
Author: Michael Wood <esiotrot@gmail.com>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1778745
--- a/mytop
+++ b/mytop
@@ -1059,7 +1059,7 @@ sub GetData()
$lines_left--;
- my($read_only) = Hashes('show global variables like "read_only"');
+ my($read_only) = Hashes("show global variables like 'read_only'");
if ($read_only->{Value} ne "OFF")
{
print RED() if ($HAS_COLOR) ;
--- End Message ---