1
0
mirror of https://github.com/MariaDB/server.git synced 2025-06-13 13:01:51 +03:00
merged conflicts about my previous commit
it seems there are some errors left - gonna check...
This commit is contained in:
hf@deer.(none)
2003-06-17 21:53:13 +05:00
82 changed files with 1527 additions and 1106 deletions

View File

@ -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);