1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Add shared memory protocol and option --protocol

This commit is contained in:
wax@mysql.com
2002-11-15 00:16:30 +05:00
parent fc54b13799
commit e91d1b2cbe
20 changed files with 1112 additions and 101 deletions

View File

@@ -31,6 +31,11 @@ static my_string host=0,opt_password=0,user=0;
static my_bool opt_show_keys=0,opt_compress=0,opt_status=0, tty_password=0;
static uint opt_verbose=0;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
#endif
static uint opt_protocol=0;
static void get_options(int *argc,char ***argv);
static uint opt_mysql_port=0;
static int list_dbs(MYSQL *mysql,const char *wild);
@@ -86,6 +91,12 @@ int main(int argc, char **argv)
if (opt_use_ssl)
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
opt_ssl_capath, opt_ssl_cipher);
#endif
if (opt_protocol)
mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
#ifdef HAVE_SMEM
if (shared_memory_base_name)
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
if (!(mysql_real_connect(&mysql,host,user,opt_password,
argv[0],opt_mysql_port,opt_mysql_unix_port,
@@ -114,6 +125,9 @@ int main(int argc, char **argv)
mysql_close(&mysql); /* Close & free connection */
if (opt_password)
my_free(opt_password,MYF(0));
#ifdef HAVE_SMEM
my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
#endif
my_end(0);
exit(error ? 1 : 0);
return 0; /* No compiler warnings */
@@ -147,6 +161,13 @@ static struct my_option my_long_options[] =
#ifdef __WIN__
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"protocol", OPT_MYSQL_PROTOCOL,
"The protocol of connection (tcp,socket,pipe,memory)",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SMEM
{"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"socket", 'S', "Socket file to use for connection.",
@@ -213,9 +234,18 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
tty_password=1;
break;
case 'W':
opt_mysql_unix_port=MYSQL_NAMEDPIPE;
#ifdef __WIN__
opt_protocol = MYSQL_PROTOCOL_PIPE;
#endif
break;
case OPT_MYSQL_PROTOCOL:
{
if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == ~(ulong) 0)
{
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
exit(1);
}
break;
}
case '#':
DBUG_PUSH(argument ? argument : "d:t:o");