Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-07-21 20:29:25-07:00, jimw@rama.(none) +3 -0
Bug #19147: mysqlshow INFORMATION_SCHEMA does not work
When a wildcard database name is given the mysqlshow, but that wildcard
matches one database *exactly* (it contains the wildcard character), we
list the contents of that database instead of just listing the database
name as matching the wildcard. Probably the most common instance of users
encountering this behavior would be with "mysqlshow information_schema".
client/mysqlshow.c@stripped, 2006-07-21 20:29:23-07:00, jimw@rama.(none) +25 -2
Add special handling for listing a single database that has a name that
looked like it contained wildcards. In this case, we just go ahead and list
the contents of the database, since there is a very high probability that is
what the user really wanted to do. (For example, 'mysqlshow INFORMATION_SCHEMA'
will show the I_S tables instead of just the I_S database.)
mysql-test/r/mysqlshow.result@stripped, 2006-07-21 20:29:23-07:00, jimw@rama.(none) +49 -0
Add new results
mysql-test/t/mysqlshow.test@stripped, 2006-07-21 20:29:23-07:00, jimw@rama.(none) +9 -0
Add new regression test
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: jimw
# Host: rama.(none)
# Root: /home/jimw/my/mysql-5.0-19147
--- 1.48/client/mysqlshow.c 2006-07-21 20:29:28 -07:00
+++ 1.49/client/mysqlshow.c 2006-07-21 20:29:28 -07:00
@@ -344,7 +344,7 @@ list_dbs(MYSQL *mysql,const char *wild)
char query[255];
MYSQL_FIELD *field;
MYSQL_RES *result;
- MYSQL_ROW row, rrow;
+ MYSQL_ROW row= NULL, rrow;
if (!(result=mysql_list_dbs(mysql,wild)))
{
@@ -352,6 +352,26 @@ list_dbs(MYSQL *mysql,const char *wild)
mysql_error(mysql));
return 1;
}
+
+ /*
+ If a wildcard was used, but there was only one row and it's name is an
+ exact match, we'll assume they really wanted to see the contents of that
+ database. This is because it is fairly common for database names to
+ contain the underscore (_), like INFORMATION_SCHEMA.
+ */
+ if (wild && mysql_num_rows(result) == 1)
+ {
+ row= mysql_fetch_row(result);
+ if (!my_strcasecmp(&my_charset_latin1, row[0], wild))
+ {
+ mysql_free_result(result);
+ if (opt_status)
+ return list_table_status(mysql, wild, NULL);
+ else
+ return list_tables(mysql, wild, NULL);
+ }
+ }
+
if (wild)
printf("Wildcard: %s\n",wild);
@@ -368,7 +388,8 @@ list_dbs(MYSQL *mysql,const char *wild)
else
print_header(header,length,"Tables",6,"Total Rows",12,NullS);
- while ((row = mysql_fetch_row(result)))
+ /* The first row may have already been read up above. */
+ while (row || (row= mysql_fetch_row(result)))
{
counter++;
@@ -422,6 +443,8 @@ list_dbs(MYSQL *mysql,const char *wild)
print_row(row[0],length,tables,6,NullS);
else
print_row(row[0],length,tables,6,rows,12,NullS);
+
+ row= NULL;
}
print_trailer(length,
--- 1.3/mysql-test/r/mysqlshow.result 2006-07-21 20:29:28 -07:00
+++ 1.4/mysql-test/r/mysqlshow.result 2006-07-21 20:29:28 -07:00
@@ -75,3 +75,52 @@ Database: test
2 rows in set.
DROP TABLE t1, t2;
+Database: information_schema
++---------------------------------------+
+| Tables |
++---------------------------------------+
+| CHARACTER_SETS |
+| COLLATIONS |
+| COLLATION_CHARACTER_SET_APPLICABILITY |
+| COLUMNS |
+| COLUMN_PRIVILEGES |
+| KEY_COLUMN_USAGE |
+| ROUTINES |
+| SCHEMATA |
+| SCHEMA_PRIVILEGES |
+| STATISTICS |
+| TABLES |
+| TABLE_CONSTRAINTS |
+| TABLE_PRIVILEGES |
+| TRIGGERS |
+| USER_PRIVILEGES |
+| VIEWS |
++---------------------------------------+
+Database: INFORMATION_SCHEMA
++---------------------------------------+
+| Tables |
++---------------------------------------+
+| CHARACTER_SETS |
+| COLLATIONS |
+| COLLATION_CHARACTER_SET_APPLICABILITY |
+| COLUMNS |
+| COLUMN_PRIVILEGES |
+| KEY_COLUMN_USAGE |
+| ROUTINES |
+| SCHEMATA |
+| SCHEMA_PRIVILEGES |
+| STATISTICS |
+| TABLES |
+| TABLE_CONSTRAINTS |
+| TABLE_PRIVILEGES |
+| TRIGGERS |
+| USER_PRIVILEGES |
+| VIEWS |
++---------------------------------------+
+Wildcard: inf_rmation_schema
++--------------------+
+| Databases |
++--------------------+
+| information_schema |
++--------------------+
+End of 5.0 tests
--- 1.4/mysql-test/t/mysqlshow.test 2006-07-21 20:29:28 -07:00
+++ 1.5/mysql-test/t/mysqlshow.test 2006-07-21 20:29:28 -07:00
@@ -25,3 +25,12 @@ select "---- -v -t ---------" as "";
select "---- -v -v -t ------" as "";
--exec $MYSQL_SHOW test -v -v -t
DROP TABLE t1, t2;
+
+#
+# Bug #19147: mysqlshow INFORMATION_SCHEMA does not work
+#
+--exec $MYSQL_SHOW information_schema
+--exec $MYSQL_SHOW INFORMATION_SCHEMA
+--exec $MYSQL_SHOW inf_rmation_schema
+
+--echo End of 5.0 tests
| Thread |
|---|
| • bk commit into 5.0 tree (jimw:1.2207) BUG#19147 | Jim Winstead | 22 Jul |