normalize bool's value
This commit is contained in:
parent
f90ec9d94f
commit
44eb4661dc
|
@ -3171,8 +3171,12 @@ int32_t tColDataAddValueByBind2(SColData *pColData, TAOS_STMT2_BIND *pBind, int3
|
|||
if (allValue) {
|
||||
// optimize (todo)
|
||||
for (int32_t i = 0; i < pBind->num; ++i) {
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](
|
||||
pColData, (uint8_t *)pBind->buffer + TYPE_BYTES[pColData->type] * i, TYPE_BYTES[pColData->type]);
|
||||
uint8_t *val = (uint8_t *)pBind->buffer + TYPE_BYTES[pColData->type] * i;
|
||||
if (TSDB_DATA_TYPE_BOOL == pColData->type && *val > 1) {
|
||||
*val = 1;
|
||||
}
|
||||
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, val, TYPE_BYTES[pColData->type]);
|
||||
}
|
||||
} else if (allNull) {
|
||||
// optimize (todo)
|
||||
|
@ -3186,8 +3190,12 @@ int32_t tColDataAddValueByBind2(SColData *pColData, TAOS_STMT2_BIND *pBind, int3
|
|||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
|
||||
if (code) goto _exit;
|
||||
} else {
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](
|
||||
pColData, (uint8_t *)pBind->buffer + TYPE_BYTES[pColData->type] * i, TYPE_BYTES[pColData->type]);
|
||||
uint8_t *val = (uint8_t *)pBind->buffer + TYPE_BYTES[pColData->type] * i;
|
||||
if (TSDB_DATA_TYPE_BOOL == pColData->type && *val > 1) {
|
||||
*val = 1;
|
||||
}
|
||||
|
||||
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, val, TYPE_BYTES[pColData->type]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3252,9 +3260,12 @@ int32_t tRowBuildFromBind2(SBindInfo2 *infos, int32_t numOfInfos, bool infoSorte
|
|||
*data += length;
|
||||
// value.pData = (uint8_t *)infos[iInfo].bind->buffer + infos[iInfo].bind->buffer_length * iRow;
|
||||
} else {
|
||||
(void)memcpy(
|
||||
&value.val,
|
||||
(uint8_t *)infos[iInfo].bind->buffer + infos[iInfo].bytes /*infos[iInfo].bind->buffer_length*/ * iRow,
|
||||
uint8_t *val = (uint8_t *)infos[iInfo].bind->buffer + infos[iInfo].bytes * iRow;
|
||||
if (TSDB_DATA_TYPE_BOOL == value.type && *val > 1) {
|
||||
*val = 1;
|
||||
}
|
||||
(void)memcpy(&value.val, val,
|
||||
/*(uint8_t *)infos[iInfo].bind->buffer + infos[iInfo].bind->buffer_length * iRow,*/
|
||||
infos[iInfo].bytes /*bind->buffer_length*/);
|
||||
}
|
||||
colVal = COL_VAL_VALUE(infos[iInfo].columnId, value);
|
||||
|
|
|
@ -220,7 +220,8 @@ void veriry_stmt(TAOS* taos) {
|
|||
is_null[i] = 0;
|
||||
|
||||
v.ts[i] = ts++;
|
||||
v.b[i] = (int8_t)i % 2;
|
||||
// v.b[i] = (int8_t)i % 2;
|
||||
v.b[i] = (int8_t)i % 10;
|
||||
v.v1[i] = (int8_t)i;
|
||||
v.v2[i] = (int16_t)(i * 2);
|
||||
v.v4[i] = (int32_t)(i * 4);
|
||||
|
|
|
@ -197,7 +197,6 @@ int32_t shellRunCommand(char *command, bool recordHistory) {
|
|||
return shellRunSingleCommand(cmd);
|
||||
}
|
||||
|
||||
|
||||
char *strendG(const char *pstr) {
|
||||
if (pstr == NULL) {
|
||||
return NULL;
|
||||
|
@ -288,7 +287,8 @@ void shellRunSingleCommandImp(char *command) {
|
|||
printf("Query OK, %" PRId64 " row(s) in set (%.6fs)\r\n", numOfRows, (et - st) / 1E6);
|
||||
} else {
|
||||
terrno = error_no;
|
||||
printf("Query interrupted (%s), %"PRId64 " row(s) in set (%.6fs)\r\n", taos_errstr(NULL), numOfRows, (et - st) / 1E6);
|
||||
printf("Query interrupted (%s), %" PRId64 " row(s) in set (%.6fs)\r\n", taos_errstr(NULL), numOfRows,
|
||||
(et - st) / 1E6);
|
||||
}
|
||||
taos_free_result(pSql);
|
||||
} else {
|
||||
|
@ -640,7 +640,7 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
|
|||
char buf[LENGTH] = {0};
|
||||
switch (field->type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
shellPrintString(((((int32_t)(*((char *)val))) == 1) ? "true" : "false"), width);
|
||||
shellPrintString(((((int32_t)(*((char *)val))) == TSDB_FALSE) ? "false" : "true"), width);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
printf("%*d", width, *((int8_t *)val));
|
||||
|
@ -1122,7 +1122,8 @@ void shellSourceFile(const char *file) {
|
|||
char *line = taosMemoryMalloc(TSDB_MAX_ALLOWED_SQL_LEN + 1);
|
||||
while ((read_len = taosGetsFile(pFile, TSDB_MAX_ALLOWED_SQL_LEN, line)) > 0) {
|
||||
if (cmd_len + read_len >= TSDB_MAX_ALLOWED_SQL_LEN) {
|
||||
printf("read command line too long over 1M, ignore this line. cmd_len = %d read_len=%d \n", (int32_t)cmd_len, read_len);
|
||||
printf("read command line too long over 1M, ignore this line. cmd_len = %d read_len=%d \n", (int32_t)cmd_len,
|
||||
read_len);
|
||||
cmd_len = 0;
|
||||
memset(line, 0, TSDB_MAX_ALLOWED_SQL_LEN + 1);
|
||||
continue;
|
||||
|
@ -1207,8 +1208,7 @@ bool shellGetGrantInfo(char* buf) {
|
|||
sprintf(buf, "Server is %s, %s and will never expire.\r\n", serverVersion, sinfo);
|
||||
} else {
|
||||
community = false;
|
||||
sprintf(buf, "Server is %s, %s and will expire at %s.\r\n", serverVersion, sinfo,
|
||||
expiretime);
|
||||
sprintf(buf, "Server is %s, %s and will expire at %s.\r\n", serverVersion, sinfo, expiretime);
|
||||
}
|
||||
|
||||
taos_free_result(tres);
|
||||
|
|
Loading…
Reference in New Issue