List:Internals« Previous MessageNext Message »
From:Monty Taylor Date:November 14 2000 3:07pm
Subject:Show table status
View as plain text  
Hello guys,
Here's a patch I made, for what it's worth, that adds a C-API function
for extended table info, similar to mysql_show_tables. This is patched
from 3.23.27, but I don't imagine that should make much of a difference.

I did this because I'm working on an adapter for Zope that needs to call
'show table status' as part of it's functionality, and it seemed all the
similar commands had API functions. I also patched mysqlshow.c to use
the API rather than create the SQL directly.

Please let me know if there is an overall design reason why this
shouldn't be.

Thanks.
Mordred

*** mysql.orig/client/mysqlshow.c	Tue Nov 14 15:37:31 2000
--- mysql.curr/client/mysqlshow.c	Tue Nov 14 15:38:19 2000
***************
*** 347,360 ****
  static int
  list_table_status(MYSQL *mysql,const char *db,const char *wild)
  {
!   char query[1024],*end;
    MYSQL_RES *result;
    MYSQL_ROW row;
  
!   end=strxmov(query,"show table status from ",db,NullS);
!   if (wild && wild[0])
!     strxmov(end," 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));
--- 347,357 ----
  static int
  list_table_status(MYSQL *mysql,const char *db,const char *wild)
  {
!   char query[1024];
    MYSQL_RES *result;
    MYSQL_ROW row;
  
!   if (!(result=mysql_list_table_status(mysql,db,table)))
    {
      fprintf(stderr,"%s: Cannot get status for db: %s, table: %s: %s\n",
  	    my_progname,db,wild ? wild : "",mysql_error(mysql));
*** mysql.orig/libmysql/libmysql.c	Tue Nov 14 15:37:44 2000
--- mysql.curr/libmysql/libmysql.c	Tue Nov 14 15:38:13 2000
***************
*** 2052,2057 ****
--- 2052,2074 ----
  }
  
  
+ /*****************************************************************************
+  * ** List extended table information
+  * *****************************************************************************/
+ 
+ MYSQL_RES * STDCALL
+ mysql_list_table_status(MYSQL *mysqlconst, char *db,const char *wild)
+ {
+   char buff[255];
+   DBUG_ENTER("mysql_list_table_status");
+ 
+   append_wild(strxmov(buff,"show table status from ",db,NullS),buff+sizeof(buff),wild);
+ 
+   if (mysql_query(mysql,buff))
+     DBUG_RETURN(0);
+   DBUG_RETURN (mysql_store_result(mysql));
+ }
+ 
  /**************************************************************************
  ** List all fields in a table
  ** If wild is given then only the fields matching wild is returned
*** mysql.orig/include/mysql.h	Tue Nov 14 15:56:54 2000
--- mysql.curr/include/mysql.h	Tue Nov 14 15:59:07 2000
***************
*** 246,251 ****
--- 246,253 ----
  unsigned int	STDCALL mysql_get_proto_info(MYSQL *mysql);
  MYSQL_RES *	STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
  MYSQL_RES *	STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
+ MYSQL_RES *	STDCALL mysql_list_table_status(MYSQL *mysql, const char *db,
+ 					 const char *wild);
  MYSQL_RES *	STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
  					 const char *wild);
  MYSQL_RES *	STDCALL mysql_list_processes(MYSQL *mysql);

Thread
Show table statusMonty Taylor14 Nov
  • Re: Show table statusMonty Taylor16 Nov
  • Re: Show table statusMonty Taylor16 Nov
  • Re: Show table statusMonty Taylor17 Nov
  • Re: Show table statusMonty Taylor17 Nov