diff options
Diffstat (limited to 'storage/connect/ha_connect.cc')
-rw-r--r-- | storage/connect/ha_connect.cc | 125 |
1 files changed, 63 insertions, 62 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 06c68c846c9..8ec14cd4349 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,10 +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); + char* str= NULL; + + if (ls.str) { + str= (char*)PlugSubAlloc(g, NULL, ls.length + 1); + memcpy(str, ls.str, ls.length); + str[ls.length] = 0; + } // endif str - memcpy(str, ls.str, ls.length); - str[ls.length]= 0; return str; } // end of strz @@ -506,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) { @@ -800,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); @@ -863,9 +867,9 @@ static 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) { @@ -939,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; @@ -4371,7 +4375,6 @@ int ha_connect::info(uint flag) // tdbp must be available to get updated info if (xp->CheckQuery(valid_query_id) || !tdbp) { PDBUSER dup= PlgGetUser(g); - PCATLG cat= (dup) ? dup->Catalog : NULL; if (xmod == MODE_ANY || xmod == MODE_ALTER) { // Pure info, not a query @@ -4547,11 +4550,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); @@ -5469,14 +5472,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("'"); @@ -5607,11 +5609,11 @@ 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= 0, rc= 0, mul= 0, lrecl= 0; + int port= 0, mxr= 0, rc= 0, mul= 0; //PCSZ tabtyp= NULL; #if defined(ODBC_SUPPORT) POPARM sop= NULL; @@ -5625,7 +5627,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; @@ -5634,8 +5636,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd, if (!g) return HA_ERR_INTERNAL_ERROR; - PDBUSER dup= PlgGetUser(g); - PCATLG cat= (dup) ? dup->Catalog : NULL; PTOS topt= table_s->option_struct; char buf[1024]; String sql(buf, sizeof(buf), system_charset_info); @@ -5670,10 +5670,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); @@ -5707,7 +5707,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; @@ -5715,13 +5715,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: @@ -5904,11 +5904,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; case TAB_PRX: @@ -5940,9 +5940,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: @@ -5955,7 +5956,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; @@ -6071,11 +6072,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: @@ -6175,7 +6176,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; @@ -6605,11 +6606,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': @@ -6992,11 +6993,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()); @@ -7513,7 +7514,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; |