You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Added build option WITH_REMOTEIO (default=off)
This commit is contained in:
@@ -27,6 +27,7 @@ ELSE()
|
|||||||
OPTION(WITH_SIGNCODE "digitally sign files" OFF)
|
OPTION(WITH_SIGNCODE "digitally sign files" OFF)
|
||||||
OPTION(WITH_RTC "enables run time checks for debug builds" OFF)
|
OPTION(WITH_RTC "enables run time checks for debug builds" OFF)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
OPTION(WITH_REMOTEIO "enables remote io support (requires libcurl)" OFF)
|
||||||
|
|
||||||
OPTION(WITH_EXTERNAL_ZLIB "Enables use of external zlib" OFF)
|
OPTION(WITH_EXTERNAL_ZLIB "Enables use of external zlib" OFF)
|
||||||
###############
|
###############
|
||||||
@@ -90,9 +91,8 @@ IF(NOT MYSQL_UNIX_ADDR)
|
|||||||
SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
|
SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
FIND_PACKAGE(CURL)
|
IF(WITH_REMOTEIO)
|
||||||
IF(CURL_FOUND)
|
ADD_DEFINITIONS(-DHAVE_REMOTEIO)
|
||||||
ADD_DEFINITIONS(-DHAVE_CURL=1)
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/install.cmake")
|
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/install.cmake")
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#ifndef _ma_io_h_
|
#ifndef _ma_io_h_
|
||||||
#define _ma_io_h_
|
#define _ma_io_h_
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CURL
|
#ifdef HAVE_CURL
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -34,6 +35,7 @@ typedef struct
|
|||||||
void *ptr;
|
void *ptr;
|
||||||
} MA_FILE;
|
} MA_FILE;
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
struct st_rio_methods {
|
struct st_rio_methods {
|
||||||
MA_FILE *(*open)(const char *url, const char *mode);
|
MA_FILE *(*open)(const char *url, const char *mode);
|
||||||
int (*close)(MA_FILE *ptr);
|
int (*close)(MA_FILE *ptr);
|
||||||
@@ -41,6 +43,7 @@ struct st_rio_methods {
|
|||||||
size_t (*read)(void *ptr, size_t size, size_t nmemb, MA_FILE *file);
|
size_t (*read)(void *ptr, size_t size, size_t nmemb, MA_FILE *file);
|
||||||
char * (*gets)(char *ptr, size_t size, MA_FILE *file);
|
char * (*gets)(char *ptr, size_t size, MA_FILE *file);
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* function prototypes */
|
/* function prototypes */
|
||||||
MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql);
|
MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql);
|
||||||
|
@@ -40,13 +40,16 @@
|
|||||||
#define MYSQL_CLIENT_reserved 1
|
#define MYSQL_CLIENT_reserved 1
|
||||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2
|
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2
|
||||||
#define MYSQL_CLIENT_reserved22 3
|
#define MYSQL_CLIENT_reserved22 3
|
||||||
#define MYSQL_CLIENT_REMOTEIO_PLUGIN 4
|
|
||||||
|
|
||||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0100
|
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0100
|
||||||
#define MYSQL_CLIENT_DB_PLUGIN_INTERFACE_VERSION 0x0100
|
#define MYSQL_CLIENT_DB_PLUGIN_INTERFACE_VERSION 0x0100
|
||||||
#define MYSQL_CLIENT_REMOTEIO_PLUGIN_INTERFACE_VERSION 0x0100
|
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
|
#define MYSQL_CLIENT_REMOTEIO_PLUGIN 4
|
||||||
#define MYSQL_CLIENT_MAX_PLUGINS 5
|
#define MYSQL_CLIENT_MAX_PLUGINS 5
|
||||||
|
#define MYSQL_CLIENT_REMOTEIO_PLUGIN_INTERFACE_VERSION 0x0100
|
||||||
|
#else
|
||||||
|
#define MYSQL_CLIENT_MAX_PLUGINS 4
|
||||||
|
#endif
|
||||||
|
|
||||||
#define mysql_declare_client_plugin(X) \
|
#define mysql_declare_client_plugin(X) \
|
||||||
struct st_mysql_client_plugin_ ## X \
|
struct st_mysql_client_plugin_ ## X \
|
||||||
@@ -113,6 +116,7 @@ typedef char *(*mysql_authentication_dialog_ask_t)(struct st_mysql *mysql,
|
|||||||
int type, const char *prompt, char *buf, int buf_len);
|
int type, const char *prompt, char *buf, int buf_len);
|
||||||
|
|
||||||
/********************** remote IO plugin **********************/
|
/********************** remote IO plugin **********************/
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
#include <mariadb/ma_io.h>
|
#include <mariadb/ma_io.h>
|
||||||
|
|
||||||
/* Remote IO plugin */
|
/* Remote IO plugin */
|
||||||
@@ -121,6 +125,7 @@ struct st_mysql_client_plugin_REMOTEIO
|
|||||||
MYSQL_CLIENT_PLUGIN_HEADER
|
MYSQL_CLIENT_PLUGIN_HEADER
|
||||||
struct st_rio_methods *methods;
|
struct st_rio_methods *methods;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/******** using plugins ************/
|
/******** using plugins ************/
|
||||||
|
|
||||||
|
@@ -64,7 +64,9 @@ static uint plugin_version[MYSQL_CLIENT_MAX_PLUGINS]=
|
|||||||
0, /* these two are taken by Connector/C */
|
0, /* these two are taken by Connector/C */
|
||||||
MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION,
|
MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION,
|
||||||
0,
|
0,
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
MYSQL_CLIENT_REMOTEIO_PLUGIN_INTERFACE_VERSION
|
MYSQL_CLIENT_REMOTEIO_PLUGIN_INTERFACE_VERSION
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct st_mysql_client_plugin_AUTHENTICATION auth_plugin_t;
|
typedef struct st_mysql_client_plugin_AUTHENTICATION auth_plugin_t;
|
||||||
|
@@ -23,10 +23,13 @@
|
|||||||
#include <errmsg.h>
|
#include <errmsg.h>
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
#include <mysql/client_plugin.h>
|
#include <mysql/client_plugin.h>
|
||||||
|
#include <mariadb/ma_io.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
struct st_mysql_client_plugin_REMOTEIO *rio_plugin= NULL;
|
struct st_mysql_client_plugin_REMOTEIO *rio_plugin= NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* {{{ ma_open */
|
/* {{{ ma_open */
|
||||||
MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql)
|
MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql)
|
||||||
@@ -37,9 +40,10 @@ MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql)
|
|||||||
|
|
||||||
if (!location || !location[0])
|
if (!location || !location[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
if (strstr(location, "://"))
|
if (strstr(location, "://"))
|
||||||
goto remote;
|
goto remote;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (mysql && mysql->charset)
|
if (mysql && mysql->charset)
|
||||||
@@ -118,6 +122,7 @@ MA_FILE *ma_open(const char *location, const char *mode, MYSQL *mysql)
|
|||||||
ma_file->ptr= (void *)fp;
|
ma_file->ptr= (void *)fp;
|
||||||
}
|
}
|
||||||
return ma_file;
|
return ma_file;
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
remote:
|
remote:
|
||||||
/* check if plugin for remote io is available and try
|
/* check if plugin for remote io is available and try
|
||||||
* to open location */
|
* to open location */
|
||||||
@@ -128,6 +133,7 @@ remote:
|
|||||||
return rio_plugin->methods->open(location, mode);
|
return rio_plugin->methods->open(location, mode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
@@ -143,9 +149,11 @@ int ma_close(MA_FILE *file)
|
|||||||
rc= fclose((FILE *)file->ptr);
|
rc= fclose((FILE *)file->ptr);
|
||||||
my_free(file);
|
my_free(file);
|
||||||
break;
|
break;
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
case MA_FILE_REMOTE:
|
case MA_FILE_REMOTE:
|
||||||
rc= rio_plugin->methods->close(file);
|
rc= rio_plugin->methods->close(file);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -163,9 +171,11 @@ int ma_feof(MA_FILE *file)
|
|||||||
case MA_FILE_LOCAL:
|
case MA_FILE_LOCAL:
|
||||||
return feof((FILE *)file->ptr);
|
return feof((FILE *)file->ptr);
|
||||||
break;
|
break;
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
case MA_FILE_REMOTE:
|
case MA_FILE_REMOTE:
|
||||||
return rio_plugin->methods->feof(file);
|
return rio_plugin->methods->feof(file);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -184,9 +194,11 @@ size_t ma_read(void *ptr, size_t size, size_t nmemb, MA_FILE *file)
|
|||||||
s= fread(ptr, size, nmemb, (FILE *)file->ptr);
|
s= fread(ptr, size, nmemb, (FILE *)file->ptr);
|
||||||
return s;
|
return s;
|
||||||
break;
|
break;
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
case MA_FILE_REMOTE:
|
case MA_FILE_REMOTE:
|
||||||
return rio_plugin->methods->read(ptr, size, nmemb, file);
|
return rio_plugin->methods->read(ptr, size, nmemb, file);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -203,9 +215,11 @@ char *ma_gets(char *ptr, size_t size, MA_FILE *file)
|
|||||||
case MA_FILE_LOCAL:
|
case MA_FILE_LOCAL:
|
||||||
return fgets(ptr, size, (FILE *)file->ptr);
|
return fgets(ptr, size, (FILE *)file->ptr);
|
||||||
break;
|
break;
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
case MA_FILE_REMOTE:
|
case MA_FILE_REMOTE:
|
||||||
return rio_plugin->methods->gets(ptr, size, file);
|
return rio_plugin->methods->gets(ptr, size, file);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
|
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
|
||||||
|
|
||||||
IF(CURL_FOUND)
|
IF(WITH_REMOTEIO)
|
||||||
|
FIND_PACKAGE(CURL)
|
||||||
|
IF(CURL_FOUND)
|
||||||
|
ADD_DEFINITIONS(-DHAVE_CURL=1)
|
||||||
# remote file plugin
|
# remote file plugin
|
||||||
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
|
||||||
SET(REMOTE_IO_SOURCES remote_io.c)
|
SET(REMOTE_IO_SOURCES remote_io.c)
|
||||||
@@ -14,4 +17,5 @@ IF(CURL_FOUND)
|
|||||||
RUNTIME DESTINATION "${PLUGIN_INSTALL_DIR}"
|
RUNTIME DESTINATION "${PLUGIN_INSTALL_DIR}"
|
||||||
LIBRARY DESTINATION "${PLUGIN_INSTALL_DIR}"
|
LIBRARY DESTINATION "${PLUGIN_INSTALL_DIR}"
|
||||||
ARCHIVE DESTINATION "${PLUGIN_INSTALL_DIR}")
|
ARCHIVE DESTINATION "${PLUGIN_INSTALL_DIR}")
|
||||||
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
@@ -26,7 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#include <mysql/client_plugin.h>
|
#include <mysql/client_plugin.h>
|
||||||
|
|
||||||
void *remote_plugin;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bug#28075 "COM_DEBUG crashes mysqld"
|
Bug#28075 "COM_DEBUG crashes mysqld"
|
||||||
@@ -1003,6 +1002,8 @@ static int test_conc117(MYSQL *mysql)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
|
void *remote_plugin;
|
||||||
static int test_remote1(MYSQL *mysql)
|
static int test_remote1(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
@@ -1048,10 +1049,13 @@ static int test_remote2(MYSQL *my)
|
|||||||
mysql_close(mysql);
|
mysql_close(mysql);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
#ifdef HAVE_REMOTEIO
|
||||||
{"test_remote1", test_remote1, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
{"test_remote1", test_remote1, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||||
{"test_remote2", test_remote2, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
{"test_remote2", test_remote2, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||||
|
#endif
|
||||||
{"test_conc117", test_conc117, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_conc117", test_conc117, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_conc_114", test_conc_114, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_conc_114", test_conc_114, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_connect_attrs", test_connect_attrs, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_connect_attrs", test_connect_attrs, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
|
@@ -3871,7 +3871,6 @@ static int test_conc_5(MYSQL *mysql)
|
|||||||
static int test_conc141(MYSQL *mysql)
|
static int test_conc141(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
MYSQL_RES *res;
|
|
||||||
char *query= "CALL p_conc141";
|
char *query= "CALL p_conc141";
|
||||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user