From: Monty Taylor Date: November 17 2000 12:43pm Subject: Re: Show table status List-Archive: http://lists.mysql.com/internals/122 Message-Id: <3A15280B.3F4C6C14@goldridge.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F277981E607F67DC1DF05BF9" --------------F277981E607F67DC1DF05BF9 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit ARRRRRRGH!!!!! I sent the wrong file. Monty Beotel wrote: > On Tue, 14 Nov 2000 16:07:07 +0100, Monty Taylor said: > > > 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 > > > > Thanks a lot for your effort ! > -- > > Regards, > > Sinisa > > ____ __ _____ _____ ___ == MySQL AB > /*/\*\/\*\ /*/ \*\ /*/ \*\ |*| Sinisa Milivojevic > /*/ /*/ /*/ \*\_ |*| |*||*| mailto:sinisa@stripped > /*/ /*/ /*/\*\/*/ \*\|*| |*||*| Larnaka, Cyprus > /*/ /*/ /*/\*\_/*/ \*\_/*/ |*|____ > ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^ > /*/ \*\ Developers Team --------------F277981E607F67DC1DF05BF9 Content-Type: text/plain; charset=us-ascii; name="mysqlshow.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mysqlshow.patch" *** 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,wild))) { 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 *mysql, const 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); --------------F277981E607F67DC1DF05BF9--