diff options
Diffstat (limited to 'storage/connect/ha_connect.cc')
-rw-r--r-- | storage/connect/ha_connect.cc | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 0be262f6a63..7d9c7517159 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -170,7 +170,7 @@ #define JSONMAX 10 // JSON Default max grp size extern "C" { - char version[]= "Version 1.07.0002 January 27, 2021"; + char version[]= "Version 1.07.0002 March 22, 2021"; #if defined(__WIN__) char compver[]= "Version 1.07.0002 " __DATE__ " " __TIME__; char slash= '\\'; @@ -275,6 +275,10 @@ static handler *connect_create_handler(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root); +static bool checkPrivileges(THD* thd, TABTYPE type, PTOS options, + const char* db, TABLE* table = NULL, + bool quick = false); + static int connect_assisted_discovery(handlerton *hton, THD* thd, TABLE_SHARE *table_s, HA_CREATE_INFO *info); @@ -762,8 +766,8 @@ DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir) For engines that have two file name extensions (separate meta/index file and data file), the order of elements is relevant. First element of engine - file name extensions array should be meta/index file extention. Second - element - data file extention. This order is assumed by + file name extensions array should be meta/index file extension. Second + element - data file extension. This order is assumed by prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued. @see @@ -1299,9 +1303,9 @@ PCSZ GetStringTableOption(PGLOBAL g, PTOS options, PCSZ opname, PCSZ sdef) else if (!stricmp(opname, "Data_charset")) opval= options->data_charset; else if (!stricmp(opname, "Http") || !stricmp(opname, "URL")) - opval = options->http; + opval= options->http; else if (!stricmp(opname, "Uri")) - opval = options->uri; + opval= options->uri; if (!opval && options->oplist) opval= GetListOption(g, opname, options->oplist); @@ -1615,7 +1619,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) pcf->Opt= (fop) ? (int)fop->opt : 0; if (fp->field_length >= 0) { - pcf->Length = fp->field_length; + pcf->Length= fp->field_length; // length is bytes for Connect, not characters if (!strnicmp(chset, "utf8", 4)) @@ -1630,7 +1634,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) pcf->Offset= (int)fop->offset; pcf->Freq= (int)fop->freq; pcf->Datefmt= (char*)fop->dateformat; - pcf->Fieldfmt = fop->fieldformat ? (char*)fop->fieldformat + pcf->Fieldfmt= fop->fieldformat ? (char*)fop->fieldformat : fop->jsonpath ? (char*)fop->jsonpath : (char*)fop->xmlpath; } else { pcf->Offset= -1; @@ -4511,11 +4515,9 @@ int ha_connect::delete_all_rows() } // end of delete_all_rows -bool ha_connect::check_privileges(THD *thd, PTOS options, const char *dbn, bool quick) +static bool checkPrivileges(THD *thd, TABTYPE type, PTOS options, + const char *db, TABLE *table, bool quick) { - const char *db= (dbn && *dbn) ? dbn : NULL; - TABTYPE type=GetRealType(options); - switch (type) { case TAB_UNDEF: // case TAB_CATLG: @@ -4598,6 +4600,16 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, const char *dbn, bool my_printf_error(ER_UNKNOWN_ERROR, "check_privileges failed", MYF(0)); return true; +} // end of checkPrivileges + +// Check whether the user has required (file) privileges +bool ha_connect::check_privileges(THD *thd, PTOS options, const char *dbn, + bool quick) +{ + const char *db= (dbn && *dbn) ? dbn : NULL; + TABTYPE type=GetRealType(options); + + return checkPrivileges(thd, type, options, db, table, quick); } // end of check_privileges // Check that two indexes are equivalent @@ -5394,12 +5406,7 @@ static bool add_field(String* sql, TABTYPE ttp, const char* field_name, int typ, int len, int dec, char* key, uint tm, const char* rem, char* dft, char* xtra, char* fmt, int flag, bool dbf, char v) { -#if defined(DEVELOPMENT) - // Some client programs regard CHAR(36) as GUID - char var = (len > 255 || len == 36) ? 'V' : v; -#else char var = (len > 255) ? 'V' : v; -#endif bool q, error = false; const char* type = PLGtoMYSQLtype(typ, dbf, var); @@ -5733,6 +5740,29 @@ static int connect_assisted_discovery(handlerton *, THD* thd, #endif // REST_SUPPORT } // endif ttp + if (fn && *fn) + switch (ttp) { + case TAB_FMT: + case TAB_DBF: + case TAB_XML: + case TAB_INI: + case TAB_VEC: + case TAB_REST: + case TAB_JSON: +#if defined(BSON_SUPPORT) + case TAB_BSON: +#endif // BSON_SUPPORT + if (checkPrivileges(thd, ttp, topt, db)) { + strcpy(g->Message, "This operation requires the FILE privilege"); + rc= HA_ERR_INTERNAL_ERROR; + goto err; + } // endif check_privileges + + break; + default: + break; + } // endswitch ttp + if (!tab) { if (ttp == TAB_TBL) { // Make tab the first table of the list |