未验证 提交 976ed04a 编写于 作者: S slguan 提交者: GitHub

Merge pull request #697 from taosdata/feature/liaohj

Feature/liaohj
......@@ -169,8 +169,6 @@ int32_t taosInitTimer(void (*callback)(int), int32_t ms);
*/
uint32_t MurmurHash3_32(const void *key, int32_t len);
bool taosCheckDbName(char *db, char *monitordb);
bool taosMbsToUcs4(char *mbs, int32_t mbs_len, char *ucs4, int32_t ucs4_max_len);
bool taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs);
......
......@@ -30,6 +30,7 @@ char* mgmtMeterGetTag(STabObj* pMeter, int32_t col, SSchema* pTagColSchema);
int32_t mgmtFindTagCol(STabObj * pMetric, const char * tagName);
int32_t mgmtGetTagsLength(STabObj* pMetric, int32_t col);
bool mgmtCheckIsMonitorDB(char *db, char *monitordb);
int32_t mgmtRetrieveMetersFromMetric(SMetricMetaMsg* pInfo, int32_t tableIndex, tQueryResultset* pRes);
int32_t mgmtDoJoin(SMetricMetaMsg* pMetricMetaMsg, tQueryResultset* pRes);
......
......@@ -14,9 +14,11 @@
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "mgmt.h"
#include <arpa/inet.h>
#include "mgmtBalance.h"
#include "mgmtUtil.h"
#include "tschemautil.h"
void *dbSdb = NULL;
......@@ -373,10 +375,12 @@ int mgmtDropDbByName(SAcctObj *pAcct, char *name) {
if (pDb == NULL) {
mWarn("db:%s is not there", name);
// return TSDB_CODE_INVALID_DB;
return 0;
return TSDB_CODE_SUCCESS;
}
if (taosCheckDbName(pDb->name, tsMonitorDbName)) return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
}
return mgmtDropDb(pDb);
}
......
......@@ -688,8 +688,10 @@ int mgmtDropMeter(SDbObj *pDb, char *meterId, int ignore) {
pAcct = mgmtGetAcct(pDb->cfg.acct);
// 0.sys
if (taosCheckDbName(pDb->name, tsMonitorDbName)) return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
// 0.log
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) {
return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
}
if (mgmtIsNormalMeter(pMeter)) {
return dropMeterImp(pDb, pMeter, pAcct);
......@@ -719,8 +721,8 @@ int mgmtAlterMeter(SDbObj *pDb, SAlterTableMsg *pAlter) {
return TSDB_CODE_INVALID_TABLE;
}
// 0.sys
if (taosCheckDbName(pDb->name, tsMonitorDbName)) return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
// 0.log
if (mgmtCheckIsMonitorDB(pDb->name, tsMonitorDbName)) return TSDB_CODE_MONITOR_DB_FORBEIDDEN;
if (pAlter->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) {
if (!mgmtIsNormalMeter(pMeter) || !mgmtMeterCreateFromMetric(pMeter)) {
......
......@@ -87,3 +87,10 @@ int32_t mgmtGetTagsLength(STabObj* pMetric, int32_t col) { // length before col
return len;
}
bool mgmtCheckIsMonitorDB(char *db, char *monitordb) {
char dbName[TSDB_DB_NAME_LEN + 1] = {0};
extractDBName(db, dbName);
return (strncasecmp(dbName, monitordb, strlen(dbName)) == 0);
}
......@@ -406,13 +406,6 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
return rename(fullPath, *dstPath);
}
bool taosCheckDbName(char *db, char *monitordb) {
char *pos = strchr(db, '.');
if (pos == NULL) return false;
return strncasecmp(pos + 1, monitordb, strlen(monitordb)) == 0;
}
bool taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) {
#ifdef USE_LIBICONV
iconv_t cd = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册