Just to add support for this request as simple things like using -N to suppress column headings is not possible once at the mysql prompt. Created attachment 40322 [details] [review] Bug 12372: koha-mysql: process any mysql args Created attachment 40323 [details] [review] Bug 12372: koha-mysql: process any mysql args Created attachment 40379 [details] [review] Bug 12372: koha-mysql: process any mysql args Signed-off-by: Ian Bays <ian.bays@ptfs-europe.com> I am not an expert at all of the debian scripts, but it seems that in others, there are 2 errors raised if the usage is incorrect: I would suggest to die "Missing instance name..." if the number of arg is not correct and warn "Unknown instance $name." if is_instance returns 0. Ccing Tomas to be sure I am not wrong. (In reply to Jonathan Druart from comment #5) > I am not an expert at all of the debian scripts, but it seems that in > others, there are 2 errors raised if the usage is incorrect: > > > I would suggest to > die "Missing instance name..." > if the number of arg is not correct and > warn "Unknown instance $name." > if is_instance returns 0. > > Ccing Tomas to be sure I am not wrong. Yeah, Barton, please replicate the structure from scripts like koha-enable while you are on it. Thanks Created attachment 40526 [details] [review] Standardized argument parsing for koha-mysql. Created attachment 40527 [details] [review] Bug 12372: (QA followup) Standardized argument parsing for koha-mysql. (In reply to Jonathan Druart from comment #5) > I am not an expert at all of the debian scripts, but it seems that in > others, there are 2 errors raised if the usage is incorrect: > > > I would suggest to > die "Missing instance name..." > if the number of arg is not correct and > warn "Unknown instance $name." > if is_instance returns 0. > > Ccing Tomas to be sure I am not wrong. Ok, I've followed the convention set by koha-enable as closely as possible. In the context of the script, it didn't make sense to have the "Unknown instance" message be a warning. We're only processing a single instance, and if we don't die when we get a bad instance name, we'll get all of the calls to xmlstartlet and the call to mysql throwing confusing messages to stderr, and the script will fail anyway. Comment on attachment 40526 [details] [review] Standardized argument parsing for koha-mysql. This should have been obsoleted by the following patch. Comment on attachment 40379 [details] [review] Bug 12372: koha-mysql: process any mysql args Was accidentally obsoleted -- reversing. Update koha-mysql man page: bug 14443 TODO:
Update
debian/docs/koha-mysql.xml:
The synopsis should change to
koha-mysql INSTANCE-NAME [ mysql arguments ]
Also, the '-e' option is now available, so the example usage may change to
koha-mysql {instancename} -e "Some SQL query"
It would also be useful to provide an explicit example of a mysql argument whose functionality was previously entirely unavailable, e.g.
koha-mysql {instancename} --skip-column-names
'See Also' should mention mysql.
*** Bug 14443 has been marked as a duplicate of this bug. *** Created attachment 41243 [details] [review] Updated man pages for koha-mysql Updated man page:
KOHA-MYSQL(8)
NAME
koha-mysql - Provide a mysql shell set up for the specified Koha instance.
SYNOPSIS
koha-mysql {instancename} [mysql option...]
DESCRIPTION
Provide a mysql shell set up for the specified Koha instance.
EXAMPLE USAGE
Run interactive mysql shell for speicified Koha instance
koha-mysql {instancename}
Run a query given as an argument without launching mysql shell
koha-mysql {instancename} -e "SOME SQL QUERY"
Run a query, skip column names on output
koha-mysql {instancename} -e "SOME SQL QUERY" --skip-column-names
Load a database dump (e.g. one produced by mysqldump) into the database of the given instance
koha-mysql {instancename} < /path/to/mysqldump.sql
SEE ALSO
mysql (1), koha-dump-defaults(8), koha-reset-passwd(8), koha-upgrade-schema(8)
Created attachment 41244 [details] [review] Updated man pages for koha-mysql http://bugs.koha-community.org/show_bug.cgi?id=12372 Signed-off-by: Liz Rea <liz@catalyst.net.nz> Created attachment 41245 [details] [review] Bug 12372: koha-mysql: process any mysql args Signed-off-by: Ian Bays <ian.bays@ptfs-europe.com> Signed-off-by: Liz Rea <liz@catalyst.net.nz> Created attachment 41246 [details] [review] Bug 12372: (QA followup) Standardized argument parsing for koha-mysql. http://bugs.koha-community.org/show_bug.cgi?id=12372 Signed-off-by: Liz Rea <liz@catalyst.net.nz> Created attachment 41247 [details] [review] Updated man pages for koha-mysql http://bugs.koha-community.org/show_bug.cgi?id=12372 Signed-off-by: Liz Rea <liz@catalyst.net.nz> Created attachment 41366 [details] [review] Bug 12372: koha-mysql: process any mysql args Signed-off-by: Ian Bays <ian.bays@ptfs-europe.com> Signed-off-by: Liz Rea <liz@catalyst.net.nz> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Created attachment 41367 [details] [review] Bug 12372: (QA followup) Standardized argument parsing for koha-mysql. http://bugs.koha-community.org/show_bug.cgi?id=12372 Signed-off-by: Liz Rea <liz@catalyst.net.nz> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Created attachment 41368 [details] [review] Updated man pages for koha-mysql http://bugs.koha-community.org/show_bug.cgi?id=12372 Signed-off-by: Liz Rea <liz@catalyst.net.nz> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Patch pushed to master. Thanks Barton! |
The call to 'mysql' in /home/koha/kohaclone/debian/scripts/koha-mysql looks like this: mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpass" \ "$mysqldb" If $name were shifted off the argument stack, rather than simply assigned from $1, we could then pass the rest of the arguments directly to mysql: mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpass" \ "$mysqldb" "$@" This would make the koha-mysql command far more flexible at the command line, for instance koha-mysql mybranch --vertical or koha-mysql mybranch --html or koha-mysql mybranch --table would all be possible.