diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index a2c3919b1c..30bf900803 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1445,9 +1445,14 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) int32_t numOfCreatedDbs = taosHashGetSize(pRsp->createdDbs); int32_t numOfReadDbs = taosHashGetSize(pRsp->readDbs); int32_t numOfWriteDbs = taosHashGetSize(pRsp->writeDbs); + int32_t numOfReadTbs = taosHashGetSize(pRsp->readTbs); + int32_t numOfWriteTbs = taosHashGetSize(pRsp->writeTbs); + if (tEncodeI32(pEncoder, numOfCreatedDbs) < 0) return -1; if (tEncodeI32(pEncoder, numOfReadDbs) < 0) return -1; if (tEncodeI32(pEncoder, numOfWriteDbs) < 0) return -1; + if (tEncodeI32(pEncoder, numOfReadTbs) < 0) return -1; + if (tEncodeI32(pEncoder, numOfWriteTbs) < 0) return -1; char *db = taosHashIterate(pRsp->createdDbs, NULL); while (db != NULL) { @@ -1467,6 +1472,36 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) db = taosHashIterate(pRsp->writeDbs, db); } + char *tb = taosHashIterate(pRsp->readTbs, NULL); + while (tb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(tb, &keyLen); + if (tEncodeI32(pEncoder, keyLen) < 0) return -1; + if (tEncodeCStr(pEncoder, key) < 0) return -1; + + size_t valueLen = 0; + valueLen = strlen(tb); + if (tEncodeI32(pEncoder, valueLen) < 0) return -1; + if (tEncodeCStr(pEncoder, tb) < 0) return -1; + + tb = taosHashIterate(pRsp->readTbs, tb); + } + + tb = taosHashIterate(pRsp->writeTbs, NULL); + while (tb != NULL) { + size_t keyLen = 0; + void *key = taosHashGetKey(tb, &keyLen); + if (tEncodeI32(pEncoder, keyLen) < 0) return -1; + if (tEncodeCStr(pEncoder, key) < 0) return -1; + + size_t valueLen = 0; + valueLen = strlen(tb); + if (tEncodeI32(pEncoder, valueLen) < 0) return -1; + if (tEncodeCStr(pEncoder, tb) < 0) return -1; + + tb = taosHashIterate(pRsp->writeTbs, tb); + } + return 0; } @@ -1503,9 +1538,13 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs int32_t numOfCreatedDbs = 0; int32_t numOfReadDbs = 0; int32_t numOfWriteDbs = 0; + int32_t numOfReadTbs = 0; + int32_t numOfWriteTbs = 0; if (tDecodeI32(pDecoder, &numOfCreatedDbs) < 0) return -1; if (tDecodeI32(pDecoder, &numOfReadDbs) < 0) return -1; if (tDecodeI32(pDecoder, &numOfWriteDbs) < 0) return -1; + if (tDecodeI32(pDecoder, &numOfReadTbs) < 0) return -1; + if (tDecodeI32(pDecoder, &numOfWriteTbs) < 0) return -1; for (int32_t i = 0; i < numOfCreatedDbs; ++i) { char db[TSDB_DB_FNAME_LEN] = {0}; @@ -1528,6 +1567,42 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs taosHashPut(pRsp->writeDbs, db, len, db, len); } + for (int32_t i = 0; i < numOfReadTbs; ++i) { + int32_t keyLen = 0; + if (tDecodeI32(pDecoder, &keyLen) < 0) return -1; + + char *key = taosMemoryCalloc(keyLen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, key) < 0) return -1; + + int32_t valuelen = 0; + if (tDecodeI32(pDecoder, &valuelen) < 0) return -1; + char *value = taosMemoryCalloc(valuelen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, value) < 0) return -1; + + taosHashPut(pRsp->readTbs, key, keyLen, value, valuelen); + + taosMemoryFree(key); + taosMemoryFree(value); + } + + for (int32_t i = 0; i < numOfWriteTbs; ++i) { + int32_t keyLen = 0; + if (tDecodeI32(pDecoder, &keyLen) < 0) return -1; + + char *key = taosMemoryCalloc(keyLen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, key) < 0) return -1; + + int32_t valuelen = 0; + if (tDecodeI32(pDecoder, &valuelen) < 0) return -1; + char *value = taosMemoryCalloc(valuelen + 1, sizeof(char)); + if (tDecodeCStrTo(pDecoder, value) < 0) return -1; + + taosHashPut(pRsp->writeTbs, key, keyLen, value, valuelen); + + taosMemoryFree(key); + taosMemoryFree(value); + } + return 0; }