Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bf041f21
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bf041f21
编写于
6月 23, 2022
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: undo trimming EOL whitespaces or some formatting
上级
b824256e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
191 addition
and
186 deletion
+191
-186
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+63
-62
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+105
-103
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+14
-12
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+2
-2
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+7
-7
未找到文件。
src/client/src/tscLocal.c
浏览文件 @
bf041f21
...
@@ -25,23 +25,23 @@
...
@@ -25,23 +25,23 @@
#include "taos.h"
#include "taos.h"
#include "tscSubquery.h"
#include "tscSubquery.h"
#define STR_NOCASE_EQUAL(str1, len1, str2, len2) ((len1 == len2) && 0 == strncasecmp(str1, str2, len1))
#define STR_NOCASE_EQUAL(str1, len1, str2, len2) ((len1 == len2) && 0 == strncasecmp(str1, str2, len1))
typedef
enum
BuildType
{
typedef
enum
BuildType
{
SCREATE_BUILD_TABLE
=
1
,
SCREATE_BUILD_TABLE
=
1
,
SCREATE_BUILD_DB
=
2
,
SCREATE_BUILD_DB
=
2
,
}
BuildType
;
}
BuildType
;
typedef
enum
Stage
{
typedef
enum
Stage
{
SCREATE_CALLBACK_QUERY
=
1
,
SCREATE_CALLBACK_QUERY
=
1
,
SCREATE_CALLBACK_RETRIEVE
=
2
,
SCREATE_CALLBACK_RETRIEVE
=
2
,
}
Stage
;
}
Stage
;
// support 'show create table'
// support 'show create table'
typedef
struct
SCreateBuilder
{
typedef
struct
SCreateBuilder
{
char
sTableName
[
TSDB_TABLE_FNAME_LEN
];
char
sTableName
[
TSDB_TABLE_FNAME_LEN
];
char
buf
[
TSDB_TABLE_FNAME_LEN
];
char
buf
[
TSDB_TABLE_FNAME_LEN
];
SSqlObj
*
pParentSql
;
SSqlObj
*
pParentSql
;
SSqlObj
*
pInterSql
;
SSqlObj
*
pInterSql
;
int32_t
(
*
fp
)(
void
*
para
,
char
*
result
);
int32_t
(
*
fp
)(
void
*
para
,
char
*
result
);
Stage
callStage
;
Stage
callStage
;
...
@@ -54,7 +54,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -54,7 +54,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
// one column for each row
// one column for each row
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMeta
*
pMeta
=
pTableMetaInfo
->
pTableMeta
;
STableMeta
*
pMeta
=
pTableMetaInfo
->
pTableMeta
;
...
@@ -121,7 +121,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
...
@@ -121,7 +121,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
// type name
// type name
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
1
);
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
1
);
char
*
type
=
tDataTypes
[
pSchema
[
i
].
type
].
name
;
char
*
type
=
tDataTypes
[
pSchema
[
i
].
type
].
name
;
output
=
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
1
)
*
totalNumOfRows
+
pField
->
bytes
*
i
;
output
=
pRes
->
data
+
tscFieldInfoGetOffset
(
pQueryInfo
,
1
)
*
totalNumOfRows
+
pField
->
bytes
*
i
;
STR_WITH_MAXSIZE_TO_VARSTR
(
output
,
type
,
pField
->
bytes
);
STR_WITH_MAXSIZE_TO_VARSTR
(
output
,
type
,
pField
->
bytes
);
...
@@ -153,7 +153,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
...
@@ -153,7 +153,7 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
int32_t
noteColLength
)
{
int32_t
noteColLength
)
{
int32_t
rowLen
=
0
;
int32_t
rowLen
=
0
;
SColumnIndex
index
=
{
0
};
SColumnIndex
index
=
{
0
};
pSql
->
cmd
.
numOfCols
=
numOfCols
;
pSql
->
cmd
.
numOfCols
=
numOfCols
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
...
@@ -161,48 +161,48 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
...
@@ -161,48 +161,48 @@ static int32_t tscBuildTableSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
TAOS_FIELD
f
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
(
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
};
TAOS_FIELD
f
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
(
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
};
tstrncpy
(
f
.
name
,
"Field"
,
sizeof
(
f
.
name
));
tstrncpy
(
f
.
name
,
"Field"
,
sizeof
(
f
.
name
));
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
(
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
,
-
1000
,
(
TSDB_COL_NAME_LEN
-
1
),
false
);
(
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
,
-
1000
,
(
TSDB_COL_NAME_LEN
-
1
),
false
);
rowLen
+=
((
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
);
rowLen
+=
((
TSDB_COL_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
);
f
.
bytes
=
(
int16_t
)(
typeColLength
+
VARSTR_HEADER_SIZE
);
f
.
bytes
=
(
int16_t
)(
typeColLength
+
VARSTR_HEADER_SIZE
);
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
tstrncpy
(
f
.
name
,
"Type"
,
sizeof
(
f
.
name
));
tstrncpy
(
f
.
name
,
"Type"
,
sizeof
(
f
.
name
));
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
(
int16_t
)(
typeColLength
+
VARSTR_HEADER_SIZE
),
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
(
int16_t
)(
typeColLength
+
VARSTR_HEADER_SIZE
),
-
1000
,
typeColLength
,
false
);
-
1000
,
typeColLength
,
false
);
rowLen
+=
typeColLength
+
VARSTR_HEADER_SIZE
;
rowLen
+=
typeColLength
+
VARSTR_HEADER_SIZE
;
f
.
bytes
=
sizeof
(
int32_t
);
f
.
bytes
=
sizeof
(
int32_t
);
f
.
type
=
TSDB_DATA_TYPE_INT
;
f
.
type
=
TSDB_DATA_TYPE_INT
;
tstrncpy
(
f
.
name
,
"Length"
,
sizeof
(
f
.
name
));
tstrncpy
(
f
.
name
,
"Length"
,
sizeof
(
f
.
name
));
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
),
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
),
-
1000
,
sizeof
(
int32_t
),
false
);
-
1000
,
sizeof
(
int32_t
),
false
);
rowLen
+=
sizeof
(
int32_t
);
rowLen
+=
sizeof
(
int32_t
);
f
.
bytes
=
(
int16_t
)(
noteColLength
+
VARSTR_HEADER_SIZE
);
f
.
bytes
=
(
int16_t
)(
noteColLength
+
VARSTR_HEADER_SIZE
);
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
tstrncpy
(
f
.
name
,
"Note"
,
sizeof
(
f
.
name
));
tstrncpy
(
f
.
name
,
"Note"
,
sizeof
(
f
.
name
));
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
(
int16_t
)(
noteColLength
+
VARSTR_HEADER_SIZE
),
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
(
int16_t
)(
noteColLength
+
VARSTR_HEADER_SIZE
),
-
1000
,
noteColLength
,
false
);
-
1000
,
noteColLength
,
false
);
rowLen
+=
noteColLength
+
VARSTR_HEADER_SIZE
;
rowLen
+=
noteColLength
+
VARSTR_HEADER_SIZE
;
return
rowLen
;
return
rowLen
;
}
}
static
int32_t
tscProcessDescribeTable
(
SSqlObj
*
pSql
)
{
static
int32_t
tscProcessDescribeTable
(
SSqlObj
*
pSql
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
assert
(
tscGetMetaInfo
(
pQueryInfo
,
0
)
->
pTableMeta
!=
NULL
);
assert
(
tscGetMetaInfo
(
pQueryInfo
,
0
)
->
pTableMeta
!=
NULL
);
const
int32_t
NUM_OF_DESC_TABLE_COLUMNS
=
4
;
const
int32_t
NUM_OF_DESC_TABLE_COLUMNS
=
4
;
...
@@ -220,25 +220,25 @@ static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengt
...
@@ -220,25 +220,25 @@ static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengt
if
(
val
==
NULL
)
{
if
(
val
==
NULL
)
{
sprintf
(
result
,
"%s"
,
TSDB_DATA_NULL_STR
);
sprintf
(
result
,
"%s"
,
TSDB_DATA_NULL_STR
);
return
-
1
;
return
-
1
;
}
}
uint8_t
type
=
fields
[
idx
].
type
;
uint8_t
type
=
fields
[
idx
].
type
;
int32_t
length
=
lengths
[
idx
];
int32_t
length
=
lengths
[
idx
];
switch
(
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
sprintf
(
result
,
"%s"
,
((((
int32_t
)(
*
((
char
*
)
val
)))
==
1
)
?
"true"
:
"false"
));
sprintf
(
result
,
"%s"
,
((((
int32_t
)(
*
((
char
*
)
val
)))
==
1
)
?
"true"
:
"false"
));
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
sprintf
(
result
,
"%d"
,
*
((
int8_t
*
)
val
));
sprintf
(
result
,
"%d"
,
*
((
int8_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
sprintf
(
result
,
"%d"
,
*
((
int16_t
*
)
val
));
sprintf
(
result
,
"%d"
,
*
((
int16_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
sprintf
(
result
,
"%d"
,
*
((
int32_t
*
)
val
));
sprintf
(
result
,
"%d"
,
*
((
int32_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
sprintf
(
result
,
"%"
PRId64
,
*
((
int64_t
*
)
val
));
sprintf
(
result
,
"%"
PRId64
,
*
((
int64_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
sprintf
(
result
,
"%u"
,
*
((
uint8_t
*
)
val
));
sprintf
(
result
,
"%u"
,
*
((
uint8_t
*
)
val
));
...
@@ -253,57 +253,57 @@ static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengt
...
@@ -253,57 +253,57 @@ static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengt
sprintf
(
result
,
"%"
PRIu64
,
*
((
uint64_t
*
)
val
));
sprintf
(
result
,
"%"
PRIu64
,
*
((
uint64_t
*
)
val
));
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
sprintf
(
result
,
"%f"
,
GET_FLOAT_VAL
(
val
));
sprintf
(
result
,
"%f"
,
GET_FLOAT_VAL
(
val
));
break
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_DOUBLE
:
sprintf
(
result
,
"%f"
,
GET_DOUBLE_VAL
(
val
));
sprintf
(
result
,
"%f"
,
GET_DOUBLE_VAL
(
val
));
break
;
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_JSON
:
memcpy
(
result
,
val
,
length
);
memcpy
(
result
,
val
,
length
);
break
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
///formatTimestamp(buf, *(int64_t*)val, TSDB_TIME_PRECISION_MICRO);
///formatTimestamp(buf, *(int64_t*)val, TSDB_TIME_PRECISION_MICRO);
//memcpy(result, val, strlen(buf));
//memcpy(result, val, strlen(buf));
sprintf
(
result
,
"%"
PRId64
,
*
((
int64_t
*
)
val
));
sprintf
(
result
,
"%"
PRId64
,
*
((
int64_t
*
)
val
));
break
;
break
;
default:
default:
break
;
break
;
}
}
return
0
;
return
0
;
}
}
void
tscSCreateCallBack
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
void
tscSCreateCallBack
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
if
(
param
==
NULL
||
tres
==
NULL
)
{
if
(
param
==
NULL
||
tres
==
NULL
)
{
return
;
return
;
}
}
SCreateBuilder
*
builder
=
(
SCreateBuilder
*
)(
param
);
SCreateBuilder
*
builder
=
(
SCreateBuilder
*
)(
param
);
SSqlObj
*
pParentSql
=
builder
->
pParentSql
;
SSqlObj
*
pParentSql
=
builder
->
pParentSql
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
SSqlRes
*
pRes
=
&
pParentSql
->
res
;
SSqlRes
*
pRes
=
&
pParentSql
->
res
;
pRes
->
code
=
taos_errno
(
pSql
);
pRes
->
code
=
taos_errno
(
pSql
);
if
(
pRes
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRes
->
code
!=
TSDB_CODE_SUCCESS
)
{
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
free
(
builder
);
free
(
builder
);
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
return
;
return
;
}
}
if
(
builder
->
callStage
==
SCREATE_CALLBACK_QUERY
)
{
if
(
builder
->
callStage
==
SCREATE_CALLBACK_QUERY
)
{
taos_fetch_rows_a
(
tres
,
tscSCreateCallBack
,
param
);
taos_fetch_rows_a
(
tres
,
tscSCreateCallBack
,
param
);
builder
->
callStage
=
SCREATE_CALLBACK_RETRIEVE
;
builder
->
callStage
=
SCREATE_CALLBACK_RETRIEVE
;
}
else
{
}
else
{
char
*
result
=
calloc
(
1
,
TSDB_MAX_BINARY_LEN
);
char
*
result
=
calloc
(
1
,
TSDB_MAX_BINARY_LEN
);
pRes
->
code
=
builder
->
fp
(
builder
,
result
);
pRes
->
code
=
builder
->
fp
(
builder
,
result
);
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
free
(
builder
);
free
(
builder
);
free
(
result
);
free
(
result
);
if
(
pRes
->
code
==
TSDB_CODE_SUCCESS
)
{
if
(
pRes
->
code
==
TSDB_CODE_SUCCESS
)
{
(
*
pParentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
code
);
(
*
pParentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
code
);
}
else
{
}
else
{
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
}
}
...
@@ -314,16 +314,16 @@ TAOS_ROW tscFetchRow(void *param) {
...
@@ -314,16 +314,16 @@ TAOS_ROW tscFetchRow(void *param) {
SCreateBuilder
*
builder
=
(
SCreateBuilder
*
)
param
;
SCreateBuilder
*
builder
=
(
SCreateBuilder
*
)
param
;
if
(
builder
==
NULL
)
{
if
(
builder
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
SSqlObj
*
pSql
=
builder
->
pInterSql
;
SSqlObj
*
pSql
=
builder
->
pInterSql
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
return
NULL
;
}
}
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
pRes
->
qId
==
0
||
if
(
pRes
->
qId
==
0
||
pCmd
->
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
pCmd
->
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
pCmd
->
command
==
TSDB_SQL_INSERT
)
{
pCmd
->
command
==
TSDB_SQL_INSERT
)
{
...
@@ -367,7 +367,7 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
...
@@ -367,7 +367,7 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
return
TSDB_CODE_TSC_INVALID_TABLE_NAME
;
return
TSDB_CODE_TSC_INVALID_TABLE_NAME
;
}
}
int32_t
*
lengths
=
taos_fetch_lengths
(
pSql
);
int32_t
*
lengths
=
taos_fetch_lengths
(
pSql
);
int
num_fields
=
taos_num_fields
(
pSql
);
int
num_fields
=
taos_num_fields
(
pSql
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
pSql
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
pSql
);
...
@@ -382,10 +382,10 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
...
@@ -382,10 +382,10 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
if
(
i
==
0
)
{
if
(
i
==
0
)
{
snprintf
(
result
+
strlen
(
result
),
TSDB_MAX_BINARY_LEN
-
strlen
(
result
),
"%s"
,
"("
);
snprintf
(
result
+
strlen
(
result
),
TSDB_MAX_BINARY_LEN
-
strlen
(
result
),
"%s"
,
"("
);
}
}
if
((
fields
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
||
fields
[
i
].
type
==
TSDB_DATA_TYPE_BINARY
||
if
((
fields
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
fields
[
i
].
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
&&
||
fields
[
i
].
type
==
TSDB_DATA_TYPE_BINARY
0
==
ret
)
{
||
fields
[
i
].
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
&&
0
==
ret
)
{
snprintf
(
result
+
strlen
(
result
),
TSDB_MAX_BINARY_LEN
-
strlen
(
result
),
"
\"
%s
\"
,"
,
buf
);
snprintf
(
result
+
strlen
(
result
),
TSDB_MAX_BINARY_LEN
-
strlen
(
result
),
"
\"
%s
\"
,"
,
buf
);
}
else
if
(
fields
[
i
].
type
==
TSDB_DATA_TYPE_JSON
)
{
}
else
if
(
fields
[
i
].
type
==
TSDB_DATA_TYPE_JSON
)
{
snprintf
(
result
+
strlen
(
result
),
TSDB_MAX_BINARY_LEN
-
strlen
(
result
),
"'%s,"
,
buf
);
snprintf
(
result
+
strlen
(
result
),
TSDB_MAX_BINARY_LEN
-
strlen
(
result
),
"'%s,"
,
buf
);
...
@@ -410,17 +410,18 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
...
@@ -410,17 +410,18 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
// build 'show create table/database' result fields
// build 'show create table/database' result fields
static
int32_t
tscSCreateBuildResultFields
(
SSqlObj
*
pSql
,
BuildType
type
,
const
char
*
ddl
)
{
static
int32_t
tscSCreateBuildResultFields
(
SSqlObj
*
pSql
,
BuildType
type
,
const
char
*
ddl
)
{
int32_t
rowLen
=
0
;
int32_t
rowLen
=
0
;
int16_t
ddlLen
=
(
int16_t
)
strlen
(
ddl
);
int16_t
ddlLen
=
(
int16_t
)
strlen
(
ddl
);
SColumnIndex
index
=
{
0
};
SColumnIndex
index
=
{
0
};
pSql
->
cmd
.
numOfCols
=
2
;
pSql
->
cmd
.
numOfCols
=
2
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
pQueryInfo
->
order
.
order
=
TSDB_ORDER_ASC
;
pQueryInfo
->
order
.
order
=
TSDB_ORDER_ASC
;
TAOS_FIELD
f
;
TAOS_FIELD
f
;
if
(
type
==
SCREATE_BUILD_TABLE
)
{
if
(
type
==
SCREATE_BUILD_TABLE
)
{
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
f
.
bytes
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
f
.
bytes
=
(
TSDB_TABLE_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
...
@@ -429,12 +430,12 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
...
@@ -429,12 +430,12 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
f
.
bytes
=
(
TSDB_DB_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
f
.
bytes
=
(
TSDB_DB_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
;
tstrncpy
(
f
.
name
,
"Database"
,
sizeof
(
f
.
name
));
tstrncpy
(
f
.
name
,
"Database"
,
sizeof
(
f
.
name
));
}
}
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
SInternalField
*
pInfo
=
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
f
.
bytes
,
-
1000
,
f
.
bytes
-
VARSTR_HEADER_SIZE
,
false
);
pInfo
->
pExpr
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TS_DUMMY
,
&
index
,
TSDB_DATA_TYPE_BINARY
,
f
.
bytes
,
-
1000
,
f
.
bytes
-
VARSTR_HEADER_SIZE
,
false
);
rowLen
+=
f
.
bytes
;
rowLen
+=
f
.
bytes
;
f
.
bytes
=
(
int16_t
)(
ddlLen
+
VARSTR_HEADER_SIZE
);
f
.
bytes
=
(
int16_t
)(
ddlLen
+
VARSTR_HEADER_SIZE
);
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
f
.
type
=
TSDB_DATA_TYPE_BINARY
;
...
@@ -639,7 +640,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
...
@@ -639,7 +640,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
param
->
fp
=
tscRebuildCreateTableStatement
;
param
->
fp
=
tscRebuildCreateTableStatement
;
param
->
callStage
=
SCREATE_CALLBACK_QUERY
;
param
->
callStage
=
SCREATE_CALLBACK_QUERY
;
char
*
query
=
(
char
*
)
calloc
(
1
,
TSDB_MAX_BINARY_LEN
);
char
*
query
=
(
char
*
)
calloc
(
1
,
TSDB_MAX_BINARY_LEN
);
if
(
query
==
NULL
)
{
if
(
query
==
NULL
)
{
free
(
param
);
free
(
param
);
free
(
pInterSql
);
free
(
pInterSql
);
...
@@ -649,7 +650,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
...
@@ -649,7 +650,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
char
*
columns
=
NULL
;
char
*
columns
=
NULL
;
int32_t
code
=
tscGetTableTagColumnName
(
pSql
,
&
columns
)
;
int32_t
code
=
tscGetTableTagColumnName
(
pSql
,
&
columns
)
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
free
(
param
);
free
(
param
);
free
(
pInterSql
);
free
(
pInterSql
);
free
(
query
);
free
(
query
);
return
code
;
return
code
;
...
@@ -660,7 +661,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
...
@@ -660,7 +661,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
free
(
query
);
free
(
query
);
free
(
columns
);
free
(
columns
);
return
TSDB_CODE_TSC_ACTION_IN_PROGRESS
;
return
TSDB_CODE_TSC_ACTION_IN_PROGRESS
;
}
}
static
int32_t
tscRebuildDDLForNormalTable
(
SSqlObj
*
pSql
,
const
char
*
tableName
,
char
*
ddl
)
{
static
int32_t
tscRebuildDDLForNormalTable
(
SSqlObj
*
pSql
,
const
char
*
tableName
,
char
*
ddl
)
{
...
@@ -755,7 +756,7 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) {
...
@@ -755,7 +756,7 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
tscSCreateBuildResult
(
pSql
,
SCREATE_BUILD_TABLE
,
tableName
,
result
);
code
=
tscSCreateBuildResult
(
pSql
,
SCREATE_BUILD_TABLE
,
tableName
,
result
);
}
}
free
(
result
);
free
(
result
);
return
code
;
return
code
;
}
}
...
@@ -765,12 +766,12 @@ static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) {
...
@@ -765,12 +766,12 @@ static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
SSqlObj
*
pInterSql
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
SSqlObj
*
pInterSql
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
pInterSql
==
NULL
)
{
if
(
pInterSql
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
SCreateBuilder
*
param
=
(
SCreateBuilder
*
)
calloc
(
1
,
sizeof
(
SCreateBuilder
));
SCreateBuilder
*
param
=
(
SCreateBuilder
*
)
calloc
(
1
,
sizeof
(
SCreateBuilder
));
if
(
param
==
NULL
)
{
if
(
param
==
NULL
)
{
free
(
pInterSql
);
free
(
pInterSql
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
@@ -781,7 +782,7 @@ static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) {
...
@@ -781,7 +782,7 @@ static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) {
param
->
pInterSql
=
pInterSql
;
param
->
pInterSql
=
pInterSql
;
param
->
fp
=
tscRebuildCreateDBStatement
;
param
->
fp
=
tscRebuildCreateDBStatement
;
param
->
callStage
=
SCREATE_CALLBACK_QUERY
;
param
->
callStage
=
SCREATE_CALLBACK_QUERY
;
const
char
*
query
=
"show databases"
;
const
char
*
query
=
"show databases"
;
doAsyncQuery
(
pSql
->
pTscObj
,
pInterSql
,
tscSCreateCallBack
,
param
,
query
,
strlen
(
query
));
doAsyncQuery
(
pSql
->
pTscObj
,
pInterSql
,
tscSCreateCallBack
,
param
,
query
,
strlen
(
query
));
return
TSDB_CODE_TSC_ACTION_IN_PROGRESS
;
return
TSDB_CODE_TSC_ACTION_IN_PROGRESS
;
...
@@ -960,8 +961,8 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
...
@@ -960,8 +961,8 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
if
(
taosCfgDynamicOptions
(
pCmd
->
payload
))
{
if
(
taosCfgDynamicOptions
(
pCmd
->
payload
))
{
pRes
->
code
=
TSDB_CODE_SUCCESS
;
pRes
->
code
=
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
pRes
->
code
=
TSDB_CODE_COM_INVALID_CFG_MSG
;
pRes
->
code
=
TSDB_CODE_COM_INVALID_CFG_MSG
;
}
}
pRes
->
numOfRows
=
0
;
pRes
->
numOfRows
=
0
;
}
else
if
(
pCmd
->
command
==
TSDB_SQL_DESCRIBE_TABLE
)
{
}
else
if
(
pCmd
->
command
==
TSDB_SQL_DESCRIBE_TABLE
)
{
pRes
->
code
=
(
uint8_t
)
tscProcessDescribeTable
(
pSql
);
pRes
->
code
=
(
uint8_t
)
tscProcessDescribeTable
(
pSql
);
...
@@ -973,9 +974,9 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
...
@@ -973,9 +974,9 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
pRes
->
qId
=
0x1
;
pRes
->
qId
=
0x1
;
pRes
->
numOfRows
=
0
;
pRes
->
numOfRows
=
0
;
}
else
if
(
pCmd
->
command
==
TSDB_SQL_SHOW_CREATE_TABLE
||
pCmd
->
command
==
TSDB_SQL_SHOW_CREATE_STABLE
)
{
}
else
if
(
pCmd
->
command
==
TSDB_SQL_SHOW_CREATE_TABLE
||
pCmd
->
command
==
TSDB_SQL_SHOW_CREATE_STABLE
)
{
pRes
->
code
=
tscProcessShowCreateTable
(
pSql
);
pRes
->
code
=
tscProcessShowCreateTable
(
pSql
);
}
else
if
(
pCmd
->
command
==
TSDB_SQL_SHOW_CREATE_DATABASE
)
{
}
else
if
(
pCmd
->
command
==
TSDB_SQL_SHOW_CREATE_DATABASE
)
{
pRes
->
code
=
tscProcessShowCreateDatabase
(
pSql
);
pRes
->
code
=
tscProcessShowCreateDatabase
(
pSql
);
}
else
if
(
pCmd
->
command
==
TSDB_SQL_RESET_CACHE
)
{
}
else
if
(
pCmd
->
command
==
TSDB_SQL_RESET_CACHE
)
{
taosHashClear
(
UTIL_GET_TABLEMETA
(
pSql
));
taosHashClear
(
UTIL_GET_TABLEMETA
(
pSql
));
taosCacheEmpty
(
UTIL_GET_VGROUPLIST
(
pSql
));
taosCacheEmpty
(
UTIL_GET_VGROUPLIST
(
pSql
));
...
...
src/client/src/tscSQLParser.c
浏览文件 @
bf041f21
...
@@ -1081,7 +1081,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -1081,7 +1081,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
// async load table meta
return
code
;
// async load table meta
}
}
// vgroupInfo if super
// vgroupInfo if super
if
(
code
==
0
&&
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
code
==
0
&&
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
code
=
tscGetSTableVgroupInfo
(
pSql
,
pQueryInfo
);
code
=
tscGetSTableVgroupInfo
(
pSql
,
pQueryInfo
);
...
@@ -1117,7 +1117,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -1117,7 +1117,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
*/
*/
static
bool
isTopBottomUniqueQuery
(
SQueryInfo
*
pQueryInfo
)
{
static
bool
isTopBottomUniqueQuery
(
SQueryInfo
*
pQueryInfo
)
{
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
int32_t
functionId
=
tscExprGet
(
pQueryInfo
,
i
)
->
base
.
functionId
;
int32_t
functionId
=
tscExprGet
(
pQueryInfo
,
i
)
->
base
.
functionId
;
...
@@ -1228,7 +1228,7 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS
...
@@ -1228,7 +1228,7 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS
if
(
interpQuery
)
{
if
(
interpQuery
)
{
return
addPrimaryTsColumnForTimeWindowQuery
(
pQueryInfo
,
pCmd
);
return
addPrimaryTsColumnForTimeWindowQuery
(
pQueryInfo
,
pCmd
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1344,7 +1344,7 @@ static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
...
@@ -1344,7 +1344,7 @@ static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
}
}
}
tscColumnListInsert
(
pQueryInfo
->
colList
,
index
.
columnIndex
,
pTableMeta
->
id
.
uid
,
pSchema
);
tscColumnListInsert
(
pQueryInfo
->
colList
,
index
.
columnIndex
,
pTableMeta
->
id
.
uid
,
pSchema
);
SColIndex
colIndex
=
{
.
colIndex
=
index
.
columnIndex
,
.
flag
=
TSDB_COL_NORMAL
,
.
colId
=
pSchema
->
colId
};
SColIndex
colIndex
=
{
.
colIndex
=
index
.
columnIndex
,
.
flag
=
TSDB_COL_NORMAL
,
.
colId
=
pSchema
->
colId
};
taosArrayPush
(
pGroupExpr
->
columnInfo
,
&
colIndex
);
taosArrayPush
(
pGroupExpr
->
columnInfo
,
&
colIndex
);
...
@@ -1515,11 +1515,11 @@ int32_t tscSetTableFullName(SName* pName, SStrToken* pTableName, SSqlObj* pSql,
...
@@ -1515,11 +1515,11 @@ int32_t tscSetTableFullName(SName* pName, SStrToken* pTableName, SSqlObj* pSql,
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
idx
=
-
1
;
int32_t
idx
=
-
1
;
if
(
dbIncluded
)
{
if
(
dbIncluded
)
{
idx
=
getDelimiterIndex
(
pTableName
);
idx
=
getDelimiterIndex
(
pTableName
);
}
}
if
(
idx
!=
-
1
)
{
// db has been specified in sql string so we ignore current db path
if
(
idx
!=
-
1
)
{
// db has been specified in sql string so we ignore current db path
char
*
acctId
=
getAccountId
(
pSql
);
char
*
acctId
=
getAccountId
(
pSql
);
if
(
acctId
==
NULL
||
strlen
(
acctId
)
<=
0
)
{
if
(
acctId
==
NULL
||
strlen
(
acctId
)
<=
0
)
{
...
@@ -1822,10 +1822,10 @@ int32_t validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
...
@@ -1822,10 +1822,10 @@ int32_t validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
// assert(pCmd->numOfClause == 1);
// assert(pCmd->numOfClause == 1);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
0
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
int32_t
numOfTags
=
tscGetNumOfTags
(
pTableMeta
);
int32_t
numOfTags
=
tscGetNumOfTags
(
pTableMeta
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
);
// no more max columns
// no more max columns
if
(
numOfCols
>=
TSDB_MAX_COLUMNS
||
numOfTags
+
numOfCols
>=
TSDB_MAX_COLUMNS
)
{
if
(
numOfCols
>=
TSDB_MAX_COLUMNS
||
numOfTags
+
numOfCols
>=
TSDB_MAX_COLUMNS
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
...
@@ -2242,7 +2242,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS
...
@@ -2242,7 +2242,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS
const
char
*
msg3
=
"not support query expression"
;
const
char
*
msg3
=
"not support query expression"
;
const
char
*
msg4
=
"not support distinct mixed with proj/agg func"
;
const
char
*
msg4
=
"not support distinct mixed with proj/agg func"
;
const
char
*
msg5
=
"invalid function name"
;
const
char
*
msg5
=
"invalid function name"
;
const
char
*
msg6
=
"not support distinct mixed with join"
;
const
char
*
msg6
=
"not support distinct mixed with join"
;
const
char
*
msg7
=
"not support distinct mixed with groupby"
;
const
char
*
msg7
=
"not support distinct mixed with groupby"
;
const
char
*
msg8
=
"not support distinct in nest query"
;
const
char
*
msg8
=
"not support distinct in nest query"
;
const
char
*
msg9
=
"_block_dist not support subquery, only support stable/table"
;
const
char
*
msg9
=
"_block_dist not support subquery, only support stable/table"
;
...
@@ -2379,11 +2379,11 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi
...
@@ -2379,11 +2379,11 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
tscColumnListInsert
(
pQueryInfo
->
colList
,
pColList
->
ids
[
i
].
columnIndex
,
uid
,
&
pSchema
[
pColList
->
ids
[
i
].
columnIndex
]);
tscColumnListInsert
(
pQueryInfo
->
colList
,
pColList
->
ids
[
i
].
columnIndex
,
uid
,
&
pSchema
[
pColList
->
ids
[
i
].
columnIndex
]);
}
}
TAOS_FIELD
f
=
tscCreateField
(
type
,
fieldName
,
bytes
);
TAOS_FIELD
f
=
tscCreateField
(
type
,
fieldName
,
bytes
);
SInternalField
*
pInfo
=
tscFieldInfoInsert
(
&
pQueryInfo
->
fieldsInfo
,
outputIndex
,
&
f
);
SInternalField
*
pInfo
=
tscFieldInfoInsert
(
&
pQueryInfo
->
fieldsInfo
,
outputIndex
,
&
f
);
pInfo
->
pExpr
=
pSqlExpr
;
pInfo
->
pExpr
=
pSqlExpr
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2391,12 +2391,12 @@ SExprInfo* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t colIndex, int32_t tab
...
@@ -2391,12 +2391,12 @@ SExprInfo* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t colIndex, int32_t tab
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMeta
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
colIndex
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
colIndex
);
int16_t
functionId
=
(
int16_t
)((
colIndex
>=
numOfCols
)
?
TSDB_FUNC_TAGPRJ
:
TSDB_FUNC_PRJ
);
int16_t
functionId
=
(
int16_t
)((
colIndex
>=
numOfCols
)
?
TSDB_FUNC_TAGPRJ
:
TSDB_FUNC_PRJ
);
SColumnIndex
index
=
{.
tableIndex
=
tableIndex
,};
SColumnIndex
index
=
{.
tableIndex
=
tableIndex
,};
if
(
functionId
==
TSDB_FUNC_TAGPRJ
)
{
if
(
functionId
==
TSDB_FUNC_TAGPRJ
)
{
index
.
columnIndex
=
colIndex
-
tscGetNumOfColumns
(
pTableMeta
);
index
.
columnIndex
=
colIndex
-
tscGetNumOfColumns
(
pTableMeta
);
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
index
.
columnIndex
,
pTableMeta
->
id
.
uid
,
pSchema
);
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
index
.
columnIndex
,
pTableMeta
->
id
.
uid
,
pSchema
);
...
@@ -2424,7 +2424,7 @@ SExprInfo* tscAddFuncInSelectClause(SQueryInfo* pQueryInfo, int32_t outputColInd
...
@@ -2424,7 +2424,7 @@ SExprInfo* tscAddFuncInSelectClause(SQueryInfo* pQueryInfo, int32_t outputColInd
pExpr
->
base
.
colInfo
.
flag
=
flag
;
pExpr
->
base
.
colInfo
.
flag
=
flag
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
if
(
TSDB_COL_IS_TAG
(
flag
))
{
if
(
TSDB_COL_IS_TAG
(
flag
))
{
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
pIndex
->
columnIndex
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
,
pColSchema
);
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
pIndex
->
columnIndex
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
,
pColSchema
);
}
}
...
@@ -2440,7 +2440,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
...
@@ -2440,7 +2440,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMeta
);
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
numOfTotalColumns
=
tinfo
.
numOfColumns
+
tinfo
.
numOfTags
;
numOfTotalColumns
=
tinfo
.
numOfColumns
+
tinfo
.
numOfTags
;
}
else
{
}
else
{
...
@@ -2670,7 +2670,7 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
...
@@ -2670,7 +2670,7 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
pExpr
->
base
.
param
[
0
].
i64
=
TSDB_ORDER_DESC
;
pExpr
->
base
.
param
[
0
].
i64
=
TSDB_ORDER_DESC
;
pExpr
->
base
.
param
[
0
].
nType
=
TSDB_DATA_TYPE_INT
;
pExpr
->
base
.
param
[
0
].
nType
=
TSDB_DATA_TYPE_INT
;
}
}
// for all queries, the timestamp column needs to be loaded
// for all queries, the timestamp column needs to be loaded
SSchema
s
=
{.
colId
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
,
.
bytes
=
TSDB_KEYSIZE
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
,};
SSchema
s
=
{.
colId
=
PRIMARYKEY_TIMESTAMP_COL_INDEX
,
.
bytes
=
TSDB_KEYSIZE
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
,};
tscColumnListInsert
(
pQueryInfo
->
colList
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
,
pExpr
->
base
.
uid
,
&
s
);
tscColumnListInsert
(
pQueryInfo
->
colList
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
,
pExpr
->
base
.
uid
,
&
s
);
...
@@ -3945,7 +3945,7 @@ static int16_t doGetColumnIndex(SQueryInfo* pQueryInfo, int32_t index, SStrToken
...
@@ -3945,7 +3945,7 @@ static int16_t doGetColumnIndex(SQueryInfo* pQueryInfo, int32_t index, SStrToken
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// create tmp buf to avoid alter orginal sqlstr
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// create tmp buf to avoid alter orginal sqlstr
strncpy
(
tmpTokenBuf
,
pToken
->
z
,
pToken
->
n
);
strncpy
(
tmpTokenBuf
,
pToken
->
z
,
pToken
->
n
);
pToken
->
z
=
tmpTokenBuf
;
pToken
->
z
=
tmpTokenBuf
;
pToken
->
n
=
stringProcess
(
pToken
->
z
,
pToken
->
n
);
pToken
->
n
=
stringProcess
(
pToken
->
z
,
pToken
->
n
);
...
@@ -4136,7 +4136,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -4136,7 +4136,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
pShowInfo
->
prefix
.
n
<=
0
)
{
if
(
pShowInfo
->
prefix
.
n
<=
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -4147,7 +4147,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) {
...
@@ -4147,7 +4147,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) {
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
command
=
pInfo
->
type
;
pCmd
->
command
=
pInfo
->
type
;
SStrToken
*
idStr
=
&
(
pInfo
->
pMiscInfo
->
id
);
SStrToken
*
idStr
=
&
(
pInfo
->
pMiscInfo
->
id
);
if
(
idStr
->
n
>
TSDB_KILL_MSG_LEN
)
{
if
(
idStr
->
n
>
TSDB_KILL_MSG_LEN
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
return
TSDB_CODE_TSC_INVALID_OPERATION
;
...
@@ -4180,7 +4180,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) {
...
@@ -4180,7 +4180,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) {
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
setCompactVnodeInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
static
int32_t
setCompactVnodeInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
...
@@ -4202,7 +4202,7 @@ int32_t tscTansformFuncForSTableQuery(SQueryInfo* pQueryInfo) {
...
@@ -4202,7 +4202,7 @@ int32_t tscTansformFuncForSTableQuery(SQueryInfo* pQueryInfo) {
int32_t
bytes
=
0
;
int32_t
bytes
=
0
;
int16_t
type
=
0
;
int16_t
type
=
0
;
int32_t
interBytes
=
0
;
int32_t
interBytes
=
0
;
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
k
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
k
);
...
@@ -4214,7 +4214,7 @@ int32_t tscTansformFuncForSTableQuery(SQueryInfo* pQueryInfo) {
...
@@ -4214,7 +4214,7 @@ int32_t tscTansformFuncForSTableQuery(SQueryInfo* pQueryInfo) {
int32_t
colIndex
=
pExpr
->
base
.
colInfo
.
colIndex
;
int32_t
colIndex
=
pExpr
->
base
.
colInfo
.
colIndex
;
SSchema
*
pSrcSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
colIndex
);
SSchema
*
pSrcSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
colIndex
);
if
((
functionId
>=
TSDB_FUNC_SUM
&&
functionId
<=
TSDB_FUNC_TWA
)
||
if
((
functionId
>=
TSDB_FUNC_SUM
&&
functionId
<=
TSDB_FUNC_TWA
)
||
(
functionId
>=
TSDB_FUNC_FIRST_DST
&&
functionId
<=
TSDB_FUNC_STDDEV_DST
)
||
(
functionId
>=
TSDB_FUNC_FIRST_DST
&&
functionId
<=
TSDB_FUNC_STDDEV_DST
)
||
(
functionId
>=
TSDB_FUNC_RATE
&&
functionId
<=
TSDB_FUNC_IRATE
)
||
(
functionId
>=
TSDB_FUNC_RATE
&&
functionId
<=
TSDB_FUNC_IRATE
)
||
...
@@ -4246,16 +4246,16 @@ void tscRestoreFuncForSTableQuery(SQueryInfo* pQueryInfo) {
...
@@ -4246,16 +4246,16 @@ void tscRestoreFuncForSTableQuery(SQueryInfo* pQueryInfo) {
if
(
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
return
;
return
;
}
}
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
pExpr
->
base
.
colInfo
.
colIndex
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
pExpr
->
base
.
colInfo
.
colIndex
);
// the final result size and type in the same as query on single table.
// the final result size and type in the same as query on single table.
// so here, set the flag to be false;
// so here, set the flag to be false;
int32_t
inter
=
0
;
int32_t
inter
=
0
;
int32_t
functionId
=
pExpr
->
base
.
functionId
;
int32_t
functionId
=
pExpr
->
base
.
functionId
;
if
(
functionId
<
0
)
{
if
(
functionId
<
0
)
{
continue
;
continue
;
...
@@ -4264,7 +4264,7 @@ void tscRestoreFuncForSTableQuery(SQueryInfo* pQueryInfo) {
...
@@ -4264,7 +4264,7 @@ void tscRestoreFuncForSTableQuery(SQueryInfo* pQueryInfo) {
if
(
functionId
>=
TSDB_FUNC_TS
&&
functionId
<=
TSDB_FUNC_DIFF
)
{
if
(
functionId
>=
TSDB_FUNC_TS
&&
functionId
<=
TSDB_FUNC_DIFF
)
{
continue
;
continue
;
}
}
if
(
functionId
==
TSDB_FUNC_FIRST_DST
)
{
if
(
functionId
==
TSDB_FUNC_FIRST_DST
)
{
functionId
=
TSDB_FUNC_FIRST
;
functionId
=
TSDB_FUNC_FIRST
;
}
else
if
(
functionId
==
TSDB_FUNC_LAST_DST
)
{
}
else
if
(
functionId
==
TSDB_FUNC_LAST_DST
)
{
...
@@ -4319,7 +4319,7 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo)
...
@@ -4319,7 +4319,7 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo)
return
true
;
return
true
;
}
}
}
}
if
(
tscIsSessionWindowQuery
(
pQueryInfo
))
{
if
(
tscIsSessionWindowQuery
(
pQueryInfo
))
{
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
true
;
return
true
;
...
@@ -4668,7 +4668,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
...
@@ -4668,7 +4668,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
}
}
if
(
pExpr
->
tokenId
==
TK_IN
)
{
if
(
pExpr
->
tokenId
==
TK_IN
)
{
tVariant
*
pVal
;
tVariant
*
pVal
;
if
(
pRight
->
tokenId
!=
TK_SET
||
!
serializeExprListToVariant
(
pRight
->
Expr
.
paramList
,
&
pVal
,
colType
,
timePrecision
))
{
if
(
pRight
->
tokenId
!=
TK_SET
||
!
serializeExprListToVariant
(
pRight
->
Expr
.
paramList
,
&
pVal
,
colType
,
timePrecision
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
}
...
@@ -4703,7 +4703,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
...
@@ -4703,7 +4703,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
if
(
retVal
!=
TSDB_CODE_SUCCESS
)
{
if
(
retVal
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
}
switch
(
pExpr
->
tokenId
)
{
switch
(
pExpr
->
tokenId
)
{
case
TK_LE
:
case
TK_LE
:
...
@@ -4768,7 +4768,7 @@ enum {
...
@@ -4768,7 +4768,7 @@ enum {
TSQL_EXPR_TAG
=
2
,
TSQL_EXPR_TAG
=
2
,
TSQL_EXPR_COLUMN
=
4
,
TSQL_EXPR_COLUMN
=
4
,
TSQL_EXPR_TBNAME
=
8
,
TSQL_EXPR_TBNAME
=
8
,
TSQL_EXPR_JOIN
=
16
,
TSQL_EXPR_JOIN
=
16
,
};
};
#define GET_MIXED_TYPE(t) (((t) >= TSQL_EXPR_JOIN) || ((t) > TSQL_EXPR_COLUMN && (t) < TSQL_EXPR_TBNAME) || ((t) == (TSQL_EXPR_TS|TSQL_EXPR_TAG)))
#define GET_MIXED_TYPE(t) (((t) >= TSQL_EXPR_JOIN) || ((t) > TSQL_EXPR_COLUMN && (t) < TSQL_EXPR_TBNAME) || ((t) == (TSQL_EXPR_TS|TSQL_EXPR_TAG)))
...
@@ -4800,7 +4800,7 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol
...
@@ -4800,7 +4800,7 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol
ret
=
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
ret
=
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
goto
_err_ret
;
goto
_err_ret
;
}
}
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_BOOL
)
{
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_BOOL
)
{
int32_t
t
=
pExpr
->
tokenId
;
int32_t
t
=
pExpr
->
tokenId
;
if
(
t
!=
TK_EQ
&&
t
!=
TK_NE
&&
t
!=
TK_NOTNULL
&&
t
!=
TK_ISNULL
&&
t
!=
TK_IN
)
{
if
(
t
!=
TK_EQ
&&
t
!=
TK_NE
&&
t
!=
TK_NOTNULL
&&
t
!=
TK_ISNULL
&&
t
!=
TK_IN
)
{
...
@@ -4820,7 +4820,7 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol
...
@@ -4820,7 +4820,7 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol
_err_ret:
_err_ret:
freeColumnFilterInfo
(
pColFilter
,
1
);
freeColumnFilterInfo
(
pColFilter
,
1
);
return
ret
;
return
ret
;
}
}
...
@@ -4850,7 +4850,7 @@ static int32_t addAllColumn(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pEx
...
@@ -4850,7 +4850,7 @@ static int32_t addAllColumn(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pEx
static
int32_t
getColQueryCondExpr
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
tSqlExpr
**
pExpr
)
{
static
int32_t
getColQueryCondExpr
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
tSqlExpr
**
pExpr
)
{
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
const
char
*
msg6
=
"illegal condition expression"
;
const
char
*
msg6
=
"illegal condition expression"
;
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
tSqlExpr
*
p1
=
extractExprForSTable
(
pCmd
,
pExpr
,
pQueryInfo
,
i
);
tSqlExpr
*
p1
=
extractExprForSTable
(
pCmd
,
pExpr
,
pQueryInfo
,
i
);
if
(
p1
==
NULL
)
{
// no query condition on this table
if
(
p1
==
NULL
)
{
// no query condition on this table
...
@@ -4859,7 +4859,7 @@ static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlEx
...
@@ -4859,7 +4859,7 @@ static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlEx
tExprNode
*
p
=
NULL
;
tExprNode
*
p
=
NULL
;
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
p1
,
pQueryInfo
,
colList
,
NULL
);
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
p1
,
pQueryInfo
,
colList
,
NULL
);
size_t
colNum
=
taosArrayGetSize
(
colList
);
size_t
colNum
=
taosArrayGetSize
(
colList
);
for
(
int32_t
k
=
0
;
k
<
colNum
;
k
++
)
{
for
(
int32_t
k
=
0
;
k
<
colNum
;
k
++
)
{
...
@@ -4898,12 +4898,12 @@ static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlEx
...
@@ -4898,12 +4898,12 @@ static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlEx
if
(
pQueryInfo
->
colCond
==
NULL
)
{
if
(
pQueryInfo
->
colCond
==
NULL
)
{
pQueryInfo
->
colCond
=
taosArrayInit
(
2
,
sizeof
(
STblCond
));
pQueryInfo
->
colCond
=
taosArrayInit
(
2
,
sizeof
(
STblCond
));
}
}
taosArrayPush
(
pQueryInfo
->
colCond
,
&
cond
);
taosArrayPush
(
pQueryInfo
->
colCond
,
&
cond
);
tSqlExprDestroy
(
p1
);
tSqlExprDestroy
(
p1
);
tExprTreeDestroy
(
p
,
NULL
);
tExprTreeDestroy
(
p
,
NULL
);
if
(
ret
)
{
if
(
ret
)
{
break
;
break
;
}
}
...
@@ -5029,7 +5029,7 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
...
@@ -5029,7 +5029,7 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
index
.
columnIndex
,
pTableMeta
->
id
.
uid
,
pTagSchema2
);
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
index
.
columnIndex
,
pTableMeta
->
id
.
uid
,
pTagSchema2
);
atomic_add_fetch_32
(
&
pTableMetaInfo
->
joinTagNum
,
1
);
atomic_add_fetch_32
(
&
pTableMetaInfo
->
joinTagNum
,
1
);
if
(
pTableMetaInfo
->
joinTagNum
>
1
)
{
if
(
pTableMetaInfo
->
joinTagNum
>
1
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
...
@@ -5073,9 +5073,9 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr,
...
@@ -5073,9 +5073,9 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr,
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
const
char
*
msg1
=
"invalid function parameters"
;
const
char
*
msg1
=
"invalid function parameters"
;
const
char
*
msg2
=
"not supported functions in arithmetic expression"
;
const
char
*
msg2
=
"not supported functions in arithmetic expression"
;
int32_t
functionId
=
isValidFunction
(
pExpr
->
Expr
.
operand
.
z
,
pExpr
->
Expr
.
operand
.
n
);
int32_t
functionId
=
isValidFunction
(
pExpr
->
Expr
.
operand
.
z
,
pExpr
->
Expr
.
operand
.
n
);
pExpr
->
functionId
=
functionId
;
pExpr
->
functionId
=
functionId
;
if
(
pExpr
->
Expr
.
paramList
!=
NULL
)
{
if
(
pExpr
->
Expr
.
paramList
!=
NULL
)
{
size_t
numChildren
=
taosArrayGetSize
(
pExpr
->
Expr
.
paramList
);
size_t
numChildren
=
taosArrayGetSize
(
pExpr
->
Expr
.
paramList
);
...
@@ -6041,7 +6041,7 @@ static void doExtractExprForSTable(SSqlCmd* pCmd, tSqlExpr** pExpr, SQueryInfo*
...
@@ -6041,7 +6041,7 @@ static void doExtractExprForSTable(SSqlCmd* pCmd, tSqlExpr** pExpr, SQueryInfo*
*
pOut
=
NULL
;
*
pOut
=
NULL
;
return
;
return
;
}
}
if
(
!
isLogicalOperator
(
*
pExpr
))
{
if
(
!
isLogicalOperator
(
*
pExpr
))
{
tSqlExpr
*
pLeft
=
(
*
pExpr
)
->
pLeft
;
tSqlExpr
*
pLeft
=
(
*
pExpr
)
->
pLeft
;
...
@@ -6099,17 +6099,17 @@ int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_
...
@@ -6099,17 +6099,17 @@ int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_
#define SET_EMPTY_RANGE(w) do { (w)->skey = INT64_MAX; (w)->ekey = INT64_MIN; } while (0)
#define SET_EMPTY_RANGE(w) do { (w)->skey = INT64_MAX; (w)->ekey = INT64_MIN; } while (0)
#define IS_EMPTY_RANGE(w) ((w)->skey == INT64_MAX && (w)->ekey == INT64_MIN)
#define IS_EMPTY_RANGE(w) ((w)->skey == INT64_MAX && (w)->ekey == INT64_MIN)
if
(
optr
==
TSDB_RELATION_AND
)
{
if
(
optr
==
TSDB_RELATION_AND
)
{
if
(
res
->
skey
>
win
->
ekey
||
win
->
skey
>
res
->
ekey
)
{
if
(
res
->
skey
>
win
->
ekey
||
win
->
skey
>
res
->
ekey
)
{
SET_EMPTY_RANGE
(
res
);
SET_EMPTY_RANGE
(
res
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
res
->
skey
<
win
->
skey
)
{
if
(
res
->
skey
<
win
->
skey
)
{
res
->
skey
=
win
->
skey
;
res
->
skey
=
win
->
skey
;
}
}
if
(
res
->
ekey
>
win
->
ekey
)
{
if
(
res
->
ekey
>
win
->
ekey
)
{
res
->
ekey
=
win
->
ekey
;
res
->
ekey
=
win
->
ekey
;
}
}
...
@@ -6134,7 +6134,7 @@ int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_
...
@@ -6134,7 +6134,7 @@ int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_
if
(
res
->
skey
>
win
->
skey
)
{
if
(
res
->
skey
>
win
->
skey
)
{
res
->
skey
=
win
->
skey
;
res
->
skey
=
win
->
skey
;
}
}
if
(
res
->
ekey
<
win
->
ekey
)
{
if
(
res
->
ekey
<
win
->
ekey
)
{
res
->
ekey
=
win
->
ekey
;
res
->
ekey
=
win
->
ekey
;
}
}
...
@@ -6144,7 +6144,7 @@ int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_
...
@@ -6144,7 +6144,7 @@ int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_
static
int32_t
createTimeRangeExpr
(
tSqlExpr
**
pExpr
,
STimeWindow
*
win
,
uint32_t
tokenId
)
{
static
int32_t
createTimeRangeExpr
(
tSqlExpr
**
pExpr
,
STimeWindow
*
win
,
uint32_t
tokenId
)
{
*
pExpr
=
calloc
(
1
,
sizeof
(
tSqlExpr
));
*
pExpr
=
calloc
(
1
,
sizeof
(
tSqlExpr
));
(
*
pExpr
)
->
type
=
SQL_NODE_VALUE
;
(
*
pExpr
)
->
type
=
SQL_NODE_VALUE
;
(
*
pExpr
)
->
tokenId
=
tokenId
;
(
*
pExpr
)
->
tokenId
=
tokenId
;
(
*
pExpr
)
->
value
.
nType
=
TSDB_DATA_TYPE_VALUE_ARRAY
;
(
*
pExpr
)
->
value
.
nType
=
TSDB_DATA_TYPE_VALUE_ARRAY
;
...
@@ -6167,6 +6167,7 @@ static int32_t convertTimeRangeFromExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
...
@@ -6167,6 +6167,7 @@ static int32_t convertTimeRangeFromExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
pQueryInfo
->
onlyHasTagCond
&=
false
;
pQueryInfo
->
onlyHasTagCond
&=
false
;
if
(
!
tSqlExprIsParentOfLeaf
(
pExpr
))
{
if
(
!
tSqlExprIsParentOfLeaf
(
pExpr
))
{
code
=
convertTimeRangeFromExpr
(
pCmd
,
pQueryInfo
,
pExpr
->
pLeft
);
code
=
convertTimeRangeFromExpr
(
pCmd
,
pQueryInfo
,
pExpr
->
pLeft
);
...
@@ -6186,7 +6187,7 @@ static int32_t convertTimeRangeFromExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
...
@@ -6186,7 +6187,7 @@ static int32_t convertTimeRangeFromExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
if
(
getTimeRange
(
&
win
,
pRight
,
pExpr
->
tokenId
,
tinfo
.
precision
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
getTimeRange
(
&
win
,
pRight
,
pExpr
->
tokenId
,
tinfo
.
precision
)
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -6263,7 +6264,7 @@ static void doAddJoinTagsColumnsIntoTagList(SSqlCmd* pCmd, SQueryInfo* pQueryInf
...
@@ -6263,7 +6264,7 @@ static void doAddJoinTagsColumnsIntoTagList(SSqlCmd* pCmd, SQueryInfo* pQueryInf
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
tscColumnListInsert(pTableMetaInfo->tagColList, &index, &pSchema[index.columnIndex]);
tscColumnListInsert(pTableMetaInfo->tagColList, &index, &pSchema[index.columnIndex]);
if (getColumnIndexByName(pCmd, &pCondExpr->pJoinExpr->pRight->ColName, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
if (getColumnIndexByName(pCmd, &pCondExpr->pJoinExpr->pRight->ColName, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
tscError("%p: invalid column name (right)", pQueryInfo);
tscError("%p: invalid column name (right)", pQueryInfo);
}
}
...
@@ -6369,7 +6370,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -6369,7 +6370,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
if
(
pCondExpr
->
pTagCond
==
NULL
)
{
if
(
pCondExpr
->
pTagCond
==
NULL
)
{
return
ret
;
return
ret
;
}
}
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
tSqlExpr
*
p1
=
extractExprForSTable
(
pCmd
,
&
pCondExpr
->
pTagCond
,
pQueryInfo
,
i
);
tSqlExpr
*
p1
=
extractExprForSTable
(
pCmd
,
&
pCondExpr
->
pTagCond
,
pQueryInfo
,
i
);
if
(
p1
==
NULL
)
{
// no query condition on this table
if
(
p1
==
NULL
)
{
// no query condition on this table
...
@@ -6377,7 +6378,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -6377,7 +6378,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
}
}
tExprNode
*
p
=
NULL
;
tExprNode
*
p
=
NULL
;
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
p1
,
pQueryInfo
,
colList
,
NULL
);
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
p1
,
pQueryInfo
,
colList
,
NULL
);
size_t
colNum
=
taosArrayGetSize
(
colList
);
size_t
colNum
=
taosArrayGetSize
(
colList
);
...
@@ -6394,7 +6395,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -6394,7 +6395,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
//if (ret == TSDB_CODE_SUCCESS) {
//if (ret == TSDB_CODE_SUCCESS) {
// ret = filterInitFromTree(p, &pQueryInfo->tagFilter, (int32_t)taosArrayGetSize(colList), NULL);
// ret = filterInitFromTree(p, &pQueryInfo->tagFilter, (int32_t)taosArrayGetSize(colList), NULL);
//}
//}
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
TRY
(
0
)
{
TRY
(
0
)
{
...
@@ -6409,7 +6410,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -6409,7 +6410,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
i
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
i
);
int64_t
uid
=
pTableMetaInfo
->
pTableMeta
->
id
.
uid
;
int64_t
uid
=
pTableMetaInfo
->
pTableMeta
->
id
.
uid
;
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
size_t
num
=
taosArrayGetSize
(
colList
);
size_t
num
=
taosArrayGetSize
(
colList
);
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
SColIndex
*
pIndex
=
taosArrayGet
(
colList
,
j
);
SColIndex
*
pIndex
=
taosArrayGet
(
colList
,
j
);
...
@@ -6419,7 +6420,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -6419,7 +6420,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
index
.
columnIndex
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
,
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
index
.
columnIndex
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
,
&
s
[
pIndex
->
colIndex
]);
&
s
[
pIndex
->
colIndex
]);
}
}
tsSetSTableQueryCond
(
&
pQueryInfo
->
tagCond
,
uid
,
&
bw
);
tsSetSTableQueryCond
(
&
pQueryInfo
->
tagCond
,
uid
,
&
bw
);
tSqlExprCompact
(
&
pCondExpr
->
pTagCond
);
tSqlExprCompact
(
&
pCondExpr
->
pTagCond
);
...
@@ -6429,7 +6430,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -6429,7 +6430,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
tSqlExprDestroy
(
p1
);
tSqlExprDestroy
(
p1
);
tExprTreeDestroy
(
p
,
NULL
);
//TODO
tExprTreeDestroy
(
p
,
NULL
);
//TODO
taosArrayDestroy
(
&
colList
);
taosArrayDestroy
(
&
colList
);
if
(
pQueryInfo
->
tagCond
.
pCond
!=
NULL
&&
taosArrayGetSize
(
pQueryInfo
->
tagCond
.
pCond
)
>
0
&&
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
pQueryInfo
->
tagCond
.
pCond
!=
NULL
&&
taosArrayGetSize
(
pQueryInfo
->
tagCond
.
pCond
)
>
0
&&
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"filter on tag not supported for normal table"
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"filter on tag not supported for normal table"
);
...
@@ -6544,13 +6545,13 @@ static int32_t getQueryTimeRange(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr
...
@@ -6544,13 +6545,13 @@ static int32_t getQueryTimeRange(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr
if
(
*
pExpr
==
NULL
)
{
if
(
*
pExpr
==
NULL
)
{
return
ret
;
return
ret
;
}
}
//multiple tables's query time range mixed together
//multiple tables's query time range mixed together
tExprNode
*
p
=
NULL
;
tExprNode
*
p
=
NULL
;
void
*
filter
=
NULL
;
void
*
filter
=
NULL
;
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
*
pExpr
,
pQueryInfo
,
colList
,
NULL
);
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
*
pExpr
,
pQueryInfo
,
colList
,
NULL
);
taosArrayDestroy
(
&
colList
);
taosArrayDestroy
(
&
colList
);
...
@@ -6807,7 +6808,7 @@ int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNo
...
@@ -6807,7 +6808,7 @@ int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNo
if
((
!
isTimeWindowQuery
(
pQueryInfo
))
&&
(
!
pointInterp
))
{
if
((
!
isTimeWindowQuery
(
pQueryInfo
))
&&
(
!
pointInterp
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
}
}
if
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
)
&&
(
!
pointInterp
))
{
if
(
QUERY_IS_JOIN_QUERY
(
pQueryInfo
->
type
)
&&
(
!
pointInterp
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
}
}
...
@@ -6823,9 +6824,9 @@ int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNo
...
@@ -6823,9 +6824,9 @@ int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNo
if
(
pItem
->
pVar
.
nType
!=
TSDB_DATA_TYPE_BINARY
)
{
if
(
pItem
->
pVar
.
nType
!=
TSDB_DATA_TYPE_BINARY
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
size_t
numOfFields
=
tscNumOfFields
(
pQueryInfo
);
size_t
numOfFields
=
tscNumOfFields
(
pQueryInfo
);
if
(
pQueryInfo
->
fillVal
==
NULL
)
{
if
(
pQueryInfo
->
fillVal
==
NULL
)
{
pQueryInfo
->
fillVal
=
calloc
(
numOfFields
,
sizeof
(
int64_t
));
pQueryInfo
->
fillVal
=
calloc
(
numOfFields
,
sizeof
(
int64_t
));
pQueryInfo
->
numOfFillVal
=
(
int32_t
)
numOfFields
;
pQueryInfo
->
numOfFillVal
=
(
int32_t
)
numOfFields
;
...
@@ -6886,7 +6887,7 @@ int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNo
...
@@ -6886,7 +6887,7 @@ int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNo
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
}
}
}
if
((
num
<
numOfFields
)
||
((
num
-
1
<
numOfFields
)
&&
pointInterp
))
{
if
((
num
<
numOfFields
)
||
((
num
-
1
<
numOfFields
)
&&
pointInterp
))
{
tVariantListItem
*
lastItem
=
taosArrayGetLast
(
pFillToken
);
tVariantListItem
*
lastItem
=
taosArrayGetLast
(
pFillToken
);
...
@@ -6922,13 +6923,13 @@ int32_t validateRangeNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pSqlN
...
@@ -6922,13 +6923,13 @@ int32_t validateRangeNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pSqlN
const
char
*
msg0
=
"invalid usage of range clause"
;
const
char
*
msg0
=
"invalid usage of range clause"
;
const
char
*
msg1
=
"invalid timestamp in range"
;
const
char
*
msg1
=
"invalid timestamp in range"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
bool
interpQuery
=
tscIsPointInterpQuery
(
pQueryInfo
);
bool
interpQuery
=
tscIsPointInterpQuery
(
pQueryInfo
);
if
((
!
interpQuery
)
&&
(
pSqlNode
->
pRange
.
start
||
pSqlNode
->
pRange
.
end
))
{
if
((
!
interpQuery
)
&&
(
pSqlNode
->
pRange
.
start
||
pSqlNode
->
pRange
.
end
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg0
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg0
);
}
}
if
(
pSqlNode
->
pRange
.
start
==
NULL
||
pSqlNode
->
pRange
.
end
==
NULL
)
{
if
(
pSqlNode
->
pRange
.
start
==
NULL
||
pSqlNode
->
pRange
.
end
==
NULL
)
{
pQueryInfo
->
range
.
skey
=
INT64_MIN
;
pQueryInfo
->
range
.
skey
=
INT64_MIN
;
pQueryInfo
->
range
.
ekey
=
INT64_MIN
;
pQueryInfo
->
range
.
ekey
=
INT64_MIN
;
...
@@ -7006,8 +7007,8 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
...
@@ -7006,8 +7007,8 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
setDefaultOrderInfo
(
pQueryInfo
);
setDefaultOrderInfo
(
pQueryInfo
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
if
(
pSqlNode
->
pSortOrder
==
NULL
)
{
if
(
pSqlNode
->
pSortOrder
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
char
*
pMsgBuf
=
tscGetErrorMsgPayload
(
pCmd
);
char
*
pMsgBuf
=
tscGetErrorMsgPayload
(
pCmd
);
SArray
*
pSortOrder
=
pSqlNode
->
pSortOrder
;
SArray
*
pSortOrder
=
pSqlNode
->
pSortOrder
;
...
@@ -7578,12 +7579,12 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -7578,12 +7579,12 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
len
=
varDataTLen
(
pUpdateMsg
->
data
+
schemaLen
);
len
=
varDataTLen
(
pUpdateMsg
->
data
+
schemaLen
);
if
(
len
>
pTagsSchema
->
bytes
)
return
invalidOperationMsg
(
pMsg
,
msg14
);
if
(
len
>
pTagsSchema
->
bytes
)
return
invalidOperationMsg
(
pMsg
,
msg14
);
}
}
pUpdateMsg
->
tagValLen
=
htonl
(
len
);
// length may be changed after dump data
pUpdateMsg
->
tagValLen
=
htonl
(
len
);
// length may be changed after dump data
int32_t
total
=
sizeof
(
SUpdateTableTagValMsg
)
+
len
+
schemaLen
;
int32_t
total
=
sizeof
(
SUpdateTableTagValMsg
)
+
len
+
schemaLen
;
pUpdateMsg
->
head
.
contLen
=
htonl
(
total
);
pUpdateMsg
->
head
.
contLen
=
htonl
(
total
);
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
)
{
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
)
{
SArray
*
pFieldList
=
pAlterSQL
->
pAddColumns
;
SArray
*
pFieldList
=
pAlterSQL
->
pAddColumns
;
if
(
taosArrayGetSize
(
pFieldList
)
>
1
)
{
if
(
taosArrayGetSize
(
pFieldList
)
>
1
)
{
...
@@ -7596,7 +7597,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -7596,7 +7597,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
p
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
p
);
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
if
(
tscGetNumOfColumns
(
pTableMeta
)
==
TSDB_MIN_COLUMNS
)
{
//
if
(
tscGetNumOfColumns
(
pTableMeta
)
==
TSDB_MIN_COLUMNS
)
{
//
...
@@ -7749,7 +7750,7 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
...
@@ -7749,7 +7750,7 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
pQueryInfo
->
interval
.
intervalUnit
!=
'y'
)
{
pQueryInfo
->
interval
.
intervalUnit
!=
'y'
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg0
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg0
);
}
}
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
int32_t
functId
=
tscExprGet
(
pQueryInfo
,
i
)
->
base
.
functionId
;
int32_t
functId
=
tscExprGet
(
pQueryInfo
,
i
)
->
base
.
functionId
;
...
@@ -7770,7 +7771,7 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu
...
@@ -7770,7 +7771,7 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu
// multi-output set/ todo refactor
// multi-output set/ todo refactor
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
size
;
++
k
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
k
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
k
);
...
@@ -7828,7 +7829,8 @@ typedef struct SDNodeDynConfOption {
...
@@ -7828,7 +7829,8 @@ typedef struct SDNodeDynConfOption {
int32_t
len
;
// name string length
int32_t
len
;
// name string length
}
SDNodeDynConfOption
;
}
SDNodeDynConfOption
;
int32_t
validateEp
(
char
*
ep
)
{
int32_t
validateEp
(
char
*
ep
)
{
char
buf
[
TSDB_EP_LEN
+
1
]
=
{
0
};
char
buf
[
TSDB_EP_LEN
+
1
]
=
{
0
};
tstrncpy
(
buf
,
ep
,
TSDB_EP_LEN
);
tstrncpy
(
buf
,
ep
,
TSDB_EP_LEN
);
...
@@ -8031,10 +8033,10 @@ int32_t validateLimitNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlN
...
@@ -8031,10 +8033,10 @@ int32_t validateLimitNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlN
pQueryInfo
->
limit
=
pSqlNode
->
limit
;
pQueryInfo
->
limit
=
pSqlNode
->
limit
;
pQueryInfo
->
clauseLimit
=
pQueryInfo
->
limit
.
limit
;
pQueryInfo
->
clauseLimit
=
pQueryInfo
->
limit
.
limit
;
pQueryInfo
->
slimit
=
pSqlNode
->
slimit
;
pQueryInfo
->
slimit
=
pSqlNode
->
slimit
;
tscDebug
(
"0x%"
PRIx64
" limit:%"
PRId64
", offset:%"
PRId64
" slimit:%"
PRId64
", soffset:%"
PRId64
,
pSql
->
self
,
tscDebug
(
"0x%"
PRIx64
" limit:%"
PRId64
", offset:%"
PRId64
" slimit:%"
PRId64
", soffset:%"
PRId64
,
pSql
->
self
,
pQueryInfo
->
limit
.
limit
,
pQueryInfo
->
limit
.
offset
,
pQueryInfo
->
slimit
.
limit
,
pQueryInfo
->
slimit
.
offset
);
pQueryInfo
->
limit
.
limit
,
pQueryInfo
->
limit
.
offset
,
pQueryInfo
->
slimit
.
limit
,
pQueryInfo
->
slimit
.
offset
);
if
(
pQueryInfo
->
slimit
.
offset
<
0
||
pQueryInfo
->
limit
.
offset
<
0
)
{
if
(
pQueryInfo
->
slimit
.
offset
<
0
||
pQueryInfo
->
limit
.
offset
<
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg0
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg0
);
}
}
...
@@ -8329,7 +8331,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) {
...
@@ -8329,7 +8331,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) {
static
int32_t
doUpdateSqlFunctionForColPrj
(
SQueryInfo
*
pQueryInfo
)
{
static
int32_t
doUpdateSqlFunctionForColPrj
(
SQueryInfo
*
pQueryInfo
)
{
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
...
@@ -8337,7 +8339,7 @@ static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) {
...
@@ -8337,7 +8339,7 @@ static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) {
bool
qualifiedCol
=
false
;
bool
qualifiedCol
=
false
;
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
;
++
j
)
{
SColIndex
*
pColIndex
=
taosArrayGet
(
pQueryInfo
->
groupbyExpr
.
columnInfo
,
j
);
SColIndex
*
pColIndex
=
taosArrayGet
(
pQueryInfo
->
groupbyExpr
.
columnInfo
,
j
);
if
(
pExpr
->
base
.
colInfo
.
colId
==
pColIndex
->
colId
)
{
if
(
pExpr
->
base
.
colInfo
.
colId
==
pColIndex
->
colId
)
{
qualifiedCol
=
true
;
qualifiedCol
=
true
;
doLimitOutputNormalColOfGroupby
(
pExpr
);
doLimitOutputNormalColOfGroupby
(
pExpr
);
...
@@ -8377,7 +8379,7 @@ static bool tagColumnInGroupby(SGroupbyExpr* pGroupbyExpr, int16_t columnId, int
...
@@ -8377,7 +8379,7 @@ static bool tagColumnInGroupby(SGroupbyExpr* pGroupbyExpr, int16_t columnId, int
static
bool
onlyTagPrjFunction
(
SQueryInfo
*
pQueryInfo
)
{
static
bool
onlyTagPrjFunction
(
SQueryInfo
*
pQueryInfo
)
{
bool
hasTagPrj
=
false
;
bool
hasTagPrj
=
false
;
bool
hasColumnPrj
=
false
;
bool
hasColumnPrj
=
false
;
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
...
@@ -8415,7 +8417,7 @@ static bool allTagPrjInGroupby(SQueryInfo* pQueryInfo) {
...
@@ -8415,7 +8417,7 @@ static bool allTagPrjInGroupby(SQueryInfo* pQueryInfo) {
static
void
updateTagPrjFunction
(
SQueryInfo
*
pQueryInfo
)
{
static
void
updateTagPrjFunction
(
SQueryInfo
*
pQueryInfo
)
{
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
size_t
size
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_TAGPRJ
)
{
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_TAGPRJ
)
{
...
@@ -8605,7 +8607,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
...
@@ -8605,7 +8607,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
s
=
&
pSchema
[
colIndex
];
s
=
&
pSchema
[
colIndex
];
}
}
}
}
if
(
TSDB_COL_IS_TAG
(
pColIndex
->
flag
))
{
if
(
TSDB_COL_IS_TAG
(
pColIndex
->
flag
))
{
int32_t
f
=
TSDB_FUNC_TAG
;
int32_t
f
=
TSDB_FUNC_TAG
;
...
@@ -8613,7 +8615,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
...
@@ -8613,7 +8615,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
f
=
TSDB_FUNC_TAGPRJ
;
f
=
TSDB_FUNC_TAGPRJ
;
}
}
int32_t
pos
=
tscGetFirstInvisibleFieldPos
(
pQueryInfo
);
int32_t
pos
=
tscGetFirstInvisibleFieldPos
(
pQueryInfo
);
SColumnIndex
index
=
{.
tableIndex
=
pQueryInfo
->
groupbyExpr
.
tableIndex
,
.
columnIndex
=
colIndex
};
SColumnIndex
index
=
{.
tableIndex
=
pQueryInfo
->
groupbyExpr
.
tableIndex
,
.
columnIndex
=
colIndex
};
SExprInfo
*
pExpr
=
tscExprInsert
(
pQueryInfo
,
pos
,
f
,
&
index
,
s
->
type
,
s
->
bytes
,
getNewResColId
(
pCmd
),
s
->
bytes
,
true
);
SExprInfo
*
pExpr
=
tscExprInsert
(
pQueryInfo
,
pos
,
f
,
&
index
,
s
->
type
,
s
->
bytes
,
getNewResColId
(
pCmd
),
s
->
bytes
,
true
);
...
@@ -8803,10 +8805,10 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
...
@@ -8803,10 +8805,10 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
int32_t
numOfExprs
=
(
int32_t
)
tscNumOfExprs
(
pQueryInfo
);
int32_t
numOfExprs
=
(
int32_t
)
tscNumOfExprs
(
pQueryInfo
);
size_t
upNum
=
taosArrayGetSize
(
pQueryInfo
->
pUpstream
);
size_t
upNum
=
taosArrayGetSize
(
pQueryInfo
->
pUpstream
);
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
int32_t
f
=
pExpr
->
base
.
functionId
;
int32_t
f
=
pExpr
->
base
.
functionId
;
if
(
f
==
TSDB_FUNC_DERIVATIVE
||
if
(
f
==
TSDB_FUNC_DERIVATIVE
||
f
==
TSDB_FUNC_TWA
||
f
==
TSDB_FUNC_TWA
||
...
@@ -8823,7 +8825,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
...
@@ -8823,7 +8825,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
return
invalidOperationMsg
(
msg
,
msg1
);
return
invalidOperationMsg
(
msg
,
msg1
);
}
else
if
(
f
==
TSDB_FUNC_INTERP
)
{
}
else
if
(
f
==
TSDB_FUNC_INTERP
)
{
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
)
{
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
)
{
...
@@ -8839,7 +8841,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
...
@@ -8839,7 +8841,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
if
(
pUp
->
groupbyExpr
.
columnInfo
)
{
if
(
pUp
->
groupbyExpr
.
columnInfo
)
{
return
invalidOperationMsg
(
msg
,
msg2
);
return
invalidOperationMsg
(
msg
,
msg2
);
}
}
if
(
pUp
->
order
.
order
==
TSDB_ORDER_DESC
||
(
pUp
->
order
.
orderColId
!=
INT32_MIN
&&
pUp
->
order
.
orderColId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
))
{
if
(
pUp
->
order
.
order
==
TSDB_ORDER_DESC
||
(
pUp
->
order
.
orderColId
!=
INT32_MIN
&&
pUp
->
order
.
orderColId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
))
{
return
invalidOperationMsg
(
msg
,
msg3
);
return
invalidOperationMsg
(
msg
,
msg3
);
}
}
...
@@ -8860,7 +8862,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
...
@@ -8860,7 +8862,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
if
(
TSDB_QUERY_HAS_TYPE
(
pUp
->
type
,
TSDB_QUERY_TYPE_PROJECTION_QUERY
))
{
if
(
TSDB_QUERY_HAS_TYPE
(
pUp
->
type
,
TSDB_QUERY_TYPE_PROJECTION_QUERY
))
{
return
invalidOperationMsg
(
msg
,
msg5
);
return
invalidOperationMsg
(
msg
,
msg5
);
}
}
for
(
int32_t
n
=
0
;
n
<
exprNum
;
++
n
)
{
for
(
int32_t
n
=
0
;
n
<
exprNum
;
++
n
)
{
expr
=
taosArrayGetP
(
pUp
->
exprList
,
n
);
expr
=
taosArrayGetP
(
pUp
->
exprList
,
n
);
if
(
expr
->
functionId
==
TSDB_FUNC_TOP
||
if
(
expr
->
functionId
==
TSDB_FUNC_TOP
||
...
@@ -8897,11 +8899,11 @@ int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
...
@@ -8897,11 +8899,11 @@ int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
if
(
pExpr
->
Expr
.
operand
.
z
==
NULL
)
{
if
(
pExpr
->
Expr
.
operand
.
z
==
NULL
)
{
//handle 'select 1'
//handle 'select 1'
if
(
pExpr
->
exprToken
.
n
==
1
&&
0
==
strncasecmp
(
pExpr
->
exprToken
.
z
,
"1"
,
1
))
{
if
(
pExpr
->
exprToken
.
n
==
1
&&
0
==
strncasecmp
(
pExpr
->
exprToken
.
z
,
"1"
,
1
))
{
server_status
=
true
;
server_status
=
true
;
}
else
{
}
else
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
}
}
// TODO redefine the function
// TODO redefine the function
SDNodeDynConfOption
functionsInfo
[
5
]
=
{{
"database()"
,
10
},
SDNodeDynConfOption
functionsInfo
[
5
]
=
{{
"database()"
,
10
},
{
"server_version()"
,
16
},
{
"server_version()"
,
16
},
...
@@ -8935,7 +8937,7 @@ int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
...
@@ -8935,7 +8937,7 @@ int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
pQueryInfo
->
command
=
TSDB_SQL_CURRENT_USER
;
break
;
pQueryInfo
->
command
=
TSDB_SQL_CURRENT_USER
;
break
;
default:
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
default:
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
}
SColumnIndex
ind
=
{
0
};
SColumnIndex
ind
=
{
0
};
SExprInfo
*
pExpr1
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TAG_DUMMY
,
&
ind
,
TSDB_DATA_TYPE_INT
,
SExprInfo
*
pExpr1
=
tscExprAppend
(
pQueryInfo
,
TSDB_FUNC_TAG_DUMMY
,
&
ind
,
TSDB_DATA_TYPE_INT
,
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
,
getNewResColId
(
pCmd
),
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
,
false
);
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
,
getNewResColId
(
pCmd
),
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
,
false
);
...
@@ -8943,7 +8945,7 @@ int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
...
@@ -8943,7 +8945,7 @@ int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
tSqlExprItem
*
item
=
taosArrayGet
(
pExprList
,
0
);
tSqlExprItem
*
item
=
taosArrayGet
(
pExprList
,
0
);
const
char
*
name
=
(
item
->
aliasName
!=
NULL
)
?
item
->
aliasName
:
functionsInfo
[
index
].
name
;
const
char
*
name
=
(
item
->
aliasName
!=
NULL
)
?
item
->
aliasName
:
functionsInfo
[
index
].
name
;
tstrncpy
(
pExpr1
->
base
.
aliasName
,
name
,
tListLen
(
pExpr1
->
base
.
aliasName
));
tstrncpy
(
pExpr1
->
base
.
aliasName
,
name
,
tListLen
(
pExpr1
->
base
.
aliasName
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -9104,7 +9106,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
...
@@ -9104,7 +9106,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
// if sql specifies db, use it, otherwise use default db
// if sql specifies db, use it, otherwise use default db
SStrToken
*
pzTableName
=
&
(
pCreateTable
->
name
);
SStrToken
*
pzTableName
=
&
(
pCreateTable
->
name
);
bool
dbIncluded
=
false
;
bool
dbIncluded
=
false
;
if
(
tscValidateName
(
pzTableName
,
true
,
&
dbIncluded
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscValidateName
(
pzTableName
,
true
,
&
dbIncluded
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
...
@@ -9382,7 +9384,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -9382,7 +9384,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
kvRowCpy
(
pTag
->
data
,
row
);
kvRowCpy
(
pTag
->
data
,
row
);
free
(
row
);
free
(
row
);
bool
dbIncluded2
=
false
;
bool
dbIncluded2
=
false
;
char
tmp
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
char
tmp
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
SStrToken
tbName
=
taosTokenDup
(
&
pCreateTableInfo
->
name
,
tmp
,
tListLen
(
tmp
));
SStrToken
tbName
=
taosTokenDup
(
&
pCreateTableInfo
->
name
,
tmp
,
tListLen
(
tmp
));
...
@@ -9434,7 +9436,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -9434,7 +9436,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
if
(
tscValidateName
(
pName
,
true
,
&
dbIncluded1
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscValidateName
(
pName
,
true
,
&
dbIncluded1
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
STR_INVALID_TABLE_NAME
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
STR_INVALID_TABLE_NAME
);
}
}
// check to valid and create to name
// check to valid and create to name
if
(
pInfo
->
pCreateTableInfo
->
to
.
n
>
0
)
{
if
(
pInfo
->
pCreateTableInfo
->
to
.
n
>
0
)
{
bool
dbInclude
=
false
;
bool
dbInclude
=
false
;
...
@@ -9909,12 +9911,12 @@ static int32_t getTableNameFromSqlNode(SSqlNode* pSqlNode, SArray* tableNameList
...
@@ -9909,12 +9911,12 @@ static int32_t getTableNameFromSqlNode(SSqlNode* pSqlNode, SArray* tableNameList
if
(
t
->
type
==
TK_INTEGER
||
t
->
type
==
TK_FLOAT
)
{
if
(
t
->
type
==
TK_INTEGER
||
t
->
type
==
TK_FLOAT
)
{
return
invalidOperationMsg
(
msgBuf
,
STR_INVALID_TABLE_NAME
);
return
invalidOperationMsg
(
msgBuf
,
STR_INVALID_TABLE_NAME
);
}
}
bool
dbIncluded
=
false
;
bool
dbIncluded
=
false
;
char
buf
[
TSDB_TABLE_FNAME_LEN
];
char
buf
[
TSDB_TABLE_FNAME_LEN
];
SStrToken
sTblToken
;
SStrToken
sTblToken
;
sTblToken
.
z
=
buf
;
sTblToken
.
z
=
buf
;
if
(
validateTableName
(
t
->
z
,
t
->
n
,
&
sTblToken
,
&
dbIncluded
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
validateTableName
(
t
->
z
,
t
->
n
,
&
sTblToken
,
&
dbIncluded
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
msgBuf
,
STR_INVALID_TABLE_NAME
);
return
invalidOperationMsg
(
msgBuf
,
STR_INVALID_TABLE_NAME
);
}
}
...
@@ -9943,7 +9945,7 @@ static int32_t getTableNameFromSubquery(SSqlNode* pSqlNode, SArray* tableNameLis
...
@@ -9943,7 +9945,7 @@ static int32_t getTableNameFromSubquery(SSqlNode* pSqlNode, SArray* tableNameLis
if
(
p
->
from
==
NULL
)
{
if
(
p
->
from
==
NULL
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
if
(
p
->
from
->
type
==
SQL_NODE_FROM_TABLELIST
)
{
if
(
p
->
from
->
type
==
SQL_NODE_FROM_TABLELIST
)
{
int32_t
code
=
getTableNameFromSqlNode
(
p
,
tableNameList
,
msgBuf
,
pSql
);
int32_t
code
=
getTableNameFromSqlNode
(
p
,
tableNameList
,
msgBuf
,
pSql
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -10041,7 +10043,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -10041,7 +10043,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tNameExtractFullName
(
pname
,
name
);
tNameExtractFullName
(
pname
,
name
);
size_t
len
=
strlen
(
name
);
size_t
len
=
strlen
(
name
);
if
(
NULL
==
taosHashGetCloneExt
(
UTIL_GET_TABLEMETA
(
pSql
),
name
,
len
,
NULL
,
(
void
**
)
&
pTableMeta
,
&
tableMetaCapacity
))
{
if
(
NULL
==
taosHashGetCloneExt
(
UTIL_GET_TABLEMETA
(
pSql
),
name
,
len
,
NULL
,
(
void
**
)
&
pTableMeta
,
&
tableMetaCapacity
))
{
// not found
// not found
tfree
(
pTableMeta
);
tfree
(
pTableMeta
);
...
@@ -10054,7 +10056,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -10054,7 +10056,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
void
*
pVgroupIdList
=
NULL
;
void
*
pVgroupIdList
=
NULL
;
if
(
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
)
{
if
(
pTableMeta
->
tableType
==
TSDB_CHILD_TABLE
)
{
code
=
tscCreateTableMetaFromSTableMeta
(
pSql
,
(
STableMeta
**
)(
&
pTableMeta
),
name
,
&
tableMetaCapacity
,
(
STableMeta
**
)(
&
pSTMeta
));
code
=
tscCreateTableMetaFromSTableMeta
(
pSql
,
(
STableMeta
**
)(
&
pTableMeta
),
name
,
&
tableMetaCapacity
,
(
STableMeta
**
)(
&
pSTMeta
));
pSql
->
pBuf
=
(
void
*
)
pSTMeta
;
pSql
->
pBuf
=
(
void
*
)
pSTMeta
;
// create the child table meta from super table failed, try load it from mnode
// create the child table meta from super table failed, try load it from mnode
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -10135,7 +10137,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -10135,7 +10137,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
else
if
(
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
)
>
0
)
{
}
else
if
(
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
)
>
0
)
{
int32_t
usize
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
);
int32_t
usize
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
);
int32_t
exist
=
0
;
int32_t
exist
=
0
;
for
(
int32_t
j
=
0
;
j
<
usize
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
usize
;
++
j
)
{
SUdfInfo
*
pUdfInfo
=
taosArrayGet
(
pQueryInfo
->
pUdfInfo
,
j
);
SUdfInfo
*
pUdfInfo
=
taosArrayGet
(
pQueryInfo
->
pUdfInfo
,
j
);
int32_t
len
=
(
int32_t
)
strlen
(
pUdfInfo
->
name
);
int32_t
len
=
(
int32_t
)
strlen
(
pUdfInfo
->
name
);
...
@@ -10155,7 +10157,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -10155,7 +10157,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
)
>
1
)
{
if
(
taosArrayGetSize
(
pQueryInfo
->
pUdfInfo
)
>
1
)
{
code
=
tscInvalidOperationMsg
(
pCmd
->
payload
,
"only one udf allowed"
,
NULL
);
code
=
tscInvalidOperationMsg
(
pCmd
->
payload
,
"only one udf allowed"
,
NULL
);
goto
_end
;
goto
_end
;
}
}
}
}
}
}
}
}
...
@@ -10813,9 +10815,9 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
...
@@ -10813,9 +10815,9 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
*
pExpr
=
calloc
(
1
,
sizeof
(
tExprNode
));
*
pExpr
=
calloc
(
1
,
sizeof
(
tExprNode
));
(
*
pExpr
)
->
nodeType
=
TSQL_NODE_TYPE
;
(
*
pExpr
)
->
nodeType
=
TSQL_NODE_TYPE
;
(
*
pExpr
)
->
pType
=
calloc
(
1
,
sizeof
(
TAOS_FIELD
));
(
*
pExpr
)
->
pType
=
calloc
(
1
,
sizeof
(
TAOS_FIELD
));
*
(
*
pExpr
)
->
pType
=
pSqlExpr
->
dataType
;
*
(
*
pExpr
)
->
pType
=
pSqlExpr
->
dataType
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pSqlExpr
->
tokenId
==
TK_SET
)
{
}
else
if
(
pSqlExpr
->
tokenId
==
TK_SET
)
{
int32_t
colType
=
-
1
;
int32_t
colType
=
-
1
;
...
...
src/client/src/tscUtil.c
浏览文件 @
bf041f21
...
@@ -1418,7 +1418,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
...
@@ -1418,7 +1418,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
};
};
SUdfInfo
*
pUdfInfo
=
NULL
;
SUdfInfo
*
pUdfInfo
=
NULL
;
size_t
size
=
tscNumOfExprs
(
px
);
size_t
size
=
tscNumOfExprs
(
px
);
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
size
;
++
j
)
{
SExprInfo
*
pExprInfo
=
tscExprGet
(
px
,
j
);
SExprInfo
*
pExprInfo
=
tscExprGet
(
px
,
j
);
...
@@ -1429,7 +1429,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
...
@@ -1429,7 +1429,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
pSql
->
res
.
code
=
tscInvalidOperationMsg
(
pSql
->
cmd
.
payload
,
"only one udf allowed"
,
NULL
);
pSql
->
res
.
code
=
tscInvalidOperationMsg
(
pSql
->
cmd
.
payload
,
"only one udf allowed"
,
NULL
);
return
;
return
;
}
}
pUdfInfo
=
taosArrayGet
(
px
->
pUdfInfo
,
-
1
*
functionId
-
1
);
pUdfInfo
=
taosArrayGet
(
px
->
pUdfInfo
,
-
1
*
functionId
-
1
);
int32_t
code
=
initUdfInfo
(
pUdfInfo
);
int32_t
code
=
initUdfInfo
(
pUdfInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -1537,7 +1537,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
...
@@ -1537,7 +1537,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
px
->
pQInfo
->
runtimeEnv
.
udfIsCopy
=
true
;
px
->
pQInfo
->
runtimeEnv
.
udfIsCopy
=
true
;
px
->
pQInfo
->
runtimeEnv
.
pUdfInfo
=
pUdfInfo
;
px
->
pQInfo
->
runtimeEnv
.
pUdfInfo
=
pUdfInfo
;
tfree
(
schema
);
tfree
(
schema
);
// set the pRuntimeEnv for pSourceOperator
// set the pRuntimeEnv for pSourceOperator
...
@@ -2702,9 +2702,11 @@ int32_t tscExprTopBottomIndex(SQueryInfo* pQueryInfo){
...
@@ -2702,9 +2702,11 @@ int32_t tscExprTopBottomIndex(SQueryInfo* pQueryInfo){
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
==
NULL
)
if
(
pExpr
==
NULL
)
continue
;
continue
;
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_TOP
||
pExpr
->
base
.
functionId
==
TSDB_FUNC_BOTTOM
||
if
(
pExpr
->
base
.
functionId
==
TSDB_FUNC_TOP
pExpr
->
base
.
functionId
==
TSDB_FUNC_SAMPLE
||
pExpr
->
base
.
functionId
==
TSDB_FUNC_UNIQUE
||
||
pExpr
->
base
.
functionId
==
TSDB_FUNC_BOTTOM
pExpr
->
base
.
functionId
==
TSDB_FUNC_TAIL
)
{
||
pExpr
->
base
.
functionId
==
TSDB_FUNC_SAMPLE
||
pExpr
->
base
.
functionId
==
TSDB_FUNC_UNIQUE
||
pExpr
->
base
.
functionId
==
TSDB_FUNC_TAIL
)
{
return
i
;
return
i
;
}
}
}
}
...
@@ -4195,20 +4197,20 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
...
@@ -4195,20 +4197,20 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
}
}
int32_t
doInitSubState
(
SSqlObj
*
pSql
,
int32_t
numOfSubqueries
)
{
int32_t
doInitSubState
(
SSqlObj
*
pSql
,
int32_t
numOfSubqueries
)
{
//
bug fix. Above doInitSubState level, the loop invocation with the same SSqlObj will be fail.
//bug fix. Above doInitSubState level, the loop invocation with the same SSqlObj will be fail.
//
assert(pSql->subState.numOfSub == 0 && pSql->pSubs == NULL && pSql->subState.states == NULL);
//
assert(pSql->subState.numOfSub == 0 && pSql->pSubs == NULL && pSql->subState.states == NULL);
if
(
pSql
->
pSubs
)
{
if
(
pSql
->
pSubs
)
{
free
(
pSql
->
pSubs
);
free
(
pSql
->
pSubs
);
pSql
->
pSubs
=
NULL
;
pSql
->
pSubs
=
NULL
;
}
}
if
(
pSql
->
subState
.
states
)
{
if
(
pSql
->
subState
.
states
)
{
free
(
pSql
->
subState
.
states
);
free
(
pSql
->
subState
.
states
);
pSql
->
subState
.
states
=
NULL
;
pSql
->
subState
.
states
=
NULL
;
}
}
pSql
->
subState
.
numOfSub
=
numOfSubqueries
;
pSql
->
subState
.
numOfSub
=
numOfSubqueries
;
pSql
->
pSubs
=
calloc
(
pSql
->
subState
.
numOfSub
,
POINTER_BYTES
);
pSql
->
pSubs
=
calloc
(
pSql
->
subState
.
numOfSub
,
POINTER_BYTES
);
pSql
->
subState
.
states
=
calloc
(
pSql
->
subState
.
numOfSub
,
sizeof
(
int8_t
));
pSql
->
subState
.
states
=
calloc
(
pSql
->
subState
.
numOfSub
,
sizeof
(
int8_t
));
...
@@ -4234,7 +4236,7 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
...
@@ -4234,7 +4236,7 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
0
);
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
0
);
}
}
return
;
return
;
}
}
if
(
pSql
->
cmd
.
command
==
TSDB_SQL_SELECT
)
{
if
(
pSql
->
cmd
.
command
==
TSDB_SQL_SELECT
)
{
tscAddIntoSqlList
(
pSql
);
tscAddIntoSqlList
(
pSql
);
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
bf041f21
...
@@ -136,7 +136,7 @@ void shellInit(SShellArguments *_args) {
...
@@ -136,7 +136,7 @@ void shellInit(SShellArguments *_args) {
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
#endif
#endif
return
;
return
;
}
}
...
@@ -1515,7 +1515,7 @@ int wsclient_print_data(int rows, TAOS_FIELD *fields, int cols, int64_t id, int
...
@@ -1515,7 +1515,7 @@ int wsclient_print_data(int rows, TAOS_FIELD *fields, int cols, int64_t id, int
if
(
*
pshowed_rows
==
DEFAULT_RES_SHOW_NUM
)
{
if
(
*
pshowed_rows
==
DEFAULT_RES_SHOW_NUM
)
{
free
(
recv_buffer
);
free
(
recv_buffer
);
return
0
;
return
0
;
}
}
for
(
int
c
=
0
;
c
<
cols
;
c
++
)
{
for
(
int
c
=
0
;
c
<
cols
;
c
++
)
{
pos
=
start
;
pos
=
start
;
pos
+=
i
*
fields
[
c
].
bytes
;
pos
+=
i
*
fields
[
c
].
bytes
;
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
bf041f21
...
@@ -1047,7 +1047,7 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -1047,7 +1047,7 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLInfo
(
"stable:%s, is created in sdb, uid:%"
PRIu64
,
pTable
->
info
.
tableId
,
pTable
->
uid
);
mLInfo
(
"stable:%s, is created in sdb, uid:%"
PRIu64
,
pTable
->
info
.
tableId
,
pTable
->
uid
);
if
(
pMsg
->
pBatchMasterMsg
)
if
(
pMsg
->
pBatchMasterMsg
)
pMsg
->
pBatchMasterMsg
->
successed
++
;
pMsg
->
pBatchMasterMsg
->
successed
++
;
}
else
{
}
else
{
mError
(
"msg:%p, app:%p stable:%s, failed to create in sdb, reason:%s"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
mError
(
"msg:%p, app:%p stable:%s, failed to create in sdb, reason:%s"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
tstrerror
(
code
));
tstrerror
(
code
));
...
@@ -1060,7 +1060,7 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -1060,7 +1060,7 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
// if super table create by batch msg, check done and send finished to client
// if super table create by batch msg, check done and send finished to client
if
(
pMsg
->
pBatchMasterMsg
)
{
if
(
pMsg
->
pBatchMasterMsg
)
{
if
(
pMsg
->
pBatchMasterMsg
->
successed
+
pMsg
->
pBatchMasterMsg
->
received
>=
pMsg
->
pBatchMasterMsg
->
expected
)
if
(
pMsg
->
pBatchMasterMsg
->
successed
+
pMsg
->
pBatchMasterMsg
->
received
>=
pMsg
->
pBatchMasterMsg
->
expected
)
dnodeSendRpcMWriteRsp
(
pMsg
->
pBatchMasterMsg
,
code
);
dnodeSendRpcMWriteRsp
(
pMsg
->
pBatchMasterMsg
,
code
);
}
}
return
code
;
return
code
;
...
@@ -3558,7 +3558,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
...
@@ -3558,7 +3558,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pTable
->
sql
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pTable
->
sql
,
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
numOfRows
++
;
numOfRows
++
;
...
@@ -3593,13 +3593,13 @@ static int32_t mnodeCompactSuperTables() {
...
@@ -3593,13 +3593,13 @@ static int32_t mnodeCompactSuperTables() {
};
};
//mInfo("compact super %" PRIu64, pTable->uid);
//mInfo("compact super %" PRIu64, pTable->uid);
sdbInsertCompactRow
(
&
row
);
sdbInsertCompactRow
(
&
row
);
}
}
mInfo
(
"end to compact super table..."
);
mInfo
(
"end to compact super table..."
);
return
0
;
return
0
;
}
}
static
int32_t
mnodeCompactChildTables
()
{
static
int32_t
mnodeCompactChildTables
()
{
...
@@ -3619,13 +3619,13 @@ static int32_t mnodeCompactChildTables() {
...
@@ -3619,13 +3619,13 @@ static int32_t mnodeCompactChildTables() {
};
};
//mInfo("compact child %" PRIu64 ":%d", pTable->uid, pTable->tid);
//mInfo("compact child %" PRIu64 ":%d", pTable->uid, pTable->tid);
sdbInsertCompactRow
(
&
row
);
sdbInsertCompactRow
(
&
row
);
}
}
mInfo
(
"end to compact child table..."
);
mInfo
(
"end to compact child table..."
);
return
0
;
return
0
;
}
}
int32_t
mnodeCompactTables
()
{
int32_t
mnodeCompactTables
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录