Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aa9d3ac5
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
aa9d3ac5
编写于
6月 28, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: a problem of auto-create-table insert statement
上级
364250b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
7 deletion
+25
-7
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+20
-7
source/libs/parser/test/parInsertTest.cpp
source/libs/parser/test/parInsertTest.cpp
+5
-0
未找到文件。
source/libs/parser/src/parInsert.c
浏览文件 @
aa9d3ac5
...
@@ -67,6 +67,13 @@ typedef struct SInsertParseContext {
...
@@ -67,6 +67,13 @@ typedef struct SInsertParseContext {
SParseMetaCache
*
pMetaCache
;
SParseMetaCache
*
pMetaCache
;
}
SInsertParseContext
;
}
SInsertParseContext
;
typedef
struct
SInsertParseSyntaxCxt
{
SParseContext
*
pComCxt
;
char
*
pSql
;
SMsgBuf
msg
;
SParseMetaCache
*
pMetaCache
;
}
SInsertParseSyntaxCxt
;
typedef
int32_t
(
*
_row_append_fn_t
)(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
);
typedef
int32_t
(
*
_row_append_fn_t
)(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
);
static
uint8_t
TRUE_VALUE
=
(
uint8_t
)
TSDB_TRUE
;
static
uint8_t
TRUE_VALUE
=
(
uint8_t
)
TSDB_TRUE
;
...
@@ -1098,11 +1105,24 @@ static int32_t storeTableMeta(SInsertParseContext* pCxt, SHashObj* pHash, SName*
...
@@ -1098,11 +1105,24 @@ static int32_t storeTableMeta(SInsertParseContext* pCxt, SHashObj* pHash, SName*
return
taosHashPut
(
pHash
,
pName
,
len
,
&
pBackup
,
POINTER_BYTES
);
return
taosHashPut
(
pHash
,
pName
,
len
,
&
pBackup
,
POINTER_BYTES
);
}
}
static
int32_t
skipUsingClause
(
SInsertParseSyntaxCxt
*
pCxt
);
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
static
int32_t
ignoreAutoCreateTableClause
(
SInsertParseContext
*
pCxt
)
{
SToken
sToken
;
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
SInsertParseSyntaxCxt
cxt
=
{.
pComCxt
=
pCxt
->
pComCxt
,
.
pSql
=
pCxt
->
pSql
,
.
msg
=
pCxt
->
msg
,
.
pMetaCache
=
NULL
};
int32_t
code
=
skipUsingClause
(
&
cxt
);
pCxt
->
pSql
=
cxt
.
pSql
;
return
code
;
}
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
// pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)
static
int32_t
parseUsingClause
(
SInsertParseContext
*
pCxt
,
SName
*
name
,
char
*
tbFName
)
{
static
int32_t
parseUsingClause
(
SInsertParseContext
*
pCxt
,
SName
*
name
,
char
*
tbFName
)
{
int32_t
len
=
strlen
(
tbFName
);
int32_t
len
=
strlen
(
tbFName
);
STableMeta
**
pMeta
=
taosHashGet
(
pCxt
->
pSubTableHashObj
,
tbFName
,
len
);
STableMeta
**
pMeta
=
taosHashGet
(
pCxt
->
pSubTableHashObj
,
tbFName
,
len
);
if
(
NULL
!=
pMeta
)
{
if
(
NULL
!=
pMeta
)
{
CHECK_CODE
(
ignoreAutoCreateTableClause
(
pCxt
));
return
cloneTableMeta
(
*
pMeta
,
&
pCxt
->
pTableMeta
);
return
cloneTableMeta
(
*
pMeta
,
&
pCxt
->
pTableMeta
);
}
}
...
@@ -1522,13 +1542,6 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache
...
@@ -1522,13 +1542,6 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache
return
code
;
return
code
;
}
}
typedef
struct
SInsertParseSyntaxCxt
{
SParseContext
*
pComCxt
;
char
*
pSql
;
SMsgBuf
msg
;
SParseMetaCache
*
pMetaCache
;
}
SInsertParseSyntaxCxt
;
static
int32_t
skipParentheses
(
SInsertParseSyntaxCxt
*
pCxt
)
{
static
int32_t
skipParentheses
(
SInsertParseSyntaxCxt
*
pCxt
)
{
SToken
sToken
;
SToken
sToken
;
int32_t
expectRightParenthesis
=
1
;
int32_t
expectRightParenthesis
=
1
;
...
...
source/libs/parser/test/parInsertTest.cpp
浏览文件 @
aa9d3ac5
...
@@ -265,6 +265,11 @@ TEST_F(InsertTest, autoCreateTableTest) {
...
@@ -265,6 +265,11 @@ TEST_F(InsertTest, autoCreateTableTest) {
"insert into st1s1 using st1 (tag1, tag2) tags(1, 'wxy') values (now, 1,
\"
beijing
\"
)"
"insert into st1s1 using st1 (tag1, tag2) tags(1, 'wxy') values (now, 1,
\"
beijing
\"
)"
"(now+1s, 2,
\"
shanghai
\"
)(now+2s, 3,
\"
guangzhou
\"
)"
);
"(now+1s, 2,
\"
shanghai
\"
)(now+2s, 3,
\"
guangzhou
\"
)"
);
ASSERT_EQ
(
runAsync
(),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
runAsync
(),
TSDB_CODE_SUCCESS
);
bind
(
"insert into st1s1 using st1 tags(1, 'wxy', now) values (now, 1,
\"
beijing
\"
)"
"st1s1 using st1 tags(1, 'wxy', now) values (now+1s, 2,
\"
shanghai
\"
)"
);
ASSERT_EQ
(
run
(),
TSDB_CODE_SUCCESS
);
}
}
TEST_F
(
InsertTest
,
toleranceTest
)
{
TEST_F
(
InsertTest
,
toleranceTest
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录