Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
adminstrot
TDengine
提交
13d3d4c7
TDengine
项目概览
adminstrot
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
13d3d4c7
编写于
7月 16, 2021
作者:
W
wpan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add set sub tbname
上级
09698c15
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
1 deletion
+60
-1
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+59
-1
src/inc/taos.h
src/inc/taos.h
+1
-0
未找到文件。
src/client/src/tscPrepare.c
浏览文件 @
13d3d4c7
...
@@ -47,6 +47,7 @@ typedef struct SNormalStmt {
...
@@ -47,6 +47,7 @@ typedef struct SNormalStmt {
typedef
struct
SMultiTbStmt
{
typedef
struct
SMultiTbStmt
{
bool
nameSet
;
bool
nameSet
;
bool
tagSet
;
bool
tagSet
;
bool
subSet
;
uint64_t
currentUid
;
uint64_t
currentUid
;
char
*
sqlstr
;
char
*
sqlstr
;
uint32_t
tbNum
;
uint32_t
tbNum
;
...
@@ -1522,6 +1523,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
...
@@ -1522,6 +1523,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long 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
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
int32_t
code
=
0
;
if
(
stmt
==
NULL
||
pStmt
->
pSql
==
NULL
||
pStmt
->
taos
==
NULL
)
{
if
(
stmt
==
NULL
||
pStmt
->
pSql
==
NULL
||
pStmt
->
taos
==
NULL
)
{
STMT_RET
(
TSDB_CODE_TSC_DISCONNECTED
);
STMT_RET
(
TSDB_CODE_TSC_DISCONNECTED
);
...
@@ -1566,6 +1568,52 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
...
@@ -1566,6 +1568,52 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
STMT_RET
(
TSDB_CODE_SUCCESS
);
STMT_RET
(
TSDB_CODE_SUCCESS
);
}
}
if
(
pStmt
->
mtb
.
subSet
&&
taosHashGetSize
(
pStmt
->
mtb
.
pTableHash
)
>
0
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
0
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
char
sTableName
[
TSDB_TABLE_FNAME_LEN
];
strncpy
(
sTableName
,
pTableMeta
->
sTableName
,
sizeof
(
sTableName
));
SStrToken
tname
=
{
0
};
tname
.
type
=
TK_STRING
;
tname
.
z
=
(
char
*
)
name
;
tname
.
n
=
strlen
(
name
);
SName
fullname
=
{
0
};
tscSetTableFullName
(
&
fullname
,
&
tname
,
pSql
);
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
STMT_RET
(
code
);
}
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
strcmp
(
sTableName
,
pTableMeta
->
sTableName
))
{
tscError
(
"0x%"
PRIx64
" only tables belongs to one stable is allowed"
,
pSql
->
self
);
STMT_RET
(
TSDB_CODE_TSC_APP_ERROR
);
}
memcpy
(
&
pTableMetaInfo
->
name
,
&
fullname
,
sizeof
(
fullname
));
STableDataBlocks
*
pBlock
=
NULL
;
code
=
tscGetDataBlockFromList
(
pCmd
->
insertParam
.
pTableBlockHashList
,
pTableMeta
->
id
.
uid
,
TSDB_PAYLOAD_SIZE
,
sizeof
(
SSubmitBlk
),
pTableMeta
->
tableInfo
.
rowSize
,
&
pTableMetaInfo
->
name
,
pTableMeta
,
&
pBlock
,
NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
STMT_RET
(
code
);
}
SSubmitBlk
*
blk
=
(
SSubmitBlk
*
)
pBlock
->
pData
;
blk
->
numOfRows
=
0
;
pStmt
->
mtb
.
currentUid
=
pTableMeta
->
id
.
uid
;
pStmt
->
mtb
.
tbNum
++
;
taosHashPut
(
pStmt
->
mtb
.
pTableBlockHashList
,
(
void
*
)
&
pStmt
->
mtb
.
currentUid
,
sizeof
(
pStmt
->
mtb
.
currentUid
),
(
void
*
)
&
pBlock
,
POINTER_BYTES
);
taosHashPut
(
pStmt
->
mtb
.
pTableHash
,
name
,
strlen
(
name
),
(
char
*
)
&
pTableMeta
->
id
.
uid
,
sizeof
(
pTableMeta
->
id
.
uid
));
tscDebug
(
"0x%"
PRIx64
" table:%s is prepared, uid:%"
PRIx64
,
pSql
->
self
,
name
,
pStmt
->
mtb
.
currentUid
);
STMT_RET
(
TSDB_CODE_SUCCESS
);
}
if
(
pStmt
->
mtb
.
tagSet
)
{
if
(
pStmt
->
mtb
.
tagSet
)
{
pStmt
->
mtb
.
tbname
=
tscReplaceStrToken
(
&
pSql
->
sqlstr
,
&
pStmt
->
mtb
.
tbname
,
name
);
pStmt
->
mtb
.
tbname
=
tscReplaceStrToken
(
&
pSql
->
sqlstr
,
&
pStmt
->
mtb
.
tbname
,
name
);
}
else
{
}
else
{
...
@@ -1594,7 +1642,7 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
...
@@ -1594,7 +1642,7 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
pCmd
->
insertParam
.
pTableBlockHashList
=
hashList
;
pCmd
->
insertParam
.
pTableBlockHashList
=
hashList
;
}
}
int32_t
code
=
tsParseSql
(
pStmt
->
pSql
,
true
);
code
=
tsParseSql
(
pStmt
->
pSql
,
true
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
// wait for the callback function to post the semaphore
// wait for the callback function to post the semaphore
tsem_wait
(
&
pStmt
->
pSql
->
rspSem
);
tsem_wait
(
&
pStmt
->
pSql
->
rspSem
);
...
@@ -1629,7 +1677,17 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
...
@@ -1629,7 +1677,17 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
}
}
int
taos_stmt_set_sub_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
pStmt
->
mtb
.
subSet
=
true
;
return
taos_stmt_set_tbname_tags
(
stmt
,
name
,
NULL
);
}
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
)
{
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
pStmt
->
mtb
.
subSet
=
false
;
return
taos_stmt_set_tbname_tags
(
stmt
,
name
,
NULL
);
return
taos_stmt_set_tbname_tags
(
stmt
,
name
,
NULL
);
}
}
...
...
src/inc/taos.h
浏览文件 @
13d3d4c7
...
@@ -114,6 +114,7 @@ TAOS_STMT *taos_stmt_init(TAOS *taos);
...
@@ -114,6 +114,7 @@ TAOS_STMT *taos_stmt_init(TAOS *taos);
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
);
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
);
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
int
taos_stmt_set_sub_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
int
taos_stmt_is_insert
(
TAOS_STMT
*
stmt
,
int
*
insert
);
int
taos_stmt_is_insert
(
TAOS_STMT
*
stmt
,
int
*
insert
);
int
taos_stmt_num_params
(
TAOS_STMT
*
stmt
,
int
*
nums
);
int
taos_stmt_num_params
(
TAOS_STMT
*
stmt
,
int
*
nums
);
int
taos_stmt_get_param
(
TAOS_STMT
*
stmt
,
int
idx
,
int
*
type
,
int
*
bytes
);
int
taos_stmt_get_param
(
TAOS_STMT
*
stmt
,
int
idx
,
int
*
type
,
int
*
bytes
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录