summaryrefslogtreecommitdiff
path: root/VC++Files/libmysqltest
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-06-28 17:26:11 +0300
committerunknown <monty@hundin.mysql.fi>2002-06-28 17:26:11 +0300
commit7311cbe7dee5980d921ec43177fd268783eb18e2 (patch)
tree27f0f967ee5f642c6cb7ecfab977612a3d7e57d3 /VC++Files/libmysqltest
parenta6ca5cbb9172ba7fb56834d78d6527525a59d1c3 (diff)
downloadmariadb-git-7311cbe7dee5980d921ec43177fd268783eb18e2.tar.gz
Updated windows files (VC++ files and winmysqladmin).
Portability fixes. Removed compiler warnings. VC++Files/client/mysql.dsp: Updated to 4.0.2 VC++Files/client/mysqladmin.dsp: Updated to 4.0.2 VC++Files/client/mysqlclient.dsp: Updated to 4.0.2 VC++Files/client/mysqldump.dsp: Updated to 4.0.2 VC++Files/client/mysqlimport.dsp: Updated to 4.0.2 VC++Files/client/mysqlshow.dsp: Updated to 4.0.2 VC++Files/innobase/innobase.dsp: Updated to 4.0.2 VC++Files/libmysql/libmySQL.dsp: Updated to 4.0.2 VC++Files/libmysqltest/myTest.dsp: Updated to 4.0.2 VC++Files/merge/merge.dsp: Updated to 4.0.2 VC++Files/myisam/myisam.dsp: Updated to 4.0.2 VC++Files/mysql.dsw: Updated to 4.0.2 VC++Files/mysqlbinlog/mysqlbinlog.dsp: Updated to 4.0.2 VC++Files/mysqlcheck/mysqlcheck.dsp: Updated to 4.0.2 VC++Files/mysqlmanager/MySqlManager.dsp: Updated to 4.0.2 VC++Files/mysys/mysys.dsp: Updated to 4.0.2 VC++Files/pack_isam/pack_isam.dsp: Updated to 4.0.2 VC++Files/perror/perror.dsp: Updated to 4.0.2 VC++Files/replace/replace.dsp: Updated to 4.0.2 VC++Files/sql/mysqld.dsp: Updated to 4.0.2 VC++Files/test1/test1.dsp: Updated to 4.0.2 VC++Files/thr_insert_test/thr_insert_test.dsp: Updated to 4.0.2 VC++Files/thr_test/thr_test.dsp: Updated to 4.0.2 VC++Files/vio/vio.dsp: Updated to 4.0.2 VC++Files/zlib/zlib.dsp: Updated to 4.0.2 include/config-win.h: Added isnan() and finite() include/myisam.h: Move thr_xxx functions to myisam_priv.h myisam/mi_check.c: Portability fix. myisam/mi_locking.c: Comment cleanup myisam/myisamchk.c: Removed compiler warning myisam/myisamdef.h: Added thr_xxx functions myisam/sort.c: Portability fix sql/field.cc: Portability fix sql/sql_insert.cc: R
Diffstat (limited to 'VC++Files/libmysqltest')
-rw-r--r--VC++Files/libmysqltest/myTest.dsp3
-rw-r--r--VC++Files/libmysqltest/mytest.c170
2 files changed, 171 insertions, 2 deletions
diff --git a/VC++Files/libmysqltest/myTest.dsp b/VC++Files/libmysqltest/myTest.dsp
index fec250e7a40..74f7b8ae48e 100644
--- a/VC++Files/libmysqltest/myTest.dsp
+++ b/VC++Files/libmysqltest/myTest.dsp
@@ -67,8 +67,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "..\include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
-# SUBTRACT CPP /Fr /YX
+# ADD CPP /nologo /G6 /MTd /W3 /Gm /Zi /Od /I "..\include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
diff --git a/VC++Files/libmysqltest/mytest.c b/VC++Files/libmysqltest/mytest.c
new file mode 100644
index 00000000000..9c6818ecf6c
--- /dev/null
+++ b/VC++Files/libmysqltest/mytest.c
@@ -0,0 +1,170 @@
+/*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 <windows.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <mysql.h>
+
+#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", 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",sizeof(myData->net),offsetof(MYSQL,net));
+ printf("host:\t%3d %3d\n",sizeof(myData->host),offsetof(MYSQL,host));
+ printf("port:\t%3d %3d\n",sizeof(myData->port),offsetof(MYSQL,port));
+ printf("protocol_version:\t%3d %3d\n",sizeof(myData->protocol_version),
+ offsetof(MYSQL,protocol_version));
+ printf("thread_id:\t%3d %3d\n",sizeof(myData->thread_id),
+ offsetof(MYSQL,thread_id));
+ printf("affected_rows:\t%3d %3d\n",sizeof(myData->affected_rows),
+ offsetof(MYSQL,affected_rows));
+ printf("packet_length:\t%3d %3d\n",sizeof(myData->packet_length),
+ offsetof(MYSQL,packet_length));
+ printf("status:\t%3d %3d\n",sizeof(myData->status),
+ offsetof(MYSQL,status));
+ printf("fields:\t%3d %3d\n",sizeof(myData->fields),
+ offsetof(MYSQL,fields));
+ printf("field_alloc:\t%3d %3d\n",sizeof(myData->field_alloc),
+ offsetof(MYSQL,field_alloc));
+ printf("free_me:\t%3d %3d\n",sizeof(myData->free_me),
+ offsetof(MYSQL,free_me));
+ printf("options:\t%3d %3d\n",sizeof(myData->options),
+ 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 ) )
+ {
+ 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 ;
+
+}