Merge pull request #9361 from taosdata/feature/3.0_liaohj
Feature/3.0 liaohj
This commit is contained in:
commit
e15c5a919d
|
@ -113,6 +113,13 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
|
||||||
return taosConnectImpl(ip, user, &secretEncrypt[0], db, port, NULL, NULL, *pInst);
|
return taosConnectImpl(ip, user, &secretEncrypt[0], db, port, NULL, NULL, *pInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool supportedQueryType(int32_t type) {
|
||||||
|
return (type == TSDB_MSG_TYPE_CREATE_USER || type == TSDB_MSG_TYPE_SHOW || type == TSDB_MSG_TYPE_DROP_USER ||
|
||||||
|
type == TSDB_MSG_TYPE_DROP_ACCT || type == TSDB_MSG_TYPE_CREATE_DB || type == TSDB_MSG_TYPE_CREATE_ACCT ||
|
||||||
|
type == TSDB_MSG_TYPE_CREATE_TABLE || type == TSDB_MSG_TYPE_CREATE_STB || type == TSDB_MSG_TYPE_USE_DB ||
|
||||||
|
type == TSDB_MSG_TYPE_DROP_DB || type == TSDB_MSG_TYPE_DROP_STB);
|
||||||
|
}
|
||||||
|
|
||||||
TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
||||||
STscObj *pTscObj = (STscObj *)taos;
|
STscObj *pTscObj = (STscObj *)taos;
|
||||||
if (sqlLen > (size_t) tsMaxSQLStringLen) {
|
if (sqlLen > (size_t) tsMaxSQLStringLen) {
|
||||||
|
@ -145,16 +152,17 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
||||||
tscDebugL("0x%"PRIx64" SQL: %s", pRequest->requestId, pRequest->sqlstr);
|
tscDebugL("0x%"PRIx64" SQL: %s", pRequest->requestId, pRequest->sqlstr);
|
||||||
|
|
||||||
SParseContext cxt = {
|
SParseContext cxt = {
|
||||||
.ctx = {.requestId = pRequest->requestId, .acctId = pTscObj->acctId, .db = getConnectionDB(pTscObj)},
|
.ctx = {.requestId = pRequest->requestId, .acctId = pTscObj->acctId, .db = getConnectionDB(pTscObj)},
|
||||||
.pSql = pRequest->sqlstr,
|
.pSql = pRequest->sqlstr,
|
||||||
.sqlLen = sqlLen,
|
.sqlLen = sqlLen,
|
||||||
.pMsg = pRequest->msgBuf,
|
.pMsg = pRequest->msgBuf,
|
||||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE
|
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
SQueryNode* pQuery = NULL;
|
SQueryNode* pQuery = NULL;
|
||||||
int32_t code = qParseQuerySql(&cxt, &pQuery);
|
int32_t code = qParseQuerySql(&cxt, &pQuery);
|
||||||
if (qIsDclQuery(pQuery)) {
|
if (qIsDclQuery(pQuery)) {
|
||||||
SDclStmtInfo* pDcl = (SDclStmtInfo*)pQuery;
|
SDclStmtInfo* pDcl = (SDclStmtInfo*) pQuery;
|
||||||
pRequest->type = pDcl->msgType;
|
pRequest->type = pDcl->msgType;
|
||||||
pRequest->body.requestMsg = (SReqMsgInfo){.pMsg = pDcl->pMsg, .len = pDcl->msgLen};
|
pRequest->body.requestMsg = (SReqMsgInfo){.pMsg = pDcl->pMsg, .len = pDcl->msgLen};
|
||||||
|
|
||||||
|
@ -215,7 +223,7 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
||||||
int initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSet) {
|
int initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSet) {
|
||||||
pEpSet->version = 0;
|
pEpSet->version = 0;
|
||||||
|
|
||||||
// init mgmt ip set
|
// init mnode ip set
|
||||||
SEpSet *mgmtEpSet = &(pEpSet->epSet);
|
SEpSet *mgmtEpSet = &(pEpSet->epSet);
|
||||||
mgmtEpSet->numOfEps = 0;
|
mgmtEpSet->numOfEps = 0;
|
||||||
mgmtEpSet->inUse = 0;
|
mgmtEpSet->inUse = 0;
|
||||||
|
|
|
@ -110,9 +110,9 @@ SRequestMsgBody buildRequestMsgImpl(SRequestObj *pRequest) {
|
||||||
assert(pRequest != NULL);
|
assert(pRequest != NULL);
|
||||||
SRequestMsgBody body = {
|
SRequestMsgBody body = {
|
||||||
.requestObjRefId = pRequest->self,
|
.requestObjRefId = pRequest->self,
|
||||||
.msgInfo = pRequest->body.requestMsg,
|
.msgInfo = pRequest->body.requestMsg,
|
||||||
.msgType = pRequest->type,
|
.msgType = pRequest->type,
|
||||||
.requestId = pRequest->requestId,
|
.requestId = pRequest->requestId,
|
||||||
};
|
};
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,101 +49,101 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
TEST(testCase, driverInit_Test) { taos_init(); }
|
TEST(testCase, driverInit_Test) { taos_init(); }
|
||||||
|
|
||||||
// TEST(testCase, connect_Test) {
|
TEST(testCase, connect_Test) {
|
||||||
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||||
//// assert(pConn != NULL);
|
|
||||||
// taos_close(pConn);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
// TEST(testCase, create_user_Test) {
|
|
||||||
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
|
||||||
// assert(pConn != NULL);
|
// assert(pConn != NULL);
|
||||||
//
|
taos_close(pConn);
|
||||||
// TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'");
|
}
|
||||||
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
|
||||||
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
TEST(testCase, create_user_Test) {
|
||||||
// }
|
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||||
//
|
assert(pConn != NULL);
|
||||||
// taos_free_result(pRes);
|
|
||||||
// taos_close(pConn);
|
TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'");
|
||||||
//}
|
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||||
//
|
printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||||
// TEST(testCase, create_account_Test) {
|
}
|
||||||
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
|
||||||
|
taos_free_result(pRes);
|
||||||
|
taos_close(pConn);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, create_account_Test) {
|
||||||
|
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||||
|
assert(pConn != NULL);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(pConn, "create account aabc pass 'abc'");
|
||||||
|
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||||
|
printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||||
|
}
|
||||||
|
|
||||||
|
taos_free_result(pRes);
|
||||||
|
taos_close(pConn);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, drop_account_Test) {
|
||||||
|
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||||
|
assert(pConn != NULL);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(pConn, "drop account aabc");
|
||||||
|
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||||
|
printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||||
|
}
|
||||||
|
|
||||||
|
taos_free_result(pRes);
|
||||||
|
taos_close(pConn);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, show_user_Test) {
|
||||||
|
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||||
// assert(pConn != NULL);
|
// assert(pConn != NULL);
|
||||||
//
|
|
||||||
// TAOS_RES* pRes = taos_query(pConn, "create account aabc pass 'abc'");
|
TAOS_RES* pRes = taos_query(pConn, "show users");
|
||||||
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
TAOS_ROW pRow = NULL;
|
||||||
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
|
||||||
// }
|
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
//
|
int32_t numOfFields = taos_num_fields(pRes);
|
||||||
// taos_free_result(pRes);
|
|
||||||
// taos_close(pConn);
|
char str[512] = {0};
|
||||||
//}
|
while((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
//
|
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
// TEST(testCase, drop_account_Test) {
|
printf("%s\n", str);
|
||||||
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
}
|
||||||
|
|
||||||
|
taos_close(pConn);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, drop_user_Test) {
|
||||||
|
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||||
|
assert(pConn != NULL);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(pConn, "drop user abc");
|
||||||
|
if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
||||||
|
printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
||||||
|
}
|
||||||
|
|
||||||
|
taos_free_result(pRes);
|
||||||
|
taos_close(pConn);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, show_db_Test) {
|
||||||
|
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||||
// assert(pConn != NULL);
|
// assert(pConn != NULL);
|
||||||
//
|
|
||||||
// TAOS_RES* pRes = taos_query(pConn, "drop account aabc");
|
TAOS_RES* pRes = taos_query(pConn, "show databases");
|
||||||
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
TAOS_ROW pRow = NULL;
|
||||||
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
|
||||||
// }
|
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
//
|
int32_t numOfFields = taos_num_fields(pRes);
|
||||||
// taos_free_result(pRes);
|
|
||||||
// taos_close(pConn);
|
char str[512] = {0};
|
||||||
//}
|
while((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
//
|
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
// TEST(testCase, show_user_Test) {
|
printf("%s\n", str);
|
||||||
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
}
|
||||||
//// assert(pConn != NULL);
|
|
||||||
//
|
taos_close(pConn);
|
||||||
// TAOS_RES* pRes = taos_query(pConn, "show users");
|
}
|
||||||
// TAOS_ROW pRow = NULL;
|
|
||||||
//
|
|
||||||
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
|
||||||
// int32_t numOfFields = taos_num_fields(pRes);
|
|
||||||
//
|
|
||||||
// char str[512] = {0};
|
|
||||||
// while((pRow = taos_fetch_row(pRes)) != NULL) {
|
|
||||||
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
|
||||||
// printf("%s\n", str);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taos_close(pConn);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
// TEST(testCase, drop_user_Test) {
|
|
||||||
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
|
||||||
// assert(pConn != NULL);
|
|
||||||
//
|
|
||||||
// TAOS_RES* pRes = taos_query(pConn, "drop user abc");
|
|
||||||
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
|
|
||||||
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taos_free_result(pRes);
|
|
||||||
// taos_close(pConn);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
// TEST(testCase, show_db_Test) {
|
|
||||||
// TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
|
||||||
//// assert(pConn != NULL);
|
|
||||||
//
|
|
||||||
// TAOS_RES* pRes = taos_query(pConn, "show databases");
|
|
||||||
// TAOS_ROW pRow = NULL;
|
|
||||||
//
|
|
||||||
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
|
||||||
// int32_t numOfFields = taos_num_fields(pRes);
|
|
||||||
//
|
|
||||||
// char str[512] = {0};
|
|
||||||
// while((pRow = taos_fetch_row(pRes)) != NULL) {
|
|
||||||
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
|
||||||
// printf("%s\n", str);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taos_close(pConn);
|
|
||||||
//}
|
|
||||||
|
|
||||||
TEST(testCase, create_db_Test) {
|
TEST(testCase, create_db_Test) {
|
||||||
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
TAOS* pConn = taos_connect("ubuntu", "root", "taosdata", NULL, 0);
|
||||||
|
|
|
@ -4457,8 +4457,6 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm
|
||||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pCreateMsg->db, token.z, token.n);
|
|
||||||
|
|
||||||
pDcl->pMsg = (char*)pCreateMsg;
|
pDcl->pMsg = (char*)pCreateMsg;
|
||||||
pDcl->msgLen = sizeof(SCreateDbMsg);
|
pDcl->msgLen = sizeof(SCreateDbMsg);
|
||||||
pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_DB)? TSDB_MSG_TYPE_CREATE_DB:TSDB_MSG_TYPE_ALTER_DB;
|
pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_DB)? TSDB_MSG_TYPE_CREATE_DB:TSDB_MSG_TYPE_ALTER_DB;
|
||||||
|
|
Loading…
Reference in New Issue