summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2021-04-06 00:10:07 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2021-04-06 00:10:07 +0200
commit28b76afceac1eb2c35e77439142daac53908cdc3 (patch)
treeec9c1c66bf1d3ab9688959d164d7ca268eadac19
parent2aefe0bee1fc1bb74f1e02448825917183c305e5 (diff)
downloadmariadb-git-28b76afceac1eb2c35e77439142daac53908cdc3.tar.gz
- Fix(?) Linux compile errors
modified: storage/connect/tabrest.cpp modified: storage/connect/CMakeLists.txt -fix MDEV-24794 modified: storage/connect/valblk.h
-rw-r--r--storage/connect/CMakeLists.txt3
-rw-r--r--storage/connect/tabrest.cpp30
-rw-r--r--storage/connect/valblk.h2
3 files changed, 20 insertions, 15 deletions
diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt
index 72934aa953c..028376d510b 100644
--- a/storage/connect/CMakeLists.txt
+++ b/storage/connect/CMakeLists.txt
@@ -354,6 +354,9 @@ IF(CONNECT_WITH_REST)
##ELSE(NOT cpprestsdk_FOUND)
## MESSAGE(STATUS "=====> cpprestsdk package not found")
# ENDIF (cpprestsdk_FOUND)
+IF(UNIX)
+ SET(REST_LIBRARY -lexplain)
+ENDIF(UNIX)
ENDIF(CONNECT_WITH_REST)
#
diff --git a/storage/connect/tabrest.cpp b/storage/connect/tabrest.cpp
index 9204043da62..af1961c8314 100644
--- a/storage/connect/tabrest.cpp
+++ b/storage/connect/tabrest.cpp
@@ -24,6 +24,10 @@
#else // !__WIN__
#define __stdcall
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
+#include <sys/types.h>
+#include <unistd.h>
+#include "stdio.h"
+#include <sys/wait.h>
#include <libexplain/execlp.h>
#endif // !__WIN__
#endif // !REST_SOURCE
@@ -98,18 +102,6 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename)
int rc = 0;
FILE *pipe;
- if ((pipe = popen("curl --version", "r"))) {
- if (trace(515))
- while (fgets(buf, sizeof(buf), pipe)) {
- htrc("%s", buf);
- } // endwhile
-
- pclose(pipe);
- } else {
- sprintf(g->Message, "curl not available, errno=%d", errno);
- return 1;
- } // endif pipe
-
if (strchr(filename, '"')) {
strcpy(g->Message, "Invalid file name");
return 1;
@@ -149,15 +141,25 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename)
} // endif CreateProcess
#else // !__WIN__
char fn[600];
- pid_t pID = vfork();
+ pid_t pID;
+ // Check if curl package is availabe by executing subprocess
+ FILE *f= popen("command -v curl", "r");
+
+ if (!f) {
+ strcpy(g->Message, "curl CLI not installed");
+ return 1;
+ } else
+ close(f);
+
+ pID = vfork();
sprintf(fn, "-o%s", filename);
if (pID == 0) {
// Code executed by child process
execlp("curl", "curl", buf, fn, (char*)NULL);
// If execlp() is successful, we should not reach this next line.
- strcpy(g->Message, explain_execlp());
+ strcpy(g->Message, explain_execlp("curl", "curl", buf, fn, (char*)NULL)));
rc = 1;
exit(rc);
} // endif execlp
diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h
index ad970105868..568fc172c6a 100644
--- a/storage/connect/valblk.h
+++ b/storage/connect/valblk.h
@@ -69,7 +69,7 @@ class VALBLK : public BLOCK {
int GetPrec(void) {return Prec;}
void SetCheck(bool b) {Check = b;}
void MoveNull(int i, int j)
- {if (To_Nulls) To_Nulls[j] = To_Nulls[j];}
+ {if (To_Nulls) To_Nulls[j] = To_Nulls[i];}
virtual void SetNull(int n, bool b)
{if (To_Nulls) {To_Nulls[n] = (b) ? '*' : 0;}}
virtual bool IsNull(int n) {return To_Nulls && To_Nulls[n];}