提交 51ab64d9 编写于 作者: A Alex Duan

<feat>(mnode): add limit user for query

上级 88f79701
......@@ -89,6 +89,9 @@ extern const int32_t TYPE_BYTES[16];
#define TSDB_PASS_LEN 16
#define SHELL_MAX_PASSWORD_LEN 20
// user set query tags max len
#define TSDB_TAGS_LEN 256
#define TSDB_TRUE 1
#define TSDB_FALSE 0
#define TSDB_OK 0
......
......@@ -202,6 +202,20 @@ typedef struct SDbObj {
pthread_mutex_t mutex;
} SDbObj;
// old tags
typedef struct SUserObjOld {
char user[TSDB_USER_LEN];
char pass[TSDB_KEY_LEN];
char acct[TSDB_USER_LEN];
int64_t createdTime;
int8_t superAuth;
int8_t writeAuth;
int8_t reserved[10];
int8_t updateEnd[4];
int32_t refCount;
struct SAcctObj * pAcct;
} SUserObjOld;
typedef struct SUserObj {
char user[TSDB_USER_LEN];
char pass[TSDB_KEY_LEN];
......@@ -210,6 +224,7 @@ typedef struct SUserObj {
int8_t superAuth;
int8_t writeAuth;
int8_t reserved[10];
char tags[TSDB_TAGS_LEN];
int8_t updateEnd[4];
int32_t refCount;
struct SAcctObj * pAcct;
......
......@@ -93,11 +93,23 @@ static int32_t mnodeUserActionEncode(SSdbRow *pRow) {
return TSDB_CODE_SUCCESS;
}
static int32_t tsUserUpdateSizeOld = 0;
static int32_t mnodeUserActionDecode(SSdbRow *pRow) {
SUserObj *pUser = (SUserObj *)calloc(1, sizeof(SUserObj));
if (pUser == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
memcpy(pUser, pRow->rowData, tsUserUpdateSize);
// check old format
if(tsUserUpdateSizeOld == 0) {
//int32_t nUpdateSizeOld = (int32_t)((int8_t *)old.updateEnd - (int8_t *)&old);
tsUserUpdateSizeOld = (int32_t)((SUserObjOld*)0)->updateEnd;
}
if (pRow->rowSize == tsUserUpdateSizeOld) {
memcpy(pUser, pRow->rowData, tsUserUpdateSizeOld);
} else {
memcpy(pUser, pRow->rowData, tsUserUpdateSize);
}
pRow->pObj = pUser;
return TSDB_CODE_SUCCESS;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册