summaryrefslogtreecommitdiff
path: root/client/mysqlshow.c
diff options
context:
space:
mode:
authorSinisa@sinisa.nasamreza.org <>2002-11-08 17:02:33 +0200
committerSinisa@sinisa.nasamreza.org <>2002-11-08 17:02:33 +0200
commitd54bb36df7a351eda94ac9d8b5a67beaee6735ac (patch)
tree42bad57cc70f87d297bfbc192838228bcdd1c144 /client/mysqlshow.c
parentaceaf381efc92d32b5109313c472557a1ad6e1d2 (diff)
downloadmariadb-git-d54bb36df7a351eda94ac9d8b5a67beaee6735ac.tar.gz
Changes that will enable proper wildcarding of databases, plus
proper escaping of databases with '_' in their name. More explanations in the manual.
Diffstat (limited to 'client/mysqlshow.c')
-rw-r--r--client/mysqlshow.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 5475fc7b531..0b47e06534f 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -51,6 +51,7 @@ static my_string opt_mysql_unix_port=0;
int main(int argc, char **argv)
{
int error;
+ my_bool first_argument_uses_wildcards=0;
char *wild;
MYSQL mysql;
MY_INIT(argv[0]);
@@ -58,21 +59,37 @@ int main(int argc, char **argv)
get_options(&argc,&argv);
wild=0;
- if (argc && strcont(argv[argc-1],"*?%_"))
+ if (argc)
{
- char *pos;
-
- wild=argv[--argc];
- for (pos=wild ; *pos ; pos++)
- { /* Unix wildcards to sql */
- if (*pos == '*')
- *pos='%';
- else if (*pos == '?')
- *pos='_';
- }
+ char *pos= argv[argc-1], *to;
+ for (to= pos ; *pos ; pos++, to++)
+ {
+ switch (*pos)
+ {
+ case '*':
+ *pos= '%';
+ first_argument_uses_wildcards= 1;
+ break;
+ case '?':
+ *pos= '_';
+ first_argument_uses_wildcards= 1;
+ break;
+ case '%':
+ case '_':
+ first_argument_uses_wildcards= 1;
+ break;
+ case '\\':
+ pos++;
+ default: break;
+ }
+ *to= *pos;
+ }
+ *to= *pos; // just to copy a '\0' if '\\' was used
}
+ if (first_argument_uses_wildcards)
+ wild= argv[--argc];
else if (argc == 3) /* We only want one field */
- wild=argv[--argc];
+ wild= argv[--argc];
if (argc > 2)
{
@@ -88,7 +105,7 @@ int main(int argc, char **argv)
opt_ssl_capath, opt_ssl_cipher);
#endif
if (!(mysql_real_connect(&mysql,host,user,opt_password,
- argv[0],opt_mysql_port,opt_mysql_unix_port,
+ (first_argument_uses_wildcards) ? "" : argv[0],opt_mysql_port,opt_mysql_unix_port,
0)))
{
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));