Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
846704de
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
846704de
编写于
8月 06, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-473]
上级
321f7b27
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
28 deletion
+37
-28
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+5
-4
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+32
-24
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
846704de
...
...
@@ -80,8 +80,9 @@ typedef struct STableMetaInfo {
* 2. keep the vgroup index for multi-vnode insertion
*/
int32_t
vgroupIndex
;
char
name
[
TSDB_TABLE_ID_LEN
];
// (super) table name
SArray
*
tagColList
;
// SArray<SColumn*>, involved tag columns
char
name
[
TSDB_TABLE_FNAME_LEN
];
// (super) table name
char
aliasName
[
TSDB_TABLE_NAME_LEN
];
// alias name of table specified in query sql
SArray
*
tagColList
;
// SArray<SColumn*>, involved tag columns
}
STableMetaInfo
;
/* the structure for sql function in select clause */
...
...
@@ -128,7 +129,7 @@ typedef struct SCond {
}
SCond
;
typedef
struct
SJoinNode
{
char
tableId
[
TSDB_TABLE_
ID
_LEN
];
char
tableId
[
TSDB_TABLE_
FNAME
_LEN
];
uint64_t
uid
;
int16_t
tagColId
;
}
SJoinNode
;
...
...
@@ -162,7 +163,7 @@ typedef struct SParamInfo {
}
SParamInfo
;
typedef
struct
STableDataBlocks
{
char
tableId
[
TSDB_TABLE_
ID
_LEN
];
char
tableId
[
TSDB_TABLE_
FNAME
_LEN
];
int8_t
tsSource
;
// where does the UNIX timestamp come from, server or client
bool
ordered
;
// if current rows are ordered or not
int64_t
vgId
;
// virtual group id
...
...
src/client/src/tscSQLParser.c
浏览文件 @
846704de
...
...
@@ -1087,11 +1087,11 @@ int32_t setObjFullName(char* fullName, const char* account, SSQLToken* pDB, SSQL
*
xlen
=
totalLen
;
}
if
(
totalLen
<
TSDB_TABLE_
ID
_LEN
)
{
if
(
totalLen
<
TSDB_TABLE_
FNAME
_LEN
)
{
fullName
[
totalLen
]
=
0
;
}
return
(
totalLen
<
TSDB_TABLE_
ID
_LEN
)
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_TSC_INVALID_SQL
;
return
(
totalLen
<
TSDB_TABLE_
FNAME
_LEN
)
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_TSC_INVALID_SQL
;
}
static
void
extractColumnNameFromString
(
tSQLExprItem
*
pItem
)
{
...
...
@@ -2136,13 +2136,10 @@ int32_t getTableIndexImpl(SSQLToken* pTableToken, SQueryInfo* pQueryInfo, SColum
}
pIndex
->
tableIndex
=
COLUMN_INDEX_INITIAL_VAL
;
char
tableName
[
TSDB_TABLE_ID_LEN
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
numOfTables
;
++
i
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
i
);
extractTableName
(
pTableMetaInfo
->
name
,
tableName
);
if
(
strncasecmp
(
tableName
,
pTableToken
->
z
,
pTableToken
->
n
)
==
0
&&
strlen
(
tableName
)
==
pTableToken
->
n
)
{
char
*
name
=
pTableMetaInfo
->
aliasName
;
if
(
strncasecmp
(
name
,
pTableToken
->
z
,
pTableToken
->
n
)
==
0
&&
strlen
(
name
)
==
pTableToken
->
n
)
{
pIndex
->
tableIndex
=
i
;
break
;
}
...
...
@@ -3658,7 +3655,7 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
SStringBuilder
sb1
;
memset
(
&
sb1
,
0
,
sizeof
(
sb1
));
taosStringBuilderAppendStringLen
(
&
sb1
,
QUERY_COND_REL_PREFIX_IN
,
QUERY_COND_REL_PREFIX_IN_LEN
);
char
db
[
TSDB_TABLE_
ID
_LEN
]
=
{
0
};
char
db
[
TSDB_TABLE_
FNAME
_LEN
]
=
{
0
};
// remove the duplicated input table names
int32_t
num
=
0
;
...
...
@@ -3683,7 +3680,7 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
taosStringBuilderAppendStringLen
(
&
sb1
,
TBNAME_LIST_SEP
,
1
);
}
char
idBuf
[
TSDB_TABLE_
ID
_LEN
]
=
{
0
};
char
idBuf
[
TSDB_TABLE_
FNAME
_LEN
]
=
{
0
};
int32_t
xlen
=
strlen
(
segments
[
i
]);
SSQLToken
t
=
{.
z
=
segments
[
i
],
.
n
=
xlen
,
.
type
=
TK_STRING
};
...
...
@@ -5915,15 +5912,16 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
int32_t
doCheckForQuery
(
SSqlObj
*
pSql
,
SQuerySQL
*
pQuerySql
,
int32_t
index
)
{
assert
(
pQuerySql
!=
NULL
&&
(
pQuerySql
->
from
==
NULL
||
pQuerySql
->
from
->
nExpr
>
0
));
const
char
*
msg0
=
"invalid table name"
;
const
char
*
msg1
=
"table name too long"
;
const
char
*
msg2
=
"point interpolation query needs timestamp"
;
const
char
*
msg5
=
"fill only available for interval query"
;
const
char
*
msg6
=
"start(end) time of query range required or time range too large"
;
const
char
*
msg7
=
"illegal number of tables in from clause"
;
const
char
*
msg8
=
"too many columns in selection clause"
;
const
char
*
msg9
=
"TWA query requires both the start and end time"
;
const
char
*
msg10
=
"too many tables in from clause"
;
const
char
*
msg0
=
"invalid table name"
;
const
char
*
msg1
=
"table name too long"
;
const
char
*
msg2
=
"point interpolation query needs timestamp"
;
const
char
*
msg5
=
"fill only available for interval query"
;
const
char
*
msg6
=
"start(end) time of query range required or time range too large"
;
const
char
*
msg7
=
"illegal number of tables in from clause"
;
const
char
*
msg8
=
"too many columns in selection clause"
;
const
char
*
msg9
=
"TWA query requires both the start and end time"
;
const
char
*
msg10
=
"too many tables in from clause"
;
const
char
*
msg11
=
"invalid table alias name"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -5966,7 +5964,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
}
// set all query tables, which are maybe more than one.
for
(
int32_t
i
=
0
;
i
<
pQuerySql
->
from
->
nExpr
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQuerySql
->
from
->
nExpr
;
)
{
tVariant
*
pTableItem
=
&
pQuerySql
->
from
->
a
[
i
].
pVar
;
if
(
pTableItem
->
nType
!=
TSDB_DATA_TYPE_BINARY
)
{
...
...
@@ -5980,24 +5978,34 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg0
);
}
if
(
pQueryInfo
->
numOfTables
<=
i
)
{
// more than one table
if
(
pQueryInfo
->
numOfTables
<=
i
/
2
)
{
// more than one table
tscAddEmptyMetaInfo
(
pQueryInfo
);
}
STableMetaInfo
*
p
Meter
Info1
=
tscGetMetaInfo
(
pQueryInfo
,
i
);
STableMetaInfo
*
p
TableMeta
Info1
=
tscGetMetaInfo
(
pQueryInfo
,
i
);
SSQLToken
t
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
n
=
pTableItem
->
nLen
,
.
z
=
pTableItem
->
pz
};
if
(
tscSetTableFullName
(
p
Meter
Info1
,
&
t
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscSetTableFullName
(
p
TableMeta
Info1
,
&
t
,
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
code
=
tscGetTableMeta
(
pSql
,
pMeterInfo1
);
tVariant
*
pTableItem1
=
&
pQuerySql
->
from
->
a
[
i
+
1
].
pVar
;
SSQLToken
aliasName
=
{.
z
=
pTableItem1
->
pz
,
.
n
=
pTableItem1
->
nLen
,
.
type
=
TK_STRING
};
if
(
tscValidateName
(
&
aliasName
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg11
);
}
tstrncpy
(
pTableMetaInfo1
->
aliasName
,
pTableItem1
->
pz
,
sizeof
(
pTableMetaInfo1
->
aliasName
));
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
i
+=
2
;
}
assert
(
pQueryInfo
->
numOfTables
==
pQuerySql
->
from
->
nExpr
);
assert
(
pQueryInfo
->
numOfTables
==
pQuerySql
->
from
->
nExpr
/
2
);
bool
isSTable
=
false
;
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录