Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
36244066
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
36244066
编写于
4月 13, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/feature/qnode3' into feature/qnode
上级
3bc95502
d57ecd97
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
168 addition
and
35 deletion
+168
-35
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+48
-0
source/client/src/clientMain.c
source/client/src/clientMain.c
+104
-31
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+0
-1
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+16
-3
未找到文件。
source/client/inc/clientStmt.h
0 → 100644
浏览文件 @
36244066
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_CLIENTSTMT_H
#define TDENGINE_CLIENTSTMT_H
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
enum
{
STMT_TYPE_INSERT
=
1
,
STMT_TYPE_MULTI_INSERT
,
STMT_TYPE_QUERY
,
}
STMT_TYPE
;
typedef
struct
STscStmt
{
STMT_TYPE
type
;
int16_t
last
;
STscObj
*
taos
;
SSqlObj
*
pSql
;
SMultiTbStmt
mtb
;
SNormalStmt
normal
;
int
numOfRows
;
}
STscStmt
;
#define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_CLIENTSTMT_H
source/client/src/clientMain.c
浏览文件 @
36244066
...
@@ -559,76 +559,149 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
...
@@ -559,76 +559,149 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
}
}
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
// TODO
if
(
taos
==
NULL
)
{
return
NULL
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
NULL
;
}
return
stmtInit
(
taos
);
}
}
int
taos_stmt_close
(
TAOS_STMT
*
stmt
)
{
int
taos_stmt_close
(
TAOS_STMT
*
stmt
)
{
// TODO
if
(
stmt
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtClose
(
stmt
);
}
}
int
taos_stmt_execute
(
TAOS_STMT
*
stmt
)
{
int
taos_stmt_execute
(
TAOS_STMT
*
stmt
)
{
// TODO
if
(
stmt
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtExec
(
stmt
);
}
}
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
)
{
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
)
{
// TODO
if
(
stmt
==
NULL
)
{
return
NULL
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
NULL
;
}
return
stmtErrstr
(
stmt
);
}
}
int
taos_stmt_affected_rows
(
TAOS_STMT
*
stmt
)
{
int
taos_stmt_affected_rows
(
TAOS_STMT
*
stmt
)
{
// TODO
if
(
stmt
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
}
terrno
=
TSDB_CODE_INVALID_PARA
;
return
0
;
}
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
return
stmtAffectedRows
(
stmt
);
// TODO
return
NULL
;
}
}
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_BIND
*
bind
)
{
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_BIND
*
bind
)
{
// TODO
if
(
stmt
==
NULL
||
bind
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtBind
(
stmt
,
bind
);
}
}
int
taos_stmt_prepare
(
TAOS_STMT
*
stmt
,
const
char
*
sql
,
unsigned
long
length
)
{
int
taos_stmt_prepare
(
TAOS_STMT
*
stmt
,
const
char
*
sql
,
unsigned
long
length
)
{
// TODO
if
(
stmt
==
NULL
||
sql
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtPrepare
(
stmt
,
sql
,
length
);
}
}
int
taos_stmt_set_tbname_tags
(
TAOS_STMT
*
stmt
,
const
char
*
name
,
TAOS_BIND
*
tags
)
{
int
taos_stmt_set_tbname_tags
(
TAOS_STMT
*
stmt
,
const
char
*
name
,
TAOS_BIND
*
tags
)
{
// TODO
if
(
stmt
==
NULL
||
name
==
NULL
||
tags
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtSetTbNameTags
(
stmt
,
name
,
tags
);
}
}
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
)
{
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
)
{
// TODO
if
(
stmt
==
NULL
||
name
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtSetTbNameTags
(
stmt
,
name
,
NULL
);
}
}
int
taos_stmt_is_insert
(
TAOS_STMT
*
stmt
,
int
*
insert
)
{
int
taos_stmt_is_insert
(
TAOS_STMT
*
stmt
,
int
*
insert
)
{
// TODO
if
(
stmt
==
NULL
||
insert
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtIsInsert
(
stmt
,
insert
);
}
}
int
taos_stmt_num_params
(
TAOS_STMT
*
stmt
,
int
*
nums
)
{
int
taos_stmt_num_params
(
TAOS_STMT
*
stmt
,
int
*
nums
)
{
// TODO
if
(
stmt
==
NULL
||
nums
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtGetParamNum
(
stmt
,
nums
);
}
}
int
taos_stmt_add_batch
(
TAOS_STMT
*
stmt
)
{
int
taos_stmt_add_batch
(
TAOS_STMT
*
stmt
)
{
// TODO
if
(
stmt
==
NULL
)
{
return
-
1
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtAddBatch
(
stmt
);
}
}
TAOS_RES
*
taos_stmt_use_result
(
TAOS_STMT
*
stmt
)
{
TAOS_RES
*
taos_stmt_use_result
(
TAOS_STMT
*
stmt
)
{
// TODO
if
(
stmt
==
NULL
)
{
return
NULL
;
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtUseResult
(
stmt
);
}
}
int
taos_stmt_bind_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
)
{
int
taos_stmt_bind_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
)
{
if
(
stmt
==
NULL
||
bind
==
NULL
)
{
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtBindBatch
(
stmt
,
bind
);
}
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
// TODO
// TODO
return
-
1
;
return
NULL
;
}
}
source/client/src/clientStmt.c
浏览文件 @
36244066
...
@@ -46,4 +46,3 @@ TAOS_STMT *stmtInit(TAOS *taos) {
...
@@ -46,4 +46,3 @@ TAOS_STMT *stmtInit(TAOS *taos) {
return
pStmt
;
return
pStmt
;
}
}
source/libs/parser/src/parInsert.c
浏览文件 @
36244066
...
@@ -223,11 +223,15 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
...
@@ -223,11 +223,15 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
return
code
;
return
code
;
}
}
static
int32_t
getTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
static
int32_t
getTableMeta
Impl
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
,
bool
isStb
)
{
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SName
name
=
{
0
};
SName
name
=
{
0
};
createSName
(
&
name
,
pTname
,
pBasicCtx
,
&
pCxt
->
msg
);
createSName
(
&
name
,
pTname
,
pBasicCtx
,
&
pCxt
->
msg
);
CHECK_CODE
(
catalogGetTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
if
(
isStb
)
{
CHECK_CODE
(
catalogGetSTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
}
else
{
CHECK_CODE
(
catalogGetTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
}
SVgroupInfo
vg
;
SVgroupInfo
vg
;
CHECK_CODE
(
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
vg
));
CHECK_CODE
(
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
vg
));
CHECK_CODE
(
taosHashPut
(
pCxt
->
pVgroupsHashObj
,
(
const
char
*
)
&
vg
.
vgId
,
sizeof
(
vg
.
vgId
),
(
char
*
)
&
vg
,
sizeof
(
vg
)));
CHECK_CODE
(
taosHashPut
(
pCxt
->
pVgroupsHashObj
,
(
const
char
*
)
&
vg
.
vgId
,
sizeof
(
vg
.
vgId
),
(
char
*
)
&
vg
,
sizeof
(
vg
)));
...
@@ -235,6 +239,15 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
...
@@ -235,6 +239,15 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
getTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
return
getTableMetaImpl
(
pCxt
,
pTname
,
false
);
}
static
int32_t
getSTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
return
getTableMetaImpl
(
pCxt
,
pTname
,
true
);
}
static
int32_t
findCol
(
SToken
*
pColname
,
int32_t
start
,
int32_t
end
,
SSchema
*
pSchema
)
{
static
int32_t
findCol
(
SToken
*
pColname
,
int32_t
start
,
int32_t
end
,
SSchema
*
pSchema
)
{
while
(
start
<
end
)
{
while
(
start
<
end
)
{
if
(
strlen
(
pSchema
[
start
].
name
)
==
pColname
->
n
&&
strncmp
(
pColname
->
z
,
pSchema
[
start
].
name
,
pColname
->
n
)
==
0
)
{
if
(
strlen
(
pSchema
[
start
].
name
)
==
pColname
->
n
&&
strncmp
(
pColname
->
z
,
pSchema
[
start
].
name
,
pColname
->
n
)
==
0
)
{
...
@@ -811,7 +824,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken)
...
@@ -811,7 +824,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken)
SToken
sToken
;
SToken
sToken
;
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
CHECK_CODE
(
getTableMeta
(
pCxt
,
&
sToken
));
CHECK_CODE
(
get
S
TableMeta
(
pCxt
,
&
sToken
));
if
(
TSDB_SUPER_TABLE
!=
pCxt
->
pTableMeta
->
tableType
)
{
if
(
TSDB_SUPER_TABLE
!=
pCxt
->
pTableMeta
->
tableType
)
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"create table only from super table is allowed"
);
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"create table only from super table is allowed"
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录