Win fixes

 - Use tmp sh file both in system and popen 
parent dfe158fc
...@@ -455,6 +455,7 @@ static void do_eval(DYNAMIC_STRING *query_eval, const char *query, ...@@ -455,6 +455,7 @@ static void do_eval(DYNAMIC_STRING *query_eval, const char *query,
static void str_to_file(const char *fname, char *str, int size); static void str_to_file(const char *fname, char *str, int size);
#ifdef __WIN__ #ifdef __WIN__
static void free_tmp_sh_file();
static void free_win_path_patterns(); static void free_win_path_patterns();
#endif #endif
...@@ -604,6 +605,7 @@ static void free_used_memory() ...@@ -604,6 +605,7 @@ static void free_used_memory()
mysql_server_end(); mysql_server_end();
free_re(); free_re();
#ifdef __WIN__ #ifdef __WIN__
free_tmp_sh_file();
free_win_path_patterns(); free_win_path_patterns();
#endif #endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -1046,6 +1048,35 @@ int do_source(struct st_query *query) ...@@ -1046,6 +1048,35 @@ int do_source(struct st_query *query)
return open_file(name); return open_file(name);
} }
//#ifdef __WIN__
/* Variables used for temuprary sh files used for emulating Unix on Windows */
char tmp_sh_name[64], tmp_sh_cmd[70];
static void init_tmp_sh_file()
{
/* Format a name for the tmp sh file that is unique for this process */
my_snprintf(tmp_sh_name, sizeof(tmp_sh_name), "tmp_%d.sh", getpid());
/* Format the command to execute in order to run the script */
my_snprintf(tmp_sh_cmd, sizeof(tmp_sh_cmd), "sh %s", tmp_sh_name);
}
static void free_tmp_sh_file()
{
my_delete(tmp_sh_name, MYF(0));
}
FILE* my_popen(DYNAMIC_STRING* ds_cmd, const char* mode)
{
#ifdef __WIN__
/* Dump the command into a sh script file and execute with popen */
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
return popen(tmp_sh_cmd, mode);
#else
return popen(ds_cmd->str, mode);
#endif
}
/* /*
Execute given command. Execute given command.
...@@ -1092,7 +1123,7 @@ static void do_exec(struct st_query *query) ...@@ -1092,7 +1123,7 @@ static void do_exec(struct st_query *query)
DBUG_PRINT("info", ("Executing '%s' as '%s'", DBUG_PRINT("info", ("Executing '%s' as '%s'",
query->first_argument, cmd)); query->first_argument, cmd));
if (!(res_file= popen(cmd, "r")) && query->abort_on_error) if (!(res_file= my_popen(&ds_cmd, "r")) && query->abort_on_error)
die("popen(\"%s\", \"r\") failed", query->first_argument); die("popen(\"%s\", \"r\") failed", query->first_argument);
while (fgets(buf, sizeof(buf), res_file)) while (fgets(buf, sizeof(buf), res_file))
...@@ -1365,15 +1396,9 @@ int do_modify_var(struct st_query *query, const char *name, ...@@ -1365,15 +1396,9 @@ int do_modify_var(struct st_query *query, const char *name,
int my_system(DYNAMIC_STRING* ds_cmd) int my_system(DYNAMIC_STRING* ds_cmd)
{ {
#ifdef __WIN__ #ifdef __WIN__
/* Dump the command into a sh script file and execute with "sh" */ /* Dump the command into a sh script file and execute with system */
int err;
char tmp_sh_name[64], tmp_sh_cmd[70];
my_snprintf(tmp_sh_name, sizeof(tmp_sh_name), "tmp_%d.sh", getpid());
my_snprintf(tmp_sh_cmd, sizeof(tmp_sh_cmd), "sh %s", tmp_sh_name);
str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length); str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
err= system(tmp_sh_cmd); return system(tmp_sh_cmd);
my_delete(tmp_sh_name, MYF(0));
return err;
#else #else
return system(ds_cmd->str); return system(ds_cmd->str);
#endif #endif
......
...@@ -379,9 +379,9 @@ mysqltest: At line 1: Could not open connection 'con2': 1049 Unknown database 'i ...@@ -379,9 +379,9 @@ mysqltest: At line 1: Could not open connection 'con2': 1049 Unknown database 'i
mysqltest: At line 1: Illegal argument for port: 'illegal_port' mysqltest: At line 1: Illegal argument for port: 'illegal_port'
mysqltest: At line 1: Illegal option to connect: SMTP mysqltest: At line 1: Illegal option to connect: SMTP
OK OK
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/con.sql": At line 7: Connection limit exhausted - increase MAX_CONS in mysqltest.c mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 7: Connection limit exhausted - increase MAX_CONS in mysqltest.c
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/con.sql": At line 3: connection 'test_con1' not found in connection pool mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 3: connection 'test_con1' not found in connection pool
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/con.sql": At line 2: Connection test_con1 already exists mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql": At line 2: Connection test_con1 already exists
connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET); connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET);
Output from mysqltest-x.inc Output from mysqltest-x.inc
Output from mysqltest-x.inc Output from mysqltest-x.inc
......
...@@ -599,6 +599,8 @@ echo $var3_var3; ...@@ -599,6 +599,8 @@ echo $var3_var3;
--error 1 --error 1
--exec echo "source ;" | $MYSQL_TEST 2>&1 --exec echo "source ;" | $MYSQL_TEST 2>&1
# Fix win paths
--replace_result \\ /
--error 1 --error 1
--exec echo "source non_existingFile;" | $MYSQL_TEST 2>&1 --exec echo "source non_existingFile;" | $MYSQL_TEST 2>&1
...@@ -806,6 +808,8 @@ while (!$i) ...@@ -806,6 +808,8 @@ while (!$i)
} }
# Exceed max nesting level # Exceed max nesting level
# Fix win path
--replace_result \\ /
--error 1 --error 1
--exec echo "source include/mysqltest_while.inc;" | $MYSQL_TEST 2>&1 --exec echo "source include/mysqltest_while.inc;" | $MYSQL_TEST 2>&1
--error 1 --error 1
...@@ -925,41 +929,41 @@ select "a" as col1, "c" as col2; ...@@ -925,41 +929,41 @@ select "a" as col1, "c" as col2;
--exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1 --exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1
# Repeat connect/disconnect # Repeat connect/disconnect
--exec echo "let \$i=100;" > $MYSQLTEST_VARDIR/tmp/con.sql --system echo "let \$i=100;" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "{" >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo "{" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "}" >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo "}" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "source $MYSQLTEST_VARDIR/tmp/con.sql; echo OK;" | $MYSQL_TEST 2>&1 --exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql; echo OK;" | $MYSQL_TEST 2>&1
# Repeat connect/disconnect, exceed max number of connections # Repeat connect/disconnect, exceed max number of connections
--exec echo "let \$i=200;" > $MYSQLTEST_VARDIR/tmp/con.sql --system echo "let \$i=200;" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo "while (\$i)" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "{" >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo "{" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo " connect (test_con1,localhost,root,,); " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo " disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo " dec \$i; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "}" >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo "}" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1 --error 1
--exec echo "source $MYSQLTEST_VARDIR/tmp/con.sql;" | $MYSQL_TEST 2>&1 --exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
# Select disconnected connection # Select disconnected connection
--exec echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/con.sql --system echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo "disconnect test_con1; " >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "connection test_con1;" >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo "connection test_con1;" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1 --error 1
--exec echo "source $MYSQLTEST_VARDIR/tmp/con.sql;" | $MYSQL_TEST 2>&1 --exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
# Connection name already used # Connection name already used
--exec echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/con.sql --system echo "connect (test_con1,localhost,root,,);" > $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--exec echo "connect (test_con1,localhost,root,,);" >> $MYSQLTEST_VARDIR/tmp/con.sql --system echo "connect (test_con1,localhost,root,,);" >> $MYSQLTEST_VARDIR/tmp/mysqltest.sql
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1 --error 1
--exec echo "source $MYSQLTEST_VARDIR/tmp/con.sql;" | $MYSQL_TEST 2>&1 --exec echo "source $MYSQLTEST_VARDIR/tmp/mysqltest.sql;" | $MYSQL_TEST 2>&1
# connect when "disable_abort_on_error" caused "connection not found" # connect when "disable_abort_on_error" caused "connection not found"
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
...@@ -977,6 +981,8 @@ connection con1; ...@@ -977,6 +981,8 @@ connection con1;
--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc --exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc
--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc --exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc
--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc --exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc
# Fix Win paths
--replace_result \\ /
--error 1 --error 1
--exec $MYSQL_TEST -x non_existing_file.inc 2>&1 --exec $MYSQL_TEST -x non_existing_file.inc 2>&1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment