mysql5 version Zawodny's patch adding cd and ls commands to the
mysql client
Richard Bronosky
BrunosJunk at Bronosky.com
Wed Apr 16 22:01:10 PDT 2008
Well, it's been 5 months and no one has commented on this. I guess I
should assume that no one has used it, because when I tried to follow
these instructions on my new system I found a few flaws. I'm going to
document it here just to be thorough for when I need to do this again.
Most importantly the patch didn't survive the email very well and
there are a few white space issues that are breaking the patch
command. I was able to read the patch from this email and make the
changes by hand. I then created a new patch file
http://bronosky.com/pub/patch-client-mysql.cc.diff and have attached
it.
Also, step 4 should state:
Use your favorite editor (like vim) to open the file Portfile in that
directory. If the line...
patchfiles \
...exists, add a new line after it like so...
patch-client-mysql.cc.diff \
... otherwise add both lines after
On Wed, Oct 3, 2007 at 4:03 PM, Richard Bronosky
<BrunosJunk at bronosky.com> wrote:
>
> I'd started with his original from
> http://jeremy.zawodny.com/blog/archives/002230.html and updated it to
> work with the 5.0.45 source. I have included the result at the end of
> this email. Here is how you can use it:
> 1. sudo port fetch mysql5
> 2. put the contents of the patch below into a new file called -
> /opt/local/var/macports/sources/rsync.macports.org/release/ports/databases/mysql5/files/patch-client-mysql.cc.diff
> 3. cd /opt/local/var/macports/sources/rsync.macports.org/release/ports/databases/mysql5
> 4. after the "patchfiles \" line add a line with: "
> patch-client-mysql.cc.diff \"
> 5. sudo port patch
> 6. sudo port build
> 7. sudo port install
>
> The patch demonstrates how easy it is to add your own custom commands.
> You really could go crazy tweaking your mysql client.
>
> Enjoy!
>
> --
> .!# RichardBronosky #!.
>
> --- client/mysql.cc.orig 2007-07-04 09:06:09.000000000 -0400
> +++ client/mysql.cc 2007-10-01 17:23:50.000000000 -0400
> @@ -200,6 +200,7 @@
> com_rehash(String *str, char*), com_tee(String *str, char*),
> com_notee(String *str, char*), com_charset(String *str,char*),
> com_prompt(String *str, char*), com_delimiter(String *str, char*),
> + com_ls(String *str, char*),
> com_warnings(String *str, char*), com_nowarnings(String *str, char*);
>
> #ifdef USE_POPEN
> @@ -238,6 +239,7 @@
>
> static COMMANDS commands[] = {
> { "?", '?', com_help, 1, "Synonym for `help'." },
> + { "cd", 'C', com_use, 1, "Synonym for `use'." },
> { "clear", 'c', com_clear, 0, "Clear command."},
> { "connect",'r', com_connect,1,
> "Reconnect to the server. Optional arguments are db and host." },
> @@ -250,6 +252,7 @@
> "Send command to mysql server, display result vertically."},
> { "exit", 'q', com_quit, 0, "Exit mysql. Same as quit."},
> { "go", 'g', com_go, 0, "Send command to mysql server." },
> + { "ls", 'l', com_ls, 0, "List databases or tables." },
> { "help", 'h', com_help, 1, "Display this help." },
> #ifdef USE_POPEN
> { "nopager",'n', com_nopager,0, "Disable pager, print to stdout." },
> @@ -2251,6 +2254,25 @@
> return;
> }
>
> +static int
> +com_ls(String *buffer __attribute__((unused)), char *line)
> +{
> +
> + if (!connected && reconnect())
> + return status.batch ? 1 : -1;
> +
> + if (!current_db)
> + {
> + buffer->set_ascii("SHOW DATABASES", 14);
> + com_go(buffer, 0);
> + }
> + else
> + {
> + buffer->set_ascii("SHOW TABLES", 11);
> + com_go(buffer, 0);
> + }
> + return 0;
> +}
>
> static int
> com_ego(String *buffer,char *line)
>
--
.!# RichardBronosky #!.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-client-mysql.cc.diff
Type: application/octet-stream
Size: 1696 bytes
Desc: not available
Url : http://lists.macosforge.org/pipermail/macports-users/attachments/20080417/b620fdb3/patch-client-mysql.cc.obj
More information about the macports-users
mailing list