未验证 提交 ca995be3 编写于 作者: S shenglian-zhou 提交者: GitHub

Merge pull request #11079 from taosdata/szhou/feature/nchar-subquery

TD-14317: convert mbs to nchar when execute subquery and convert nchar to mbs after executing query
......@@ -978,6 +978,26 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, void* pFilterI
pColData->pData = pRes->urow[i];
}
if (pColData->info.type == TSDB_DATA_TYPE_NCHAR) {
int32_t rows = pBlock->info.rows;
int32_t bytes = pColData->info.bytes;
char *dstData = malloc(bytes * rows);
char *srcData = pColData->pData;
for (int32_t j = 0; j < rows; ++j) {
char *srcRow = srcData + bytes * j;
char *dstRow = dstData + bytes * j;
if(isNull(srcRow, TSDB_DATA_TYPE_NCHAR)){
varDataCopy(dstRow, srcRow);
continue;
}
int32_t len = 0;
taosMbsToUcs4(varDataVal(srcRow), varDataLen(srcRow), varDataVal(dstRow),
bytes-VARSTR_HEADER_SIZE, &len);
varDataSetLen(dstRow, len);
}
memcpy(srcData, dstData, bytes*rows);
free(dstData);
}
offset += pColData->info.bytes;
}
......@@ -986,14 +1006,9 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, void* pFilterI
SColumnDataParam param = {.numOfCols = pBlock->info.numOfCols, .pDataBlock = pBlock->pDataBlock};
filterSetColFieldData(pFilterInfo, &param, getColumnDataFromId);
bool gotNchar = false;
filterConverNcharColumns(pFilterInfo, pBlock->info.rows, &gotNchar);
int8_t* p = NULL;
//bool all = doFilterDataBlock(pFilterInfo, numOfFilterCols, pBlock->info.rows, p);
bool all = filterExecute(pFilterInfo, pBlock->info.rows, &p, NULL, 0);
if (gotNchar) {
filterFreeNcharColumns(pFilterInfo);
}
if (!all) {
if (p) {
doCompactSDataBlock(pBlock, pBlock->info.rows, p);
......@@ -1508,7 +1523,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
uint64_t qId = pSql->self;
qTableQuery(px->pQInfo, &qId);
convertQueryResult(pOutput, px, pSql->self, false, false);
convertQueryResult(pOutput, px, pSql->self, true, false);
}
static void tscDestroyResPointerInfo(SSqlRes* pRes) {
......
......@@ -1024,7 +1024,7 @@ if $data60 != @10@ then
endi
print execute sql select char_length(c15) from (select * from stb1);
sql select char_length(c15) from (select * from stb1);
if $data00 != @0@ then
if $data00 != @1@ then
return -1
endi
if $data10 != @NULL@ then
......@@ -1033,25 +1033,25 @@ endi
if $data20 != @NULL@ then
return -1
endi
if $data30 != @0@ then
if $data30 != @1@ then
return -1
endi
if $data40 != @0@ then
if $data40 != @1@ then
return -1
endi
if $data50 != @0@ then
if $data50 != @3@ then
return -1
endi
if $data60 != @0@ then
return -1
endi
if $data70 != @0@ then
if $data70 != @1@ then
return -1
endi
if $data80 != @0@ then
if $data80 != @1@ then
return -1
endi
if $data90 != @0@ then
if $data90 != @1@ then
return -1
endi
print execute sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册