Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d57ecd97
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
d57ecd97
编写于
4月 13, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stmt
上级
d04c0bc4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
174 addition
and
34 deletion
+174
-34
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
+6
-0
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+16
-3
未找到文件。
source/client/inc/clientStmt.h
0 → 100644
浏览文件 @
d57ecd97
/*
* 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
浏览文件 @
d57ecd97
...
...
@@ -559,76 +559,149 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
}
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
// TODO
return
NULL
;
if
(
taos
==
NULL
)
{
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
NULL
;
}
return
stmtInit
(
taos
);
}
int
taos_stmt_close
(
TAOS_STMT
*
stmt
)
{
// TODO
return
-
1
;
if
(
stmt
==
NULL
)
{
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtClose
(
stmt
);
}
int
taos_stmt_execute
(
TAOS_STMT
*
stmt
)
{
// TODO
return
-
1
;
if
(
stmt
==
NULL
)
{
tscError
(
"NULL parameter for %s"
,
__FUNC__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
return
stmtExec
(
stmt
);
}
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
)
{
// TODO
return
NULL
;
if
(
stmt
==
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
)
{
// TODO
return
-
1
;
}
if
(
stmt
==
NULL
)
{
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
)
{
// TODO
return
NULL
;
return
stmtAffectedRows
(
stmt
);
}
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_BIND
*
bind
)
{
// TODO
return
-
1
;
if
(
stmt
==
NULL
||
bind
==
NULL
)
{
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
)
{
// TODO
return
-
1
;
if
(
stmt
==
NULL
||
sql
==
NULL
)
{
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
)
{
// TODO
return
-
1
;
if
(
stmt
==
NULL
||
name
==
NULL
||
tags
==
NULL
)
{
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
)
{
// TODO
return
-
1
;
if
(
stmt
==
NULL
||
name
==
NULL
)
{
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
)
{
// TODO
return
-
1
;
if
(
stmt
==
NULL
||
insert
==
NULL
)
{
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
)
{
// TODO
return
-
1
;
if
(
stmt
==
NULL
||
nums
==
NULL
)
{
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
)
{
// TODO
return
-
1
;
if
(
stmt
==
NULL
)
{
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
)
{
// TODO
return
NULL
;
if
(
stmt
==
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
)
{
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
return
-
1
;
return
NULL
;
}
source/client/src/clientStmt.c
0 → 100644
浏览文件 @
d57ecd97
#include "clientInt.h"
#include "clientLog.h"
#include "tdef.h"
source/libs/parser/src/parInsert.c
浏览文件 @
d57ecd97
...
...
@@ -223,11 +223,15 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
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
;
SName
name
=
{
0
};
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
;
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
)));
...
...
@@ -235,6 +239,15 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) {
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
)
{
while
(
start
<
end
)
{
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)
SToken
sToken
;
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
CHECK_CODE
(
getTableMeta
(
pCxt
,
&
sToken
));
CHECK_CODE
(
get
S
TableMeta
(
pCxt
,
&
sToken
));
if
(
TSDB_SUPER_TABLE
!=
pCxt
->
pTableMeta
->
tableType
)
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录