mariadb/VC++Files/libmysqltest/mytest.c

176 lines
5.5 KiB
C
Raw Normal View History

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
2002-06-28 17:26:11 +03:00
/*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 ] ;
Updated VC++ dsp files from windows build machine Remove some compiler warnings when using VC++ Add InnoDB in normal MySQL binary for windows. BitKeeper/deleted/.del-lib_load.cc~854092828128d7f9: Delete: libmysqld/lib_load.cc VC++Files/bdb/bdb.dsp: Updated VC++ dsp files from windows build machine VC++Files/client/mysql.dsp: Updated VC++ dsp files from windows build machine VC++Files/client/mysqladmin.dsp: Updated VC++ dsp files from windows build machine VC++Files/client/mysqlclient.dsp: Updated VC++ dsp files from windows build machine VC++Files/client/mysqldump.dsp: Updated VC++ dsp files from windows build machine VC++Files/client/mysqlimport.dsp: Updated VC++ dsp files from windows build machine VC++Files/client/mysqlshow.dsp: Updated VC++ dsp files from windows build machine VC++Files/innobase/innobase.dsp: Updated VC++ dsp files from windows build machine VC++Files/libmysqld/libmysqld.dsp: Updated VC++ dsp files from windows build machine VC++Files/libmysqltest/myTest.dsp: Updated VC++ dsp files from windows build machine VC++Files/libmysqltest/mytest.c: Removed compiler warning for VC++ VC++Files/mysql.dsw: Add Innodb to standard binary VC++Files/mysqlbinlog/mysqlbinlog.dsp: Updated VC++ dsp files from windows build machine VC++Files/mysqlcheck/mysqlcheck.dsp: Updated VC++ dsp files from windows build machine VC++Files/mysqlmanager/MySqlManager.dsp: Updated VC++ dsp files from windows build machine VC++Files/mysys/mysys.dsp: Updated VC++ dsp files from windows build machine VC++Files/pack_isam/pack_isam.dsp: Updated VC++ dsp files from windows build machine VC++Files/perror/perror.dsp: Updated VC++ dsp files from windows build machine VC++Files/replace/replace.dsp: Updated VC++ dsp files from windows build machine VC++Files/sql/mysqld.dsp: Updated VC++ dsp files from windows build machine VC++Files/test1/test1.dsp: Updated VC++ dsp files from windows build machine VC++Files/thr_insert_test/thr_insert_test.dsp: Updated VC++ dsp files from windows build machine VC++Files/thr_test/thr_test.dsp: Updated VC++ dsp files from windows build machine VC++Files/vio/vio.dsp: Updated VC++ dsp files from windows build machine sql/item_strfunc.cc: Removed compiler warning on VC++ VC++Files/libmysql/libmysql.dsp: Updated VC++ dsp files from windows build machine
2002-08-29 18:20:04 +03:00
const char *pszT;
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
2002-06-28 17:26:11 +03:00
int i, j, k, l, x ;
MYSQL * myData ;
MYSQL_RES * res ;
MYSQL_FIELD * fd ;
MYSQL_ROW row ;
//....just curious....
Fixed compiler warnings from Intel compiler in Win64 Added option --max-record-length=# to myisamchk Don't try repair twice if doing myisamchk --repair --force Shared memory handler didn't clean up things on errors or shutdown VC++Files/libmysqltest/mytest.c: Fixed compiler warnings from Intel compiler include/myisam.h: Added option --max-record-length=# to myisamchk include/mysql_com.h: Fixed compiler warnings from Intel compiler innobase/btr/btr0btr.c: Fixed compiler warnings from Intel compiler innobase/btr/btr0cur.c: Fixed compiler warnings from Intel compiler innobase/include/btr0btr.ic: Fixed compiler warnings from Intel compiler innobase/include/buf0buf.ic: Fixed compiler warnings from Intel compiler innobase/include/row0sel.ic: Fixed compiler warnings from Intel compiler innobase/include/row0upd.ic: Fixed compiler warnings from Intel compiler innobase/include/trx0rseg.ic: Fixed compiler warnings from Intel compiler innobase/pars/pars0opt.c: Fixed compiler warnings from Intel compiler innobase/que/que0que.c: Fixed compiler warnings from Intel compiler myisam/mi_check.c: Added option --max-record-length=# to myisamchk Better error messages myisam/myisamchk.c: Added option --max-record-length=# to myisamchk Don't try repair twice if doing myisamchk --repair --force mysql-test/r/create.result: Updated test results mysql-test/t/create.test: Better initialization sql/ha_innodb.cc: Fixed compiler warnings from Intel compiler sql/item_func.cc: Fixed compiler warnings from Intel compiler sql/mysqld.cc: Fixed compiler warnings from Intel compiler Cleaned up handle_connections_shared_memory Shared memory handler didn't clean up things on errors or shutdown strings/bmove512.c: Fixed compiler warnings from Intel compiler
2003-11-23 14:36:41 +02:00
printf( "sizeof( MYSQL ) == %d\n", (int) sizeof( MYSQL ) ) ;
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
2002-06-28 17:26:11 +03:00
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");
Fixed compiler warnings from Intel compiler in Win64 Added option --max-record-length=# to myisamchk Don't try repair twice if doing myisamchk --repair --force Shared memory handler didn't clean up things on errors or shutdown VC++Files/libmysqltest/mytest.c: Fixed compiler warnings from Intel compiler include/myisam.h: Added option --max-record-length=# to myisamchk include/mysql_com.h: Fixed compiler warnings from Intel compiler innobase/btr/btr0btr.c: Fixed compiler warnings from Intel compiler innobase/btr/btr0cur.c: Fixed compiler warnings from Intel compiler innobase/include/btr0btr.ic: Fixed compiler warnings from Intel compiler innobase/include/buf0buf.ic: Fixed compiler warnings from Intel compiler innobase/include/row0sel.ic: Fixed compiler warnings from Intel compiler innobase/include/row0upd.ic: Fixed compiler warnings from Intel compiler innobase/include/trx0rseg.ic: Fixed compiler warnings from Intel compiler innobase/pars/pars0opt.c: Fixed compiler warnings from Intel compiler innobase/que/que0que.c: Fixed compiler warnings from Intel compiler myisam/mi_check.c: Added option --max-record-length=# to myisamchk Better error messages myisam/myisamchk.c: Added option --max-record-length=# to myisamchk Don't try repair twice if doing myisamchk --repair --force mysql-test/r/create.result: Updated test results mysql-test/t/create.test: Better initialization sql/ha_innodb.cc: Fixed compiler warnings from Intel compiler sql/item_func.cc: Fixed compiler warnings from Intel compiler sql/mysqld.cc: Fixed compiler warnings from Intel compiler Cleaned up handle_connections_shared_memory Shared memory handler didn't clean up things on errors or shutdown strings/bmove512.c: Fixed compiler warnings from Intel compiler
2003-11-23 14:36:41 +02:00
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));
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
2002-06-28 17:26:11 +03:00
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 ) )
{
Changing the default of libmysqlclient : it's now NO reconnection. All our programs which use mysql_real_connect() and mysql_connect() are updated accordingly, though I have deliberately made mysqlimport not reconnect anymore (already true for mysqldump >= 4.1.8). All Connector devs have been warned about the change I'm doing here - which was agreed with Monty, and fixes BUG#2555. VC++Files/libmysqltest/mytest.c: explicit mention of reconnect (no behaviour change) VC++Files/mysqlmanager/mysqlmanagerview.cpp: explicit mention of reconnect (no behaviour change) VC++Files/test1/mysql_thr.c: explicit mention of reconnect (no behaviour change) VC++Files/winmysqladmin/main.cpp: explicit mention of reconnect (no behaviour change) client/mysql.cc: explicit mention of reconnect if embedded (no behaviour change) client/mysqladmin.cc: explicit mention of reconnect (no behaviour change) client/mysqlbinlog.cc: explicit mention of reconnect (no behaviour change) client/mysqlcheck.c: explicit mention of reconnect (no behaviour change) client/mysqlimport.c: explicit mention of NO reconnect (behaviour change). As most time is passed in LOAD DATA INFILE, and as it does not make sense to reconnect after a partly failed LOAD... And as mysqlimport sometimes does LOCK TABLES where we mustn't reconnect... client/mysqlshow.c: explicit mention of reconnect (no behaviour change) client/mysqltest.c: explicit mention of reconnect (no behaviour change). Normally we should not reconnect (it's not good to have silent reconnection in the middle of a test), but 5.0 is too touchy to change it now. I'm marking it TODO. libmysql/libmysql.c: explicit mention of reconnect (no behaviour change) libmysqld/examples/builder-sample/emb_samples.cpp: explicit mention of reconnect (no behaviour change) ndb/test/ndbapi/flex_bench_mysql.cpp: explicit mention of reconnect (no behaviour change) ndb/tools/restore/consumer_restorem.cpp: explicit mention of reconnect (no behaviour change) sql-common/client.c: Changing the default of libmysqlclient : it's now NO reconnection. sql/repl_failsafe.cc: explicit mention of reconnect (no behaviour change) sql/slave.cc: explicit mention of reconnect (no behaviour change) tests/client_test.c: explicit mention of reconnect (no behaviour change) tests/connect_test.c: explicit mention of reconnect (no behaviour change) tests/deadlock_test.c: explicit mention of reconnect (no behaviour change) tests/insert_test.c: explicit mention of reconnect (no behaviour change) tests/list_test.c: explicit mention of reconnect (no behaviour change) tests/select_test.c: explicit mention of reconnect (no behaviour change) tests/showdb_test.c: explicit mention of reconnect (no behaviour change) tests/ssl_test.c: explicit mention of reconnect (no behaviour change) tests/thread_test.c: explicit mention of reconnect (no behaviour change) tools/mysqlmanager.c: explicit mention of reconnect (no behaviour change)
2004-12-09 14:44:10 +01:00
myData->reconnect= 1;
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
2002-06-28 17:26:11 +03:00
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 ;
}