SCRUM
including client code into embedded server code to guess what library to use added net_field_length moved to pack.c include/mysql.h: typedefinitions moved for suitability mysql_option.methods_to_use added include/mysql_com.h: net_store_length declaration libmysql/libmysql.c: net_store_length moved to sql-common/pack.c libmysqld/libmysqld.c: added code to guess whether to use remote or embedded connection sql-common/client.c: options checking added sql-common/pack.c: net_store_length implementation moved here sql/protocol.cc: net_store_length moved to sql-common/pack.c
This commit is contained in:
parent
4c7431dc90
commit
13e8bf67fc
@ -134,6 +134,17 @@ typedef struct st_mysql_data {
|
|||||||
#endif
|
#endif
|
||||||
} MYSQL_DATA;
|
} MYSQL_DATA;
|
||||||
|
|
||||||
|
enum mysql_option
|
||||||
|
{
|
||||||
|
MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
|
||||||
|
MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
|
||||||
|
MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
|
||||||
|
MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
|
||||||
|
MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT,
|
||||||
|
MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
|
||||||
|
MYSQL_OPT_GUESS_CONNECTION
|
||||||
|
};
|
||||||
|
|
||||||
struct st_mysql_options {
|
struct st_mysql_options {
|
||||||
unsigned int connect_timeout, read_timeout, write_timeout;
|
unsigned int connect_timeout, read_timeout, write_timeout;
|
||||||
unsigned int port, protocol;
|
unsigned int port, protocol;
|
||||||
@ -168,15 +179,7 @@ struct st_mysql_options {
|
|||||||
#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
|
#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
|
||||||
my_bool separate_thread;
|
my_bool separate_thread;
|
||||||
#endif
|
#endif
|
||||||
};
|
enum mysql_option methods_to_use;
|
||||||
|
|
||||||
enum mysql_option
|
|
||||||
{
|
|
||||||
MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
|
|
||||||
MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
|
|
||||||
MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
|
|
||||||
MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
|
|
||||||
MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum mysql_status
|
enum mysql_status
|
||||||
|
@ -341,6 +341,7 @@ void my_thread_end(void);
|
|||||||
#ifdef _global_h
|
#ifdef _global_h
|
||||||
ulong STDCALL net_field_length(uchar **packet);
|
ulong STDCALL net_field_length(uchar **packet);
|
||||||
my_ulonglong net_field_length_ll(uchar **packet);
|
my_ulonglong net_field_length_ll(uchar **packet);
|
||||||
|
char *net_store_length(char *pkg, ulonglong length);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -1730,39 +1730,6 @@ static void store_param_type(NET *net, uint type)
|
|||||||
net->write_pos+=2;
|
net->write_pos+=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Store the length of parameter data
|
|
||||||
(Same function as in sql/net_pkg.cc)
|
|
||||||
*/
|
|
||||||
|
|
||||||
char *
|
|
||||||
net_store_length(char *pkg, ulong length)
|
|
||||||
{
|
|
||||||
uchar *packet=(uchar*) pkg;
|
|
||||||
if (length < 251)
|
|
||||||
{
|
|
||||||
*packet=(uchar) length;
|
|
||||||
return (char*) packet+1;
|
|
||||||
}
|
|
||||||
/* 251 is reserved for NULL */
|
|
||||||
if (length < 65536L)
|
|
||||||
{
|
|
||||||
*packet++=252;
|
|
||||||
int2store(packet,(uint) length);
|
|
||||||
return (char*) packet+2;
|
|
||||||
}
|
|
||||||
if (length < 16777216L)
|
|
||||||
{
|
|
||||||
*packet++=253;
|
|
||||||
int3store(packet,(ulong) length);
|
|
||||||
return (char*) packet+3;
|
|
||||||
}
|
|
||||||
*packet++=254;
|
|
||||||
int8store(packet, (ulonglong) length);
|
|
||||||
return (char*) packet+9;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Functions to store parameter data from a prepared statement.
|
Functions to store parameter data from a prepared statement.
|
||||||
|
|
||||||
|
@ -68,6 +68,10 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
|
|||||||
*/
|
*/
|
||||||
void mysql_read_default_options(struct st_mysql_options *options,
|
void mysql_read_default_options(struct st_mysql_options *options,
|
||||||
const char *filename,const char *group);
|
const char *filename,const char *group);
|
||||||
|
MYSQL * STDCALL
|
||||||
|
cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
||||||
|
const char *passwd, const char *db,
|
||||||
|
uint port, const char *unix_socket,ulong client_flag);
|
||||||
|
|
||||||
#ifdef HAVE_GETPWUID
|
#ifdef HAVE_GETPWUID
|
||||||
struct passwd *getpwuid(uid_t);
|
struct passwd *getpwuid(uid_t);
|
||||||
@ -179,7 +183,7 @@ static MYSQL_METHODS embedded_methods=
|
|||||||
|
|
||||||
MYSQL * STDCALL
|
MYSQL * STDCALL
|
||||||
mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
||||||
const char *passwd __attribute__((unused)), const char *db,
|
const char *passwd, const char *db,
|
||||||
uint port, const char *unix_socket,ulong client_flag)
|
uint port, const char *unix_socket,ulong client_flag)
|
||||||
{
|
{
|
||||||
char *db_name;
|
char *db_name;
|
||||||
@ -189,6 +193,14 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||||||
db ? db : "(Null)",
|
db ? db : "(Null)",
|
||||||
user ? user : "(Null)"));
|
user ? user : "(Null)"));
|
||||||
|
|
||||||
|
if (mysql->options.methods_to_use == MYSQL_OPT_USE_REMOTE_CONNECTION)
|
||||||
|
cli_mysql_real_connect(mysql, host, user,
|
||||||
|
passwd, db, port, unix_socket, client_flag);
|
||||||
|
if ((mysql->options.methods_to_use == MYSQL_OPT_GUESS_CONNECTION) &&
|
||||||
|
host && strcmp(host,LOCAL_HOST))
|
||||||
|
cli_mysql_real_connect(mysql, host, user,
|
||||||
|
passwd, db, port, unix_socket, client_flag);
|
||||||
|
|
||||||
mysql->methods= &embedded_methods;
|
mysql->methods= &embedded_methods;
|
||||||
|
|
||||||
/* use default options */
|
/* use default options */
|
||||||
|
@ -1303,6 +1303,7 @@ mysql_init(MYSQL *mysql)
|
|||||||
#ifdef HAVE_SMEM
|
#ifdef HAVE_SMEM
|
||||||
mysql->options.shared_memory_base_name= (char*) def_shared_memory_base_name;
|
mysql->options.shared_memory_base_name= (char*) def_shared_memory_base_name;
|
||||||
#endif
|
#endif
|
||||||
|
mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION;
|
||||||
return mysql;
|
return mysql;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2512,6 +2513,10 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
|
|||||||
my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||||
mysql->options.shared_memory_base_name=my_strdup(arg,MYF(MY_WME));
|
mysql->options.shared_memory_base_name=my_strdup(arg,MYF(MY_WME));
|
||||||
#endif
|
#endif
|
||||||
|
case MYSQL_OPT_USE_REMOTE_CONNECTION:
|
||||||
|
case MYSQL_OPT_USE_EMBEDDED_CONNECTION:
|
||||||
|
case MYSQL_OPT_GUESS_CONNECTION:
|
||||||
|
mysql->options.methods_to_use= option;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
|
@ -96,3 +96,30 @@ void my_net_local_init(NET *net)
|
|||||||
net->max_packet_size= max(net_buffer_length, max_allowed_packet);
|
net->max_packet_size= max(net_buffer_length, max_allowed_packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
net_store_length(char *pkg, ulonglong length)
|
||||||
|
{
|
||||||
|
uchar *packet=(uchar*) pkg;
|
||||||
|
if (length < LL(251))
|
||||||
|
{
|
||||||
|
*packet=(uchar) length;
|
||||||
|
return (char*) packet+1;
|
||||||
|
}
|
||||||
|
/* 251 is reserved for NULL */
|
||||||
|
if (length < LL(65536))
|
||||||
|
{
|
||||||
|
*packet++=252;
|
||||||
|
int2store(packet,(uint) length);
|
||||||
|
return (char*) packet+2;
|
||||||
|
}
|
||||||
|
if (length < LL(16777216))
|
||||||
|
{
|
||||||
|
*packet++=253;
|
||||||
|
int3store(packet,(ulong) length);
|
||||||
|
return (char*) packet+3;
|
||||||
|
}
|
||||||
|
*packet++=254;
|
||||||
|
int8store(packet,length);
|
||||||
|
return (char*) packet+8;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -349,40 +349,6 @@ send_eof(THD *thd, bool no_flush)
|
|||||||
}
|
}
|
||||||
#endif /* EMBEDDED_LIBRARY */
|
#endif /* EMBEDDED_LIBRARY */
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
Store a field length in logical packet
|
|
||||||
This is used to code the string length for normal protocol
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
char *
|
|
||||||
net_store_length(char *pkg, ulonglong length)
|
|
||||||
{
|
|
||||||
uchar *packet=(uchar*) pkg;
|
|
||||||
if (length < LL(251))
|
|
||||||
{
|
|
||||||
*packet=(uchar) length;
|
|
||||||
return (char*) packet+1;
|
|
||||||
}
|
|
||||||
/* 251 is reserved for NULL */
|
|
||||||
if (length < LL(65536))
|
|
||||||
{
|
|
||||||
*packet++=252;
|
|
||||||
int2store(packet,(uint) length);
|
|
||||||
return (char*) packet+2;
|
|
||||||
}
|
|
||||||
if (length < LL(16777216))
|
|
||||||
{
|
|
||||||
*packet++=253;
|
|
||||||
int3store(packet,(ulong) length);
|
|
||||||
return (char*) packet+3;
|
|
||||||
}
|
|
||||||
*packet++=254;
|
|
||||||
int8store(packet,length);
|
|
||||||
return (char*) packet+8;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Faster net_store_length when we know length is a 32 bit integer
|
Faster net_store_length when we know length is a 32 bit integer
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user