Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1c499c94
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看板
提交
1c499c94
编写于
4月 16, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stmt
上级
9547c0a0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
94 addition
and
23 deletion
+94
-23
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+0
-6
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+18
-9
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+26
-7
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+50
-1
未找到文件。
source/client/inc/clientStmt.h
浏览文件 @
1c499c94
...
...
@@ -51,7 +51,6 @@ typedef struct SStmtBindInfo {
void
*
boundTags
;
char
*
tbName
;
SName
sname
;
TAOS_BIND
*
bindTags
;
}
SStmtBindInfo
;
typedef
struct
SStmtExecInfo
{
...
...
@@ -78,11 +77,6 @@ typedef struct STscStmt {
SStmtSQLInfo
sql
;
SStmtExecInfo
exec
;
SStmtBindInfo
bind
;
//SMultiTbStmt mtb;
//SNormalStmt normal;
//int numOfRows;
}
STscStmt
;
...
...
source/client/src/clientStmt.c
浏览文件 @
1c499c94
...
...
@@ -85,7 +85,7 @@ void stmtResetDataBlock(STableDataBlocks* pBlock) {
pBlock
->
size
=
sizeof
(
SSubmitBlk
);
pBlock
->
tsSource
=
-
1
;
pBlock
->
numOfTables
=
1
;
pBlock
->
nAllocSize
=
0
;
pBlock
->
nAllocSize
=
TSDB_PAYLOAD_SIZE
;
pBlock
->
headerSize
=
pBlock
->
size
;
memset
(
&
pBlock
->
rowBuilder
,
0
,
sizeof
(
pBlock
->
rowBuilder
));
...
...
@@ -237,6 +237,12 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
STableDataBlocks
*
pNewBlock
=
NULL
;
STMT_ERR_RET
(
stmtCloneDataBlock
(
&
pNewBlock
,
pCache
->
pDataBlock
));
pNewBlock
->
pData
=
taosMemoryMalloc
(
pNewBlock
->
nAllocSize
);
if
(
NULL
==
pNewBlock
->
pData
)
{
stmtFreeDataBlock
(
pNewBlock
);
STMT_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
if
(
taosHashPut
(
pStmt
->
exec
.
pBlockHash
,
&
pStmt
->
bind
.
tbUid
,
sizeof
(
pStmt
->
bind
.
tbUid
),
&
pNewBlock
,
POINTER_BYTES
))
{
STMT_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
...
...
@@ -284,7 +290,7 @@ int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
}
int
stmtSetTbName
(
TAOS_STMT
*
stmt
,
const
char
*
tbName
,
TAOS_BIND
*
tags
)
{
int
stmtSetTbName
(
TAOS_STMT
*
stmt
,
const
char
*
tbName
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_SWITCH_STATUS
(
stmt
,
STMT_SETTBNAME
,
TSDB_CODE_TSC_STMT_API_ERROR
);
...
...
@@ -304,20 +310,23 @@ int stmtSetTbName(TAOS_STMT *stmt, const char *tbName, TAOS_BIND *tags) {
return
TSDB_CODE_SUCCESS
;
}
int
stmtSetTbTags
(
TAOS_STMT
*
stmt
,
const
char
*
tbName
,
TAOS_BIND
*
tags
)
{
int
stmtSetTbTags
(
TAOS_STMT
*
stmt
,
TAOS_BIND
*
tags
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_SWITCH_STATUS
(
stmt
,
STMT_SETTBNAME
,
TSDB_CODE_TSC_STMT_API_ERROR
);
if
(
pStmt
->
bind
.
needParse
)
{
taosMemoryFree
(
pStmt
->
bind
.
bindTags
);
pStmt
->
bind
.
bindTags
=
tags
;
STMT_ERR_RET
(
stmtParseSql
(
pStmt
));
}
else
{
//TODO BIND TAG DATA
}
STableDataBlocks
*
pDataBlock
=
(
STableDataBlocks
**
)
taosHashGet
(
pStmt
->
exec
.
pBlockHash
,
(
const
char
*
)
&
pStmt
->
bind
.
tbUid
,
sizeof
(
pStmt
->
bind
.
tbUid
));
if
(
NULL
==
pDataBlock
)
{
tscError
(
"table uid %"
PRIx64
"not found in exec blockHash"
,
pStmt
->
bind
.
tbUid
);
STMT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
STMT_ERR_RET
(
qBindStmtTagsValue
(
pDataBlock
,
pStmt
->
bind
.
boundTags
,
pStmt
->
bind
.
tbSuid
,
&
pStmt
->
bind
.
sname
,
tags
,
pStmt
->
exec
.
pRequest
->
msgBuf
,
pStmt
->
exec
.
pRequest
->
msgBufLen
));
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -395,7 +404,7 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
STMT_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
qBindStmt
Data
(
pDataBlock
,
bind
,
pStmt
->
exec
.
pRequest
->
msgBuf
,
pStmt
->
exec
.
pRequest
->
msgBufLen
);
qBindStmt
ColsValue
(
pDataBlock
,
bind
,
pStmt
->
exec
.
pRequest
->
msgBuf
,
pStmt
->
exec
.
pRequest
->
msgBufLen
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
1c499c94
...
...
@@ -753,14 +753,14 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void *value, int32_t len, voi
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
buildCreateTbReq
(
S
InsertParseContext
*
pCxt
,
const
SName
*
pName
,
SKVRow
row
)
{
static
int32_t
buildCreateTbReq
(
S
VCreateTbReq
*
pTbReq
,
const
SName
*
pName
,
SKVRow
row
,
int64_t
suid
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pName
,
dbFName
);
p
Cxt
->
createTblReq
.
type
=
TD_CHILD_TABLE
;
p
Cxt
->
createTblReq
.
dbFName
=
strdup
(
dbFName
);
p
Cxt
->
createTblReq
.
name
=
strdup
(
pName
->
tname
);
p
Cxt
->
createTblReq
.
ctbCfg
.
suid
=
pCxt
->
pTableMeta
->
suid
;
p
Cxt
->
createTblReq
.
ctbCfg
.
pTag
=
row
;
p
TbReq
->
type
=
TD_CHILD_TABLE
;
p
TbReq
->
dbFName
=
strdup
(
dbFName
);
p
TbReq
->
name
=
strdup
(
pName
->
tname
);
p
TbReq
->
ctbCfg
.
suid
=
suid
;
p
TbReq
->
ctbCfg
.
pTag
=
row
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -773,21 +773,40 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
SKvParam
param
=
{.
builder
=
&
pCxt
->
tagsBuilder
};
SToken
sToken
;
bool
isParseBindParam
=
false
;
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
for
(
int
i
=
0
;
i
<
pCxt
->
tags
.
numOfBound
;
++
i
)
{
NEXT_TOKEN_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
if
(
sToken
.
type
==
TK_NK_QUESTION
)
{
isParseBindParam
=
true
;
if
(
NULL
==
pCxt
->
pStmtCb
)
{
return
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"? only used in stmt"
,
sToken
.
z
);
}
continue
;
}
if
(
isParseBindParam
)
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"no mix usage for ? and tag values"
);
}
SSchema
*
pTagSchema
=
&
pSchema
[
pCxt
->
tags
.
boundColumns
[
i
]
-
1
];
// colId starts with 1
param
.
schema
=
pTagSchema
;
CHECK_CODE
(
parseValueToken
(
&
pCxt
->
pSql
,
&
sToken
,
pTagSchema
,
precision
,
tmpTokenBuf
,
KvRowAppend
,
&
param
,
&
pCxt
->
msg
));
}
if
(
isParseBindParam
)
{
return
TSDB_CODE_SUCCESS
;
}
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
pCxt
->
tagsBuilder
);
if
(
NULL
==
row
)
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"tag value expected"
);
}
tdSortKVRowByColIdx
(
row
);
return
buildCreateTbReq
(
pCxt
,
pName
,
row
);
return
buildCreateTbReq
(
&
pCxt
->
createTblReq
,
pName
,
row
,
pCxt
->
pTableMeta
->
suid
);
}
static
int32_t
cloneTableMeta
(
STableMeta
*
pSrc
,
STableMeta
**
pDst
)
{
...
...
source/libs/parser/src/parser.c
浏览文件 @
1c499c94
...
...
@@ -77,8 +77,57 @@ int32_t qCreateSName(SName* pName, char* pTableName, int32_t acctId, char* dbNam
return
TSDB_CODE_SUCCESS
;
}
int32_t
qBindStmtTagsValue
(
STableDataBlocks
*
pDataBlock
,
void
*
boundTags
,
int64_t
suid
,
SName
*
pName
,
TAOS_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
){
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SParsedDataColInfo
*
tags
=
(
SParsedDataColInfo
*
)
boundTags
;
if
(
NULL
==
tags
)
{
return
TSDB_CODE_QRY_APP_ERROR
;
}
SKVRowBuilder
tagBuilder
;
if
(
tdInitKVRowBuilder
(
&
tagBuilder
)
<
0
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SSchema
*
pSchema
=
getTableTagSchema
(
pDataBlock
->
pTableMeta
);
SKvParam
param
=
{.
builder
=
&
tagBuilder
};
for
(
int
c
=
0
;
c
<
tags
->
numOfBound
;
++
c
)
{
if
(
bind
[
c
].
is_null
&&
bind
[
c
].
is_null
[
0
])
{
KvRowAppend
(
&
pBuf
,
NULL
,
0
,
&
param
);
continue
;
}
SSchema
*
pTagSchema
=
&
pSchema
[
tags
->
boundColumns
[
c
]
-
1
];
// colId starts with 1
param
.
schema
=
pTagSchema
;
int32_t
colLen
=
pTagSchema
->
bytes
;
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
colLen
=
bind
[
c
].
length
[
0
];
}
CHECK_CODE
(
KvRowAppend
(
&
pBuf
,
(
char
*
)
bind
[
c
].
buffer
,
colLen
,
&
param
));
}
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
tagBuilder
);
if
(
NULL
==
row
)
{
tdDestroyKVRowBuilder
(
&
tagBuilder
);
return
buildInvalidOperationMsg
(
&
pBuf
,
"tag value expected"
);
}
tdSortKVRowByColIdx
(
row
);
SVCreateTbReq
tbReq
=
{
0
};
CHECK_CODE
(
buildCreateTbReq
(
&
tbReq
,
pName
,
row
,
suid
));
CHECK_CODE
(
buildCreateTbMsg
(
pDataBlock
,
&
tbReq
));
destroyCreateSubTbReq
(
&
tbReq
);
tdDestroyKVRowBuilder
(
&
tagBuilder
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
qBindStmt
Data
(
STableDataBlocks
*
pDataBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
int32_t
qBindStmt
ColsValue
(
STableDataBlocks
*
pDataBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
SSchema
*
pSchema
=
getTableColumnSchema
(
pDataBlock
->
pTableMeta
);
int32_t
extendedRowSize
=
getExtendedRowSize
(
pDataBlock
);
SParsedDataColInfo
*
spd
=
&
pDataBlock
->
boundColumnInfo
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录