From c4d0901d00bdeb496aeffedc80e6d583711086d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Nov 2007 18:59:25 +0300 Subject: Fix for bug #32221: bug25714, mytest, mysql_client_test complaints and crashes. MySQL distributions contain a number of programs that are used only by the MySQL test suite internally, i.e. they are not indended to be invoked directly by a user. As a result, such programs are not documented, do not have any built-in help or proper error reporting, which may confuse users. This patch fixes the problem with the following changes: - mytest, libmysqltest and all references to them were removed from the distribution since they are not used anymore - bug25714 now displays an error message when run with incorrect arguments or with the --help option - mysql_client_test now does not call abort() in case of errors, instead it does a clean exit() with a proper error status. BitKeeper/deleted/.del-mytest.c: Delete: libmysql/mytest.c BitKeeper/deleted/.del-myTest-package.dsp: Delete: VC++Files/libmysqltest/myTest-package.dsp BitKeeper/deleted/.del-myTest-package_ia64.dsp: Delete: VC++Files/libmysqltest/myTest-package_ia64.dsp BitKeeper/deleted/.del-myTest.dsp~4a8c480769193952: Delete: VC++Files/libmysqltest/myTest.dsp BitKeeper/deleted/.del-myTest.vcproj: Delete: VC++Files/libmysqltest/myTest.vcproj BitKeeper/deleted/.del-myTest_ia64.dsp: Delete: VC++Files/libmysqltest/myTest_ia64.dsp BitKeeper/deleted/.del-mytest.c~9a99338689e5de8: Delete: VC++Files/libmysqltest/mytest.c BitKeeper/deleted/.del-mytest.dsw~2324698861155335: Delete: VC++Files/libmysqltest/mytest.dsw VC++Files/copy_mysql_files.bat: Removed references to libmysqltest. libmysql/CMakeLists.txt: Removed rules for myTest. libmysql/Makefile.am: Removed mytest.c from EXTRA_DIST. tests/bug25714.c: Display a meaningful error message when run incorrectly or with the --help option. tests/mysql_client_test.c: In case of error, don't cause abnormal program termination, do a clean exit() with an error status. --- libmysql/CMakeLists.txt | 3 - libmysql/Makefile.am | 2 +- libmysql/mytest.c | 175 ------------------------------------------------ 3 files changed, 1 insertion(+), 179 deletions(-) delete mode 100644 libmysql/mytest.c (limited to 'libmysql') diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 59e70d68a6d..7de504aa2f0 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -125,9 +125,6 @@ TARGET_LINK_LIBRARIES(mysqlclient) ADD_DEPENDENCIES(mysqlclient_notls GenError) TARGET_LINK_LIBRARIES(mysqlclient_notls) -ADD_EXECUTABLE(myTest mytest.c) -TARGET_LINK_LIBRARIES(myTest libmysql) - IF(EMBED_MANIFESTS) MYSQL_EMBED_MANIFEST("myTest" "asInvoker") ENDIF(EMBED_MANIFESTS) diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 38680c98d53..13497331683 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -31,7 +31,7 @@ include $(srcdir)/Makefile.shared libmysqlclient_la_SOURCES = $(target_sources) libmysqlclient_la_LIBADD = $(target_libadd) $(yassl_las) libmysqlclient_la_LDFLAGS = $(target_ldflags) -EXTRA_DIST = Makefile.shared libmysql.def dll.c mytest.c CMakeLists.txt +EXTRA_DIST = Makefile.shared libmysql.def dll.c CMakeLists.txt noinst_HEADERS = client_settings.h # This is called from the toplevel makefile diff --git a/libmysql/mytest.c b/libmysql/mytest.c deleted file mode 100644 index 2d5c576b72a..00000000000 --- a/libmysql/mytest.c +++ /dev/null @@ -1,175 +0,0 @@ -/*C4*/ -/****************************************************************/ -/* Author: Jethro Wright, III TS : 3/ 4/1998 9:15 */ -/* Date: 02/18/1998 */ -/* mytest.c : do some testing of the libmySQL.DLL.... */ -/* */ -/* History: */ -/* 02/18/1998 jw3 also sprach zarathustra.... */ -/****************************************************************/ - - -#include -#include -#include - -#include - -#define DEFALT_SQL_STMT "SELECT * FROM db" -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - - -/******************************************************** -** -** main :- -** -********************************************************/ - -int -main( int argc, char * argv[] ) -{ - - char szSQL[ 200 ], aszFlds[ 25 ][ 25 ], szDB[ 50 ] ; - const char *pszT; - int i, j, k, l, x ; - MYSQL * myData ; - MYSQL_RES * res ; - MYSQL_FIELD * fd ; - MYSQL_ROW row ; - - //....just curious.... - printf( "sizeof( MYSQL ) == %d\n", (int) sizeof( MYSQL ) ) ; - if ( argc == 2 ) - { - strcpy( szDB, argv[ 1 ] ) ; - strcpy( szSQL, DEFALT_SQL_STMT ) ; - if (!strcmp(szDB,"--debug")) - { - strcpy( szDB, "mysql" ) ; - printf("Some mysql struct information (size and offset):\n"); - printf("net:\t%3d %3d\n",(int) sizeof(myData->net), - (int) offsetof(MYSQL,net)); - printf("host:\t%3d %3d\n",(int) sizeof(myData->host), - (int) offsetof(MYSQL,host)); - printf("port:\t%3d %3d\n", (int) sizeof(myData->port), - (int) offsetof(MYSQL,port)); - printf("protocol_version:\t%3d %3d\n", - (int) sizeof(myData->protocol_version), - (int) offsetof(MYSQL,protocol_version)); - printf("thread_id:\t%3d %3d\n",(int) sizeof(myData->thread_id), - (int) offsetof(MYSQL,thread_id)); - printf("affected_rows:\t%3d %3d\n",(int) sizeof(myData->affected_rows), - (int) offsetof(MYSQL,affected_rows)); - printf("packet_length:\t%3d %3d\n",(int) sizeof(myData->packet_length), - (int) offsetof(MYSQL,packet_length)); - printf("status:\t%3d %3d\n",(int) sizeof(myData->status), - (int) offsetof(MYSQL,status)); - printf("fields:\t%3d %3d\n",(int) sizeof(myData->fields), - (int) offsetof(MYSQL,fields)); - printf("field_alloc:\t%3d %3d\n",(int) sizeof(myData->field_alloc), - (int) offsetof(MYSQL,field_alloc)); - printf("free_me:\t%3d %3d\n",(int) sizeof(myData->free_me), - (int) offsetof(MYSQL,free_me)); - printf("options:\t%3d %3d\n",(int) sizeof(myData->options), - (int) offsetof(MYSQL,options)); - puts(""); - } - } - else if ( argc > 2 ) { - strcpy( szDB, argv[ 1 ] ) ; - strcpy( szSQL, argv[ 2 ] ) ; - } - else { - strcpy( szDB, "mysql" ) ; - strcpy( szSQL, DEFALT_SQL_STMT ) ; - } - //.... - - if ( (myData = mysql_init((MYSQL*) 0)) && - mysql_real_connect( myData, NULL, NULL, NULL, NULL, MYSQL_PORT, - NULL, 0 ) ) - { - myData->reconnect= 1; - if ( mysql_select_db( myData, szDB ) < 0 ) { - printf( "Can't select the %s database !\n", szDB ) ; - mysql_close( myData ) ; - return 2 ; - } - } - else { - printf( "Can't connect to the mysql server on port %d !\n", - MYSQL_PORT ) ; - mysql_close( myData ) ; - return 1 ; - } - //.... - if ( ! mysql_query( myData, szSQL ) ) { - res = mysql_store_result( myData ) ; - i = (int) mysql_num_rows( res ) ; l = 1 ; - printf( "Query: %s\nNumber of records found: %ld\n", szSQL, i ) ; - //....we can get the field-specific characteristics here.... - for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ ) - strcpy( aszFlds[ x ], fd->name ) ; - //.... - while ( row = mysql_fetch_row( res ) ) { - j = mysql_num_fields( res ) ; - printf( "Record #%ld:-\n", l++ ) ; - for ( k = 0 ; k < j ; k++ ) - printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ], - (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ; - puts( "==============================\n" ) ; - } - mysql_free_result( res ) ; - } - else printf( "Couldn't execute %s on the server !\n", szSQL ) ; - //.... - puts( "==== Diagnostic info ====" ) ; - pszT = mysql_get_client_info() ; - printf( "Client info: %s\n", pszT ) ; - //.... - pszT = mysql_get_host_info( myData ) ; - printf( "Host info: %s\n", pszT ) ; - //.... - pszT = mysql_get_server_info( myData ) ; - printf( "Server info: %s\n", pszT ) ; - //.... - res = mysql_list_processes( myData ) ; l = 1 ; - if (res) - { - for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ ) - strcpy( aszFlds[ x ], fd->name ) ; - while ( row = mysql_fetch_row( res ) ) { - j = mysql_num_fields( res ) ; - printf( "Process #%ld:-\n", l++ ) ; - for ( k = 0 ; k < j ; k++ ) - printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ], - (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ; - puts( "==============================\n" ) ; - } - } - else - { - printf("Got error %s when retreiving processlist\n",mysql_error(myData)); - } - //.... - res = mysql_list_tables( myData, "%" ) ; l = 1 ; - for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ ) - strcpy( aszFlds[ x ], fd->name ) ; - while ( row = mysql_fetch_row( res ) ) { - j = mysql_num_fields( res ) ; - printf( "Table #%ld:-\n", l++ ) ; - for ( k = 0 ; k < j ; k++ ) - printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ], - (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ; - puts( "==============================\n" ) ; - } - //.... - pszT = mysql_stat( myData ) ; - puts( pszT ) ; - //.... - mysql_close( myData ) ; - return 0 ; - -} -- cgit v1.2.1