<?xml version="1.0" encoding="utf-8"?>
<launchpad-bug id="956585">
  <date_last_updated>2012-03-27 13:06:21.670453+00:00</date_last_updated>
  <api_links>
    <bug_api_link>https://api.launchpad.net/1.0/bugs/956585</bug_api_link>
    <bug_owner_link>https://api.launchpad.net/1.0/~wlad-montyprogram</bug_owner_link>
    <milestone_link>https://api.launchpad.net/1.0/maria/+milestone/5.3</milestone_link>
    <linked_branches_collection_link>https://api.launchpad.net/1.0/bugs/956585/linked_branches</linked_branches_collection_link>
    <activity_link>https://api.launchpad.net/1.0/bugs/956585/activity</activity_link>
  </api_links>
  <bug_web_link>https://bugs.launchpad.net/bugs/956585</bug_web_link>
  <owner>Vladislav Vaintroub</owner>
  <assignee>Michael Widenius</assignee>
  <milestone_title>Maria 5.3</milestone_title>
  <duplicate_link></duplicate_link>
  <duplicate_bug_id></duplicate_bug_id>
  <title>Feature request - prevent truncating query in mytop</title>
  <status>Fix Released</status>
  <importance>Wishlist</importance>
  <created>2012-03-16 00:06:35.024232+00:00</created>
  <description>
<![CDATA[Asked by MariaDB user on IRC . He also created a patch for mytop - additional -L option (long queries).]]>  </description>
  <activities>
    <activity datechanged="2012-03-16T00:06:35.024232+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Vladislav Vaintroub</person>
      <message>added bug</message>
    </activity>
    <activity datechanged="2012-03-16T00:07:34.540633+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Patch for -L option https://bugs.launchpad.net/maria/+bug/956585/+attachment/2878494/+files/mytop-fullqueries.diff]]>      </newvalue>
      <whatchanged>attachment added</whatchanged>
      <person>Vladislav Vaintroub</person>
      <message></message>
    </activity>
    <activity datechanged="2012-03-27T11:12:33.434826+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Michael Widenius (monty)]]>      </newvalue>
      <whatchanged>maria: assignee</whatchanged>
      <person>Elena Stepanova</person>
      <message></message>
    </activity>
    <activity datechanged="2012-03-27T12:46:58.099560+00:00">
      <oldvalue>
<![CDATA[New]]>      </oldvalue>
      <newvalue>
<![CDATA[In Progress]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Michael Widenius</person>
      <message></message>
    </activity>
    <activity datechanged="2012-03-27T12:47:05.871199+00:00">
      <oldvalue>
<![CDATA[Undecided]]>      </oldvalue>
      <newvalue>
<![CDATA[Wishlist]]>      </newvalue>
      <whatchanged>maria: importance</whatchanged>
      <person>Michael Widenius</person>
      <message></message>
    </activity>
    <activity datechanged="2012-03-27T12:47:12.344248+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.3]]>      </newvalue>
      <whatchanged>maria: milestone</whatchanged>
      <person>Michael Widenius</person>
      <message></message>
    </activity>
    <activity datechanged="2012-03-27T13:02:19.507321+00:00">
      <oldvalue>
<![CDATA[In Progress]]>      </oldvalue>
      <newvalue>
<![CDATA[Fix Released]]>      </newvalue>
      <whatchanged>maria: status</whatchanged>
      <person>Michael Widenius</person>
      <message></message>
    </activity>
    <activity datechanged="2012-03-27T13:06:16.961471+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[lp:maria]]>      </newvalue>
      <whatchanged>branch linked</whatchanged>
      <person>Launchpad Janitor</person>
      <message></message>
    </activity>
  </activities>
  <comments>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/956585/comments/1" datecreated="2012-03-16T00:07:34.540633+00:00">
      <person>Vladislav Vaintroub</person>
      <subject>
<![CDATA[Re: Feature request - prevent truncating query in mytop]]>      </subject>
      <content>
<![CDATA[]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/956585/comments/2" datecreated="2012-03-16T18:23:18.691454+00:00">
      <person>Jean Weisbuch</person>
      <subject>
<![CDATA[Re: Feature request - prevent truncating query in mytop]]>      </subject>
      <content>
<![CDATA[--- mytop.sh	2012-03-16 00:53:10.418317632 +0100
+++ mytop.sh	2012-03-16 19:20:15.251143868 +0100
@@ -15,6 +15,7 @@
 use 5.005;
 use strict;
 use DBI;
+use Config::IniFiles;
 use Getopt::Long;
 use Socket;
 use List::Util qw(min max);
@@ -75,7 +76,7 @@
 my %config = (
     batchmode     => 0,
     color         => 1,
-    db            => 'test',
+    db            => '',
     delay         => 5,
     filter_user   => qr/.?/,
     filter_db     => qr/.?/,
@@ -113,6 +114,26 @@
 my $RM_RESET   = 0;
 my $RM_NOBLKRD = 3; ## using 4 traps Ctrl-C :-(
 
+## Try ~/.my.cnf first
+
+my $mycnf = "$ENV{HOME}/.my.cnf";
+
+if (-e $mycnf)
+{
+        my $cfgini = new Config::IniFiles( -file => $mycnf );
+        my @sections = ('client', 'mytop');
+
+        foreach my $section (@sections) {
+                foreach my $param ($cfgini->Parameters ($section))
+                {
+                        $config{$param} = $cfgini->val($section, $param) if exists $config{$param};
+                }
+        }
+        ## map database/password onto db/pass (long version gets precedence in .my.cnf)
+        $config{'db'} = $config{'database'} if $config{'database'};
+        $config{'pass'} = $config{'password'} if $config{'password'};
+}
+
 ## Read the user's config file, if it exists.
 
 my $config = "$ENV{HOME}/.mytop";
]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/956585/comments/3" datecreated="2012-03-16T18:25:58.323145+00:00">
      <person>Jean Weisbuch</person>
      <subject>
<![CDATA[Re: Feature request - prevent truncating query in mytop]]>      </subject>
      <content>
<![CDATA[Diff patch on #2 allow mytop to read informations from ~/.my.cnf like it does in Debian and Ubuntu packaged versions of mytop so you can replace it directly without having to create a ~/.mytop file to put your connection parameters for example.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/956585/comments/4" datecreated="2012-03-27T12:48:45.990111+00:00">
      <person>Michael Widenius</person>
      <subject>
<![CDATA[Re: Feature request - prevent truncating query in mytop]]>      </subject>
      <content>
<![CDATA[I have added the original patch to MariaDB 5.3.6
I have added a different patch to read the my.cnf file that relies on my_print_defaults. This way all options files are read, like with all other MariaDB programs.

Thanks for the patches!]]>      </content>
    </comment>
  </comments>
  <branches>
    <branch>lp:maria/5.3</branch>
  </branches>
  <messages>
    <message created="2012-03-16 00:07:34.540633+00:00" owner="Vladislav Vaintroub">
<![CDATA[]]>      <attachment link="https://bugs.launchpad.net/bugs/956585/+attachment/2878494" type="Patch">
        <title>Patch for -L option</title>
        <file>LPexportBug956585_mytop-fullqueries.diff</file>
      </attachment>
    </message>
  </messages>
</launchpad-bug>
