1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Manual merge from mysql-trunk-merge.

This commit is contained in:
Alexander Nozdrin
2009-11-06 17:20:27 +03:00
137 changed files with 2948 additions and 1099 deletions

View File

@ -46,6 +46,9 @@ static char *opt_user= 0;
static char *opt_password= 0;
static char *opt_host= 0;
static char *opt_unix_socket= 0;
#ifdef HAVE_SMEM
static char *shared_memory_base_name= 0;
#endif
static unsigned int opt_port;
static my_bool tty_password= 0, opt_silent= 0;
@ -230,6 +233,26 @@ static void print_st_error(MYSQL_STMT *stmt, const char *msg)
}
}
/*
Enhanced version of mysql_client_init(), which may also set shared memory
base on Windows.
*/
static MYSQL *mysql_client_init(MYSQL* con)
{
MYSQL* res = mysql_init(con);
#ifdef HAVE_SMEM
if (res && shared_memory_base_name)
mysql_options(res, MYSQL_SHARED_MEMORY_BASE_NAME, shared_memory_base_name);
#endif
return res;
}
/*
Disable direct calls of mysql_init, as it disregards shared memory base.
*/
#define mysql_init(A) Please use mysql_client_init instead of mysql_init
/* Check if the connection has InnoDB tables */
static my_bool check_have_innodb(MYSQL *conn)
@ -293,10 +316,10 @@ static MYSQL* client_connect(ulong flag, uint protocol, my_bool auto_reconnect)
fprintf(stdout, "\n Establishing a connection to '%s' ...",
opt_host ? opt_host : "");
if (!(mysql= mysql_init(NULL)))
if (!(mysql= mysql_client_init(NULL)))
{
opt_silent= 0;
myerror("mysql_init() failed");
myerror("mysql_client_init() failed");
exit(1);
}
/* enable local infile, in non-binary builds often disabled by default */
@ -1183,9 +1206,9 @@ static my_bool thread_query(char *query)
error= 0;
if (!opt_silent)
fprintf(stdout, "\n in thread_query(%s)", query);
if (!(l_mysql= mysql_init(NULL)))
if (!(l_mysql= mysql_client_init(NULL)))
{
myerror("mysql_init() failed");
myerror("mysql_client_init() failed");
return 1;
}
if (!(mysql_real_connect(l_mysql, opt_host, opt_user,
@ -3097,9 +3120,9 @@ static void test_ps_query_cache()
case TEST_QCACHE_ON_WITH_OTHER_CONN:
if (!opt_silent)
fprintf(stdout, "\n Establishing a test connection ...");
if (!(lmysql= mysql_init(NULL)))
if (!(lmysql= mysql_client_init(NULL)))
{
printf("mysql_init() failed");
printf("mysql_client_init() failed");
DIE_UNLESS(0);
}
if (!(mysql_real_connect(lmysql, opt_host, opt_user,
@ -5545,9 +5568,9 @@ static void test_stmt_close()
if (!opt_silent)
fprintf(stdout, "\n Establishing a test connection ...");
if (!(lmysql= mysql_init(NULL)))
if (!(lmysql= mysql_client_init(NULL)))
{
myerror("mysql_init() failed");
myerror("mysql_client_init() failed");
exit(1);
}
if (!(mysql_real_connect(lmysql, opt_host, opt_user,
@ -6436,9 +6459,9 @@ DROP TABLE IF EXISTS test_multi_tab";
rc= mysql_more_results(mysql);
DIE_UNLESS(rc == 0);
if (!(mysql_local= mysql_init(NULL)))
if (!(mysql_local= mysql_client_init(NULL)))
{
fprintf(stdout, "\n mysql_init() failed");
fprintf(stdout, "\n mysql_client_init() failed");
exit(1);
}
@ -6561,9 +6584,9 @@ static void test_prepare_multi_statements()
char query[MAX_TEST_QUERY_LENGTH];
myheader("test_prepare_multi_statements");
if (!(mysql_local= mysql_init(NULL)))
if (!(mysql_local= mysql_client_init(NULL)))
{
fprintf(stderr, "\n mysql_init() failed");
fprintf(stderr, "\n mysql_client_init() failed");
exit(1);
}
@ -8044,9 +8067,9 @@ static void test_prepare_grant()
if (!opt_silent)
fprintf(stdout, "\n Establishing a test connection ...");
if (!(lmysql= mysql_init(NULL)))
if (!(lmysql= mysql_client_init(NULL)))
{
myerror("mysql_init() failed");
myerror("mysql_client_init() failed");
exit(1);
}
if (!(mysql_real_connect(lmysql, opt_host, "test_grant",
@ -8500,9 +8523,9 @@ static void test_drop_temp()
if (!opt_silent)
fprintf(stdout, "\n Establishing a test connection ...");
if (!(lmysql= mysql_init(NULL)))
if (!(lmysql= mysql_client_init(NULL)))
{
myerror("mysql_init() failed");
myerror("mysql_client_init() failed");
exit(1);
}
@ -13744,7 +13767,7 @@ static void test_bug15518()
int rc;
myheader("test_bug15518");
mysql1= mysql_init(NULL);
mysql1= mysql_client_init(NULL);
if (!mysql_real_connect(mysql1, opt_host, opt_user, opt_password,
opt_db ? opt_db : "test", opt_port, opt_unix_socket,
@ -13900,9 +13923,9 @@ static void test_bug8378()
if (!opt_silent)
fprintf(stdout, "\n Establishing a test connection ...");
if (!(lmysql= mysql_init(NULL)))
if (!(lmysql= mysql_client_init(NULL)))
{
myerror("mysql_init() failed");
myerror("mysql_client_init() failed");
exit(1);
}
if (mysql_options(lmysql, MYSQL_SET_CHARSET_NAME, "gbk"))
@ -14441,7 +14464,7 @@ static void test_bug9992()
if (!opt_silent)
printf("Establishing a connection with option CLIENT_MULTI_STATEMENTS..\n");
mysql1= mysql_init(NULL);
mysql1= mysql_client_init(NULL);
if (!mysql_real_connect(mysql1, opt_host, opt_user, opt_password,
opt_db ? opt_db : "test", opt_port, opt_unix_socket,
@ -15030,9 +15053,9 @@ static void test_bug12001()
myheader("test_bug12001");
if (!(mysql_local= mysql_init(NULL)))
if (!(mysql_local= mysql_client_init(NULL)))
{
fprintf(stdout, "\n mysql_init() failed");
fprintf(stdout, "\n mysql_client_init() failed");
exit(1);
}
@ -15756,9 +15779,9 @@ static void test_opt_reconnect()
myheader("test_opt_reconnect");
if (!(lmysql= mysql_init(NULL)))
if (!(lmysql= mysql_client_init(NULL)))
{
myerror("mysql_init() failed");
myerror("mysql_client_init() failed");
exit(1);
}
@ -15793,9 +15816,9 @@ static void test_opt_reconnect()
mysql_close(lmysql);
if (!(lmysql= mysql_init(NULL)))
if (!(lmysql= mysql_client_init(NULL)))
{
myerror("mysql_init() failed");
myerror("mysql_client_init() failed");
DIE_UNLESS(0);
}
@ -15830,7 +15853,7 @@ static void test_bug12744()
int rc;
myheader("test_bug12744");
lmysql= mysql_init(NULL);
lmysql= mysql_client_init(NULL);
DIE_UNLESS(lmysql);
if (!mysql_real_connect(lmysql, opt_host, opt_user, opt_password,
@ -16403,7 +16426,7 @@ static void test_bug15752()
rc= mysql_query(mysql, "create procedure p1() select 1");
myquery(rc);
mysql_init(&mysql_local);
mysql_client_init(&mysql_local);
if (! mysql_real_connect(&mysql_local, opt_host, opt_user,
opt_password, current_db, opt_port,
opt_unix_socket,
@ -17289,7 +17312,7 @@ static void test_bug29692()
{
MYSQL* conn;
if (!(conn= mysql_init(NULL)))
if (!(conn= mysql_client_init(NULL)))
{
myerror("test_bug29692 init failed");
exit(1);
@ -17424,7 +17447,7 @@ static void test_bug30472()
/* Create a new connection. */
DIE_UNLESS(mysql_init(&con));
DIE_UNLESS(mysql_client_init(&con));
DIE_UNLESS(mysql_real_connect(&con,
opt_host,
@ -17598,7 +17621,7 @@ static void test_bug20023()
/* Create a new connection. */
DIE_UNLESS(mysql_init(&con));
DIE_UNLESS(mysql_client_init(&con));
DIE_UNLESS(mysql_real_connect(&con,
opt_host,
@ -17735,7 +17758,7 @@ static void bug31418_impl()
/* Create a new connection. */
DIE_UNLESS(mysql_init(&con));
DIE_UNLESS(mysql_client_init(&con));
DIE_UNLESS(mysql_real_connect(&con,
opt_host,
@ -18413,9 +18436,9 @@ static void test_bug33831(void)
error= 0;
if (!(l_mysql= mysql_init(NULL)))
if (!(l_mysql= mysql_client_init(NULL)))
{
myerror("mysql_init() failed");
myerror("mysql_client_init() failed");
DIE_UNLESS(0);
}
if (!(mysql_real_connect(l_mysql, opt_host, opt_user,
@ -18790,7 +18813,7 @@ static void test_bug44495()
"END;");
myquery(rc);
DIE_UNLESS(mysql_init(&con));
DIE_UNLESS(mysql_client_init(&con));
DIE_UNLESS(mysql_real_connect(&con, opt_host, opt_user, opt_password,
current_db, opt_port, opt_unix_socket,
@ -18853,6 +18876,11 @@ static struct my_option client_test_long_options[] =
0, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0,
0},
#ifdef HAVE_SMEM
{"shared-memory-base-name", 'm', "Base name of shared memory.",
(uchar**) &shared_memory_base_name, (uchar**)&shared_memory_base_name, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"socket", 'S', "Socket file to use for connection",
(uchar **) &opt_unix_socket, (uchar **) &opt_unix_socket, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},