mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-40311 also fix mariadb-show and mariadb-convert-table-format
This commit is contained in:
@@ -477,7 +477,7 @@ list_dbs(MYSQL *mysql,const char *wild)
|
||||
while ((trow = mysql_fetch_row(tresult)))
|
||||
{
|
||||
my_snprintf(query, sizeof(query),
|
||||
"SELECT COUNT(*) FROM `%s`", trow[0]);
|
||||
"SELECT COUNT(*) FROM %`s", trow[0]);
|
||||
if (!(mysql_query(mysql,query)))
|
||||
{
|
||||
MYSQL_RES *rresult;
|
||||
@@ -619,7 +619,7 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
|
||||
if (opt_verbose > 1)
|
||||
{
|
||||
/* Print the count of rows for each table */
|
||||
my_snprintf(query, sizeof(query), "SELECT COUNT(*) FROM `%s`",
|
||||
my_snprintf(query, sizeof(query), "SELECT COUNT(*) FROM %`s",
|
||||
row[0]);
|
||||
if (!(mysql_query(mysql,query)))
|
||||
{
|
||||
@@ -686,15 +686,13 @@ list_table_status(MYSQL *mysql,const char *db,const char *wild)
|
||||
MYSQL_ROW row;
|
||||
|
||||
len= sizeof(query);
|
||||
len-= my_snprintf(query, len, "show table status from `%s`", db);
|
||||
len-= my_snprintf(query, len, "show table status from %`s", db);
|
||||
if (wild && wild[0] && len)
|
||||
strxnmov(query + strlen(query), len - 1, " like '", wild, "'", NullS);
|
||||
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
|
||||
{
|
||||
fprintf(stderr,"%s: Cannot get status for db: %s, table: %s: %s\n",
|
||||
my_progname,db,wild ? wild : "",mysql_error(mysql));
|
||||
if (mysql_errno(mysql) == ER_PARSE_ERROR)
|
||||
fprintf(stderr,"This error probably means that your MariaDB server doesn't support the\n\'show table status' command.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -735,7 +733,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
|
||||
|
||||
if (opt_count)
|
||||
{
|
||||
my_snprintf(query, sizeof(query), "select count(*) from `%s`", table);
|
||||
my_snprintf(query, sizeof(query), "select count(*) from %`s", table);
|
||||
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
|
||||
{
|
||||
fprintf(stderr,"%s: Cannot get record count for db: %s, table: %s: %s\n",
|
||||
@@ -748,7 +746,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
|
||||
}
|
||||
|
||||
len= sizeof(query);
|
||||
len-= my_snprintf(query, len, "show /*!32332 FULL */ columns from `%s`",
|
||||
len-= my_snprintf(query, len, "show /*!32332 FULL */ columns from %`s",
|
||||
table);
|
||||
if (wild && wild[0] && len)
|
||||
strxnmov(query + strlen(query), len - 1, " like '", wild, "'", NullS);
|
||||
@@ -770,9 +768,10 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
|
||||
while ((row=mysql_fetch_row(result)))
|
||||
print_res_row(result,row);
|
||||
print_res_top(result);
|
||||
mysql_free_result(result);
|
||||
if (opt_show_keys)
|
||||
{
|
||||
my_snprintf(query, sizeof(query), "show keys from `%s`", table);
|
||||
my_snprintf(query, sizeof(query), "show keys from %`s", table);
|
||||
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
|
||||
{
|
||||
fprintf(stderr,"%s: Cannot list keys in db: %s, table: %s: %s\n",
|
||||
|
||||
@@ -75,4 +75,39 @@ Database: test
|
||||
2 rows in set.
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
End of 5.0 tests
|
||||
# End of 5.0 tests
|
||||
create table `t``1` (a int);
|
||||
insert `t``1` values (1),(2),(3),(4),(5);
|
||||
Database: test
|
||||
+--------+----------+------------+
|
||||
| Tables | Columns | Total Rows |
|
||||
+--------+----------+------------+
|
||||
| t`1 | 1 | 5 |
|
||||
+--------+----------+------------+
|
||||
1 row in set.
|
||||
|
||||
Database: test Table: t`1 Rows: 5
|
||||
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
|
||||
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
|
||||
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
|
||||
| a | int(11) | | YES | | | | select,insert,update,references | |
|
||||
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
|
||||
Table has no keys
|
||||
drop table `t``1`;
|
||||
create schema `d``b`;
|
||||
create table `d``b`.`t``2` (a int);
|
||||
insert `d``b`.`t``2` values (1),(2),(3),(4),(5),(6),(7);
|
||||
Wildcard: d%
|
||||
+-----------+--------+--------------+
|
||||
| Databases | Tables | Total Rows |
|
||||
+-----------+--------+--------------+
|
||||
| d`b | 1 | 7 |
|
||||
+-----------+--------+--------------+
|
||||
1 row in set.
|
||||
Database: d`b
|
||||
+------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+------------------+-----------+
|
||||
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | Max_index_length | Temporary |
|
||||
+------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+------------------+-----------+
|
||||
| t`2 | MyISAM | # | Fixed | 7 | 7 | # | # | # | 0 | | #-#-# #:#:# | #-#-# #:#:# | | latin1_swedish_ci | | | | # | N |
|
||||
+------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+------------------+-----------+
|
||||
drop schema `d``b`;
|
||||
|
||||
@@ -26,7 +26,7 @@ select "---- -v -v -t ------" as "";
|
||||
--exec $MYSQL_SHOW test -v -v -t
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
--echo # End of 5.0 tests
|
||||
|
||||
# because of lp:1066512 this test shows xtradb I_S plugins, even when
|
||||
# xtradb is supposed to be disabled
|
||||
@@ -38,3 +38,16 @@ DROP TABLE t1, t2;
|
||||
#--exec $MYSQL_SHOW INFORMATION_SCHEMA
|
||||
#--exec $MYSQL_SHOW inf_rmation_schema
|
||||
|
||||
create table `t``1` (a int);
|
||||
insert `t``1` values (1),(2),(3),(4),(5);
|
||||
--exec $MYSQL_SHOW test -v -v
|
||||
--exec $MYSQL_SHOW test t\`1 -k --count
|
||||
drop table `t``1`;
|
||||
|
||||
create schema `d``b`;
|
||||
create table `d``b`.`t``2` (a int);
|
||||
insert `d``b`.`t``2` values (1),(2),(3),(4),(5),(6),(7);
|
||||
--exec $MYSQL_SHOW "d*" -v -v
|
||||
--replace_regex /\d\d+/#/
|
||||
--exec $MYSQL_SHOW d\`b -v -v -i
|
||||
drop schema `d``b`;
|
||||
|
||||
@@ -93,8 +93,8 @@ foreach $table (@tables)
|
||||
my ($sth,$row);
|
||||
|
||||
# Check if table is already converted
|
||||
$sth=$dbh->prepare("show table status like '$table'");
|
||||
if ($sth->execute && ($row = $sth->fetchrow_arrayref))
|
||||
$sth=$dbh->prepare("show table status like ?");
|
||||
if ($sth->execute($table) && ($row = $sth->fetchrow_arrayref))
|
||||
{
|
||||
if (uc($row->[1]) eq uc($opt_engine))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user