diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 9368faa0ee961fb8af98df2ddaecf1e9e748bd31..4e2272eb0566569754df5ef6201f3d190f2789c1 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -490,13 +490,13 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn (*env)->CallVoidMethod(env, rowobj, g_rowdataSetBooleanFp, i, (jboolean)(*((char *)row[i]) == 1)); break; case TSDB_DATA_TYPE_TINYINT: - (*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteFp, i, (jbyte) * ((char *)row[i])); + (*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteFp, i, (jbyte) * ((int8_t *)row[i])); break; case TSDB_DATA_TYPE_SMALLINT: - (*env)->CallVoidMethod(env, rowobj, g_rowdataSetShortFp, i, (jshort) * ((short *)row[i])); + (*env)->CallVoidMethod(env, rowobj, g_rowdataSetShortFp, i, (jshort) * ((int16_t *)row[i])); break; case TSDB_DATA_TYPE_INT: - (*env)->CallVoidMethod(env, rowobj, g_rowdataSetIntFp, i, (jint) * (int *)row[i]); + (*env)->CallVoidMethod(env, rowobj, g_rowdataSetIntFp, i, (jint) * (int32_t *)row[i]); break; case TSDB_DATA_TYPE_BIGINT: (*env)->CallVoidMethod(env, rowobj, g_rowdataSetLongFp, i, (jlong) * ((int64_t *)row[i])); diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 030b033653613faf1cc3071bedfaf79613f17ae6..5a33e05a538425ca5f67d4bab52b66d441651b92 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -306,16 +306,16 @@ static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengt switch (type) { case TSDB_DATA_TYPE_BOOL: - sprintf(result, "%s", ((((int)(*((char *)val))) == 1) ? "true" : "false")); + sprintf(result, "%s", ((((int32_t)(*((char *)val))) == 1) ? "true" : "false")); break; case TSDB_DATA_TYPE_TINYINT: - sprintf(result, "%d", (int)(*((char *)val))); + sprintf(result, "%d", *((int8_t *)val)); break; case TSDB_DATA_TYPE_SMALLINT: - sprintf(result, "%d", (int)(*((short *)val))); + sprintf(result, "%d", *((int16_t *)val)); break; case TSDB_DATA_TYPE_INT: - sprintf(result, "%d", *((int *)val)); + sprintf(result, "%d", *((int32_t *)val)); break; case TSDB_DATA_TYPE_BIGINT: sprintf(result, "%"PRId64, *((int64_t *)val)); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index f690d13164bb82749ec7ce9f6229376bfb3f61ac..ad39f9869d525083a190565369b708552ffb3edc 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1699,7 +1699,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col if (pItem->pNode->pParam != NULL) { tSQLExprItem* pParamElem = &pItem->pNode->pParam->a[0]; SStrToken* pToken = &pParamElem->pNode->colInfo; - short sqlOptr = pParamElem->pNode->nSQLOptr; + int16_t sqlOptr = pParamElem->pNode->nSQLOptr; if ((pToken->z == NULL || pToken->n == 0) && (TK_INTEGER != sqlOptr)) /*select count(1) from table*/ { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 430a762321718eb78f6271e43086390ea1f2439b..91f7fd4638347223e620f06336ebc50bfca397f2 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -719,15 +719,15 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) switch (fields[i].type) { case TSDB_DATA_TYPE_TINYINT: - len += sprintf(str + len, "%d", *((char *)row[i])); + len += sprintf(str + len, "%d", *((int8_t *)row[i])); break; case TSDB_DATA_TYPE_SMALLINT: - len += sprintf(str + len, "%d", *((short *)row[i])); + len += sprintf(str + len, "%d", *((int16_t *)row[i])); break; case TSDB_DATA_TYPE_INT: - len += sprintf(str + len, "%d", *((int *)row[i])); + len += sprintf(str + len, "%d", *((int32_t *)row[i])); break; case TSDB_DATA_TYPE_BIGINT: diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 1d1ca1c42bbb921adef67b63511d4c70be8ccf2e..d5e826fbaabfbf76dfac0256935f3222b53cd70a 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -419,16 +419,16 @@ static void dumpFieldToFile(FILE* fp, const char* val, TAOS_FIELD* field, int32_ char buf[TSDB_MAX_BYTES_PER_ROW]; switch (field->type) { case TSDB_DATA_TYPE_BOOL: - fprintf(fp, "%d", ((((int)(*((char *)val))) == 1) ? 1 : 0)); + fprintf(fp, "%d", ((((int32_t)(*((char *)val))) == 1) ? 1 : 0)); break; case TSDB_DATA_TYPE_TINYINT: - fprintf(fp, "%d", (int)(*((char *)val))); + fprintf(fp, "%d", *((int8_t *)val)); break; case TSDB_DATA_TYPE_SMALLINT: - fprintf(fp, "%d", (int)(*((short *)val))); + fprintf(fp, "%d", *((int16_t *)val)); break; case TSDB_DATA_TYPE_INT: - fprintf(fp, "%d", *((int *)val)); + fprintf(fp, "%d", *((int32_t *)val)); break; case TSDB_DATA_TYPE_BIGINT: fprintf(fp, "%" PRId64, *((int64_t *)val)); @@ -559,16 +559,16 @@ static void printField(const char* val, TAOS_FIELD* field, int width, int32_t le char buf[TSDB_MAX_BYTES_PER_ROW]; switch (field->type) { case TSDB_DATA_TYPE_BOOL: - printf("%*s", width, ((((int)(*((char *)val))) == 1) ? "true" : "false")); + printf("%*s", width, ((((int32_t)(*((char *)val))) == 1) ? "true" : "false")); break; case TSDB_DATA_TYPE_TINYINT: - printf("%*d", width, (int)(*((char *)val))); + printf("%*d", width, *((int8_t *)val)); break; case TSDB_DATA_TYPE_SMALLINT: - printf("%*d", width, (int)(*((short *)val))); + printf("%*d", width, *((int16_t *)val)); break; case TSDB_DATA_TYPE_INT: - printf("%*d", width, *((int *)val)); + printf("%*d", width, *((int32_t *)val)); break; case TSDB_DATA_TYPE_BIGINT: printf("%*" PRId64, width, *((int64_t *)val)); diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim index 8127c1923015e130a85a98a50cd8d4bca23fedb3..d43cd528781cb900f239e4e7549da91ace2d0e5c 100644 --- a/tests/script/general/parser/first_last_query.sim +++ b/tests/script/general/parser/first_last_query.sim @@ -14,12 +14,14 @@ $i = 0 $db = $dbPrefix . $i $stb = $stbPrefix . $i +print use $db sql use $db ##### select first/last from table ## TBASE-331 print ====== select first/last from table $tb = $tbPrefix . 0 +print select first(*) from $tb sql select first(*) from $tb if $rows != 1 then return -1 @@ -58,6 +60,7 @@ if $data09 != NCHAR then return -1 endi +print select last(*) from $tb sql select last(*) from $tb if $rows != 1 then return -1 diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim index f9fd919bd6c5a424ddcac52a0d00b142168702e9..46442e65b1747aeeb5fb73bea7ed949db10faa64 100644 --- a/tests/script/general/parser/where.sim +++ b/tests/script/general/parser/where.sim @@ -94,7 +94,11 @@ endi ## select specified columns +print select c1 from $mt sql select c1 from $mt + +print rows $rows +print totalNum $totalNum if $rows != $totalNum then return -1 endi