summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
Diffstat (limited to 'libmysql')
-rw-r--r--libmysql/Makefile.am2
-rw-r--r--libmysql/cmakelists.txt54
-rw-r--r--libmysql/libmysql.c10
-rw-r--r--libmysql/mytest.c175
4 files changed, 232 insertions, 9 deletions
diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am
index b580884e934..9a6f418fa49 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
+EXTRA_DIST = Makefile.shared libmysql.def dll.c mytest.c cmakelists.txt
noinst_HEADERS = client_settings.h
# This is called from the toplevel makefile
diff --git a/libmysql/cmakelists.txt b/libmysql/cmakelists.txt
new file mode 100644
index 00000000000..35795102082
--- /dev/null
+++ b/libmysql/cmakelists.txt
@@ -0,0 +1,54 @@
+# Need to set USE_TLS, since __declspec(thread) approach to thread local
+# storage does not work properly in DLLs.
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_TLS")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/zlib
+ ${CMAKE_SOURCE_DIR}/extra/yassl/include
+ ${CMAKE_SOURCE_DIR}/libmysql
+ ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_SOURCE_DIR}/strings)
+
+ADD_LIBRARY(libmysql MODULE dll.c libmysql.def
+ ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
+ ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c
+ ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c
+ ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c
+ ../strings/ctype-eucjpms.c ../strings/ctype-extra.c ../strings/ctype-gb2312.c
+ ../strings/ctype-gbk.c ../strings/ctype-latin1.c ../strings/ctype-mb.c
+ ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c
+ ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c
+ ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c
+ ../mysys/default.c ../libmysql/errmsg.c ../mysys/errors.c
+ ../libmysql/get_password.c ../strings/int2str.c ../strings/is_prefix.c
+ ../libmysql/libmysql.c ../mysys/list.c ../strings/llstr.c
+ ../strings/longlong2str.c ../libmysql/manager.c ../mysys/mf_cache.c
+ ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c
+ ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c
+ ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c
+ ../mysys/mf_wcomp.c ../mysys/mulalloc.c ../mysys/my_access.c ../mysys/my_alloc.c
+ ../mysys/my_chsize.c ../mysys/my_compress.c ../mysys/my_create.c
+ ../mysys/my_delete.c ../mysys/my_div.c ../mysys/my_error.c ../mysys/my_file.c
+ ../mysys/my_fopen.c ../mysys/my_fstream.c ../mysys/my_gethostbyname.c
+ ../mysys/my_getopt.c ../mysys/my_getwd.c ../mysys/my_init.c ../mysys/my_lib.c
+ ../mysys/my_malloc.c ../mysys/my_messnc.c ../mysys/my_net.c ../mysys/my_once.c
+ ../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c
+ ../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c
+ ../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c
+ ../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c
+ ../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c
+ ../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c
+ ../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c
+ ../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c
+ ../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c
+ ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c
+ ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c
+ ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
+ ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c)
+ADD_DEPENDENCIES(libmysql dbug vio mysys strings GenError zlib yassl taocrypt)
+TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32)
+
+ADD_EXECUTABLE(myTest mytest.c)
+TARGET_LINK_LIBRARIES(myTest libmysql)
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index bfec476fde3..3406d606692 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -179,10 +179,8 @@ void STDCALL mysql_server_end()
if (!org_my_init_done)
{
my_end(0);
-#ifndef THREAD
/* Remove TRACING, if enabled by mysql_debug() */
DBUG_POP();
-#endif
}
else
mysql_thread_end();
@@ -267,16 +265,12 @@ mysql_debug(const char *debug __attribute__((unused)))
{
#ifndef DBUG_OFF
char *env;
- if (_db_on_)
- return; /* Already using debugging */
if (debug)
{
- DEBUGGER_ON;
DBUG_PUSH(debug);
}
else if ((env = getenv("MYSQL_DEBUG")))
{
- DEBUGGER_ON;
DBUG_PUSH(env);
#if !defined(_WINVER) && !defined(WINVER)
puts("\n-------------------------------------------------------");
@@ -2793,11 +2787,11 @@ my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
{
switch (attr_type) {
case STMT_ATTR_UPDATE_MAX_LENGTH:
- *(unsigned long *) value= stmt->update_max_length;
+ *(my_bool*) value= stmt->update_max_length;
break;
case STMT_ATTR_CURSOR_TYPE:
*(ulong*) value= stmt->flags;
- break;
+ break;
case STMT_ATTR_PREFETCH_ROWS:
*(ulong*) value= stmt->prefetch_rows;
break;
diff --git a/libmysql/mytest.c b/libmysql/mytest.c
new file mode 100644
index 00000000000..a1dc13db39f
--- /dev/null
+++ b/libmysql/mytest.c
@@ -0,0 +1,175 @@
+/*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", (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 ;
+
+}