summaryrefslogtreecommitdiff
path: root/storage/connect/ha_connect.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/connect/ha_connect.cc')
-rw-r--r--storage/connect/ha_connect.cc125
1 files changed, 62 insertions, 63 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 7d9c7517159..c1262b9630a 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -139,10 +139,10 @@
//#include "reldef.h"
#include "tabcol.h"
#include "xindex.h"
-#if defined(__WIN__)
+#if defined(_WIN32)
#include <io.h>
#include "tabwmi.h"
-#endif // __WIN__
+#endif // _WIN32
#include "connect.h"
#include "user_connect.h"
#include "ha_connect.h"
@@ -167,16 +167,16 @@
#define SZCONV 1024 // Default converted text size
#define SZWORK 67108864 // Default work area size 64M
#define SZWMIN 4194304 // Minimum work area size 4M
-#define JSONMAX 10 // JSON Default max grp size
+#define JSONMAX 50 // JSON Default max grp size
extern "C" {
- char version[]= "Version 1.07.0002 March 22, 2021";
-#if defined(__WIN__)
- char compver[]= "Version 1.07.0002 " __DATE__ " " __TIME__;
+ char version[]= "Version 1.07.0003 June 06, 2021";
+#if defined(_WIN32)
+ char compver[]= "Version 1.07.0003 " __DATE__ " " __TIME__;
char slash= '\\';
-#else // !__WIN__
+#else // !_WIN32
char slash= '/';
-#endif // !__WIN__
+#endif // !_WIN32
} // extern "C"
#if MYSQL_VERSION_ID > 100200
@@ -288,15 +288,14 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
/****************************************************************************/
static char *strz(PGLOBAL g, LEX_CSTRING &ls)
{
- char *str= (char*)PlugSubAlloc(g, NULL, ls.length + 1);
-
- /*
- ls.str can be NULL, for example when called with
- create_info->connect_string
- */
- if (ls.str)
+ char* str= NULL;
+
+ if (ls.str) {
+ str= (char*)PlugSubAlloc(g, NULL, ls.length + 1);
memcpy(str, ls.str, ls.length);
- str[ls.length]= 0;
+ str[ls.length] = 0;
+ } // endif str
+
return str;
} // end of strz
@@ -511,7 +510,7 @@ char *GetJsonNull(void)
int GetDefaultDepth(void) {return THDVAR(current_thd, default_depth);}
int GetDefaultPrec(void) {return THDVAR(current_thd, default_prec);}
uint GetJsonGrpSize(void)
- {return connect_hton ? THDVAR(current_thd, json_grp_size) : 10;}
+ {return connect_hton ? THDVAR(current_thd, json_grp_size) : 50;}
size_t GetWorkSize(void) {return (size_t)THDVAR(current_thd, work_size);}
void SetWorkSize(size_t)
{
@@ -805,11 +804,11 @@ static int connect_init_func(void *p)
}
#endif // 0 (LINUX)
-#if defined(__WIN__)
+#if defined(_WIN32)
sql_print_information("CONNECT: %s", compver);
-#else // !__WIN__
+#else // !_WIN32
sql_print_information("CONNECT: %s", version);
-#endif // !__WIN__
+#endif // !_WIN32
pthread_mutex_init(&parmut, NULL);
pthread_mutex_init(&usrmut, NULL);
pthread_mutex_init(&tblmut, NULL);
@@ -868,9 +867,9 @@ int connect_done_func(void *)
JAVAConn::ResetJVM();
#endif // JAVA_SUPPORT
-#if !defined(__WIN__)
+#if !defined(_WIN32)
PROFILE_End();
-#endif // !__WIN__
+#endif // !_WIN32
pthread_mutex_lock(&usrmut);
for (pc= user_connect::to_users; pc; pc= pn) {
@@ -944,11 +943,11 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
xp= (table) ? GetUser(ha_thd(), NULL) : NULL;
if (xp)
xp->SetHandler(this);
-#if defined(__WIN__)
+#if defined(_WIN32)
datapath= ".\\";
-#else // !__WIN__
+#else // !_WIN32
datapath= "./";
-#endif // !__WIN__
+#endif // !_WIN32
tdbp= NULL;
sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
sdvalout= NULL;
@@ -4550,11 +4549,11 @@ static bool checkPrivileges(THD *thd, TABTYPE type, PTOS options,
strcpy(dbpath, mysql_real_data_home);
if (db)
-#if defined(__WIN__)
+#if defined(_WIN32)
strcat(strcat(dbpath, db), "\\");
-#else // !__WIN__
+#else // !_WIN32
strcat(strcat(dbpath, db), "/");
-#endif // !__WIN__
+#endif // !_WIN32
(void)fn_format(path, options->filename, dbpath, "",
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
@@ -5475,14 +5474,13 @@ static bool add_field(String* sql, TABTYPE ttp, const char* field_name, int typ,
} // endif rem
if (fmt && *fmt) {
- switch (ttp) {
- case TAB_JSON: error |= sql->append(" JPATH='"); break;
-#if defined(BSON_SUPPORT)
- case TAB_BSON: error |= sql->append(" JPATH='"); break;
-#endif // BSON_SUPPORT
- case TAB_XML: error |= sql->append(" XPATH='"); break;
- default: error |= sql->append(" FIELD_FORMAT='");
- } // endswitch ttp
+ switch (ttp) {
+ case TAB_MONGO:
+ case TAB_BSON:
+ case TAB_JSON: error |= sql->append(" JPATH='"); break;
+ case TAB_XML: error |= sql->append(" XPATH='"); break;
+ default: error |= sql->append(" FIELD_FORMAT='");
+ } // endswitch ttp
error |= sql->append_for_single_quote(fmt, strlen(fmt));
error |= sql->append("'");
@@ -5613,9 +5611,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
PCSZ user, fn, db, host, pwd, sep, tbl, src;
PCSZ col, ocl, rnk, pic, fcl, skc, zfn;
char *tab, *dsn, *shm, *dpath, *url;
-#if defined(__WIN__)
+#if defined(_WIN32)
PCSZ nsp= NULL, cls= NULL;
-#endif // __WIN__
+#endif // _WIN32
//int hdr, mxe;
int port= 0, mxr __attribute__((unused)) = 0, rc= 0, mul= 0;
//PCSZ tabtyp= NULL;
@@ -5631,7 +5629,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#endif // JAVA_SUPPORT
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
bool bif, ok= false, dbf= false;
- TABTYPE ttp= TAB_UNDEF;
+ TABTYPE ttp= TAB_UNDEF, ttr=TAB_UNDEF;
PQRYRES qrp= NULL;
PCOLRES crp;
PCONNECT xp= NULL;
@@ -5674,10 +5672,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
skc= GetListOption(g, "skipcol", topt->oplist, NULL);
rnk= GetListOption(g, "rankcol", topt->oplist, NULL);
pwd= GetListOption(g, "password", topt->oplist);
-#if defined(__WIN__)
+#if defined(_WIN32)
nsp= GetListOption(g, "namespace", topt->oplist);
cls= GetListOption(g, "class", topt->oplist);
-#endif // __WIN__
+#endif // _WIN32
port= atoi(GetListOption(g, "port", topt->oplist, "0"));
#if defined(ODBC_SUPPORT)
// tabtyp= GetListOption(g, "Tabtype", topt->oplist, NULL);
@@ -5711,7 +5709,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS";
ttp= GetTypeID(topt->type);
sprintf(g->Message, "No table_type. Was set to %s", topt->type);
- push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
+ push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
} else if (ttp == TAB_NIY) {
sprintf(g->Message, "Unsupported table type %s", topt->type);
rc= HA_ERR_INTERNAL_ERROR;
@@ -5719,13 +5717,13 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#if defined(REST_SUPPORT)
} else if (topt->http) {
if (ttp == TAB_UNDEF) {
- topt->type = "JSON";
- ttp= GetTypeID(topt->type);
- sprintf(g->Message, "No table_type. Was set to %s", topt->type);
- push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
- } // endif ttp
+ ttr= TAB_JSON;
+ strcpy(g->Message, "No table_type. Was set to JSON");
+ push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, 0, g->Message);
+ } else
+ ttr= ttp;
- switch (ttp) {
+ switch (ttr) {
case TAB_JSON:
#if defined(BSON_SUPPORT)
case TAB_BSON:
@@ -5908,11 +5906,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
ok= false;
break;
-#if defined(__WIN__)
+#if defined(_WIN32)
case TAB_WMI:
ok= true;
break;
-#endif // __WIN__
+#endif // _WIN32
case TAB_PIVOT:
supfnc= FNC_NO;
// fall through
@@ -5945,9 +5943,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
if (!fn && !zfn && !mul && !dsn)
sprintf(g->Message, "Missing %s file name", topt->type);
- else
- ok= true;
+ else if (dsn && !topt->tabname)
+ topt->tabname= tab;
+ ok= true;
break;
#if defined(JAVA_SUPPORT)
case TAB_MONGO:
@@ -5960,7 +5959,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#if defined(REST_SUPPORT)
case TAB_REST:
if (!topt->http)
- sprintf(g->Message, "Missing %s HTTP address", topt->type);
+ strcpy(g->Message, "Missing REST HTTP option");
else
ok = true;
@@ -6076,11 +6075,11 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case TAB_CSV:
qrp= CSVColumns(g, dpath, topt, fnc == FNC_COL);
break;
-#if defined(__WIN__)
+#if defined(_WIN32)
case TAB_WMI:
qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL);
break;
-#endif // __WIN__
+#endif // _WIN32
case TAB_PRX:
case TAB_TBL:
case TAB_XCL:
@@ -6180,7 +6179,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
// Restore language type
if (ttp == TAB_REST)
- ttp = GetTypeID(topt->type);
+ ttp = ttr;
for (i= 0; !rc && i < qrp->Nblin; i++) {
typ= len= prec= dec= flg= 0;
@@ -6610,11 +6609,11 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// on Windows and libxml2 otherwise
switch (toupper(*xsup)) {
case '*':
-#if defined(__WIN__)
+#if defined(_WIN32)
dom= true;
-#else // !__WIN__
+#else // !_WIN32
dom= false;
-#endif // !__WIN__
+#endif // !_WIN32
break;
case 'M':
case 'D':
@@ -6997,11 +6996,11 @@ bool ha_connect::FileExists(const char *fn, bool bf)
int n;
struct stat info;
-#if defined(__WIN__)
+#if defined(_WIN32)
s= "\\";
-#else // !__WIN__
+#else // !_WIN32
s= "/";
-#endif // !__WIN__
+#endif // !_WIN32
if (IsPartitioned()) {
sprintf(tfn, fn, GetPartName());
@@ -7518,7 +7517,7 @@ maria_declare_plugin(connect)
0x0107, /* version number (1.07) */
NULL, /* status variables */
connect_system_variables, /* system variables */
- "1.07.0002", /* string version */
+ "1.07.0003", /* string version */
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
}
maria_declare_plugin_end;