Merge pull request #9441 from taosdata/feature/3.0_liaohj
[td-11818] fix bug.
This commit is contained in:
		
						commit
						a29a969a8a
					
				| 
						 | 
				
			
			@ -44,11 +44,12 @@ typedef struct SField {
 | 
			
		|||
} SField;
 | 
			
		||||
 | 
			
		||||
typedef struct SParseBasicCtx {
 | 
			
		||||
  const char *db;
 | 
			
		||||
  int32_t     acctId;
 | 
			
		||||
  uint64_t         requestId;
 | 
			
		||||
  int32_t          acctId;
 | 
			
		||||
  const char      *db;
 | 
			
		||||
  void            *pTransporter;
 | 
			
		||||
  SEpSet           mgmtEpSet;
 | 
			
		||||
  struct SCatalog *pCatalog;
 | 
			
		||||
} SParseBasicCtx;
 | 
			
		||||
 | 
			
		||||
typedef struct SFieldInfo {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,6 @@ extern "C" {
 | 
			
		|||
 | 
			
		||||
typedef struct SParseContext {
 | 
			
		||||
  SParseBasicCtx   ctx;
 | 
			
		||||
  struct SCatalog *pCatalog;
 | 
			
		||||
  int8_t           schemaAttached; // denote if submit block is built with table schema or not
 | 
			
		||||
  const char      *pSql;           // sql string
 | 
			
		||||
  size_t           sqlLen;         // length of the sql string
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -145,17 +145,32 @@ int32_t buildRequest(STscObj *pTscObj, const char *sql, int sqlLen, SRequestObj*
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
int32_t parseSql(SRequestObj* pRequest, SQueryNode** pQuery) {
 | 
			
		||||
  STscObj* pTscObj = pRequest->pTscObj;
 | 
			
		||||
 | 
			
		||||
  SParseContext cxt = {
 | 
			
		||||
    .ctx = {.requestId = pRequest->requestId, .acctId = pRequest->pTscObj->acctId, .db = getConnectionDB(pRequest->pTscObj), .pTransporter = pRequest->pTscObj->pTransporter},
 | 
			
		||||
    .ctx = {.requestId = pRequest->requestId, .acctId = pTscObj->acctId, .db = getConnectionDB(pTscObj), .pTransporter = pTscObj->pTransporter},
 | 
			
		||||
    .pSql   = pRequest->sqlstr,
 | 
			
		||||
    .sqlLen = pRequest->sqlLen,
 | 
			
		||||
    .pMsg   = pRequest->msgBuf,
 | 
			
		||||
    .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  cxt.ctx.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp);
 | 
			
		||||
  cxt.ctx.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
 | 
			
		||||
 | 
			
		||||
  // todo OPT performance
 | 
			
		||||
  char buf[12] = {0};
 | 
			
		||||
  sprintf(buf, "%"PRId64, pTscObj->pAppInfo->clusterId);
 | 
			
		||||
 | 
			
		||||
  struct SCatalog* pCatalog = NULL;
 | 
			
		||||
  int32_t code = catalogGetHandle(buf, &pCatalog);
 | 
			
		||||
  if (code != TSDB_CODE_SUCCESS) {
 | 
			
		||||
    tfree(cxt.ctx.db);
 | 
			
		||||
    return code;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  cxt.ctx.pCatalog = pCatalog;
 | 
			
		||||
  code = qParseQuerySql(&cxt, pQuery);
 | 
			
		||||
 | 
			
		||||
  int32_t code = qParseQuerySql(&cxt, pQuery);
 | 
			
		||||
  tfree(cxt.ctx.db);
 | 
			
		||||
  return code;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -323,12 +323,10 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
 | 
			
		|||
    size_t valSize = taosArrayGetSize(pValList);
 | 
			
		||||
    STableMeta* pSuperTableMeta = NULL;
 | 
			
		||||
 | 
			
		||||
    struct SCatalog* pCatalog = NULL;
 | 
			
		||||
 | 
			
		||||
    char dbName[TSDB_DB_FNAME_LEN] = {0};
 | 
			
		||||
    tNameGetFullDbName(&name, dbName);
 | 
			
		||||
 | 
			
		||||
    catalogGetTableMeta(pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, pCreateTableInfo->tagdata.name, &pSuperTableMeta);
 | 
			
		||||
    catalogGetTableMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, pCreateTableInfo->tagdata.name, &pSuperTableMeta);
 | 
			
		||||
 | 
			
		||||
    // too long tag values will return invalid sql, not be truncated automatically
 | 
			
		||||
    SSchema  *pTagSchema = getTableTagSchema(pSuperTableMeta);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -173,9 +173,9 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
 | 
			
		|||
  char fullDbName[TSDB_DB_FNAME_LEN] = {0};
 | 
			
		||||
  char tableName[TSDB_TABLE_NAME_LEN] = {0};
 | 
			
		||||
  CHECK_CODE(buildName(pCxt, pTname, fullDbName, tableName));
 | 
			
		||||
  CHECK_CODE(catalogGetTableMeta(pCxt->pComCxt->pCatalog, pCxt->pComCxt->ctx.pTransporter, &pCxt->pComCxt->ctx.mgmtEpSet, fullDbName, tableName, &pCxt->pTableMeta));
 | 
			
		||||
  CHECK_CODE(catalogGetTableMeta(pCxt->pComCxt->ctx.pCatalog, pCxt->pComCxt->ctx.pTransporter, &pCxt->pComCxt->ctx.mgmtEpSet, fullDbName, tableName, &pCxt->pTableMeta));
 | 
			
		||||
  SVgroupInfo vg;
 | 
			
		||||
  CHECK_CODE(catalogGetTableHashVgroup(pCxt->pComCxt->pCatalog, pCxt->pComCxt->ctx.pTransporter, &pCxt->pComCxt->ctx.mgmtEpSet, fullDbName, tableName, &vg));
 | 
			
		||||
  CHECK_CODE(catalogGetTableHashVgroup(pCxt->pComCxt->ctx.pCatalog, pCxt->pComCxt->ctx.pTransporter, &pCxt->pComCxt->ctx.mgmtEpSet, fullDbName, tableName, &vg));
 | 
			
		||||
  CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg)));
 | 
			
		||||
  return TSDB_CODE_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -715,7 +715,7 @@ TEST(testCase, show_user_Test) {
 | 
			
		|||
  ASSERT_EQ(info1.valid, true);
 | 
			
		||||
 | 
			
		||||
  SDclStmtInfo output;
 | 
			
		||||
  SParseBasicCtx ct= {.db= "abc", .acctId = 1, .requestId = 1};
 | 
			
		||||
  SParseBasicCtx ct= {.requestId = 1, .acctId = 1, .db = "abc", .pTransporter = NULL};
 | 
			
		||||
  int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, msg, buf.len);
 | 
			
		||||
  ASSERT_EQ(code, 0);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -736,7 +736,7 @@ TEST(testCase, create_user_Test) {
 | 
			
		|||
  ASSERT_EQ(isDclSqlStatement(&info1), true);
 | 
			
		||||
 | 
			
		||||
  SDclStmtInfo output;
 | 
			
		||||
  SParseBasicCtx ct= {.db= "abc", .acctId = 1, .requestId = 1};
 | 
			
		||||
  SParseBasicCtx ct= {.requestId = 1, .acctId = 1, .db = "abc"};
 | 
			
		||||
  int32_t code = qParserValidateDclSqlNode(&info1, &ct, &output, msg, buf.len);
 | 
			
		||||
  ASSERT_EQ(code, 0);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue