Commit 2189e5e7 authored by unknown's avatar unknown

BUG#9391 mysqlshow prints incorrect "rows" information

 - Removed use of mysql->extra_info
 - Removed unused function send_records_num


VC++Files/winmysqladmin/mysql.h:
  Comment extra_info as not used anymore
client/mysqlshow.c:
  Remove use of extra info. Instead read number of records in table using SELECT COUNT(*)
include/mysql.h:
  Comment extra_info as not used anymore
libmysqld/lib_sql.cc:
  Removed unused function send_records_num
sql-common/client.c:
  Remove use of extra_info since number of records is not sent in the protocol anymore
sql/protocol.cc:
  Removed unused function send_records_num
sql/protocol.h:
  Removed unused function send_records_num
parent 5630f073
...@@ -145,7 +145,7 @@ typedef struct st_mysql { ...@@ -145,7 +145,7 @@ typedef struct st_mysql {
unsigned long thread_id; /* Id for connection in server */ unsigned long thread_id; /* Id for connection in server */
my_ulonglong affected_rows; my_ulonglong affected_rows;
my_ulonglong insert_id; /* id if insert on table with NEXTNR */ my_ulonglong insert_id; /* id if insert on table with NEXTNR */
my_ulonglong extra_info; /* Used by mysqlshow */ my_ulonglong extra_info; /* Not used */
unsigned long packet_length; unsigned long packet_length;
enum mysql_status status; enum mysql_status status;
MYSQL_FIELD *fields; MYSQL_FIELD *fields;
......
...@@ -611,6 +611,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table, ...@@ -611,6 +611,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
char query[1024],*end; char query[1024],*end;
MYSQL_RES *result; MYSQL_RES *result;
MYSQL_ROW row; MYSQL_ROW row;
ulong rows;
if (mysql_select_db(mysql,db)) if (mysql_select_db(mysql,db))
{ {
...@@ -618,6 +619,17 @@ list_fields(MYSQL *mysql,const char *db,const char *table, ...@@ -618,6 +619,17 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
mysql_error(mysql)); mysql_error(mysql));
return 1; return 1;
} }
sprintf(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",
my_progname,db,table,mysql_error(mysql));
return 1;
}
row = mysql_fetch_row(result);
rows = (ulong) strtoull(row[0], (char**) 0, 10);
mysql_free_result(result);
end=strmov(strmov(strmov(query,"show /*!32332 FULL */ columns from `"),table),"`"); end=strmov(strmov(strmov(query,"show /*!32332 FULL */ columns from `"),table),"`");
if (wild && wild[0]) if (wild && wild[0])
strxmov(end," like '",wild,"'",NullS); strxmov(end," like '",wild,"'",NullS);
...@@ -628,8 +640,8 @@ list_fields(MYSQL *mysql,const char *db,const char *table, ...@@ -628,8 +640,8 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
return 1; return 1;
} }
printf("Database: %s Table: %s Rows: %lu", db,table, printf("Database: %s Table: %s Rows: %lu", db, table, rows);
(ulong) mysql->extra_info);
if (wild && wild[0]) if (wild && wild[0])
printf(" Wildcard: %s",wild); printf(" Wildcard: %s",wild);
putchar('\n'); putchar('\n');
......
...@@ -231,7 +231,7 @@ typedef struct st_mysql ...@@ -231,7 +231,7 @@ typedef struct st_mysql
MEM_ROOT field_alloc; MEM_ROOT field_alloc;
my_ulonglong affected_rows; my_ulonglong affected_rows;
my_ulonglong insert_id; /* id if insert on table with NEXTNR */ my_ulonglong insert_id; /* id if insert on table with NEXTNR */
my_ulonglong extra_info; /* Used by mysqlshow */ my_ulonglong extra_info; /* Not used */
unsigned long thread_id; /* Id for connection in server */ unsigned long thread_id; /* Id for connection in server */
unsigned long packet_length; unsigned long packet_length;
unsigned int port; unsigned int port;
......
...@@ -709,11 +709,6 @@ bool Protocol::send_fields(List<Item> *list, uint flags) ...@@ -709,11 +709,6 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
DBUG_RETURN(1); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */
} }
bool Protocol::send_records_num(List<Item> *list, ulonglong records)
{
return false;
}
bool Protocol::write() bool Protocol::write()
{ {
if (!thd->mysql) // bootstrap file handling if (!thd->mysql) // bootstrap file handling
......
...@@ -2446,8 +2446,6 @@ get_info: ...@@ -2446,8 +2446,6 @@ get_info:
if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT)) if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT))
mysql->server_status|= SERVER_STATUS_IN_TRANS; mysql->server_status|= SERVER_STATUS_IN_TRANS;
mysql->extra_info= net_field_length_ll(&pos); /* Maybe number of rec */
if (!(fields=(*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*)0, if (!(fields=(*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*)0,
protocol_41(mysql) ? 7 : 5))) protocol_41(mysql) ? 7 : 5)))
DBUG_RETURN(1); DBUG_RETURN(1);
......
...@@ -645,16 +645,6 @@ err: ...@@ -645,16 +645,6 @@ err:
} }
bool Protocol::send_records_num(List<Item> *list, ulonglong records)
{
char *pos;
char buff[20];
pos=net_store_length(buff, (uint) list->elements);
pos=net_store_length(pos, records);
return my_net_write(&thd->net, buff,(uint) (pos-buff));
}
bool Protocol::write() bool Protocol::write()
{ {
DBUG_ENTER("Protocol::write"); DBUG_ENTER("Protocol::write");
......
...@@ -54,7 +54,6 @@ public: ...@@ -54,7 +54,6 @@ public:
enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 }; enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
virtual bool send_fields(List<Item> *list, uint flags); virtual bool send_fields(List<Item> *list, uint flags);
bool send_records_num(List<Item> *list, ulonglong records);
bool store(I_List<i_string> *str_list); bool store(I_List<i_string> *str_list);
bool store(const char *from, CHARSET_INFO *cs); bool store(const char *from, CHARSET_INFO *cs);
String *storage_packet() { return packet; } String *storage_packet() { return packet; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment