summaryrefslogtreecommitdiff
path: root/libmysql
diff options
context:
space:
mode:
Diffstat (limited to 'libmysql')
-rwxr-xr-xlibmysql/CMakeLists.txt5
-rw-r--r--libmysql/Makefile.am2
-rw-r--r--libmysql/Makefile.shared2
-rw-r--r--libmysql/libmysql.c40
-rw-r--r--libmysql/manager.c2
-rw-r--r--libmysql/mytest.c175
6 files changed, 26 insertions, 200 deletions
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index cec577fb2c6..55138e4aa06 100755
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -97,7 +97,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.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
+ ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c ../mysys/mf_qsort.c
../mysys/my_getsystime.c ../mysys/my_sync.c ${LIB_SOURCES})
# Need to set USE_TLS for building the DLL, since __declspec(thread)
@@ -126,9 +126,6 @@ ENDIF(WIN32)
ADD_DEPENDENCIES(libmysql GenError)
TARGET_LINK_LIBRARIES(libmysql wsock32)
-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 e5005553467..21f8f372d0f 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
link_sources:
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 9d85872e616..43e86ea31e8 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -73,7 +73,7 @@ sqlobjects = net.lo
sql_cmn_objects = pack.lo client.lo my_time.lo
# Not needed in the minimum library
-mysysobjects2 = my_lib.lo
+mysysobjects2 = my_lib.lo mf_qsort.lo
mysysobjects = $(mysysobjects1) $(mysysobjects2)
target_libadd = $(mysysobjects) $(mystringsobjects) $(dbugobjects) \
$(sql_cmn_objects) $(vio_objects) $(sqlobjects)
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index bf5dd7d63eb..f5ac1c09248 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -440,11 +440,11 @@ static void expand_error(MYSQL* mysql, int error)
char tmp[MYSQL_ERRMSG_SIZE];
char *p;
uint err_length;
- strmake(tmp, mysql->net.last_error, MYSQL_ERRMSG_SIZE-1);
- p = strmake(mysql->net.last_error, ER(error), MYSQL_ERRMSG_SIZE-1);
- err_length= (uint) (p - mysql->net.last_error);
+ strmake(tmp, mysql->net.client_last_error, MYSQL_ERRMSG_SIZE-1);
+ p = strmake(mysql->net.client_last_error, ER(error), MYSQL_ERRMSG_SIZE-1);
+ err_length= (uint) (p - mysql->net.client_last_error);
strmake(p, tmp, MYSQL_ERRMSG_SIZE-1 - err_length);
- mysql->net.last_errno = error;
+ mysql->net.client_last_errno = error;
}
/*
@@ -870,9 +870,10 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename)
VOID(my_net_write(net,(const uchar*) "",0)); /* Server needs one packet */
net_flush(net);
strmov(net->sqlstate, unknown_sqlstate);
- net->last_errno= (*options->local_infile_error)(li_ptr,
- net->last_error,
- sizeof(net->last_error)-1);
+ net->client_last_errno=
+ (*options->local_infile_error)(li_ptr,
+ net->client_last_error,
+ sizeof(net->client_last_error)-1);
goto err;
}
@@ -899,9 +900,10 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename)
if (readcount < 0)
{
- net->last_errno= (*options->local_infile_error)(li_ptr,
- net->last_error,
- sizeof(net->last_error)-1);
+ net->client_last_errno=
+ (*options->local_infile_error)(li_ptr,
+ net->client_last_error,
+ sizeof(net->client_last_error)-1);
goto err;
}
@@ -1395,7 +1397,7 @@ const char *cli_read_statistics(MYSQL *mysql)
if (!mysql->net.read_pos[0])
{
set_mysql_error(mysql, CR_WRONG_HOST_INFO, unknown_sqlstate);
- return mysql->net.last_error;
+ return mysql->net.client_last_error;
}
return (char*) mysql->net.read_pos;
}
@@ -1406,7 +1408,7 @@ mysql_stat(MYSQL *mysql)
{
DBUG_ENTER("mysql_stat");
if (simple_command(mysql,COM_STATISTICS,0,0,0))
- DBUG_RETURN(mysql->net.last_error);
+ DBUG_RETURN(mysql->net.client_last_error);
DBUG_RETURN((*mysql->methods->read_statistics)(mysql));
}
@@ -1771,7 +1773,7 @@ static my_bool my_realloc_str(NET *net, ulong length)
if (res)
{
strmov(net->sqlstate, unknown_sqlstate);
- strmov(net->last_error, ER(net->last_errno));
+ strmov(net->client_last_error, ER(net->client_last_errno));
}
net->write_pos= net->buff+ buf_length;
}
@@ -1822,13 +1824,15 @@ void set_stmt_error(MYSQL_STMT * stmt, int errcode,
void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net)
{
DBUG_ENTER("set_stmt_errmsg");
- DBUG_PRINT("enter", ("error: %d/%s '%s'", net->last_errno, net->sqlstate,
- net->last_error));
+ DBUG_PRINT("enter", ("error: %d/%s '%s'",
+ net->client_last_errno,
+ net->sqlstate,
+ net->client_last_error));
DBUG_ASSERT(stmt != 0);
- stmt->last_errno= net->last_errno;
- if (net->last_error && net->last_error[0])
- strmov(stmt->last_error, net->last_error);
+ stmt->last_errno= net->client_last_errno;
+ if (net->client_last_error && net->client_last_error[0])
+ strmov(stmt->last_error, net->client_last_error);
strmov(stmt->sqlstate, net->sqlstate);
DBUG_VOID_RETURN;
diff --git a/libmysql/manager.c b/libmysql/manager.c
index 53ffffa55c0..27d35758f3e 100644
--- a/libmysql/manager.c
+++ b/libmysql/manager.c
@@ -160,7 +160,7 @@ MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
msg_len=strlen(msg_buf);
if (my_net_write(&con->net,(uchar*) msg_buf,msg_len) || net_flush(&con->net))
{
- con->last_errno=con->net.last_errno;
+ con->last_errno=con->net.client_last_errno;
strmov(con->last_error,"Write error on socket");
goto err;
}
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 <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 ;
-
-}