diff options
author | unknown <hf@deer.(none)> | 2003-06-17 21:53:13 +0500 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2003-06-17 21:53:13 +0500 |
commit | 46cb15ccd477007c8ba2abaa90f86960a8adc7bd (patch) | |
tree | 8bec4511106588d39e833346b08272d3d00f72ee /libmysql | |
parent | ef726bbff367ab6c5aa735655d8ff6c3fdccdb7d (diff) | |
parent | a4792eefad19e4f70471952afedef2221fbfbd64 (diff) | |
download | mariadb-git-46cb15ccd477007c8ba2abaa90f86960a8adc7bd.tar.gz |
SCRUM
merged conflicts about my previous commit
it seems there are some errors left - gonna check...
BitKeeper/etc/logging_ok:
auto-union
client/mysqltest.c:
Auto merged
include/mysql_com.h:
Auto merged
include/sql_common.h:
Auto merged
include/mysql.h:
conflicts merged
libmysql/client_settings.h:
conflicts merged
libmysql/libmysql.c:
conflicts merged
sql-common/client.c:
conflicts merged
sql/client_settings.h:
conflicts merged
sql/protocol.cc:
conflict merged
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/client_settings.h | 21 | ||||
-rw-r--r-- | libmysql/libmysql.c | 120 |
2 files changed, 78 insertions, 63 deletions
diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index 52606fe5316..d4e8be84c48 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -14,27 +14,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - extern uint mysql_port; extern my_string mysql_unix_port; -#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \ - | CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS \ - | CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) - - -#ifdef __WIN__ -#define CONNECT_TIMEOUT 20 -#else -#define CONNECT_TIMEOUT 0 -#endif - -#ifdef HAVE_SMEM -char *shared_memory_base_name=0; -const char *def_shared_memory_base_name=default_shared_memory_base_name; -#endif - -extern my_bool org_my_init_done; +#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | \ + CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS | \ + CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) sig_handler pipe_sig_handler(int sig __attribute__((unused))); my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4f19b7492e7..e380ceb2d19 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -73,17 +73,6 @@ my_bool net_flush(NET *net); uint mysql_port=0; my_string mysql_unix_port=0; -#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \ - | CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS \ - | CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) - - -#ifdef __WIN__ -#define CONNECT_TIMEOUT 20 -#else -#define CONNECT_TIMEOUT 0 -#endif - #if defined(MSDOS) || defined(__WIN__) /* socket_errno is defined in my_global.h for all platforms */ #define perror(A) @@ -92,10 +81,6 @@ my_string mysql_unix_port=0; #define SOCKET_ERROR -1 #endif /* __WIN__ */ -const char *sql_protocol_names_lib[] = -{ "TCP", "SOCKET", "PIPE", "MEMORY", NullS }; -TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"", - sql_protocol_names_lib}; /* If allowed through some configuration, then this needs to be changed @@ -108,9 +93,54 @@ sig_handler pipe_sig_handler(int sig); static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, const char *from, ulong length); my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list); -my_bool org_my_init_done=0; -#ifndef EMBEDDED_LIBRARY +static my_bool mysql_client_init= 0; +static my_bool org_my_init_done= 0; + +void mysql_once_init(void) +{ + if (!mysql_client_init) + { + mysql_client_init=1; + org_my_init_done=my_init_done; + my_init(); /* Will init threads */ + init_client_errs(); + if (!mysql_port) + { + mysql_port = MYSQL_PORT; +#ifndef MSDOS + { + struct servent *serv_ptr; + char *env; + if ((serv_ptr = getservbyname("mysql", "tcp"))) + mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); + if ((env = getenv("MYSQL_TCP_PORT"))) + mysql_port =(uint) atoi(env); + } +#endif + } + if (!mysql_unix_port) + { + char *env; +#ifdef __WIN__ + mysql_unix_port = (char*) MYSQL_NAMEDPIPE; +#else + mysql_unix_port = (char*) MYSQL_UNIX_ADDR; +#endif + if ((env = getenv("MYSQL_UNIX_PORT"))) + mysql_unix_port = env; + } + mysql_debug(NullS); +#if defined(SIGPIPE) && !defined(THREAD) && !defined(__WIN__) + (void) signal(SIGPIPE,SIG_IGN); +#endif + } +#ifdef THREAD + else + my_thread_init(); /* Init if new thread */ +#endif +} + int STDCALL mysql_server_init(int argc __attribute__((unused)), char **argv __attribute__((unused)), char **groups __attribute__((unused))) @@ -527,30 +557,6 @@ STDCALL mysql_rpl_query_type(const char* q, int len) return MYSQL_RPL_MASTER; /* By default, send to master */ } -/* - Fill in SSL part of MYSQL structure and set 'use_ssl' flag. - NB! Errors are not reported until you do mysql_real_connect. -*/ - -#define strdup_if_not_null(A) (A) == 0 ? 0 : my_strdup((A),MYF(MY_WME)) - -my_bool STDCALL -mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , - const char *key __attribute__((unused)), - const char *cert __attribute__((unused)), - const char *ca __attribute__((unused)), - const char *capath __attribute__((unused)), - const char *cipher __attribute__((unused))) -{ -#ifdef HAVE_OPENSSL - mysql->options.ssl_key= strdup_if_not_null(key); - mysql->options.ssl_cert= strdup_if_not_null(cert); - mysql->options.ssl_ca= strdup_if_not_null(ca); - mysql->options.ssl_capath= strdup_if_not_null(capath); - mysql->options.ssl_cipher= strdup_if_not_null(cipher); -#endif /* HAVE_OPENSSL */ - return 0; -} /************************************************************************** Connect to sql server @@ -576,6 +582,7 @@ mysql_connect(MYSQL *mysql,const char *host, } #endif + /************************************************************************** Change user and database **************************************************************************/ @@ -882,8 +889,6 @@ MYSQL_RES * STDCALL CLI_MYSQL_USE_RESULT(MYSQL *mysql) DBUG_RETURN(result); /* Data is read to be fetched */ } - - /************************************************************************** Return next field of the query results **************************************************************************/ @@ -896,6 +901,13 @@ mysql_fetch_field(MYSQL_RES *result) return &result->fields[result->current_field++]; } + +/************************************************************************** + Get column lengths of the current row + If one uses mysql_use_result, res->lengths contains the length information, + else the lengths are calculated from the offset between pointers. +**************************************************************************/ + ulong * STDCALL mysql_fetch_lengths(MYSQL_RES *res) { @@ -908,6 +920,23 @@ mysql_fetch_lengths(MYSQL_RES *res) return res->lengths; } + +/************************************************************************** + Move to a specific row and column +**************************************************************************/ + +void STDCALL +mysql_data_seek(MYSQL_RES *result, my_ulonglong row) +{ + MYSQL_ROWS *tmp=0; + DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row)); + if (result->data) + for (tmp=result->data->data; row-- && tmp ; tmp = tmp->next) ; + result->current_row=0; + result->data_cursor = tmp; +} + + /************************************************************************* put the row or field cursor one a position one got from mysql_row_tell() This doesn't restore any data. The next mysql_fetch_row or @@ -932,6 +961,7 @@ mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET field_offset) return return_value; } + /***************************************************************************** List all databases *****************************************************************************/ @@ -2430,7 +2460,7 @@ static void send_data_long(MYSQL_BIND *param, longlong value) } default: { - char tmp[12]; + char tmp[22]; /* Enough for longlong */ uint length= (uint)(longlong10_to_str(value,(char *)tmp,10)-tmp); ulong copy_length= min((ulong)length-param->offset, param->buffer_length); memcpy(buffer, (char *)tmp+param->offset, copy_length); @@ -2478,7 +2508,7 @@ static void send_data_double(MYSQL_BIND *param, double value) } default: { - char tmp[12]; + char tmp[128]; uint length= my_sprintf(tmp,(tmp,"%g",value)); ulong copy_length= min((ulong)length-param->offset, param->buffer_length); memcpy(buffer, (char *)tmp+param->offset, copy_length); |