Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
be29bb0d
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
be29bb0d
编写于
11月 23, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18364 from taosdata/fix/3.0_bugfix_wxy
some problems of insert parser
上级
1a12fa92
937e5d20
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
30 addition
and
18 deletion
+30
-18
source/libs/parser/src/parInsertSql.c
source/libs/parser/src/parInsertSql.c
+30
-18
未找到文件。
source/libs/parser/src/parInsertSql.c
浏览文件 @
be29bb0d
...
@@ -172,8 +172,8 @@ static int32_t parseDuplicateUsingClause(SInsertParseContext* pCxt, SVnodeModifO
...
@@ -172,8 +172,8 @@ static int32_t parseDuplicateUsingClause(SInsertParseContext* pCxt, SVnodeModifO
}
}
// pStmt->pSql -> field1_name, ...)
// pStmt->pSql -> field1_name, ...)
static
int32_t
parseBoundColumns
(
SInsertParseContext
*
pCxt
,
const
char
**
pSql
,
SParsedDataColInfo
*
pColList
,
static
int32_t
parseBoundColumns
(
SInsertParseContext
*
pCxt
,
const
char
**
pSql
,
bool
isTags
,
SSchema
*
pSchema
)
{
S
ParsedDataColInfo
*
pColList
,
S
Schema
*
pSchema
)
{
col_id_t
nCols
=
pColList
->
numOfCols
;
col_id_t
nCols
=
pColList
->
numOfCols
;
pColList
->
numOfBound
=
0
;
pColList
->
numOfBound
=
0
;
...
@@ -227,6 +227,10 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, S
...
@@ -227,6 +227,10 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, S
}
}
}
}
if
(
!
isTags
&&
pColList
->
cols
[
0
].
valStat
==
VAL_STAT_NONE
)
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"primary timestamp column can not be null"
);
}
pColList
->
orderStatus
=
isOrdered
?
ORDER_STATUS_ORDERED
:
ORDER_STATUS_DISORDERED
;
pColList
->
orderStatus
=
isOrdered
?
ORDER_STATUS_ORDERED
:
ORDER_STATUS_DISORDERED
;
if
(
!
isOrdered
)
{
if
(
!
isOrdered
)
{
...
@@ -525,7 +529,7 @@ static int32_t parseBoundTagsClause(SInsertParseContext* pCxt, SVnodeModifOpStmt
...
@@ -525,7 +529,7 @@ static int32_t parseBoundTagsClause(SInsertParseContext* pCxt, SVnodeModifOpStmt
}
}
pStmt
->
pSql
+=
index
;
pStmt
->
pSql
+=
index
;
return
parseBoundColumns
(
pCxt
,
&
pStmt
->
pSql
,
&
pCxt
->
tags
,
pTagsSchema
);
return
parseBoundColumns
(
pCxt
,
&
pStmt
->
pSql
,
true
,
&
pCxt
->
tags
,
pTagsSchema
);
}
}
static
int32_t
parseTagValue
(
SInsertParseContext
*
pCxt
,
SVnodeModifOpStmt
*
pStmt
,
SSchema
*
pTagSchema
,
SToken
*
pToken
,
static
int32_t
parseTagValue
(
SInsertParseContext
*
pCxt
,
SVnodeModifOpStmt
*
pStmt
,
SSchema
*
pTagSchema
,
SToken
*
pToken
,
...
@@ -792,6 +796,8 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SName* pTbName, bool isSt
...
@@ -792,6 +796,8 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SName* pTbName, bool isSt
*
pMissCache
=
true
;
*
pMissCache
=
true
;
}
else
if
(
isStb
&&
TSDB_SUPER_TABLE
!=
(
*
pTableMeta
)
->
tableType
)
{
}
else
if
(
isStb
&&
TSDB_SUPER_TABLE
!=
(
*
pTableMeta
)
->
tableType
)
{
code
=
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"create table only from super table is allowed"
);
code
=
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"create table only from super table is allowed"
);
}
else
if
(
!
isStb
&&
TSDB_SUPER_TABLE
==
(
*
pTableMeta
)
->
tableType
)
{
code
=
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"insert data into super table is not supported"
);
}
}
}
}
return
code
;
return
code
;
...
@@ -935,11 +941,12 @@ static int32_t parseBoundColumnsClause(SInsertParseContext* pCxt, SVnodeModifOpS
...
@@ -935,11 +941,12 @@ static int32_t parseBoundColumnsClause(SInsertParseContext* pCxt, SVnodeModifOpS
return
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"keyword VALUES or FILE is expected"
,
token
.
z
);
return
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"keyword VALUES or FILE is expected"
,
token
.
z
);
}
}
// pStmt->pSql -> field1_name, ...)
// pStmt->pSql -> field1_name, ...)
return
parseBoundColumns
(
pCxt
,
&
pStmt
->
pSql
,
&
pDataBuf
->
boundColumnInfo
,
getTableColumnSchema
(
pStmt
->
pTableMeta
));
return
parseBoundColumns
(
pCxt
,
&
pStmt
->
pSql
,
false
,
&
pDataBuf
->
boundColumnInfo
,
getTableColumnSchema
(
pStmt
->
pTableMeta
));
}
}
if
(
NULL
!=
pStmt
->
pBoundCols
)
{
if
(
NULL
!=
pStmt
->
pBoundCols
)
{
return
parseBoundColumns
(
pCxt
,
&
pStmt
->
pBoundCols
,
&
pDataBuf
->
boundColumnInfo
,
return
parseBoundColumns
(
pCxt
,
&
pStmt
->
pBoundCols
,
false
,
&
pDataBuf
->
boundColumnInfo
,
getTableColumnSchema
(
pStmt
->
pTableMeta
));
getTableColumnSchema
(
pStmt
->
pTableMeta
));
}
}
...
@@ -1571,16 +1578,16 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt, SVnodeModifOpStmt* pSt
...
@@ -1571,16 +1578,16 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt, SVnodeModifOpStmt* pSt
static
void
destroySubTableHashElem
(
void
*
p
)
{
taosMemoryFree
(
*
(
STableMeta
**
)
p
);
}
static
void
destroySubTableHashElem
(
void
*
p
)
{
taosMemoryFree
(
*
(
STableMeta
**
)
p
);
}
static
int32_t
createVnodeModifOpStmt
(
SParseContext
*
pCxt
,
bool
reentry
,
SNode
**
pOutput
)
{
static
int32_t
createVnodeModifOpStmt
(
S
Insert
ParseContext
*
pCxt
,
bool
reentry
,
SNode
**
pOutput
)
{
SVnodeModifOpStmt
*
pStmt
=
(
SVnodeModifOpStmt
*
)
nodesMakeNode
(
QUERY_NODE_VNODE_MODIF_STMT
);
SVnodeModifOpStmt
*
pStmt
=
(
SVnodeModifOpStmt
*
)
nodesMakeNode
(
QUERY_NODE_VNODE_MODIF_STMT
);
if
(
NULL
==
pStmt
)
{
if
(
NULL
==
pStmt
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
pCxt
->
pStmtCb
)
{
if
(
pCxt
->
p
ComCxt
->
p
StmtCb
)
{
TSDB_QUERY_SET_TYPE
(
pStmt
->
insertType
,
TSDB_QUERY_TYPE_STMT_INSERT
);
TSDB_QUERY_SET_TYPE
(
pStmt
->
insertType
,
TSDB_QUERY_TYPE_STMT_INSERT
);
}
}
pStmt
->
pSql
=
pCxt
->
pSql
;
pStmt
->
pSql
=
pCxt
->
p
ComCxt
->
p
Sql
;
pStmt
->
freeHashFunc
=
insDestroyBlockHashmap
;
pStmt
->
freeHashFunc
=
insDestroyBlockHashmap
;
pStmt
->
freeArrayFunc
=
insDestroyBlockArrayList
;
pStmt
->
freeArrayFunc
=
insDestroyBlockArrayList
;
...
@@ -1604,7 +1611,7 @@ static int32_t createVnodeModifOpStmt(SParseContext* pCxt, bool reentry, SNode**
...
@@ -1604,7 +1611,7 @@ static int32_t createVnodeModifOpStmt(SParseContext* pCxt, bool reentry, SNode**
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
createInsertQuery
(
SParseContext
*
pCxt
,
SQuery
**
pOutput
)
{
static
int32_t
createInsertQuery
(
S
Insert
ParseContext
*
pCxt
,
SQuery
**
pOutput
)
{
SQuery
*
pQuery
=
(
SQuery
*
)
nodesMakeNode
(
QUERY_NODE_QUERY
);
SQuery
*
pQuery
=
(
SQuery
*
)
nodesMakeNode
(
QUERY_NODE_QUERY
);
if
(
NULL
==
pQuery
)
{
if
(
NULL
==
pQuery
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -1667,11 +1674,15 @@ static int32_t getTableVgroupFromMetaData(const SArray* pTables, SVnodeModifOpSt
...
@@ -1667,11 +1674,15 @@ static int32_t getTableVgroupFromMetaData(const SArray* pTables, SVnodeModifOpSt
sizeof
(
SVgroupInfo
));
sizeof
(
SVgroupInfo
));
}
}
static
int32_t
getTableSchemaFromMetaData
(
const
SMetaData
*
pMetaData
,
SVnodeModifOpStmt
*
pStmt
,
bool
isStb
)
{
static
int32_t
getTableSchemaFromMetaData
(
SInsertParseContext
*
pCxt
,
const
SMetaData
*
pMetaData
,
SVnodeModifOpStmt
*
pStmt
,
bool
isStb
)
{
int32_t
code
=
checkAuthFromMetaData
(
pMetaData
->
pUser
);
int32_t
code
=
checkAuthFromMetaData
(
pMetaData
->
pUser
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getTableMetaFromMetaData
(
pMetaData
->
pTableMeta
,
&
pStmt
->
pTableMeta
);
code
=
getTableMetaFromMetaData
(
pMetaData
->
pTableMeta
,
&
pStmt
->
pTableMeta
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
isStb
&&
TSDB_SUPER_TABLE
==
pStmt
->
pTableMeta
->
tableType
)
{
code
=
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"insert data into super table is not supported"
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getTableVgroupFromMetaData
(
pMetaData
->
pTableHash
,
pStmt
,
isStb
);
code
=
getTableVgroupFromMetaData
(
pMetaData
->
pTableHash
,
pStmt
,
isStb
);
}
}
...
@@ -1696,24 +1707,25 @@ static void clearCatalogReq(SCatalogReq* pCatalogReq) {
...
@@ -1696,24 +1707,25 @@ static void clearCatalogReq(SCatalogReq* pCatalogReq) {
pCatalogReq
->
pUser
=
NULL
;
pCatalogReq
->
pUser
=
NULL
;
}
}
static
int32_t
setVnodeModifOpStmt
(
SParseContext
*
pCxt
,
SCatalogReq
*
pCatalogReq
,
const
SMetaData
*
pMetaData
,
static
int32_t
setVnodeModifOpStmt
(
S
Insert
ParseContext
*
pCxt
,
SCatalogReq
*
pCatalogReq
,
const
SMetaData
*
pMetaData
,
SVnodeModifOpStmt
*
pStmt
)
{
SVnodeModifOpStmt
*
pStmt
)
{
clearCatalogReq
(
pCatalogReq
);
clearCatalogReq
(
pCatalogReq
);
if
(
pStmt
->
usingTableProcessing
)
{
if
(
pStmt
->
usingTableProcessing
)
{
return
getTableSchemaFromMetaData
(
pMetaData
,
pStmt
,
true
);
return
getTableSchemaFromMetaData
(
p
Cxt
,
p
MetaData
,
pStmt
,
true
);
}
}
return
getTableSchemaFromMetaData
(
pMetaData
,
pStmt
,
false
);
return
getTableSchemaFromMetaData
(
p
Cxt
,
p
MetaData
,
pStmt
,
false
);
}
}
static
int32_t
resetVnodeModifOpStmt
(
SParseContext
*
pCxt
,
SQuery
*
pQuery
)
{
static
int32_t
resetVnodeModifOpStmt
(
S
Insert
ParseContext
*
pCxt
,
SQuery
*
pQuery
)
{
nodesDestroyNode
(
pQuery
->
pRoot
);
nodesDestroyNode
(
pQuery
->
pRoot
);
int32_t
code
=
createVnodeModifOpStmt
(
pCxt
,
true
,
&
pQuery
->
pRoot
);
int32_t
code
=
createVnodeModifOpStmt
(
pCxt
,
true
,
&
pQuery
->
pRoot
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SVnodeModifOpStmt
*
pStmt
=
(
SVnodeModifOpStmt
*
)
pQuery
->
pRoot
;
SVnodeModifOpStmt
*
pStmt
=
(
SVnodeModifOpStmt
*
)
pQuery
->
pRoot
;
(
*
pCxt
->
pStmtCb
->
getExecInfoFn
)(
pCxt
->
pStmtCb
->
pStmt
,
&
pStmt
->
pVgroupsHashObj
,
&
pStmt
->
pTableBlockHashObj
);
(
*
pCxt
->
pComCxt
->
pStmtCb
->
getExecInfoFn
)(
pCxt
->
pComCxt
->
pStmtCb
->
pStmt
,
&
pStmt
->
pVgroupsHashObj
,
&
pStmt
->
pTableBlockHashObj
);
if
(
NULL
==
pStmt
->
pVgroupsHashObj
)
{
if
(
NULL
==
pStmt
->
pVgroupsHashObj
)
{
pStmt
->
pVgroupsHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_NO_LOCK
);
pStmt
->
pVgroupsHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_NO_LOCK
);
}
}
...
@@ -1729,13 +1741,13 @@ static int32_t resetVnodeModifOpStmt(SParseContext* pCxt, SQuery* pQuery) {
...
@@ -1729,13 +1741,13 @@ static int32_t resetVnodeModifOpStmt(SParseContext* pCxt, SQuery* pQuery) {
return
code
;
return
code
;
}
}
static
int32_t
initInsertQuery
(
SParseContext
*
pCxt
,
SCatalogReq
*
pCatalogReq
,
const
SMetaData
*
pMetaData
,
static
int32_t
initInsertQuery
(
S
Insert
ParseContext
*
pCxt
,
SCatalogReq
*
pCatalogReq
,
const
SMetaData
*
pMetaData
,
SQuery
**
pQuery
)
{
SQuery
**
pQuery
)
{
if
(
NULL
==
*
pQuery
)
{
if
(
NULL
==
*
pQuery
)
{
return
createInsertQuery
(
pCxt
,
pQuery
);
return
createInsertQuery
(
pCxt
,
pQuery
);
}
}
if
(
NULL
!=
pCxt
->
pStmtCb
)
{
if
(
NULL
!=
pCxt
->
p
ComCxt
->
p
StmtCb
)
{
return
resetVnodeModifOpStmt
(
pCxt
,
*
pQuery
);
return
resetVnodeModifOpStmt
(
pCxt
,
*
pQuery
);
}
}
...
@@ -1896,7 +1908,7 @@ int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatal
...
@@ -1896,7 +1908,7 @@ int32_t parseInsertSql(SParseContext* pCxt, SQuery** pQuery, SCatalogReq* pCatal
.
usingDuplicateTable
=
false
,
.
usingDuplicateTable
=
false
,
};
};
int32_t
code
=
initInsertQuery
(
pC
xt
,
pCatalogReq
,
pMetaData
,
pQuery
);
int32_t
code
=
initInsertQuery
(
&
conte
xt
,
pCatalogReq
,
pMetaData
,
pQuery
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
parseInsertSqlImpl
(
&
context
,
(
SVnodeModifOpStmt
*
)(
*
pQuery
)
->
pRoot
);
code
=
parseInsertSqlImpl
(
&
context
,
(
SVnodeModifOpStmt
*
)(
*
pQuery
)
->
pRoot
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录