TD-1057
This commit is contained in:
parent
f790003eeb
commit
4a25ad2b4e
|
@ -4,7 +4,6 @@ taos_options
|
|||
taos_connect
|
||||
taos_close
|
||||
taos_query
|
||||
taos_use_result
|
||||
taos_fetch_row
|
||||
taos_free_result
|
||||
taos_field_count
|
||||
|
|
|
@ -947,11 +947,11 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
|
|||
if (pCtx->inputType == TSDB_DATA_TYPE_TINYINT) {
|
||||
int8_t *data = (int8_t *)pOutput;
|
||||
|
||||
UPDATE_DATA(pCtx, *data, val, notNullElems, isMin, key);
|
||||
UPDATE_DATA(pCtx, *data, (int8_t)val, notNullElems, isMin, key);
|
||||
} else if (pCtx->inputType == TSDB_DATA_TYPE_SMALLINT) {
|
||||
int16_t *data = (int16_t *)pOutput;
|
||||
|
||||
UPDATE_DATA(pCtx, *data, val, notNullElems, isMin, key);
|
||||
UPDATE_DATA(pCtx, *data, (int16_t)val, notNullElems, isMin, key);
|
||||
} else if (pCtx->inputType == TSDB_DATA_TYPE_INT) {
|
||||
int32_t *data = (int32_t *)pOutput;
|
||||
#if defined(_DEBUG_VIEW)
|
||||
|
@ -959,7 +959,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
|
|||
#endif
|
||||
|
||||
if ((*data < val) ^ isMin) {
|
||||
*data = val;
|
||||
*data = (int32_t)val;
|
||||
for (int32_t i = 0; i < (pCtx)->tagInfo.numOfTagCols; ++i) {
|
||||
SQLFunctionCtx *__ctx = pCtx->tagInfo.pTagCtxList[i];
|
||||
if (__ctx->functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
|
@ -982,7 +982,7 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
|
|||
float *data = (float *)pOutput;
|
||||
double val = GET_DOUBLE_VAL(tval);
|
||||
|
||||
UPDATE_DATA(pCtx, *data, val, notNullElems, isMin, key);
|
||||
UPDATE_DATA(pCtx, *data, (float)val, notNullElems, isMin, key);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -2040,7 +2040,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
|
|||
case TSDB_DATA_TYPE_INT: {
|
||||
int32_t *output = (int32_t *)pCtx->aOutputBuf;
|
||||
for (int32_t i = 0; i < len; ++i, output += step) {
|
||||
*output = tvp[i]->v.i64Key;
|
||||
*output = (int32_t)tvp[i]->v.i64Key;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2061,21 +2061,21 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
|
|||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float *output = (float *)pCtx->aOutputBuf;
|
||||
for (int32_t i = 0; i < len; ++i, output += step) {
|
||||
*output = tvp[i]->v.dKey;
|
||||
*output = (float)tvp[i]->v.dKey;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
int16_t *output = (int16_t *)pCtx->aOutputBuf;
|
||||
for (int32_t i = 0; i < len; ++i, output += step) {
|
||||
*output = tvp[i]->v.i64Key;
|
||||
*output = (int16_t)tvp[i]->v.i64Key;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
int8_t *output = (int8_t *)pCtx->aOutputBuf;
|
||||
for (int32_t i = 0; i < len; ++i, output += step) {
|
||||
*output = tvp[i]->v.i64Key;
|
||||
*output = (int8_t)tvp[i]->v.i64Key;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2430,7 +2430,7 @@ static bool percentile_function_setup(SQLFunctionCtx *pCtx) {
|
|||
}
|
||||
|
||||
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||
SSchema field[1] = { { pCtx->inputType, "dummyCol", 0, (uint8_t)pCtx->inputBytes } };
|
||||
SSchema field[1] = { { (uint8_t)pCtx->inputType, "dummyCol", 0, pCtx->inputBytes } };
|
||||
|
||||
SColumnModel *pModel = createColumnModel(field, 1, 1000);
|
||||
int32_t orderIdx = 0;
|
||||
|
@ -2875,7 +2875,7 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) {
|
|||
|
||||
double(*param)[3] = pInfo->mat;
|
||||
|
||||
param[1][1] = pInfo->num;
|
||||
param[1][1] = (double)pInfo->num;
|
||||
param[1][0] = param[0][1];
|
||||
|
||||
param[0][0] -= param[1][0] * (param[0][1] / param[1][1]);
|
||||
|
@ -3335,10 +3335,10 @@ static void arithmetic_function_f(SQLFunctionCtx *pCtx, int32_t index) {
|
|||
continue; \
|
||||
} \
|
||||
if (inputData[i] < minOutput) { \
|
||||
minOutput = inputData[i]; \
|
||||
minOutput = (double)inputData[i]; \
|
||||
} \
|
||||
if (inputData[i] > maxOutput) { \
|
||||
maxOutput = inputData[i]; \
|
||||
maxOutput = (double)inputData[i]; \
|
||||
} \
|
||||
numOfNotNullElem++; \
|
||||
} \
|
||||
|
@ -3456,7 +3456,7 @@ static void spread_function_f(SQLFunctionCtx *pCtx, int32_t index) {
|
|||
} else if (pCtx->inputType == TSDB_DATA_TYPE_INT) {
|
||||
val = GET_INT32_VAL(pData);
|
||||
} else if (pCtx->inputType == TSDB_DATA_TYPE_BIGINT || pCtx->inputType == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
val = GET_INT64_VAL(pData);
|
||||
val = (double)(GET_INT64_VAL(pData));
|
||||
} else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE) {
|
||||
val = GET_DOUBLE_VAL(pData);
|
||||
} else if (pCtx->inputType == TSDB_DATA_TYPE_FLOAT) {
|
||||
|
|
|
@ -223,12 +223,12 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
|||
|
||||
rowLen += ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE);
|
||||
|
||||
f.bytes = typeColLength + VARSTR_HEADER_SIZE;
|
||||
f.bytes = (int16_t)(typeColLength + VARSTR_HEADER_SIZE);
|
||||
f.type = TSDB_DATA_TYPE_BINARY;
|
||||
tstrncpy(f.name, "Type", sizeof(f.name));
|
||||
|
||||
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, typeColLength + VARSTR_HEADER_SIZE,
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(typeColLength + VARSTR_HEADER_SIZE),
|
||||
typeColLength, false);
|
||||
|
||||
rowLen += typeColLength + VARSTR_HEADER_SIZE;
|
||||
|
@ -243,12 +243,12 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
|
|||
|
||||
rowLen += sizeof(int32_t);
|
||||
|
||||
f.bytes = noteColLength + VARSTR_HEADER_SIZE;
|
||||
f.bytes = (int16_t)(noteColLength + VARSTR_HEADER_SIZE);
|
||||
f.type = TSDB_DATA_TYPE_BINARY;
|
||||
tstrncpy(f.name, "Note", sizeof(f.name));
|
||||
|
||||
pInfo = tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, noteColLength + VARSTR_HEADER_SIZE,
|
||||
pInfo->pSqlExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS_DUMMY, &index, TSDB_DATA_TYPE_BINARY, (int16_t)(noteColLength + VARSTR_HEADER_SIZE),
|
||||
noteColLength, false);
|
||||
|
||||
rowLen += noteColLength + VARSTR_HEADER_SIZE;
|
||||
|
@ -305,7 +305,7 @@ static void tscProcessCurrentDB(SSqlObj *pSql) {
|
|||
if (t == 0) {
|
||||
setVardataNull(vx, TSDB_DATA_TYPE_BINARY);
|
||||
} else {
|
||||
STR_WITH_SIZE_TO_VARSTR(vx, db, t);
|
||||
STR_WITH_SIZE_TO_VARSTR(vx, db, (VarDataLenT)t);
|
||||
}
|
||||
|
||||
tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes);
|
||||
|
@ -320,10 +320,10 @@ static void tscProcessServerVer(SSqlObj *pSql) {
|
|||
pExpr->resType = TSDB_DATA_TYPE_BINARY;
|
||||
|
||||
size_t t = strlen(v);
|
||||
pExpr->resBytes = t + VARSTR_HEADER_SIZE;
|
||||
pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE);
|
||||
|
||||
char* vx = calloc(1, pExpr->resBytes);
|
||||
STR_WITH_SIZE_TO_VARSTR(vx, v, t);
|
||||
STR_WITH_SIZE_TO_VARSTR(vx, v, (VarDataLenT)t);
|
||||
tscSetLocalQueryResult(pSql, vx, pExpr->aliasName, pExpr->resType, pExpr->resBytes);
|
||||
|
||||
taosTFree(vx);
|
||||
|
@ -336,10 +336,10 @@ static void tscProcessClientVer(SSqlObj *pSql) {
|
|||
pExpr->resType = TSDB_DATA_TYPE_BINARY;
|
||||
|
||||
size_t t = strlen(version);
|
||||
pExpr->resBytes = t + VARSTR_HEADER_SIZE;
|
||||
pExpr->resBytes = (int16_t)(t + VARSTR_HEADER_SIZE);
|
||||
|
||||
char* v = calloc(1, pExpr->resBytes);
|
||||
STR_WITH_SIZE_TO_VARSTR(v, version, t);
|
||||
STR_WITH_SIZE_TO_VARSTR(v, version, (VarDataLenT)t);
|
||||
tscSetLocalQueryResult(pSql, v, pExpr->aliasName, pExpr->resType, pExpr->resBytes);
|
||||
|
||||
taosTFree(v);
|
||||
|
@ -379,10 +379,10 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
|
|||
pQueryInfo->fieldsInfo.pFields = taosArrayInit(1, sizeof(TAOS_FIELD));
|
||||
pQueryInfo->fieldsInfo.pSupportInfo = taosArrayInit(1, sizeof(SFieldSupInfo));
|
||||
|
||||
TAOS_FIELD f = tscCreateField(type, columnName, valueLength);
|
||||
TAOS_FIELD f = tscCreateField((int8_t)type, columnName, (int16_t)valueLength);
|
||||
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
|
||||
tscInitResObjForLocalQuery(pSql, 1, valueLength);
|
||||
tscInitResObjForLocalQuery(pSql, 1, (int32_t)valueLength);
|
||||
|
||||
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0);
|
||||
SFieldSupInfo* pInfo = tscFieldInfoGetSupp(&pQueryInfo->fieldsInfo, 0);
|
||||
|
|
|
@ -107,6 +107,9 @@ typedef SOCKET eventfd_t;
|
|||
#define taosStrdupImp(str) _strdup(str)
|
||||
#define taosStrndupImp(str, size) _strndup(str, size)
|
||||
|
||||
char *stpcpy (char *dest, const char *src);
|
||||
char *stpncpy (char *dest, const char *src, size_t n);
|
||||
|
||||
#define TAOS_OS_FUNC_SYSINFO
|
||||
|
||||
#define TAOS_OS_FUNC_TIME_DEF
|
||||
|
|
|
@ -129,3 +129,28 @@ int tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int bytes) {
|
|||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Copy memory to memory until the specified number of bytes
|
||||
has been copied, return pointer to following byte.
|
||||
Overlap is NOT handled correctly. */
|
||||
void *mempcpy(void *dest, const void *src, size_t len) {
|
||||
return (char*)memcpy(dest, src, len) + len;
|
||||
}
|
||||
|
||||
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
|
||||
char *stpcpy (char *dest, const char *src) {
|
||||
size_t len = strlen (src);
|
||||
return (char*)memcpy(dest, src, len + 1) + len;
|
||||
}
|
||||
|
||||
/* Copy no more than N characters of SRC to DEST, returning the address of
|
||||
the terminating '\0' in DEST, if any, or else DEST + N. */
|
||||
char *stpncpy (char *dest, const char *src, size_t n) {
|
||||
size_t size = strnlen (src, n);
|
||||
memcpy (dest, src, size);
|
||||
dest += size;
|
||||
if (size == n)
|
||||
return dest;
|
||||
return memset (dest, '\0', n - size);
|
||||
}
|
Loading…
Reference in New Issue