Merge pull request #29876 from taosdata/enh/3.0/TD-33802
enh(stmt2)[TD-33802]:check pk null error when stmt2 bind
This commit is contained in:
commit
0cd2384ff9
|
@ -1043,6 +1043,37 @@ TEST(stmt2Case, stmt2_insert_non_statndard) {
|
|||
taos_stmt2_close(stmt);
|
||||
}
|
||||
|
||||
// pk error
|
||||
{
|
||||
TAOS_STMT2* stmt = taos_stmt2_init(taos, &option);
|
||||
ASSERT_NE(stmt, nullptr);
|
||||
const char* sql =
|
||||
"INSERT INTO stmt2_testdb_6.? using stmt2_testdb_6.stb1 (int_tag)tags(1) (int_col,ts)VALUES (?,?)";
|
||||
int code = taos_stmt2_prepare(stmt, sql, 0);
|
||||
checkError(stmt, code);
|
||||
|
||||
int tag_i = 0;
|
||||
int tag_l = sizeof(int);
|
||||
int tag_bl = 3;
|
||||
int64_t ts[2] = {1591060628000, NULL};
|
||||
int t64_len[2] = {sizeof(int64_t), sizeof(int64_t)};
|
||||
int coli[2] = {1, 2};
|
||||
int ilen[2] = {sizeof(int), sizeof(int)};
|
||||
int total_affect_rows = 0;
|
||||
char is_null[2] = {1, 1};
|
||||
|
||||
TAOS_STMT2_BIND params1[2] = {{TSDB_DATA_TYPE_INT, &coli, &ilen[0], is_null, 2},
|
||||
{TSDB_DATA_TYPE_TIMESTAMP, &ts, &t64_len[0], is_null, 2}};
|
||||
|
||||
TAOS_STMT2_BIND* paramv = ¶ms1[0];
|
||||
char* tbname = "tb3";
|
||||
TAOS_STMT2_BINDV bindv = {1, &tbname, NULL, ¶mv};
|
||||
code = taos_stmt2_bind_param(stmt, &bindv, -1);
|
||||
ASSERT_EQ(code, TSDB_CODE_PAR_PRIMARY_KEY_IS_NULL);
|
||||
|
||||
taos_stmt2_close(stmt);
|
||||
}
|
||||
|
||||
do_query(taos, "drop database if exists stmt2_testdb_6");
|
||||
taos_close(taos);
|
||||
}
|
||||
|
|
|
@ -152,10 +152,10 @@ static int32_t tRowBuildScan(SArray *colVals, const STSchema *schema, SRowBuildS
|
|||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
if (!(colValArray[0].cid == PRIMARYKEY_TIMESTAMP_COL_ID)) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_PAR_INVALID_FIRST_COLUMN;
|
||||
}
|
||||
if (!(colValArray[0].value.type == TSDB_DATA_TYPE_TIMESTAMP)) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_PAR_INVALID_FIRST_COLUMN;;
|
||||
}
|
||||
|
||||
*sinfo = (SRowBuildScanInfo){
|
||||
|
@ -3627,13 +3627,13 @@ int32_t tColDataSortMerge(SArray **arr) {
|
|||
SColData *aColData = (SColData *)TARRAY_DATA(colDataArr);
|
||||
|
||||
if (!(aColData[0].type == TSDB_DATA_TYPE_TIMESTAMP)) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_PAR_INVALID_FIRST_COLUMN;
|
||||
}
|
||||
if (!(aColData[0].cid == PRIMARYKEY_TIMESTAMP_COL_ID)) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_PAR_INVALID_FIRST_COLUMN;
|
||||
}
|
||||
if (!(aColData[0].flag == HAS_VALUE)) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return TSDB_CODE_PAR_PRIMARY_KEY_IS_NULL;
|
||||
}
|
||||
|
||||
if (aColData[0].nVal <= 1) goto _exit;
|
||||
|
|
|
@ -834,6 +834,10 @@ int32_t qBindStmtColsValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind,
|
|||
goto _return;
|
||||
}
|
||||
|
||||
if(boundInfo->pColIndex[c]==0){
|
||||
pCol->cflag |= COL_IS_KEY;
|
||||
}
|
||||
|
||||
if (bind[c].num != rowNum) {
|
||||
code = buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same");
|
||||
goto _return;
|
||||
|
@ -863,7 +867,7 @@ int32_t qBindStmtColsValue2(void* pBlock, SArray* pCols, TAOS_STMT2_BIND* bind,
|
|||
}
|
||||
}
|
||||
|
||||
qDebug("stmt all %d columns bind %d rows data", boundInfo->numOfBound, rowNum);
|
||||
qDebug("stmt2 all %d columns bind %d rows data as col format", boundInfo->numOfBound, rowNum);
|
||||
|
||||
_return:
|
||||
|
||||
|
|
Loading…
Reference in New Issue