mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge branch '5.5' into 10.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2012, Monty Program Ab
|
||||
Copyright (c) 2000, 2015, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2015, MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -382,7 +382,7 @@ list_dbs(MYSQL *mysql,const char *wild)
|
||||
uint length, counter = 0;
|
||||
ulong rowcount = 0L;
|
||||
char tables[NAME_LEN+1], rows[NAME_LEN+1];
|
||||
char query[255];
|
||||
char query[NAME_LEN + 100];
|
||||
MYSQL_FIELD *field;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row= NULL, rrow;
|
||||
@@ -449,7 +449,8 @@ list_dbs(MYSQL *mysql,const char *wild)
|
||||
MYSQL_ROW trow;
|
||||
while ((trow = mysql_fetch_row(tresult)))
|
||||
{
|
||||
sprintf(query,"SELECT COUNT(*) FROM `%s`",trow[0]);
|
||||
my_snprintf(query, sizeof(query),
|
||||
"SELECT COUNT(*) FROM `%s`", trow[0]);
|
||||
if (!(mysql_query(mysql,query)))
|
||||
{
|
||||
MYSQL_RES *rresult;
|
||||
@@ -505,7 +506,7 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
|
||||
{
|
||||
const char *header;
|
||||
uint head_length, counter = 0;
|
||||
char query[255], rows[NAME_LEN], fields[16];
|
||||
char query[NAME_LEN + 100], rows[NAME_LEN], fields[16];
|
||||
MYSQL_FIELD *field;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row, rrow;
|
||||
@@ -590,7 +591,8 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
|
||||
if (opt_verbose > 1)
|
||||
{
|
||||
/* Print the count of rows for each table */
|
||||
sprintf(query,"SELECT COUNT(*) FROM `%s`",row[0]);
|
||||
my_snprintf(query, sizeof(query), "SELECT COUNT(*) FROM `%s`",
|
||||
row[0]);
|
||||
if (!(mysql_query(mysql,query)))
|
||||
{
|
||||
if ((rresult = mysql_store_result(mysql)))
|
||||
@@ -650,13 +652,15 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
|
||||
static int
|
||||
list_table_status(MYSQL *mysql,const char *db,const char *wild)
|
||||
{
|
||||
char query[1024],*end;
|
||||
char query[NAME_LEN + 100];
|
||||
int len;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
end=strxmov(query,"show table status from `",db,"`",NullS);
|
||||
if (wild && wild[0])
|
||||
strxmov(end," like '",wild,"'",NullS);
|
||||
len= sizeof(query);
|
||||
len-= my_snprintf(query, len, "show table status from `%s`", db);
|
||||
if (wild && wild[0] && len)
|
||||
strxnmov(query + strlen(query), len, " 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",
|
||||
@@ -688,7 +692,8 @@ static int
|
||||
list_fields(MYSQL *mysql,const char *db,const char *table,
|
||||
const char *wild)
|
||||
{
|
||||
char query[1024],*end;
|
||||
char query[NAME_LEN + 100];
|
||||
int len;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
ulong UNINIT_VAR(rows);
|
||||
@@ -702,7 +707,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
|
||||
|
||||
if (opt_count)
|
||||
{
|
||||
sprintf(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",
|
||||
@@ -714,9 +719,11 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
|
||||
mysql_free_result(result);
|
||||
}
|
||||
|
||||
end=strmov(strmov(strmov(query,"show /*!32332 FULL */ columns from `"),table),"`");
|
||||
if (wild && wild[0])
|
||||
strxmov(end," like '",wild,"'",NullS);
|
||||
len= sizeof(query);
|
||||
len-= my_snprintf(query, len, "show /*!32332 FULL */ columns from `%s`",
|
||||
table);
|
||||
if (wild && wild[0] && len)
|
||||
strxnmov(query + strlen(query), len, " like '", wild, "'", NullS);
|
||||
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
|
||||
{
|
||||
fprintf(stderr,"%s: Cannot list columns in db: %s, table: %s: %s\n",
|
||||
@@ -737,7 +744,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
|
||||
print_res_top(result);
|
||||
if (opt_show_keys)
|
||||
{
|
||||
end=strmov(strmov(strmov(query,"show keys from `"),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",
|
||||
|
Reference in New Issue
Block a user