summaryrefslogtreecommitdiff
path: root/client/mysql.cc
diff options
context:
space:
mode:
authorunknown <anozdrin/alik@alik.>2006-11-07 13:45:56 +0300
committerunknown <anozdrin/alik@alik.>2006-11-07 13:45:56 +0300
commitb4093b65bea0c57f0ecdbd14c86bcdfce35936a4 (patch)
tree42fb1db881900588ca6d4b0cce2a7d825736863a /client/mysql.cc
parente5bd94b2d4fd6937a0f5ff53a295fe14a83ccaef (diff)
parent024a1781a6310383c1e352d483e7a701d564d051 (diff)
downloadmariadb-git-b4093b65bea0c57f0ecdbd14c86bcdfce35936a4.tar.gz
Merge alik.:/mnt/raid/alik/MySQL/devel/5.0-rt
into alik.:/mnt/raid/alik/MySQL/devel/5.0-merged-5.0-rt configure.in: Auto merged include/my_time.h: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/rename.result: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/im_daemon_life_cycle.imtest: Auto merged mysql-test/t/rename.test: Auto merged sql-common/my_time.c: Auto merged sql/item_timefunc.cc: Auto merged sql/time.cc: Auto merged
Diffstat (limited to 'client/mysql.cc')
-rw-r--r--client/mysql.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 1d7abbbc38a..d0965588b80 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -388,6 +388,21 @@ int main(int argc,char *argv[])
else
status.add_to_history=1;
status.exit_status=1;
+
+ {
+ /*
+ The file descriptor-layer may be out-of-sync with the file-number layer,
+ so we make sure that "stdout" is really open. If its file is closed then
+ explicitly close the FD layer.
+ */
+ int stdout_fileno_copy;
+ stdout_fileno_copy= dup(fileno(stdout)); /* Okay if fileno fails. */
+ if (stdout_fileno_copy == -1)
+ fclose(stdout);
+ else
+ close(stdout_fileno_copy); /* Clean up dup(). */
+ }
+
load_defaults("my",load_default_groups,&argc,&argv);
defaults_argv=argv;
if (get_options(argc, (char **) argv))
@@ -2109,6 +2124,8 @@ com_go(String *buffer,char *line __attribute__((unused)))
(long) mysql_num_rows(result),
(long) mysql_num_rows(result) == 1 ? "row" : "rows");
end_pager();
+ if (mysql_errno(&mysql))
+ error= put_error(&mysql);
}
}
else if (mysql_affected_rows(&mysql) == ~(ulonglong) 0)
@@ -2919,7 +2936,11 @@ com_connect(String *buffer, char *line)
bzero(buff, sizeof(buff));
if (buffer)
{
- strmake(buff, line, sizeof(buff) - 1);
+ /*
+ Two null bytes are needed in the end of buff to allow
+ get_arg to find end of string the second time it's called.
+ */
+ strmake(buff, line, sizeof(buff)-2);
tmp= get_arg(buff, 0);
if (tmp && *tmp)
{