Skip to content

Commit

Permalink
- Fix MDEV-21450
Browse files Browse the repository at this point in the history
  Failed compile when XML table type is not supported.
  Was because XMLDEF was unconditionally called from REST table.
  modified:   storage/connect/tabrest.cpp

- Make cmake less verbose
  modified:   storage/connect/CMakeLists.txt

- Hide Switch_to_definer_security_ctx not defined for 10.1 and 10.0
  modified:   storage/connect/ha_connect.cc
  • Loading branch information
Buggynours committed Jan 12, 2020
1 parent b1c8bf4 commit 8ff3eb4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
6 changes: 3 additions & 3 deletions storage/connect/CMakeLists.txt
Expand Up @@ -318,7 +318,7 @@ ENDIF(CONNECT_WITH_MONGO)
OPTION(CONNECT_WITH_REST "Compile CONNECT storage engine with REST support" ON)

IF(CONNECT_WITH_REST)
MESSAGE(STATUS "=====> REST support is ON")
# MESSAGE(STATUS "=====> REST support is ON")
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp tabrest.h)
add_definitions(-DREST_SUPPORT)
FIND_PACKAGE(cpprestsdk QUIET)
Expand All @@ -338,8 +338,8 @@ IF(CONNECT_WITH_REST)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} restget.cpp)
add_definitions(-DREST_SOURCE)
# ENDIF()
ELSE(NOT cpprestsdk_FOUND)
# MESSAGE(STATUS "=====> cpprestsdk package not found")
# ELSE(NOT cpprestsdk_FOUND)
# MESSAGE(STATUS "=====> cpprestsdk package not found")
ENDIF (cpprestsdk_FOUND)
ENDIF(CONNECT_WITH_REST)

Expand Down
4 changes: 3 additions & 1 deletion storage/connect/ha_connect.cc
Expand Up @@ -4509,7 +4509,9 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
case TAB_OEM:
if (table && table->pos_in_table_list) // if SELECT
{
Switch_to_definer_security_ctx backup_ctx(thd, table->pos_in_table_list);
#if MYSQL_VERSION_ID > 100200
Switch_to_definer_security_ctx backup_ctx(thd, table->pos_in_table_list);
#endif // VERSION_ID > 100200
return check_global_access(thd, FILE_ACL);
}
else
Expand Down
18 changes: 13 additions & 5 deletions storage/connect/tabrest.cpp
Expand Up @@ -35,7 +35,9 @@
#include "filamtxt.h"
#include "tabdos.h"
#include "plgxml.h"
#if defined(XML_SUPPORT)
#include "tabxml.h"
#endif // XML_SUPPORT
#include "tabjson.h"
#include "tabfmt.h"
#include "tabrest.h"
Expand Down Expand Up @@ -171,13 +173,15 @@ PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
// Retrieve the file from the web and copy it locally
if (http && grf(g->Message, trace(515), http, uri, filename)) {
// sprintf(g->Message, "Failed to get file at %s", http);
} else if (!stricmp(ftype, "XML"))
qrp = XMLColumns(g, db, tab, tp, info);
else if (!stricmp(ftype, "JSON"))
} else if (!stricmp(ftype, "JSON"))
qrp = JSONColumns(g, db, NULL, tp, info);
else if (!stricmp(ftype, "CSV"))
qrp = CSVColumns(g, NULL, tp, info);
else
#if defined(XML_SUPPORT)
else if (!stricmp(ftype, "XML"))
qrp = XMLColumns(g, db, tab, tp, info);
#endif // XML_SUPPORT
else
sprintf(g->Message, "Usupported file type %s", ftype);

return qrp;
Expand Down Expand Up @@ -210,7 +214,9 @@ bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
htrc("ftype = %s am = %s\n", ftype, SVP(am));

n = (!stricmp(ftype, "JSON")) ? 1
#if defined(XML_SUPPORT)
: (!stricmp(ftype, "XML")) ? 2
#endif // XML_SUPPORT
: (!stricmp(ftype, "CSV")) ? 3 : 0;

if (n == 0) {
Expand Down Expand Up @@ -238,7 +244,9 @@ bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
return true;
else switch (n) {
case 1: Tdp = new (g) JSONDEF; break;
case 2: Tdp = new (g) XMLDEF; break;
#if defined(XML_SUPPORT)
case 2: Tdp = new (g) XMLDEF; break;
#endif // XML_SUPPORT
case 3: Tdp = new (g) CSVDEF; break;
default: Tdp = NULL;
} // endswitch n
Expand Down

0 comments on commit 8ff3eb4

Please sign in to comment.