support nchar filter in parent
This commit is contained in:
parent
31d17bdecc
commit
8756467972
|
@ -188,6 +188,7 @@ typedef struct SFilterInfo {
|
||||||
#define FILTER_GET_FIELD(i, id) (&((i)->fields[(id).type].fields[(id).idx]))
|
#define FILTER_GET_FIELD(i, id) (&((i)->fields[(id).type].fields[(id).idx]))
|
||||||
#define FILTER_GET_COL_FIELD(i, idx) (&((i)->fields[FLD_TYPE_COLUMN].fields[idx]))
|
#define FILTER_GET_COL_FIELD(i, idx) (&((i)->fields[FLD_TYPE_COLUMN].fields[idx]))
|
||||||
#define FILTER_GET_COL_FIELD_TYPE(fi) (((SSchema *)((fi)->desc))->type)
|
#define FILTER_GET_COL_FIELD_TYPE(fi) (((SSchema *)((fi)->desc))->type)
|
||||||
|
#define FILTER_GET_COL_FIELD_SIZE(fi) (((SSchema *)((fi)->desc))->bytes)
|
||||||
#define FILTER_GET_COL_FIELD_DESC(fi) ((SSchema *)((fi)->desc))
|
#define FILTER_GET_COL_FIELD_DESC(fi) ((SSchema *)((fi)->desc))
|
||||||
#define FILTER_GET_COL_FIELD_DATA(fi, ri) ((fi)->data + ((SSchema *)((fi)->desc))->bytes * (ri))
|
#define FILTER_GET_COL_FIELD_DATA(fi, ri) ((fi)->data + ((SSchema *)((fi)->desc))->bytes * (ri))
|
||||||
#define FILTER_GET_VAL_FIELD_TYPE(fi) (((tVariant *)((fi)->desc))->nType)
|
#define FILTER_GET_VAL_FIELD_TYPE(fi) (((tVariant *)((fi)->desc))->nType)
|
||||||
|
|
|
@ -1815,7 +1815,31 @@ _err_return:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *gotNchar) {
|
int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar) {
|
||||||
|
for (uint16_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) {
|
||||||
|
SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i];
|
||||||
|
int32_t type = FILTER_GET_COL_FIELD_TYPE(fi);
|
||||||
|
if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
SFilterField nfi = {0};
|
||||||
|
nfi.desc = fi->desc;
|
||||||
|
int32_t bytes = FILTER_GET_COL_FIELD_SIZE(fi);
|
||||||
|
nfi.data = malloc(rows * bytes);
|
||||||
|
int32_t bufSize = bytes - VARSTR_HEADER_SIZE;
|
||||||
|
for (int32_t j = 0; j < rows; ++j) {
|
||||||
|
char *src = FILTER_GET_COL_FIELD_DATA(fi, j);
|
||||||
|
char *dst = FILTER_GET_COL_FIELD_DATA(&nfi, j);
|
||||||
|
int32_t len = 0;
|
||||||
|
taosMbsToUcs4(varDataVal(src), varDataLen(src), varDataVal(dst), bufSize, &len);
|
||||||
|
varDataLen(dst) = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
fi->data = nfi.data;
|
||||||
|
|
||||||
|
*gotNchar = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
for (int32_t i = 0; i < numOfFilterCols; ++i) {
|
for (int32_t i = 0; i < numOfFilterCols; ++i) {
|
||||||
if (pFilterInfo[i].info.type == TSDB_DATA_TYPE_NCHAR) {
|
if (pFilterInfo[i].info.type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
@ -1837,7 +1861,7 @@ int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *g
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo) {
|
int32_t filterFreeNcharColumns(SFilterInfo* info) {
|
||||||
#if 0
|
#if 0
|
||||||
for (int32_t i = 0; i < numOfFilterCols; ++i) {
|
for (int32_t i = 0; i < numOfFilterCols; ++i) {
|
||||||
if (pFilterInfo[i].info.type == TSDB_DATA_TYPE_NCHAR) {
|
if (pFilterInfo[i].info.type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
@ -1850,6 +1874,15 @@ int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) {
|
||||||
|
SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i];
|
||||||
|
int32_t type = FILTER_GET_COL_FIELD_TYPE(fi);
|
||||||
|
if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
tfree(fi->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1200,6 +1200,31 @@ sql select * from stb1 where c1 is null and c2 is null and ts > '2021-05-05 18:1
|
||||||
if $rows != 0 then
|
if $rows != 0 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select * from stb1 where c1 is null and c1 > 0;
|
||||||
|
if $rows != 0 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from stb1 where c1 is null or c1 is not null or c1 > 1;
|
||||||
|
if $rows != 29 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from stb1 where (c1 is null or c1 > 40) and c1 < 44;
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != @21-05-05 18:19:16.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data10 != @21-05-05 18:19:17.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data20 != @21-05-05 18:19:18.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
sql select * from stb1 where c1 = 3 or c1 = 5 or c1 >= 44 and c1 <= 52;
|
sql select * from stb1 where c1 = 3 or c1 = 5 or c1 >= 44 and c1 <= 52;
|
||||||
if $rows != 4 then
|
if $rows != 4 then
|
||||||
return -1
|
return -1
|
||||||
|
@ -1738,6 +1763,20 @@ if $data20 != @21-05-05 18:19:03.000@ then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select * from (select * from stb1 where c2 > 10 and c6 < 40) where c9 in ('11','21','31');
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != @21-05-05 18:19:04.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data10 != @21-05-05 18:19:08.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data20 != @21-05-05 18:19:12.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
print "ts test"
|
print "ts test"
|
||||||
sql_error select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27'
|
sql_error select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27'
|
||||||
|
@ -2036,6 +2075,26 @@ if $data50 != @21-05-05 18:19:14.000@ then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:26.000' or ts = '2021-05-05 18:19:26.000') and ts != '2021-05-05 18:19:03.000' and ts != '2021-05-05 18:19:26.000';
|
||||||
|
if $rows != 5 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != @21-05-05 18:19:00.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data10 != @21-05-05 18:19:01.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data20 != @21-05-05 18:19:02.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data30 != @21-05-05 18:19:27.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data40 != @21-05-05 18:19:28.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
print "tbname test"
|
print "tbname test"
|
||||||
sql_error select * from stb1 where tbname like '%3' and tbname like '%4';
|
sql_error select * from stb1 where tbname like '%3' and tbname like '%4';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue