[td-245]
This commit is contained in:
parent
7ef4b3ab13
commit
309076cd03
|
@ -327,15 +327,16 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload,
|
|||
*(uint32_t*) payload = TSDB_DATA_NCHAR_NULL;
|
||||
} else {
|
||||
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
|
||||
int32_t resLen = -1;
|
||||
if (!taosMbsToUcs4(pToken->z, pToken->n, payload + VARSTR_HEADER_SIZE, pSchema->bytes - VARSTR_HEADER_SIZE, &resLen)) {
|
||||
char buf[512] = {0};
|
||||
snprintf(buf, 512, "%s", strerror(errno));
|
||||
size_t wcharLength = 0;
|
||||
if (!taosMbsToUcs4(pToken->z, pToken->n, payload + VARSTR_HEADER_SIZE, pSchema->bytes - VARSTR_HEADER_SIZE,
|
||||
&wcharLength)) {
|
||||
|
||||
char buf[512] = {0};
|
||||
snprintf(buf, tListLen(buf), "%s", strerror(errno));
|
||||
return tscInvalidSQLErrMsg(msg, buf, pToken->z);
|
||||
}
|
||||
|
||||
*(uint16_t*)payload = (uint16_t) (resLen * TSDB_NCHAR_SIZE);
|
||||
*(uint16_t*) payload = (uint16_t) (wcharLength);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void *param, void *handle,
|
|||
|
||||
void taosTmrCleanUp(void *handle);
|
||||
|
||||
int32_t taosInitTimer(void (*callback)(int), int32_t ms);
|
||||
|
||||
void taosUninitTimer();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -141,10 +141,7 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
|
|||
*/
|
||||
void getTmpfilePath(const char *fileNamePattern, char *dstPath);
|
||||
|
||||
int32_t taosInitTimer(void (*callback)(int), int32_t ms);
|
||||
void taosUninitTimer();
|
||||
|
||||
bool taosMbsToUcs4(char *mbs, int32_t mbs_len, char *ucs4, int32_t ucs4_max_len, int32_t* len);
|
||||
bool taosMbsToUcs4(char *mbs, size_t mbs_len, char *ucs4, int32_t ucs4_max_len, size_t* len);
|
||||
|
||||
int tasoUcs4Compare(void* f1_ucs4, void *f2_ucs4, int bytes);
|
||||
|
||||
|
|
|
@ -490,25 +490,26 @@ bool taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool taosMbsToUcs4(char *mbs, int32_t mbs_len, char *ucs4, int32_t ucs4_max_len, int32_t* len) {
|
||||
bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, size_t* len) {
|
||||
memset(ucs4, 0, ucs4_max_len);
|
||||
#ifdef USE_LIBICONV
|
||||
iconv_t cd = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
|
||||
size_t ucs4_input_len = mbs_len;
|
||||
size_t outLen = ucs4_max_len;
|
||||
if (iconv(cd, &mbs, &ucs4_input_len, &ucs4, &outLen) == -1) {
|
||||
size_t ucs4_input_len = mbsLength;
|
||||
size_t outLeft = ucs4_max_len;
|
||||
if (iconv(cd, &mbs, &ucs4_input_len, &ucs4, &outLeft) == -1) {
|
||||
iconv_close(cd);
|
||||
return false;
|
||||
}
|
||||
|
||||
iconv_close(cd);
|
||||
if (len != NULL) {
|
||||
*len = outLen;
|
||||
*len = ucs4_max_len - outLeft;
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
mbstate_t state = {0};
|
||||
int32_t len = mbsnrtowcs((wchar_t *) ucs4, (const char **) &mbs, mbs_len, ucs4_max_len / 4, &state);
|
||||
int32_t len = mbsnrtowcs((wchar_t *) ucs4, (const char **) &mbs, mbsLength, ucs4_max_len / 4, &state);
|
||||
return len >= 0;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -688,7 +688,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
|||
}
|
||||
|
||||
if (row[i] == 0) {
|
||||
strcpy(value, "null");
|
||||
strcpy(value, TSDB_DATA_NULL_STR);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue