summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2021-12-07 17:42:47 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2021-12-07 17:42:47 +0100
commit8dd1f01d0933596f3dde87f32b39bebca5aa1bff (patch)
tree5c1cdce7c817472d3b5eaa95f2cd324c79aa34ec
parentd5ceddb39140b34dd6fc9ac68ef3f5f17cae857d (diff)
downloadmariadb-git-8dd1f01d0933596f3dde87f32b39bebca5aa1bff.tar.gz
MDEV-27191 MariaDB client - "system" command does not work on Windows
- define USE_POPEN, like it is done elsewhere. - use Notepad as default editor on Windows for the "edit" command.
-rw-r--r--client/mysql.cc11
1 files changed, 3 insertions, 8 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 177d0f60757..382c216f772 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -96,8 +96,8 @@ extern "C" {
# include <readline.h>
# endif
#define HAVE_READLINE
-#define USE_POPEN
#endif
+#define USE_POPEN
}
#ifdef HAVE_VIDATTR
@@ -4210,11 +4210,6 @@ com_nopager(String *buffer __attribute__((unused)),
}
#endif
-
-/*
- Sorry, you can't send the result to an editor in Win32
-*/
-
#ifdef USE_POPEN
static int
com_edit(String *buffer,char *line __attribute__((unused)))
@@ -4236,7 +4231,7 @@ com_edit(String *buffer,char *line __attribute__((unused)))
if (!(editor = (char *)getenv("EDITOR")) &&
!(editor = (char *)getenv("VISUAL")))
- editor = "vi";
+ editor = IF_WIN("notepad","vi");
strxmov(buff,editor," ",filename,NullS);
if ((error= system(buff)))
{
@@ -4251,7 +4246,7 @@ com_edit(String *buffer,char *line __attribute__((unused)))
if ((fd = my_open(filename,O_RDONLY, MYF(MY_WME))) < 0)
goto err;
(void) buffer->alloc((uint) stat_arg.st_size);
- if ((tmp=read(fd,(char*) buffer->ptr(),buffer->alloced_length())) >= 0L)
+ if ((tmp=(int)my_read(fd,(uchar*) buffer->ptr(),buffer->alloced_length(),MYF(0))) >= 0)
buffer->length((uint) tmp);
else
buffer->length(0);