Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
40feeffd
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看板
未验证
提交
40feeffd
编写于
6月 04, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
6月 04, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13470 from taosdata/feature/3_liaohj_wxy
fix: a problem of parser async
上级
ad6a648d
d261c17a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
110 addition
and
83 deletion
+110
-83
source/libs/parser/inc/parInt.h
source/libs/parser/inc/parInt.h
+0
-1
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+9
-6
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+38
-26
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+48
-43
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+14
-7
source/libs/parser/test/parInsertTest.cpp
source/libs/parser/test/parInsertTest.cpp
+1
-0
未找到文件。
source/libs/parser/inc/parInt.h
浏览文件 @
40feeffd
...
@@ -32,7 +32,6 @@ int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery);
...
@@ -32,7 +32,6 @@ int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery);
int32_t
translate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
int32_t
translate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
int32_t
extractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
);
int32_t
extractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
);
int32_t
calculateConstant
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
int32_t
calculateConstant
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
int32_t
isNotSchemalessDb
(
SParseContext
*
pContext
,
char
*
dbName
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
40feeffd
...
@@ -175,11 +175,11 @@ static int32_t collectMetaKeyFromSelect(SCollectMetaKeyCxt* pCxt, SSelectStmt* p
...
@@ -175,11 +175,11 @@ static int32_t collectMetaKeyFromSelect(SCollectMetaKeyCxt* pCxt, SSelectStmt* p
}
}
static
int32_t
collectMetaKeyFromCreateTable
(
SCollectMetaKeyCxt
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
static
int32_t
collectMetaKeyFromCreateTable
(
SCollectMetaKeyCxt
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
if
(
NULL
==
pStmt
->
pTags
)
{
int32_t
code
=
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
return
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
==
pStmt
->
pTags
)
{
}
else
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
return
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
}
}
return
code
;
}
}
static
int32_t
collectMetaKeyFromCreateMultiTable
(
SCollectMetaKeyCxt
*
pCxt
,
SCreateMultiTableStmt
*
pStmt
)
{
static
int32_t
collectMetaKeyFromCreateMultiTable
(
SCollectMetaKeyCxt
*
pCxt
,
SCreateMultiTableStmt
*
pStmt
)
{
...
@@ -187,8 +187,11 @@ static int32_t collectMetaKeyFromCreateMultiTable(SCollectMetaKeyCxt* pCxt, SCre
...
@@ -187,8 +187,11 @@ static int32_t collectMetaKeyFromCreateMultiTable(SCollectMetaKeyCxt* pCxt, SCre
SNode
*
pNode
=
NULL
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pStmt
->
pSubTables
)
{
FOREACH
(
pNode
,
pStmt
->
pSubTables
)
{
SCreateSubTableClause
*
pClause
=
(
SCreateSubTableClause
*
)
pNode
;
SCreateSubTableClause
*
pClause
=
(
SCreateSubTableClause
*
)
pNode
;
code
=
code
=
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
dbName
,
pCxt
->
pMetaCache
);
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
useDbName
,
pClause
->
useTableName
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
useDbName
,
pClause
->
useTableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
dbName
,
pClause
->
tableName
,
pCxt
->
pMetaCache
);
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
dbName
,
pClause
->
tableName
,
pCxt
->
pMetaCache
);
}
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
40feeffd
...
@@ -254,7 +254,7 @@ static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, con
...
@@ -254,7 +254,7 @@ static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, con
static
int32_t
checkAuth
(
SInsertParseContext
*
pCxt
,
char
*
pDbFname
,
bool
*
pPass
)
{
static
int32_t
checkAuth
(
SInsertParseContext
*
pCxt
,
char
*
pDbFname
,
bool
*
pPass
)
{
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
if
(
NULL
!=
pCxt
->
pMetaCache
)
{
if
(
pBasicCtx
->
async
)
{
return
getUserAuthFromCache
(
pCxt
->
pMetaCache
,
pBasicCtx
->
pUser
,
pDbFname
,
AUTH_TYPE_WRITE
,
pPass
);
return
getUserAuthFromCache
(
pCxt
->
pMetaCache
,
pBasicCtx
->
pUser
,
pDbFname
,
AUTH_TYPE_WRITE
,
pPass
);
}
}
return
catalogChkAuth
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
pBasicCtx
->
pUser
,
pDbFname
,
return
catalogChkAuth
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
pBasicCtx
->
pUser
,
pDbFname
,
...
@@ -263,7 +263,7 @@ static int32_t checkAuth(SInsertParseContext* pCxt, char* pDbFname, bool* pPass)
...
@@ -263,7 +263,7 @@ static int32_t checkAuth(SInsertParseContext* pCxt, char* pDbFname, bool* pPass)
static
int32_t
getTableSchema
(
SInsertParseContext
*
pCxt
,
SName
*
pTbName
,
bool
isStb
,
STableMeta
**
pTableMeta
)
{
static
int32_t
getTableSchema
(
SInsertParseContext
*
pCxt
,
SName
*
pTbName
,
bool
isStb
,
STableMeta
**
pTableMeta
)
{
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
if
(
NULL
!=
pCxt
->
pMetaCache
)
{
if
(
pBasicCtx
->
async
)
{
return
getTableMetaFromCache
(
pCxt
->
pMetaCache
,
pTbName
,
pTableMeta
);
return
getTableMetaFromCache
(
pCxt
->
pMetaCache
,
pTbName
,
pTableMeta
);
}
}
if
(
isStb
)
{
if
(
isStb
)
{
...
@@ -275,7 +275,7 @@ static int32_t getTableSchema(SInsertParseContext* pCxt, SName* pTbName, bool is
...
@@ -275,7 +275,7 @@ static int32_t getTableSchema(SInsertParseContext* pCxt, SName* pTbName, bool is
static
int32_t
getTableVgroup
(
SInsertParseContext
*
pCxt
,
SName
*
pTbName
,
SVgroupInfo
*
pVg
)
{
static
int32_t
getTableVgroup
(
SInsertParseContext
*
pCxt
,
SName
*
pTbName
,
SVgroupInfo
*
pVg
)
{
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
if
(
NULL
!=
pCxt
->
pMetaCache
)
{
if
(
pBasicCtx
->
async
)
{
return
getTableVgroupFromCache
(
pCxt
->
pMetaCache
,
pTbName
,
pVg
);
return
getTableVgroupFromCache
(
pCxt
->
pMetaCache
,
pTbName
,
pVg
);
}
}
return
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
pTbName
,
pVg
);
return
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
pTbName
,
pVg
);
...
@@ -305,6 +305,16 @@ static int32_t getSTableMeta(SInsertParseContext* pCxt, SName* name, char* dbFna
...
@@ -305,6 +305,16 @@ static int32_t getSTableMeta(SInsertParseContext* pCxt, SName* name, char* dbFna
return
getTableMetaImpl
(
pCxt
,
name
,
dbFname
,
true
);
return
getTableMetaImpl
(
pCxt
,
name
,
dbFname
,
true
);
}
}
static
int32_t
getDBCfg
(
SInsertParseContext
*
pCxt
,
const
char
*
pDbFName
,
SDbCfgInfo
*
pInfo
)
{
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
if
(
pBasicCtx
->
async
)
{
CHECK_CODE
(
getDbCfgFromCache
(
pCxt
->
pMetaCache
,
pDbFName
,
pInfo
));
}
else
{
CHECK_CODE
(
catalogGetDBCfg
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
pDbFName
,
pInfo
));
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
findCol
(
SToken
*
pColname
,
int32_t
start
,
int32_t
end
,
SSchema
*
pSchema
)
{
static
int32_t
findCol
(
SToken
*
pColname
,
int32_t
start
,
int32_t
end
,
SSchema
*
pSchema
)
{
while
(
start
<
end
)
{
while
(
start
<
end
)
{
if
(
strlen
(
pSchema
[
start
].
name
)
==
pColname
->
n
&&
strncmp
(
pColname
->
z
,
pSchema
[
start
].
name
,
pColname
->
n
)
==
0
)
{
if
(
strlen
(
pSchema
[
start
].
name
)
==
pColname
->
n
&&
strncmp
(
pColname
->
z
,
pSchema
[
start
].
name
,
pColname
->
n
)
==
0
)
{
...
@@ -1090,10 +1100,10 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SName* name, char* tb
...
@@ -1090,10 +1100,10 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SName* name, char* tb
SName
sname
;
SName
sname
;
createSName
(
&
sname
,
&
sToken
,
pCxt
->
pComCxt
->
acctId
,
pCxt
->
pComCxt
->
db
,
&
pCxt
->
msg
);
createSName
(
&
sname
,
&
sToken
,
pCxt
->
pComCxt
->
acctId
,
pCxt
->
pComCxt
->
db
,
&
pCxt
->
msg
);
char
stbFName
[
TSDB_TABLE
_FNAME_LEN
];
char
dbFName
[
TSDB_DB
_FNAME_LEN
];
tName
ExtractFullName
(
&
sname
,
st
bFName
);
tName
GetFullDbName
(
&
sname
,
d
bFName
);
CHECK_CODE
(
getSTableMeta
(
pCxt
,
&
sname
,
st
bFName
));
CHECK_CODE
(
getSTableMeta
(
pCxt
,
&
sname
,
d
bFName
));
if
(
TSDB_SUPER_TABLE
!=
pCxt
->
pTableMeta
->
tableType
)
{
if
(
TSDB_SUPER_TABLE
!=
pCxt
->
pTableMeta
->
tableType
)
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"create table only from super table is allowed"
);
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"create table only from super table is allowed"
);
}
}
...
@@ -1282,6 +1292,14 @@ static void destroyInsertParseContext(SInsertParseContext* pCxt) {
...
@@ -1282,6 +1292,14 @@ static void destroyInsertParseContext(SInsertParseContext* pCxt) {
destroyBlockArrayList
(
pCxt
->
pVgDataBlocks
);
destroyBlockArrayList
(
pCxt
->
pVgDataBlocks
);
}
}
static
int32_t
checkSchemalessDb
(
SInsertParseContext
*
pCxt
,
char
*
pDbName
)
{
SDbCfgInfo
pInfo
=
{
0
};
char
fullName
[
TSDB_TABLE_FNAME_LEN
];
snprintf
(
fullName
,
sizeof
(
fullName
),
"%d.%s"
,
pCxt
->
pComCxt
->
acctId
,
pDbName
);
CHECK_CODE
(
getDBCfg
(
pCxt
,
fullName
,
&
pInfo
));
return
pInfo
.
schemaless
?
TSDB_CODE_SML_INVALID_DB_CONF
:
TSDB_CODE_SUCCESS
;
}
// tb_name
// tb_name
// [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
// [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
// [(field1_name, ...)]
// [(field1_name, ...)]
...
@@ -1335,7 +1353,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
...
@@ -1335,7 +1353,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
SName
name
;
SName
name
;
CHECK_CODE
(
createSName
(
&
name
,
&
tbnameToken
,
pCxt
->
pComCxt
->
acctId
,
pCxt
->
pComCxt
->
db
,
&
pCxt
->
msg
));
CHECK_CODE
(
createSName
(
&
name
,
&
tbnameToken
,
pCxt
->
pComCxt
->
acctId
,
pCxt
->
pComCxt
->
db
,
&
pCxt
->
msg
));
CHECK_CODE
(
isNotSchemalessDb
(
pCxt
->
pCom
Cxt
,
name
.
dbname
));
CHECK_CODE
(
checkSchemalessDb
(
p
Cxt
,
name
.
dbname
));
tNameExtractFullName
(
&
name
,
tbFName
);
tNameExtractFullName
(
&
name
,
tbFName
);
CHECK_CODE
(
taosHashPut
(
pCxt
->
pTableNameHashObj
,
tbFName
,
strlen
(
tbFName
),
&
name
,
sizeof
(
SName
)));
CHECK_CODE
(
taosHashPut
(
pCxt
->
pTableNameHashObj
,
tbFName
,
strlen
(
tbFName
),
&
name
,
sizeof
(
SName
)));
...
@@ -1413,23 +1431,6 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
...
@@ -1413,23 +1431,6 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
return
buildOutput
(
pCxt
);
return
buildOutput
(
pCxt
);
}
}
int32_t
isNotSchemalessDb
(
SParseContext
*
pContext
,
char
*
dbName
){
SName
name
;
tNameSetDbName
(
&
name
,
pContext
->
acctId
,
dbName
,
strlen
(
dbName
));
char
dbFname
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFname
);
SDbCfgInfo
pInfo
=
{
0
};
int32_t
code
=
catalogGetDBCfg
(
pContext
->
pCatalog
,
pContext
->
pTransporter
,
&
pContext
->
mgmtEpSet
,
dbFname
,
&
pInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
parserError
(
"catalogGetDBCfg error, code:%s, dbFName:%s"
,
tstrerror
(
code
),
dbFname
);
return
code
;
}
if
(
pInfo
.
schemaless
){
parserError
(
"can not insert into schemaless db:%s"
,
dbFname
);
return
TSDB_CODE_SML_INVALID_DB_CONF
;
}
return
TSDB_CODE_SUCCESS
;
}
// INSERT INTO
// INSERT INTO
// tb_name
// tb_name
// [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
// [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
...
@@ -1472,6 +1473,8 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
...
@@ -1472,6 +1473,8 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
if
(
NULL
==
*
pQuery
)
{
if
(
NULL
==
*
pQuery
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
}
else
{
context
.
pMetaCache
=
(
*
pQuery
)
->
pMetaCache
;
}
}
(
*
pQuery
)
->
execMode
=
QUERY_EXEC_MODE_SCHEDULE
;
(
*
pQuery
)
->
execMode
=
QUERY_EXEC_MODE_SCHEDULE
;
(
*
pQuery
)
->
haveResultSet
=
false
;
(
*
pQuery
)
->
haveResultSet
=
false
;
...
@@ -1586,12 +1589,20 @@ static int32_t skipUsingClause(SInsertParseSyntaxCxt* pCxt) {
...
@@ -1586,12 +1589,20 @@ static int32_t skipUsingClause(SInsertParseSyntaxCxt* pCxt) {
static
int32_t
collectTableMetaKey
(
SInsertParseSyntaxCxt
*
pCxt
,
SToken
*
pTbToken
)
{
static
int32_t
collectTableMetaKey
(
SInsertParseSyntaxCxt
*
pCxt
,
SToken
*
pTbToken
)
{
SName
name
;
SName
name
;
CHECK_CODE
(
createSName
(
&
name
,
pTbToken
,
pCxt
->
pComCxt
->
acctId
,
pCxt
->
pComCxt
->
db
,
&
pCxt
->
msg
));
CHECK_CODE
(
createSName
(
&
name
,
pTbToken
,
pCxt
->
pComCxt
->
acctId
,
pCxt
->
pComCxt
->
db
,
&
pCxt
->
msg
));
CHECK_CODE
(
reserveDbCfgInCache
(
pCxt
->
pComCxt
->
acctId
,
name
.
dbname
,
pCxt
->
pMetaCache
));
CHECK_CODE
(
reserveUserAuthInCacheExt
(
pCxt
->
pComCxt
->
pUser
,
&
name
,
AUTH_TYPE_WRITE
,
pCxt
->
pMetaCache
));
CHECK_CODE
(
reserveUserAuthInCacheExt
(
pCxt
->
pComCxt
->
pUser
,
&
name
,
AUTH_TYPE_WRITE
,
pCxt
->
pMetaCache
));
CHECK_CODE
(
reserveTableMetaInCacheExt
(
&
name
,
pCxt
->
pMetaCache
));
CHECK_CODE
(
reserveTableMetaInCacheExt
(
&
name
,
pCxt
->
pMetaCache
));
CHECK_CODE
(
reserveTableVgroupInCacheExt
(
&
name
,
pCxt
->
pMetaCache
));
CHECK_CODE
(
reserveTableVgroupInCacheExt
(
&
name
,
pCxt
->
pMetaCache
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
collectAutoCreateTableMetaKey
(
SInsertParseSyntaxCxt
*
pCxt
,
SToken
*
pTbToken
)
{
SName
name
;
CHECK_CODE
(
createSName
(
&
name
,
pTbToken
,
pCxt
->
pComCxt
->
acctId
,
pCxt
->
pComCxt
->
db
,
&
pCxt
->
msg
));
CHECK_CODE
(
reserveTableVgroupInCacheExt
(
&
name
,
pCxt
->
pMetaCache
));
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
parseInsertBodySyntax
(
SInsertParseSyntaxCxt
*
pCxt
)
{
static
int32_t
parseInsertBodySyntax
(
SInsertParseSyntaxCxt
*
pCxt
)
{
bool
hasData
=
false
;
bool
hasData
=
false
;
// for each table
// for each table
...
@@ -1620,6 +1631,7 @@ static int32_t parseInsertBodySyntax(SInsertParseSyntaxCxt* pCxt) {
...
@@ -1620,6 +1631,7 @@ static int32_t parseInsertBodySyntax(SInsertParseSyntaxCxt* pCxt) {
// USING clause
// USING clause
if
(
TK_USING
==
sToken
.
type
)
{
if
(
TK_USING
==
sToken
.
type
)
{
CHECK_CODE
(
collectAutoCreateTableMetaKey
(
pCxt
,
&
tbnameToken
));
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
CHECK_CODE
(
collectTableMetaKey
(
pCxt
,
&
sToken
));
CHECK_CODE
(
collectTableMetaKey
(
pCxt
,
&
sToken
));
CHECK_CODE
(
skipUsingClause
(
pCxt
));
CHECK_CODE
(
skipUsingClause
(
pCxt
));
...
@@ -2172,8 +2184,8 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p
...
@@ -2172,8 +2184,8 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p
val
.
nData
=
kv
->
length
;
val
.
nData
=
kv
->
length
;
}
else
if
(
pTagSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
}
else
if
(
pTagSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
output
=
0
;
int32_t
output
=
0
;
void
*
p
=
taosMemoryCalloc
(
1
,
kv
->
length
*
TSDB_NCHAR_SIZE
);
void
*
p
=
taosMemoryCalloc
(
1
,
kv
->
length
*
TSDB_NCHAR_SIZE
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
goto
end
;
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
40feeffd
...
@@ -829,8 +829,9 @@ static EDealRes translateComparisonOperator(STranslateContext* pCxt, SOperatorNo
...
@@ -829,8 +829,9 @@ static EDealRes translateComparisonOperator(STranslateContext* pCxt, SOperatorNo
if
(
!
IS_VAR_DATA_TYPE
(((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
.
type
))
{
if
(
!
IS_VAR_DATA_TYPE
(((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
.
type
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pLeft
))
->
aliasName
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pLeft
))
->
aliasName
);
}
}
if
(
QUERY_NODE_VALUE
!=
nodeType
(
pOp
->
pRight
)
||
if
(
QUERY_NODE_VALUE
!=
nodeType
(
pOp
->
pRight
)
||
((
!
IS_STR_DATA_TYPE
(((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
.
type
))
&&
(((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)))
{
((
!
IS_STR_DATA_TYPE
(((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
.
type
))
&&
(((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pRight
))
->
aliasName
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pRight
))
->
aliasName
);
}
}
}
}
...
@@ -2632,8 +2633,23 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
...
@@ -2632,8 +2633,23 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
return
code
;
return
code
;
}
}
static
int32_t
checkSchemalessDb
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
)
{
if
(
0
!=
pCxt
->
pParseCxt
->
schemalessType
)
{
return
TSDB_CODE_SUCCESS
;
}
SDbCfgInfo
info
=
{
0
};
int32_t
code
=
getDBCfg
(
pCxt
,
pDbName
,
&
info
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
info
.
schemaless
?
TSDB_CODE_SML_INVALID_DB_CONF
:
TSDB_CODE_SUCCESS
;
}
return
code
;
}
static
int32_t
checkCreateTable
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
static
int32_t
checkCreateTable
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
int32_t
code
=
checTableFactorOption
(
pCxt
,
pStmt
->
pOptions
->
filesFactor
);
int32_t
code
=
checkSchemalessDb
(
pCxt
,
pStmt
->
dbName
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checTableFactorOption
(
pCxt
,
pStmt
->
pOptions
->
filesFactor
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkTableRollupOption
(
pCxt
,
pStmt
->
pOptions
->
pRollupFuncs
);
code
=
checkTableRollupOption
(
pCxt
,
pStmt
->
pOptions
->
pRollupFuncs
);
}
}
...
@@ -2646,11 +2662,6 @@ static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt
...
@@ -2646,11 +2662,6 @@ static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkTableSchema
(
pCxt
,
pStmt
);
code
=
checkTableSchema
(
pCxt
,
pStmt
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
pCxt
->
pParseCxt
->
schemalessType
==
0
){
code
=
isNotSchemalessDb
(
pCxt
->
pParseCxt
,
pStmt
->
dbName
);
}
}
return
code
;
return
code
;
}
}
...
@@ -4238,7 +4249,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
...
@@ -4238,7 +4249,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
int16_t
nTags
=
0
,
nBufPos
=
0
;
int16_t
nTags
=
0
,
nBufPos
=
0
;
SSchema
*
pTagSchema
=
getTableTagSchema
(
pSuperTableMeta
);
SSchema
*
pTagSchema
=
getTableTagSchema
(
pSuperTableMeta
);
SNode
*
pTag
=
NULL
,
*
pNode
=
NULL
;
SNode
*
pTag
=
NULL
,
*
pNode
=
NULL
;
bool
isJson
=
false
;
bool
isJson
=
false
;
FORBOTH
(
pTag
,
pStmt
->
pSpecificTags
,
pNode
,
pStmt
->
pValsOfTags
)
{
FORBOTH
(
pTag
,
pStmt
->
pSpecificTags
,
pNode
,
pStmt
->
pValsOfTags
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pTag
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pTag
;
SSchema
*
pSchema
=
NULL
;
SSchema
*
pSchema
=
NULL
;
...
@@ -4271,11 +4282,11 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
...
@@ -4271,11 +4282,11 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
isJson
=
true
;
isJson
=
true
;
code
=
parseJsontoTagData
(
pVal
->
literal
,
pTagArray
,
ppTag
,
&
pCxt
->
msgBuf
);
code
=
parseJsontoTagData
(
pVal
->
literal
,
pTagArray
,
ppTag
,
&
pCxt
->
msgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
end
;
goto
end
;
}
}
}
else
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)
{
}
else
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)
{
void
*
nodeVal
=
nodesGetValueFromNode
(
pVal
);
void
*
nodeVal
=
nodesGetValueFromNode
(
pVal
);
STagVal
val
=
{.
cid
=
pTagSchema
->
colId
,
.
type
=
pTagSchema
->
type
};
STagVal
val
=
{.
cid
=
pTagSchema
->
colId
,
.
type
=
pTagSchema
->
type
};
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
val
.
pData
=
varDataVal
(
nodeVal
);
val
.
pData
=
varDataVal
(
nodeVal
);
...
@@ -4287,13 +4298,13 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
...
@@ -4287,13 +4298,13 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
}
}
}
}
if
(
!
isJson
)
code
=
tTagNew
(
pTagArray
,
1
,
false
,
ppTag
);
if
(
!
isJson
)
code
=
tTagNew
(
pTagArray
,
1
,
false
,
ppTag
);
end:
end:
if
(
isJson
)
{
if
(
isJson
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagArray
);
++
i
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagArray
);
++
i
)
{
STagVal
*
p
=
(
STagVal
*
)
taosArrayGet
(
pTagArray
,
i
);
STagVal
*
p
=
(
STagVal
*
)
taosArrayGet
(
pTagArray
,
i
);
if
(
IS_VAR_DATA_TYPE
(
p
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
p
->
type
))
{
taosMemoryFree
(
p
->
pData
);
taosMemoryFree
(
p
->
pData
);
}
}
}
}
...
@@ -4338,11 +4349,11 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
...
@@ -4338,11 +4349,11 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
isJson
=
true
;
isJson
=
true
;
code
=
parseJsontoTagData
(
pVal
->
literal
,
pTagArray
,
ppTag
,
&
pCxt
->
msgBuf
);
code
=
parseJsontoTagData
(
pVal
->
literal
,
pTagArray
,
ppTag
,
&
pCxt
->
msgBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
end
;
goto
end
;
}
}
}
else
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)
{
}
else
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)
{
char
*
tmpVal
=
nodesGetValueFromNode
(
pVal
);
char
*
tmpVal
=
nodesGetValueFromNode
(
pVal
);
STagVal
val
=
{.
cid
=
pTagSchema
->
colId
,
.
type
=
pTagSchema
->
type
};
STagVal
val
=
{.
cid
=
pTagSchema
->
colId
,
.
type
=
pTagSchema
->
type
};
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
val
.
pData
=
varDataVal
(
tmpVal
);
val
.
pData
=
varDataVal
(
tmpVal
);
...
@@ -4354,13 +4365,13 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
...
@@ -4354,13 +4365,13 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
}
}
++
index
;
++
index
;
}
}
if
(
!
isJson
)
code
=
tTagNew
(
pTagArray
,
1
,
false
,
ppTag
);
if
(
!
isJson
)
code
=
tTagNew
(
pTagArray
,
1
,
false
,
ppTag
);
end:
end:
if
(
isJson
)
{
if
(
isJson
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagArray
);
++
i
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagArray
);
++
i
)
{
STagVal
*
p
=
(
STagVal
*
)
taosArrayGet
(
pTagArray
,
i
);
STagVal
*
p
=
(
STagVal
*
)
taosArrayGet
(
pTagArray
,
i
);
if
(
IS_VAR_DATA_TYPE
(
p
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
p
->
type
))
{
taosMemoryFree
(
p
->
pData
);
taosMemoryFree
(
p
->
pData
);
}
}
}
}
...
@@ -4428,7 +4439,6 @@ static SArray* serializeVgroupsCreateTableBatch(int32_t acctId, SHashObj* pVgrou
...
@@ -4428,7 +4439,6 @@ static SArray* serializeVgroupsCreateTableBatch(int32_t acctId, SHashObj* pVgrou
}
}
static
int32_t
rewriteCreateMultiTable
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
static
int32_t
rewriteCreateMultiTable
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
SCreateMultiTableStmt
*
pStmt
=
(
SCreateMultiTableStmt
*
)
pQuery
->
pRoot
;
SCreateMultiTableStmt
*
pStmt
=
(
SCreateMultiTableStmt
*
)
pQuery
->
pRoot
;
SHashObj
*
pVgroupHashmap
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
SHashObj
*
pVgroupHashmap
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
...
@@ -4439,11 +4449,11 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery)
...
@@ -4439,11 +4449,11 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery)
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
pStmt
->
pSubTables
)
{
FOREACH
(
pNode
,
pStmt
->
pSubTables
)
{
if
(
pCxt
->
pParseCxt
->
schemalessType
==
0
&&
SCreateSubTableClause
*
pClause
=
(
SCreateSubTableClause
*
)
pNode
;
(
code
=
isNotSchemalessDb
(
pCxt
->
pParseCxt
,
((
SCreateSubTableClause
*
)
pNode
)
->
dbName
))
!=
TSDB_CODE_SUCCESS
){
code
=
checkSchemalessDb
(
pCxt
,
pClause
->
dbName
);
return
code
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteCreateSubTable
(
pCxt
,
pClause
,
pVgroupHashmap
);
}
}
code
=
rewriteCreateSubTable
(
pCxt
,
(
SCreateSubTableClause
*
)
pNode
,
pVgroupHashmap
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
taosHashCleanup
(
pVgroupHashmap
);
taosHashCleanup
(
pVgroupHashmap
);
return
code
;
return
code
;
...
@@ -4633,27 +4643,27 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
...
@@ -4633,27 +4643,27 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
strlen
(
pStmt
->
pVal
->
literal
)
>
(
TSDB_MAX_JSON_TAG_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
strlen
(
pStmt
->
pVal
->
literal
)
>
(
TSDB_MAX_JSON_TAG_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
return
buildSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
"json string too long than 4095"
,
pStmt
->
pVal
->
literal
);
return
buildSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
"json string too long than 4095"
,
pStmt
->
pVal
->
literal
);
}
}
SArray
*
pTagVals
=
taosArrayInit
(
1
,
sizeof
(
STagVal
));
SArray
*
pTagVals
=
taosArrayInit
(
1
,
sizeof
(
STagVal
));
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
STag
*
pTag
=
NULL
;
STag
*
pTag
=
NULL
;
do
{
do
{
code
=
parseJsontoTagData
(
pStmt
->
pVal
->
literal
,
pTagVals
,
&
pTag
,
&
pCxt
->
msgBuf
);
code
=
parseJsontoTagData
(
pStmt
->
pVal
->
literal
,
pTagVals
,
&
pTag
,
&
pCxt
->
msgBuf
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
break
;
}
}
}
while
(
0
);
}
while
(
0
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagVals
);
++
i
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagVals
);
++
i
)
{
STagVal
*
p
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
STagVal
*
p
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
if
(
IS_VAR_DATA_TYPE
(
p
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
p
->
type
))
{
taosMemoryFree
(
p
->
pData
);
taosMemoryFree
(
p
->
pData
);
}
}
}
}
taosArrayDestroy
(
pTagVals
);
taosArrayDestroy
(
pTagVals
);
if
(
code
!=
TSDB_CODE_SUCCESS
){
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
pReq
->
nTagVal
=
pTag
->
len
;
pReq
->
nTagVal
=
pTag
->
len
;
pReq
->
pTagVal
=
(
uint8_t
*
)
pTag
;
pReq
->
pTagVal
=
(
uint8_t
*
)
pTag
;
pStmt
->
pVal
->
datum
.
p
=
(
char
*
)
pTag
;
// for free
pStmt
->
pVal
->
datum
.
p
=
(
char
*
)
pTag
;
// for free
}
else
{
}
else
{
pReq
->
nTagVal
=
pStmt
->
pVal
->
node
.
resType
.
bytes
;
pReq
->
nTagVal
=
pStmt
->
pVal
->
node
.
resType
.
bytes
;
...
@@ -4854,13 +4864,8 @@ static int32_t buildModifyVnodeArray(STranslateContext* pCxt, SAlterTableStmt* p
...
@@ -4854,13 +4864,8 @@ static int32_t buildModifyVnodeArray(STranslateContext* pCxt, SAlterTableStmt* p
static
int32_t
rewriteAlterTable
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
static
int32_t
rewriteAlterTable
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
SAlterTableStmt
*
pStmt
=
(
SAlterTableStmt
*
)
pQuery
->
pRoot
;
SAlterTableStmt
*
pStmt
=
(
SAlterTableStmt
*
)
pQuery
->
pRoot
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
checkSchemalessDb
(
pCxt
,
pStmt
->
dbName
);
if
(
pCxt
->
pParseCxt
->
schemalessType
==
0
&&
STableMeta
*
pTableMeta
=
NULL
;
(
code
=
isNotSchemalessDb
(
pCxt
->
pParseCxt
,
pStmt
->
dbName
))
!=
TSDB_CODE_SUCCESS
){
return
code
;
}
STableMeta
*
pTableMeta
=
NULL
;
code
=
getTableMeta
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
pTableMeta
);
code
=
getTableMeta
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
pTableMeta
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
return
code
;
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
40feeffd
...
@@ -322,11 +322,11 @@ static bool isValidateTag(char* input) {
...
@@ -322,11 +322,11 @@ static bool isValidateTag(char* input) {
return
true
;
return
true
;
}
}
int32_t
parseJsontoTagData
(
const
char
*
json
,
SArray
*
pTagVals
,
STag
**
ppTag
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
parseJsontoTagData
(
const
char
*
json
,
SArray
*
pTagVals
,
STag
**
ppTag
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
retCode
=
TSDB_CODE_SUCCESS
;
int32_t
retCode
=
TSDB_CODE_SUCCESS
;
cJSON
*
root
=
NULL
;
cJSON
*
root
=
NULL
;
SHashObj
*
keyHash
=
NULL
;
SHashObj
*
keyHash
=
NULL
;
int32_t
size
=
0
;
int32_t
size
=
0
;
// set json NULL data
// set json NULL data
if
(
!
json
||
strtrim
((
char
*
)
json
)
==
0
||
strcasecmp
(
json
,
TSDB_DATA_NULL_STR_L
)
==
0
)
{
if
(
!
json
||
strtrim
((
char
*
)
json
)
==
0
||
strcasecmp
(
json
,
TSDB_DATA_NULL_STR_L
)
==
0
)
{
retCode
=
TSDB_CODE_SUCCESS
;
retCode
=
TSDB_CODE_SUCCESS
;
...
@@ -371,7 +371,8 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
...
@@ -371,7 +371,8 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
}
}
STagVal
val
=
{
0
};
STagVal
val
=
{
0
};
val
.
pKey
=
jsonKey
;
val
.
pKey
=
jsonKey
;
taosHashPut
(
keyHash
,
jsonKey
,
keyLen
,
&
keyLen
,
CHAR_BYTES
);
// add key to hash to remove dumplicate, value is useless
taosHashPut
(
keyHash
,
jsonKey
,
keyLen
,
&
keyLen
,
CHAR_BYTES
);
// add key to hash to remove dumplicate, value is useless
if
(
item
->
type
==
cJSON_String
)
{
// add json value format: type|data
if
(
item
->
type
==
cJSON_String
)
{
// add json value format: type|data
char
*
jsonValue
=
item
->
valuestring
;
char
*
jsonValue
=
item
->
valuestring
;
...
@@ -382,8 +383,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
...
@@ -382,8 +383,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
goto
end
;
goto
end
;
}
}
val
.
type
=
TSDB_DATA_TYPE_NCHAR
;
val
.
type
=
TSDB_DATA_TYPE_NCHAR
;
if
(
valLen
>
0
&&
!
taosMbsToUcs4
(
jsonValue
,
valLen
,
(
TdUcs4
*
)
tmp
,
if
(
valLen
>
0
&&
!
taosMbsToUcs4
(
jsonValue
,
valLen
,
(
TdUcs4
*
)
tmp
,
(
int32_t
)(
valLen
*
TSDB_NCHAR_SIZE
),
&
valLen
))
{
(
int32_t
)(
valLen
*
TSDB_NCHAR_SIZE
),
&
valLen
))
{
uError
(
"charset:%s to %s. val:%s, errno:%s, convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
jsonValue
,
uError
(
"charset:%s to %s. val:%s, errno:%s, convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
jsonValue
,
strerror
(
errno
));
strerror
(
errno
));
retCode
=
buildSyntaxErrMsg
(
pMsgBuf
,
"charset convert json error"
,
jsonValue
);
retCode
=
buildSyntaxErrMsg
(
pMsgBuf
,
"charset convert json error"
,
jsonValue
);
...
@@ -413,7 +413,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
...
@@ -413,7 +413,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag **ppTag, SMs
end:
end:
taosHashCleanup
(
keyHash
);
taosHashCleanup
(
keyHash
);
if
(
retCode
==
TSDB_CODE_SUCCESS
)
{
if
(
retCode
==
TSDB_CODE_SUCCESS
)
{
tTagNew
(
pTagVals
,
1
,
true
,
ppTag
);
tTagNew
(
pTagVals
,
1
,
true
,
ppTag
);
}
}
cJSON_Delete
(
root
);
cJSON_Delete
(
root
);
...
@@ -679,6 +679,7 @@ int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, S
...
@@ -679,6 +679,7 @@ int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, S
tNameExtractFullName
(
pName
,
fullName
);
tNameExtractFullName
(
pName
,
fullName
);
STableMeta
**
pRes
=
taosHashGet
(
pMetaCache
->
pTableMeta
,
fullName
,
strlen
(
fullName
));
STableMeta
**
pRes
=
taosHashGet
(
pMetaCache
->
pTableMeta
,
fullName
,
strlen
(
fullName
));
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
parserError
(
"getTableMetaFromCache error: %s"
,
fullName
);
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
}
}
*
pMeta
=
tableMetaDup
(
*
pRes
);
*
pMeta
=
tableMetaDup
(
*
pRes
);
...
@@ -707,6 +708,7 @@ int32_t reserveDbVgInfoInCache(int32_t acctId, const char* pDb, SParseMetaCache*
...
@@ -707,6 +708,7 @@ int32_t reserveDbVgInfoInCache(int32_t acctId, const char* pDb, SParseMetaCache*
int32_t
getDbVgInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pDbFName
,
SArray
**
pVgInfo
)
{
int32_t
getDbVgInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pDbFName
,
SArray
**
pVgInfo
)
{
SArray
**
pRes
=
taosHashGet
(
pMetaCache
->
pDbVgroup
,
pDbFName
,
strlen
(
pDbFName
));
SArray
**
pRes
=
taosHashGet
(
pMetaCache
->
pDbVgroup
,
pDbFName
,
strlen
(
pDbFName
));
if
(
NULL
==
pRes
)
{
if
(
NULL
==
pRes
)
{
parserError
(
"getDbVgInfoFromCache error: %s"
,
pDbFName
);
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
}
}
// *pRes is null, which is a legal value, indicating that the user DB has not been created
// *pRes is null, which is a legal value, indicating that the user DB has not been created
...
@@ -734,6 +736,7 @@ int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName,
...
@@ -734,6 +736,7 @@ int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName,
tNameExtractFullName
(
pName
,
fullName
);
tNameExtractFullName
(
pName
,
fullName
);
SVgroupInfo
**
pRes
=
taosHashGet
(
pMetaCache
->
pTableVgroup
,
fullName
,
strlen
(
fullName
));
SVgroupInfo
**
pRes
=
taosHashGet
(
pMetaCache
->
pTableVgroup
,
fullName
,
strlen
(
fullName
));
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
parserError
(
"getTableVgroupFromCache error: %s"
,
fullName
);
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
}
}
memcpy
(
pVgroup
,
*
pRes
,
sizeof
(
SVgroupInfo
));
memcpy
(
pVgroup
,
*
pRes
,
sizeof
(
SVgroupInfo
));
...
@@ -748,6 +751,7 @@ int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFNam
...
@@ -748,6 +751,7 @@ int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFNam
int32_t
*
pTableNum
)
{
int32_t
*
pTableNum
)
{
SDbInfo
**
pRes
=
taosHashGet
(
pMetaCache
->
pDbCfg
,
pDbFName
,
strlen
(
pDbFName
));
SDbInfo
**
pRes
=
taosHashGet
(
pMetaCache
->
pDbCfg
,
pDbFName
,
strlen
(
pDbFName
));
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
parserError
(
"getDbVgVersionFromCache error: %s"
,
pDbFName
);
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
}
}
*
pVersion
=
(
*
pRes
)
->
vgVer
;
*
pVersion
=
(
*
pRes
)
->
vgVer
;
...
@@ -763,6 +767,7 @@ int32_t reserveDbCfgInCache(int32_t acctId, const char* pDb, SParseMetaCache* pM
...
@@ -763,6 +767,7 @@ int32_t reserveDbCfgInCache(int32_t acctId, const char* pDb, SParseMetaCache* pM
int32_t
getDbCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pDbFName
,
SDbCfgInfo
*
pInfo
)
{
int32_t
getDbCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pDbFName
,
SDbCfgInfo
*
pInfo
)
{
SDbCfgInfo
**
pRes
=
taosHashGet
(
pMetaCache
->
pDbCfg
,
pDbFName
,
strlen
(
pDbFName
));
SDbCfgInfo
**
pRes
=
taosHashGet
(
pMetaCache
->
pDbCfg
,
pDbFName
,
strlen
(
pDbFName
));
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
parserError
(
"getDbCfgFromCache error: %s"
,
pDbFName
);
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
}
}
memcpy
(
pInfo
,
*
pRes
,
sizeof
(
SDbCfgInfo
));
memcpy
(
pInfo
,
*
pRes
,
sizeof
(
SDbCfgInfo
));
...
@@ -801,6 +806,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
...
@@ -801,6 +806,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
int32_t
len
=
userAuthToStringExt
(
pUser
,
pDbFName
,
type
,
key
);
int32_t
len
=
userAuthToStringExt
(
pUser
,
pDbFName
,
type
,
key
);
bool
*
pRes
=
taosHashGet
(
pMetaCache
->
pUserAuth
,
key
,
len
);
bool
*
pRes
=
taosHashGet
(
pMetaCache
->
pUserAuth
,
key
,
len
);
if
(
NULL
==
pRes
)
{
if
(
NULL
==
pRes
)
{
parserError
(
"getUserAuthFromCache error: %s, %s, %d"
,
pUser
,
pDbFName
,
type
);
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
}
}
*
pPass
=
*
pRes
;
*
pPass
=
*
pRes
;
...
@@ -820,6 +826,7 @@ int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache) {
...
@@ -820,6 +826,7 @@ int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache) {
int32_t
getUdfInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pFunc
,
SFuncInfo
*
pInfo
)
{
int32_t
getUdfInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pFunc
,
SFuncInfo
*
pInfo
)
{
SFuncInfo
**
pRes
=
taosHashGet
(
pMetaCache
->
pUdf
,
pFunc
,
strlen
(
pFunc
));
SFuncInfo
**
pRes
=
taosHashGet
(
pMetaCache
->
pUdf
,
pFunc
,
strlen
(
pFunc
));
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
if
(
NULL
==
pRes
||
NULL
==
*
pRes
)
{
parserError
(
"getUdfInfoFromCache error: %s"
,
pFunc
);
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
return
TSDB_CODE_PAR_INTERNAL_ERROR
;
}
}
memcpy
(
pInfo
,
*
pRes
,
sizeof
(
SFuncInfo
));
memcpy
(
pInfo
,
*
pRes
,
sizeof
(
SFuncInfo
));
...
...
source/libs/parser/test/parInsertTest.cpp
浏览文件 @
40feeffd
...
@@ -59,6 +59,7 @@ class InsertTest : public Test {
...
@@ -59,6 +59,7 @@ class InsertTest : public Test {
}
}
int32_t
runAsync
()
{
int32_t
runAsync
()
{
cxt_
.
async
=
true
;
code_
=
parseInsertSyntax
(
&
cxt_
,
&
res_
);
code_
=
parseInsertSyntax
(
&
cxt_
,
&
res_
);
if
(
code_
!=
TSDB_CODE_SUCCESS
)
{
if
(
code_
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"parseInsertSyntax code:"
<<
toString
(
code_
)
<<
", msg:"
<<
errMagBuf_
<<
endl
;
cout
<<
"parseInsertSyntax code:"
<<
toString
(
code_
)
<<
", msg:"
<<
errMagBuf_
<<
endl
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录