fix some format
This commit is contained in:
parent
e9feec94b3
commit
aa3c79100b
|
@ -95,11 +95,11 @@ typedef struct taosField {
|
||||||
} TAOS_FIELD;
|
} TAOS_FIELD;
|
||||||
|
|
||||||
typedef struct TAOS_FIELD_E {
|
typedef struct TAOS_FIELD_E {
|
||||||
char name[65];
|
char name[65];
|
||||||
int8_t type;
|
int8_t type;
|
||||||
uint8_t precision;
|
uint8_t precision;
|
||||||
uint8_t scale;
|
uint8_t scale;
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
TAOS_FIELD_T field_type;
|
TAOS_FIELD_T field_type;
|
||||||
} TAOS_FIELD_E;
|
} TAOS_FIELD_E;
|
||||||
|
|
||||||
|
@ -253,17 +253,17 @@ DLL_EXPORT int64_t taos_affected_rows64(TAOS_RES *res);
|
||||||
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||||
DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
||||||
DLL_EXPORT int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
DLL_EXPORT int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
||||||
DLL_EXPORT void taos_stop_query(TAOS_RES *res);
|
DLL_EXPORT void taos_stop_query(TAOS_RES *res);
|
||||||
DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col);
|
DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col);
|
||||||
DLL_EXPORT int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows);
|
DLL_EXPORT int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows);
|
||||||
DLL_EXPORT bool taos_is_update_query(TAOS_RES *res);
|
DLL_EXPORT bool taos_is_update_query(TAOS_RES *res);
|
||||||
DLL_EXPORT int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows);
|
DLL_EXPORT int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows);
|
||||||
DLL_EXPORT int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows);
|
DLL_EXPORT int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows);
|
||||||
DLL_EXPORT int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData);
|
DLL_EXPORT int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData);
|
||||||
DLL_EXPORT int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex);
|
DLL_EXPORT int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex);
|
||||||
DLL_EXPORT int taos_validate_sql(TAOS *taos, const char *sql);
|
DLL_EXPORT int taos_validate_sql(TAOS *taos, const char *sql);
|
||||||
DLL_EXPORT void taos_reset_current_db(TAOS *taos);
|
DLL_EXPORT void taos_reset_current_db(TAOS *taos);
|
||||||
|
|
||||||
DLL_EXPORT int *taos_fetch_lengths(TAOS_RES *res);
|
DLL_EXPORT int *taos_fetch_lengths(TAOS_RES *res);
|
||||||
DLL_EXPORT TAOS_ROW *taos_result_block(TAOS_RES *res);
|
DLL_EXPORT TAOS_ROW *taos_result_block(TAOS_RES *res);
|
||||||
|
|
|
@ -84,7 +84,7 @@ void taos_cleanup(void) {
|
||||||
taosCloseRef(id);
|
taosCloseRef(id);
|
||||||
|
|
||||||
nodesDestroyAllocatorSet();
|
nodesDestroyAllocatorSet();
|
||||||
// cleanupAppInfo();
|
// cleanupAppInfo();
|
||||||
rpcCleanup();
|
rpcCleanup();
|
||||||
tscDebug("rpc cleanup");
|
tscDebug("rpc cleanup");
|
||||||
|
|
||||||
|
@ -388,7 +388,6 @@ void taos_free_result(TAOS_RES *res) {
|
||||||
tDeleteMqBatchMetaRsp(&pRsp->batchMetaRsp);
|
tDeleteMqBatchMetaRsp(&pRsp->batchMetaRsp);
|
||||||
}
|
}
|
||||||
taosMemoryFree(pRsp);
|
taosMemoryFree(pRsp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_kill_query(TAOS *taos) {
|
void taos_kill_query(TAOS *taos) {
|
||||||
|
@ -484,7 +483,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
||||||
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
||||||
return taos_print_row_with_size(str, INT32_MAX, row, fields, num_fields);
|
return taos_print_row_with_size(str, INT32_MAX, row, fields, num_fields);
|
||||||
}
|
}
|
||||||
int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields){
|
int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
for (int i = 0; i < num_fields; ++i) {
|
for (int i = 0; i < num_fields; ++i) {
|
||||||
if (i > 0 && len < size - 1) {
|
if (i > 0 && len < size - 1) {
|
||||||
|
@ -589,7 +588,7 @@ int taos_print_row_with_size(char *str, uint32_t size, TAOS_ROW row, TAOS_FIELD
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len < size){
|
if (len < size) {
|
||||||
str[len] = 0;
|
str[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2082,7 +2081,7 @@ int taos_stmt2_is_insert(TAOS_STMT2 *stmt, int *insert) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_stmt2_get_fields(TAOS_STMT2 *stmt, TAOS_FIELD_T field_type, int *count, TAOS_FIELD_E **fields) {
|
int taos_stmt2_get_fields(TAOS_STMT2 *stmt, TAOS_FIELD_T field_type, int *count, TAOS_FIELD_E **fields) {
|
||||||
if (stmt == NULL || NULL == count) {
|
if (stmt == NULL || count == NULL) {
|
||||||
tscError("NULL parameter for %s", __FUNCTION__);
|
tscError("NULL parameter for %s", __FUNCTION__);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -2104,7 +2103,7 @@ int taos_stmt2_get_fields(TAOS_STMT2 *stmt, TAOS_FIELD_T field_type, int *count,
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_stmt2_get_all_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_E **fields) {
|
int taos_stmt2_get_all_fields(TAOS_STMT2 *stmt, int *count, TAOS_FIELD_E **fields) {
|
||||||
if (stmt == NULL || NULL == count) {
|
if (stmt == NULL || count == NULL) {
|
||||||
tscError("NULL parameter for %s", __FUNCTION__);
|
tscError("NULL parameter for %s", __FUNCTION__);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return terrno;
|
||||||
|
|
|
@ -1076,33 +1076,33 @@ static int stmtFetchFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIELD_E**
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields) {
|
if (fields != NULL) {
|
||||||
*fields = taosMemoryCalloc(tags->numOfBound, sizeof(TAOS_FIELD_E));
|
*fields = taosMemoryCalloc(tags->numOfBound, sizeof(TAOS_FIELD_E));
|
||||||
if (NULL == *fields) {
|
if (NULL == *fields) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pSchema = meta->schema;
|
SSchema* pSchema = meta->schema;
|
||||||
int32_t tbnameIdx = meta->tableInfo.numOfTags + meta->tableInfo.numOfColumns;
|
int32_t tbnameIdx = meta->tableInfo.numOfTags + meta->tableInfo.numOfColumns;
|
||||||
for (int32_t i = 0; i < tags->numOfBound; ++i) {
|
for (int32_t i = 0; i < tags->numOfBound; ++i) {
|
||||||
int16_t idx = tags->pColIndex[i];
|
int16_t idx = tags->pColIndex[i];
|
||||||
if (idx == tbnameIdx) {
|
if (idx == tbnameIdx) {
|
||||||
(*fields)[i].field_type = TAOS_FIELD_TBNAME;
|
(*fields)[i].field_type = TAOS_FIELD_TBNAME;
|
||||||
strcpy((*fields)[i].name, "tbname");
|
tstrncpy((*fields)[i].name, "tbname", sizeof((*fields)[i].name));
|
||||||
continue;
|
continue;
|
||||||
} else if (idx < meta->tableInfo.numOfColumns) {
|
} else if (idx < meta->tableInfo.numOfColumns) {
|
||||||
(*fields)[i].field_type = TAOS_FIELD_COL;
|
(*fields)[i].field_type = TAOS_FIELD_COL;
|
||||||
} else {
|
} else {
|
||||||
(*fields)[i].field_type = TAOS_FIELD_TAG;
|
(*fields)[i].field_type = TAOS_FIELD_TAG;
|
||||||
}
|
}
|
||||||
SSchema schema = pSchema[tags->pColIndex[i]];
|
|
||||||
if (TSDB_DATA_TYPE_TIMESTAMP == schema.type) {
|
if (TSDB_DATA_TYPE_TIMESTAMP == pSchema[tags->pColIndex[i]].type) {
|
||||||
(*fields)[i].precision = meta->tableInfo.precision;
|
(*fields)[i].precision = meta->tableInfo.precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
tstrncpy((*fields)[i].name, schema.name, sizeof((*fields)[i].name));
|
tstrncpy((*fields)[i].name, pSchema[tags->pColIndex[i]].name, sizeof((*fields)[i].name));
|
||||||
(*fields)[i].type = schema.type;
|
(*fields)[i].type = pSchema[tags->pColIndex[i]].type;
|
||||||
(*fields)[i].bytes = schema.bytes;
|
(*fields)[i].bytes = pSchema[tags->pColIndex[i]].bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ typedef struct SInsertParseContext {
|
||||||
bool forceUpdate;
|
bool forceUpdate;
|
||||||
bool needTableTagVal;
|
bool needTableTagVal;
|
||||||
bool needRequest; // whether or not request server
|
bool needRequest; // whether or not request server
|
||||||
bool isStmtBind; // whether is stmt bind
|
bool isStmtBind; // whether is stmt bind
|
||||||
} SInsertParseContext;
|
} SInsertParseContext;
|
||||||
|
|
||||||
typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param);
|
typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param);
|
||||||
|
@ -757,7 +757,7 @@ int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SS
|
||||||
STagVal val = {0};
|
STagVal val = {0};
|
||||||
int32_t code = parseTagToken(pSql, pToken, pTagSchema, precision, &val, pMsgBuf);
|
int32_t code = parseTagToken(pSql, pToken, pTagSchema, precision, &val, pMsgBuf);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (NULL == taosArrayPush(pTagVals, &val)){
|
if (NULL == taosArrayPush(pTagVals, &val)) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -775,8 +775,8 @@ static int32_t buildCreateTbReq(SVnodeModifyOpStmt* pStmt, STag* pTag, SArray* p
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
return insBuildCreateTbReq(pStmt->pCreateTblReq, pStmt->targetTableName.tname, pTag, pStmt->pTableMeta->suid,
|
return insBuildCreateTbReq(pStmt->pCreateTblReq, pStmt->targetTableName.tname, pTag, pStmt->pTableMeta->suid,
|
||||||
pStmt->usingTableName.tname, pTagName, pStmt->pTableMeta->tableInfo.numOfTags,
|
pStmt->usingTableName.tname, pTagName, pStmt->pTableMeta->tableInfo.numOfTags,
|
||||||
TSDB_DEFAULT_TABLE_TTL);
|
TSDB_DEFAULT_TABLE_TTL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) {
|
int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) {
|
||||||
|
@ -813,7 +813,7 @@ typedef struct SRewriteTagCondCxt {
|
||||||
|
|
||||||
static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) {
|
static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) {
|
||||||
SValueNode* pValue = NULL;
|
SValueNode* pValue = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pValue);
|
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pValue);
|
||||||
if (NULL == pValue) {
|
if (NULL == pValue) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1044,7 +1044,7 @@ static int32_t storeChildTableMeta(SInsertParseContext* pCxt, SVnodeModifyOpStmt
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
int32_t code = tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
int32_t code = tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
taosMemoryFree(pBackup);
|
taosMemoryFree(pBackup);
|
||||||
|
@ -1239,7 +1239,7 @@ static int32_t getTargetTableMetaAndVgroup(SInsertParseContext* pCxt, SVnodeModi
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectUseTable(const SName* pName, SHashObj* pTable) {
|
static int32_t collectUseTable(const SName* pName, SHashObj* pTable) {
|
||||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||||
int32_t code = tNameExtractFullName(pName, fullName);
|
int32_t code = tNameExtractFullName(pName, fullName);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -1385,7 +1385,7 @@ static int32_t getTableDataCxt(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pS
|
||||||
pStmt->pTableMeta, &pStmt->pCreateTblReq, pTableCxt, false, false);
|
pStmt->pTableMeta, &pStmt->pCreateTblReq, pTableCxt, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
int32_t code = tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
int32_t code = tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -1926,8 +1926,8 @@ static int32_t processCtbAutoCreationAndCtbMeta(SInsertParseContext* pCxt, SVnod
|
||||||
}
|
}
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
code = insBuildCreateTbReq(pStbRowsCxt->pCreateCtbReq, pStbRowsCxt->ctbName.tname, pStbRowsCxt->pTag,
|
code = insBuildCreateTbReq(pStbRowsCxt->pCreateCtbReq, pStbRowsCxt->ctbName.tname, pStbRowsCxt->pTag,
|
||||||
pStbRowsCxt->pStbMeta->uid, pStbRowsCxt->stbName.tname, pStbRowsCxt->aTagNames,
|
pStbRowsCxt->pStbMeta->uid, pStbRowsCxt->stbName.tname, pStbRowsCxt->aTagNames,
|
||||||
getNumOfTags(pStbRowsCxt->pStbMeta), TSDB_DEFAULT_TABLE_TTL);
|
getNumOfTags(pStbRowsCxt->pStbMeta), TSDB_DEFAULT_TABLE_TTL);
|
||||||
pStbRowsCxt->pTag = NULL;
|
pStbRowsCxt->pTag = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1936,9 +1936,9 @@ static int32_t processCtbAutoCreationAndCtbMeta(SInsertParseContext* pCxt, SVnod
|
||||||
code = tNameExtractFullName(&pStbRowsCxt->ctbName, ctbFName);
|
code = tNameExtractFullName(&pStbRowsCxt->ctbName, ctbFName);
|
||||||
SVgroupInfo vg;
|
SVgroupInfo vg;
|
||||||
SRequestConnInfo conn = {.pTrans = pCxt->pComCxt->pTransporter,
|
SRequestConnInfo conn = {.pTrans = pCxt->pComCxt->pTransporter,
|
||||||
.requestId = pCxt->pComCxt->requestId,
|
.requestId = pCxt->pComCxt->requestId,
|
||||||
.requestObjRefId = pCxt->pComCxt->requestRid,
|
.requestObjRefId = pCxt->pComCxt->requestRid,
|
||||||
.mgmtEps = pCxt->pComCxt->mgmtEpSet};
|
.mgmtEps = pCxt->pComCxt->mgmtEpSet};
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = catalogGetTableHashVgroup(pCxt->pComCxt->pCatalog, &conn, &pStbRowsCxt->ctbName, &vg);
|
code = catalogGetTableHashVgroup(pCxt->pComCxt->pCatalog, &conn, &pStbRowsCxt->ctbName, &vg);
|
||||||
}
|
}
|
||||||
|
@ -2179,8 +2179,8 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
SStbRowsDataContext* pStbRowsCxt = rowsDataCxt.pStbRowsCxt;
|
SStbRowsDataContext* pStbRowsCxt = rowsDataCxt.pStbRowsCxt;
|
||||||
void* pData = pTableDataCxt;
|
void* pData = pTableDataCxt;
|
||||||
code = taosHashPut(pStmt->pTableCxtHashObj, &pStbRowsCxt->pCtbMeta->uid, sizeof(pStbRowsCxt->pCtbMeta->uid), &pData,
|
code = taosHashPut(pStmt->pTableCxtHashObj, &pStbRowsCxt->pCtbMeta->uid, sizeof(pStbRowsCxt->pCtbMeta->uid),
|
||||||
POINTER_BYTES);
|
&pData, POINTER_BYTES);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2252,7 +2252,7 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt
|
||||||
if (!pStmt->stbSyntax && numOfRows > 0) {
|
if (!pStmt->stbSyntax && numOfRows > 0) {
|
||||||
void* pData = rowsDataCxt.pTableDataCxt;
|
void* pData = rowsDataCxt.pTableDataCxt;
|
||||||
code = taosHashPut(pStmt->pTableCxtHashObj, &pStmt->pTableMeta->uid, sizeof(pStmt->pTableMeta->uid), &pData,
|
code = taosHashPut(pStmt->pTableCxtHashObj, &pStmt->pTableMeta->uid, sizeof(pStmt->pTableMeta->uid), &pData,
|
||||||
POINTER_BYTES);
|
POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -2366,8 +2366,7 @@ static int32_t constructStbRowsDataContext(SVnodeModifyOpStmt* pStmt, SStbRowsDa
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
// col values and bound cols info of STableDataContext is not used
|
// col values and bound cols info of STableDataContext is not used
|
||||||
pStbRowsCxt->aColVals = taosArrayInit(getNumOfColumns(pStbRowsCxt->pStbMeta), sizeof(SColVal));
|
pStbRowsCxt->aColVals = taosArrayInit(getNumOfColumns(pStbRowsCxt->pStbMeta), sizeof(SColVal));
|
||||||
if (!pStbRowsCxt->aColVals)
|
if (!pStbRowsCxt->aColVals) code = terrno;
|
||||||
code = terrno;
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = insInitColValues(pStbRowsCxt->pStbMeta, pStbRowsCxt->aColVals);
|
code = insInitColValues(pStbRowsCxt->pStbMeta, pStbRowsCxt->aColVals);
|
||||||
|
@ -2511,9 +2510,9 @@ static int32_t checkTableClauseFirstToken(SInsertParseContext* pCxt, SVnodeModif
|
||||||
}
|
}
|
||||||
|
|
||||||
// db.? situation,ensure that the only thing following the '.' mark is '?'
|
// db.? situation,ensure that the only thing following the '.' mark is '?'
|
||||||
char *tbNameAfterDbName = strnchr(pTbName->z, '.', pTbName->n, true);
|
char* tbNameAfterDbName = strnchr(pTbName->z, '.', pTbName->n, true);
|
||||||
if ((tbNameAfterDbName != NULL) && (*(tbNameAfterDbName + 1) == '?')) {
|
if ((tbNameAfterDbName != NULL) && (*(tbNameAfterDbName + 1) == '?')) {
|
||||||
char *tbName = NULL;
|
char* tbName = NULL;
|
||||||
if (NULL == pCxt->pComCxt->pStmtCb) {
|
if (NULL == pCxt->pComCxt->pStmtCb) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msg, "? only used in stmt", pTbName->z);
|
return buildSyntaxErrMsg(&pCxt->msg, "? only used in stmt", pTbName->z);
|
||||||
}
|
}
|
||||||
|
@ -2528,7 +2527,8 @@ static int32_t checkTableClauseFirstToken(SInsertParseContext* pCxt, SVnodeModif
|
||||||
if (pCxt->isStmtBind) {
|
if (pCxt->isStmtBind) {
|
||||||
if (TK_NK_ID == pTbName->type || (tbNameAfterDbName != NULL && *(tbNameAfterDbName + 1) != '?')) {
|
if (TK_NK_ID == pTbName->type || (tbNameAfterDbName != NULL && *(tbNameAfterDbName + 1) != '?')) {
|
||||||
// In SQL statements, the table name has already been specified.
|
// In SQL statements, the table name has already been specified.
|
||||||
parserWarn("0x%" PRIx64 " table name is specified in sql, ignore the table name in bind param", pCxt->pComCxt->requestId);
|
parserWarn("0x%" PRIx64 " table name is specified in sql, ignore the table name in bind param",
|
||||||
|
pCxt->pComCxt->requestId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2614,7 +2614,7 @@ static void destroySubTableHashElem(void* p) { taosMemoryFree(*(STableMeta**)p);
|
||||||
|
|
||||||
static int32_t createVnodeModifOpStmt(SInsertParseContext* pCxt, bool reentry, SNode** pOutput) {
|
static int32_t createVnodeModifOpStmt(SInsertParseContext* pCxt, bool reentry, SNode** pOutput) {
|
||||||
SVnodeModifyOpStmt* pStmt = NULL;
|
SVnodeModifyOpStmt* pStmt = NULL;
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&pStmt);
|
int32_t code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&pStmt);
|
||||||
if (NULL == pStmt) {
|
if (NULL == pStmt) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2729,7 +2729,7 @@ static int32_t buildTagNameFromMeta(STableMeta* pMeta, SArray** pTagName) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
SSchema* pSchema = getTableTagSchema(pMeta);
|
SSchema* pSchema = getTableTagSchema(pMeta);
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
for (int32_t i = 0; i < pMeta->tableInfo.numOfTags; ++i) {
|
for (int32_t i = 0; i < pMeta->tableInfo.numOfTags; ++i) {
|
||||||
if (NULL == taosArrayPush(*pTagName, pSchema[i].name)) {
|
if (NULL == taosArrayPush(*pTagName, pSchema[i].name)) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
@ -2834,7 +2834,7 @@ static int32_t resetVnodeModifOpStmt(SInsertParseContext* pCxt, SQuery* pQuery)
|
||||||
}
|
}
|
||||||
if (NULL == pStmt->pTableBlockHashObj) {
|
if (NULL == pStmt->pTableBlockHashObj) {
|
||||||
pStmt->pTableBlockHashObj =
|
pStmt->pTableBlockHashObj =
|
||||||
taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
}
|
}
|
||||||
if (NULL == pStmt->pVgroupsHashObj || NULL == pStmt->pTableBlockHashObj) {
|
if (NULL == pStmt->pVgroupsHashObj || NULL == pStmt->pTableBlockHashObj) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -2866,7 +2866,7 @@ static int32_t initInsertQuery(SInsertParseContext* pCxt, SCatalogReq* pCatalogR
|
||||||
|
|
||||||
static int32_t setRefreshMeta(SQuery* pQuery) {
|
static int32_t setRefreshMeta(SQuery* pQuery) {
|
||||||
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)pQuery->pRoot;
|
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)pQuery->pRoot;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (taosHashGetSize(pStmt->pTableNameHashObj) > 0) {
|
if (taosHashGetSize(pStmt->pTableNameHashObj) > 0) {
|
||||||
taosArrayDestroy(pQuery->pTableList);
|
taosArrayDestroy(pQuery->pTableList);
|
||||||
|
@ -3065,7 +3065,7 @@ int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatal
|
||||||
.forceUpdate = (NULL != pCatalogReq ? pCatalogReq->forceUpdate : false),
|
.forceUpdate = (NULL != pCatalogReq ? pCatalogReq->forceUpdate : false),
|
||||||
.isStmtBind = pCxt->isStmtBind};
|
.isStmtBind = pCxt->isStmtBind};
|
||||||
|
|
||||||
int32_t code = initInsertQuery(&context, pCatalogReq, pMetaData, pQuery);
|
int32_t code = initInsertQuery(&context, pCatalogReq, pMetaData, pQuery);
|
||||||
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)((*pQuery)->pRoot);
|
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)((*pQuery)->pRoot);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = parseInsertSqlImpl(&context, pStmt);
|
code = parseInsertSqlImpl(&context, pStmt);
|
||||||
|
@ -3082,10 +3082,14 @@ int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatal
|
||||||
code == TSDB_CODE_TSC_INVALID_OPERATION) {
|
code == TSDB_CODE_TSC_INVALID_OPERATION) {
|
||||||
context.tags.numOfBound = pStmt->pStbRowsCxt->boundColsInfo.numOfBound;
|
context.tags.numOfBound = pStmt->pStbRowsCxt->boundColsInfo.numOfBound;
|
||||||
context.tags.numOfCols = pStmt->pStbRowsCxt->boundColsInfo.numOfCols;
|
context.tags.numOfCols = pStmt->pStbRowsCxt->boundColsInfo.numOfCols;
|
||||||
context.tags. hasBoundCols= pStmt->pStbRowsCxt->boundColsInfo.hasBoundCols;
|
context.tags.hasBoundCols = pStmt->pStbRowsCxt->boundColsInfo.hasBoundCols;
|
||||||
context.tags.pColIndex = taosMemoryMalloc(sizeof(int16_t) * context.tags.numOfBound);
|
context.tags.pColIndex = taosMemoryMalloc(sizeof(int16_t) * context.tags.numOfBound);
|
||||||
memcpy(context.tags.pColIndex, pStmt->pStbRowsCxt->boundColsInfo.pColIndex,
|
if (NULL == context.tags.pColIndex) {
|
||||||
sizeof(int16_t) * pStmt->pStbRowsCxt->boundColsInfo.numOfBound);
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)memcpy(context.tags.pColIndex, pStmt->pStbRowsCxt->boundColsInfo.pColIndex,
|
||||||
|
sizeof(int16_t) * pStmt->pStbRowsCxt->boundColsInfo.numOfBound);
|
||||||
code = setStmtInfo(&context, pStmt);
|
code = setStmtInfo(&context, pStmt);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
insDestroyBoundColInfo(&context.tags);
|
insDestroyBoundColInfo(&context.tags);
|
||||||
|
@ -3094,7 +3098,6 @@ int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatal
|
||||||
}
|
}
|
||||||
|
|
||||||
insDestroyBoundColInfo(&context.tags);
|
insDestroyBoundColInfo(&context.tags);
|
||||||
|
|
||||||
// if no data to insert, set emptyMode to avoid request server
|
// if no data to insert, set emptyMode to avoid request server
|
||||||
if (!context.needRequest) {
|
if (!context.needRequest) {
|
||||||
(*pQuery)->execMode = QUERY_EXEC_MODE_EMPTY_RESULT;
|
(*pQuery)->execMode = QUERY_EXEC_MODE_EMPTY_RESULT;
|
||||||
|
|
|
@ -242,7 +242,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch
|
||||||
}
|
}
|
||||||
|
|
||||||
code = insBuildCreateTbReq(pDataBlock->pData->pCreateTbReq, tName, pTag, suid, sTableName, tagName,
|
code = insBuildCreateTbReq(pDataBlock->pData->pCreateTbReq, tName, pTag, suid, sTableName, tagName,
|
||||||
pDataBlock->pMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL);
|
pDataBlock->pMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL);
|
||||||
pTag = NULL;
|
pTag = NULL;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
@ -594,7 +594,7 @@ int32_t qBindStmtTagsValue2(void* pBlock, void* boundTags, int64_t suid, const c
|
||||||
}
|
}
|
||||||
|
|
||||||
code = insBuildCreateTbReq(pDataBlock->pData->pCreateTbReq, tName, pTag, suid, sTableName, tagName,
|
code = insBuildCreateTbReq(pDataBlock->pData->pCreateTbReq, tName, pTag, suid, sTableName, tagName,
|
||||||
pDataBlock->pMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL);
|
pDataBlock->pMeta->tableInfo.numOfTags, TSDB_DEFAULT_TABLE_TTL);
|
||||||
pTag = NULL;
|
pTag = NULL;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
@ -886,7 +886,7 @@ _return:
|
||||||
|
|
||||||
int32_t buildBoundFields(int32_t numOfBound, int16_t* boundColumns, SSchema* pSchema, int32_t* fieldNum,
|
int32_t buildBoundFields(int32_t numOfBound, int16_t* boundColumns, SSchema* pSchema, int32_t* fieldNum,
|
||||||
TAOS_FIELD_E** fields, uint8_t timePrec, TAOS_FIELD_T fieldType) {
|
TAOS_FIELD_E** fields, uint8_t timePrec, TAOS_FIELD_T fieldType) {
|
||||||
if (fields) {
|
if (fields != NULL) {
|
||||||
*fields = taosMemoryCalloc(numOfBound, sizeof(TAOS_FIELD_E));
|
*fields = taosMemoryCalloc(numOfBound, sizeof(TAOS_FIELD_E));
|
||||||
if (NULL == *fields) {
|
if (NULL == *fields) {
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -940,7 +940,7 @@ int32_t qBuildStmtColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD_E** fiel
|
||||||
SSchema* pSchema = getTableColumnSchema(pDataBlock->pMeta);
|
SSchema* pSchema = getTableColumnSchema(pDataBlock->pMeta);
|
||||||
if (pDataBlock->boundColsInfo.numOfBound <= 0) {
|
if (pDataBlock->boundColsInfo.numOfBound <= 0) {
|
||||||
*fieldNum = 0;
|
*fieldNum = 0;
|
||||||
if (fields) {
|
if (fields != NULL) {
|
||||||
*fields = NULL;
|
*fields = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue