Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3b5828c0
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看板
提交
3b5828c0
编写于
2月 08, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/mnode
上级
a2162892
f300c38e
变更
54
显示空白变更内容
内联
并排
Showing
54 changed file
with
2711 addition
and
1408 deletion
+2711
-1408
example/src/tmq.c
example/src/tmq.c
+5
-5
include/common/tmsg.h
include/common/tmsg.h
+7
-7
include/common/ttokendef.h
include/common/ttokendef.h
+5
-6
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+7
-3
include/libs/qcom/query.h
include/libs/qcom/query.h
+6
-6
include/nodes/nodes.h
include/nodes/nodes.h
+19
-5
include/util/taoserror.h
include/util/taoserror.h
+4
-1
source/client/src/clientHb.c
source/client/src/clientHb.c
+128
-16
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+3
-2
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+3
-6
source/client/test/CMakeLists.txt
source/client/test/CMakeLists.txt
+13
-1
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+0
-113
source/client/test/tmqTest.cpp
source/client/test/tmqTest.cpp
+154
-0
source/dnode/mgmt/impl/test/sut/src/sut.cpp
source/dnode/mgmt/impl/test/sut/src/sut.cpp
+2
-2
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-1
source/dnode/mnode/impl/inc/mndStb.h
source/dnode/mnode/impl/inc/mndStb.h
+3
-0
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+1
-1
source/dnode/mnode/impl/src/mndCluster.c
source/dnode/mnode/impl/src/mndCluster.c
+2
-2
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+4
-4
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+2
-2
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+1
-1
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+1
-1
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+12
-4
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+1
-1
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+1
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+117
-9
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+2
-2
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+2
-2
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+1
-1
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+2
-2
source/dnode/mnode/impl/test/show/show.cpp
source/dnode/mnode/impl/test/show/show.cpp
+1
-1
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+5
-3
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+5
-5
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+26
-29
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+479
-295
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+43
-26
source/libs/parser/inc/astCreateFuncs.h
source/libs/parser/inc/astCreateFuncs.h
+1
-1
source/libs/parser/inc/new_sql.y
source/libs/parser/inc/new_sql.y
+5
-5
source/libs/parser/inc/parserImpl.h
source/libs/parser/inc/parserImpl.h
+1
-0
source/libs/parser/src/astCreateFuncs.c
source/libs/parser/src/astCreateFuncs.c
+15
-8
source/libs/parser/src/astTranslate.c
source/libs/parser/src/astTranslate.c
+0
-18
source/libs/parser/src/new_sql.c
source/libs/parser/src/new_sql.c
+678
-689
source/libs/parser/src/parserImpl.c
source/libs/parser/src/parserImpl.c
+445
-3
source/libs/parser/test/newParserTest.cpp
source/libs/parser/test/newParserTest.cpp
+140
-26
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+27
-25
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+2
-2
source/libs/scheduler/inc/schedulerInt.h
source/libs/scheduler/inc/schedulerInt.h
+1
-1
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+4
-4
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+7
-1
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+15
-14
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+26
-4
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+15
-13
source/nodes/src/nodesTraverseFuncs.c
source/nodes/src/nodesTraverseFuncs.c
+61
-28
tests/parallel_test/Jenkinsfile
tests/parallel_test/Jenkinsfile
+200
-0
未找到文件。
example/src/tmq.c
浏览文件 @
3b5828c0
...
@@ -135,30 +135,30 @@ void basic_consume_loop(tmq_t *tmq,
...
@@ -135,30 +135,30 @@ void basic_consume_loop(tmq_t *tmq,
fprintf
(
stderr
,
"%% Consumer closed
\n
"
);
fprintf
(
stderr
,
"%% Consumer closed
\n
"
);
}
}
void
sync_consume_loop
(
tmq_t
*
rk
,
void
sync_consume_loop
(
tmq_t
*
tmq
,
tmq_list_t
*
topics
)
{
tmq_list_t
*
topics
)
{
static
const
int
MIN_COMMIT_COUNT
=
1000
;
static
const
int
MIN_COMMIT_COUNT
=
1000
;
int
msg_count
=
0
;
int
msg_count
=
0
;
tmq_resp_err_t
err
;
tmq_resp_err_t
err
;
if
((
err
=
tmq_subscribe
(
rk
,
topics
)))
{
if
((
err
=
tmq_subscribe
(
tmq
,
topics
)))
{
fprintf
(
stderr
,
"%% Failed to start consuming topics: %s
\n
"
,
tmq_err2str
(
err
));
fprintf
(
stderr
,
"%% Failed to start consuming topics: %s
\n
"
,
tmq_err2str
(
err
));
return
;
return
;
}
}
while
(
running
)
{
while
(
running
)
{
tmq_message_t
*
tmqmessage
=
tmq_consumer_poll
(
rk
,
500
);
tmq_message_t
*
tmqmessage
=
tmq_consumer_poll
(
tmq
,
500
);
if
(
tmqmessage
)
{
if
(
tmqmessage
)
{
msg_process
(
tmqmessage
);
msg_process
(
tmqmessage
);
tmq_message_destroy
(
tmqmessage
);
tmq_message_destroy
(
tmqmessage
);
if
((
++
msg_count
%
MIN_COMMIT_COUNT
)
==
0
)
if
((
++
msg_count
%
MIN_COMMIT_COUNT
)
==
0
)
tmq_commit
(
rk
,
NULL
,
0
);
tmq_commit
(
tmq
,
NULL
,
0
);
}
}
}
}
err
=
tmq_consumer_close
(
rk
);
err
=
tmq_consumer_close
(
tmq
);
if
(
err
)
if
(
err
)
fprintf
(
stderr
,
"%% Failed to close consumer: %s
\n
"
,
tmq_err2str
(
err
));
fprintf
(
stderr
,
"%% Failed to close consumer: %s
\n
"
,
tmq_err2str
(
err
));
else
else
...
...
include/common/tmsg.h
浏览文件 @
3b5828c0
...
@@ -154,8 +154,8 @@ typedef enum _mgmt_table {
...
@@ -154,8 +154,8 @@ typedef enum _mgmt_table {
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
char
*
dbName
;
char
*
db
F
Name
;
char
*
t
ableFull
Name
;
char
*
t
b
Name
;
}
SBuildTableMetaInput
;
}
SBuildTableMetaInput
;
typedef
struct
{
typedef
struct
{
...
@@ -697,8 +697,8 @@ typedef struct {
...
@@ -697,8 +697,8 @@ typedef struct {
typedef
struct
{
typedef
struct
{
SMsgHead
header
;
SMsgHead
header
;
char
dbF
n
ame
[
TSDB_DB_FNAME_LEN
];
char
dbF
N
ame
[
TSDB_DB_FNAME_LEN
];
char
t
ableFname
[
TSDB_TABLE_F
NAME_LEN
];
char
t
bName
[
TSDB_TABLE_
NAME_LEN
];
}
STableInfoReq
;
}
STableInfoReq
;
typedef
struct
{
typedef
struct
{
...
@@ -723,9 +723,9 @@ typedef struct {
...
@@ -723,9 +723,9 @@ typedef struct {
}
SVgroupsInfo
;
}
SVgroupsInfo
;
typedef
struct
{
typedef
struct
{
char
tb
Fname
[
TSDB_TABLE_FNAME_LEN
];
// table full name
char
tb
Name
[
TSDB_TABLE_NAME_LEN
];
char
stb
Fname
[
TSDB_TABLE_F
NAME_LEN
];
char
stb
Name
[
TSDB_TABLE_
NAME_LEN
];
char
dbF
n
ame
[
TSDB_DB_FNAME_LEN
];
char
dbF
N
ame
[
TSDB_DB_FNAME_LEN
];
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int8_t
precision
;
int8_t
precision
;
...
...
include/common/ttokendef.h
浏览文件 @
3b5828c0
...
@@ -273,12 +273,11 @@
...
@@ -273,12 +273,11 @@
#define NEW_TK_SOFFSET 64
#define NEW_TK_SOFFSET 64
#define NEW_TK_LIMIT 65
#define NEW_TK_LIMIT 65
#define NEW_TK_OFFSET 66
#define NEW_TK_OFFSET 66
#define NEW_TK_NK_LR 67
#define NEW_TK_ASC 67
#define NEW_TK_ASC 68
#define NEW_TK_DESC 68
#define NEW_TK_DESC 69
#define NEW_TK_NULLS 69
#define NEW_TK_NULLS 70
#define NEW_TK_FIRST 70
#define NEW_TK_FIRST 71
#define NEW_TK_LAST 71
#define NEW_TK_LAST 72
#define TK_SPACE 300
#define TK_SPACE 300
#define TK_COMMENT 301
#define TK_COMMENT 301
...
...
include/libs/catalog/catalog.h
浏览文件 @
3b5828c0
...
@@ -49,17 +49,19 @@ typedef struct SCatalogCfg {
...
@@ -49,17 +49,19 @@ typedef struct SCatalogCfg {
uint32_t
maxTblCacheNum
;
uint32_t
maxTblCacheNum
;
uint32_t
maxDBCacheNum
;
uint32_t
maxDBCacheNum
;
uint32_t
dbRentSec
;
uint32_t
dbRentSec
;
uint32_t
st
able
RentSec
;
uint32_t
st
b
RentSec
;
}
SCatalogCfg
;
}
SCatalogCfg
;
typedef
struct
SSTableMetaVersion
{
typedef
struct
SSTableMetaVersion
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
stbName
[
TSDB_TABLE_NAME_LEN
];
uint64_t
suid
;
uint64_t
suid
;
int16_t
sversion
;
int16_t
sversion
;
int16_t
tversion
;
int16_t
tversion
;
}
SSTableMetaVersion
;
}
SSTableMetaVersion
;
typedef
struct
SDbVgVersion
{
typedef
struct
SDbVgVersion
{
char
dbName
[
TSDB_DB_FNAME_LEN
];
char
db
F
Name
[
TSDB_DB_FNAME_LEN
];
int64_t
dbId
;
int64_t
dbId
;
int32_t
vgVersion
;
int32_t
vgVersion
;
}
SDbVgVersion
;
}
SDbVgVersion
;
...
@@ -99,7 +101,9 @@ int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pTransporter, const
...
@@ -99,7 +101,9 @@ int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pTransporter, const
int32_t
catalogUpdateDBVgroup
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
);
int32_t
catalogUpdateDBVgroup
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
);
int32_t
catalogRemoveDBVgroup
(
struct
SCatalog
*
pCatalog
,
SDbVgVersion
*
dbInfo
);
int32_t
catalogRemoveDB
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
uint64_t
dbId
);
int32_t
catalogRemoveSTableMeta
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
const
char
*
stbName
,
uint64_t
suid
);
/**
/**
* Get a table's meta data.
* Get a table's meta data.
...
...
include/libs/qcom/query.h
浏览文件 @
3b5828c0
...
@@ -81,16 +81,15 @@ typedef struct STableMeta {
...
@@ -81,16 +81,15 @@ typedef struct STableMeta {
}
STableMeta
;
}
STableMeta
;
typedef
struct
SDBVgroupInfo
{
typedef
struct
SDBVgroupInfo
{
SRWLatch
lock
;
uint64_t
dbId
;
uint64_t
dbId
;
int32_t
vgVersion
;
int32_t
vgVersion
;
int8_t
hashMethod
;
int8_t
hashMethod
;
SHashObj
*
vg
Info
;
//key:vgId, value:SVgroupInfo
SHashObj
*
vg
Hash
;
//key:vgId, value:SVgroupInfo
}
SDBVgroupInfo
;
}
SDBVgroupInfo
;
typedef
struct
SUseDbOutput
{
typedef
struct
SUseDbOutput
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
SDBVgroupInfo
dbVgroup
;
SDBVgroupInfo
*
dbVgroup
;
}
SUseDbOutput
;
}
SUseDbOutput
;
enum
{
enum
{
...
@@ -103,8 +102,9 @@ enum {
...
@@ -103,8 +102,9 @@ enum {
typedef
struct
STableMetaOutput
{
typedef
struct
STableMetaOutput
{
int32_t
metaType
;
int32_t
metaType
;
char
ctbFname
[
TSDB_TABLE_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
tbFname
[
TSDB_TABLE_FNAME_LEN
];
char
ctbName
[
TSDB_TABLE_NAME_LEN
];
char
tbName
[
TSDB_TABLE_NAME_LEN
];
SCTableMeta
ctbMeta
;
SCTableMeta
ctbMeta
;
STableMeta
*
tbMeta
;
STableMeta
*
tbMeta
;
}
STableMetaOutput
;
}
STableMetaOutput
;
...
...
include/nodes/nodes.h
浏览文件 @
3b5828c0
...
@@ -78,6 +78,11 @@ typedef struct SNodeList {
...
@@ -78,6 +78,11 @@ typedef struct SNodeList {
SListCell
*
pTail
;
SListCell
*
pTail
;
}
SNodeList
;
}
SNodeList
;
typedef
struct
SNameStr
{
int32_t
len
;
char
*
pName
;
}
SNameStr
;
typedef
struct
SDataType
{
typedef
struct
SDataType
{
uint8_t
type
;
uint8_t
type
;
uint8_t
precision
;
uint8_t
precision
;
...
@@ -89,6 +94,7 @@ typedef struct SExprNode {
...
@@ -89,6 +94,7 @@ typedef struct SExprNode {
ENodeType
nodeType
;
ENodeType
nodeType
;
SDataType
resType
;
SDataType
resType
;
char
aliasName
[
TSDB_COL_NAME_LEN
];
char
aliasName
[
TSDB_COL_NAME_LEN
];
SNodeList
*
pAssociationList
;
}
SExprNode
;
}
SExprNode
;
typedef
enum
EColumnType
{
typedef
enum
EColumnType
{
...
@@ -102,7 +108,9 @@ typedef struct SColumnNode {
...
@@ -102,7 +108,9 @@ typedef struct SColumnNode {
EColumnType
colType
;
// column or tag
EColumnType
colType
;
// column or tag
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableAlias
[
TSDB_TABLE_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
SNode
*
pProjectRef
;
}
SColumnNode
;
}
SColumnNode
;
typedef
struct
SValueNode
{
typedef
struct
SValueNode
{
...
@@ -176,13 +184,16 @@ typedef struct SFunctionNode {
...
@@ -176,13 +184,16 @@ typedef struct SFunctionNode {
typedef
struct
STableNode
{
typedef
struct
STableNode
{
ENodeType
type
;
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableAlias
Name
[
TSDB_COL
_NAME_LEN
];
char
tableAlias
[
TSDB_TABLE
_NAME_LEN
];
}
STableNode
;
}
STableNode
;
struct
STableMeta
;
typedef
struct
SRealTableNode
{
typedef
struct
SRealTableNode
{
STableNode
table
;
// QUERY_NODE_REAL_TABLE
STableNode
table
;
// QUERY_NODE_REAL_TABLE
char
dbName
[
TSDB_DB_NAME_LEN
]
;
struct
STableMeta
*
pMeta
;
}
SRealTableNode
;
}
SRealTableNode
;
typedef
struct
STempTableNode
{
typedef
struct
STempTableNode
{
...
@@ -273,7 +284,6 @@ typedef struct SFillNode {
...
@@ -273,7 +284,6 @@ typedef struct SFillNode {
typedef
struct
SSelectStmt
{
typedef
struct
SSelectStmt
{
ENodeType
type
;
// QUERY_NODE_SELECT_STMT
ENodeType
type
;
// QUERY_NODE_SELECT_STMT
bool
isDistinct
;
bool
isDistinct
;
bool
isStar
;
SNodeList
*
pProjectionList
;
// SNode
SNodeList
*
pProjectionList
;
// SNode
SNode
*
pFromTable
;
SNode
*
pFromTable
;
SNode
*
pWhere
;
SNode
*
pWhere
;
...
@@ -295,6 +305,8 @@ typedef struct SSetOperator {
...
@@ -295,6 +305,8 @@ typedef struct SSetOperator {
ESetOperatorType
opType
;
ESetOperatorType
opType
;
SNode
*
pLeft
;
SNode
*
pLeft
;
SNode
*
pRight
;
SNode
*
pRight
;
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNode
*
pLimit
;
}
SSetOperator
;
}
SSetOperator
;
SNode
*
nodesMakeNode
(
ENodeType
type
);
SNode
*
nodesMakeNode
(
ENodeType
type
);
...
@@ -306,8 +318,10 @@ void nodesDestroyList(SNodeList* pList);
...
@@ -306,8 +318,10 @@ void nodesDestroyList(SNodeList* pList);
typedef
bool
(
*
FQueryNodeWalker
)(
SNode
*
pNode
,
void
*
pContext
);
typedef
bool
(
*
FQueryNodeWalker
)(
SNode
*
pNode
,
void
*
pContext
);
bool
nodesWalkNode
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
);
void
nodesWalkNode
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
);
bool
nodesWalkList
(
SNodeList
*
pList
,
FQueryNodeWalker
walker
,
void
*
pContext
);
void
nodesWalkList
(
SNodeList
*
pList
,
FQueryNodeWalker
walker
,
void
*
pContext
);
void
nodesWalkNodePostOrder
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
);
void
nodesWalkListPostOrder
(
SNodeList
*
pList
,
FQueryNodeWalker
walker
,
void
*
pContext
);
bool
nodesWalkStmt
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
);
bool
nodesWalkStmt
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
);
...
...
include/util/taoserror.h
浏览文件 @
3b5828c0
...
@@ -440,7 +440,10 @@ int32_t* taosGetErrno();
...
@@ -440,7 +440,10 @@ int32_t* taosGetErrno();
#define TSDB_CODE_SCH_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2501) //scheduler status error
#define TSDB_CODE_SCH_STATUS_ERROR TAOS_DEF_ERROR_CODE(0, 0x2501) //scheduler status error
#define TSDB_CODE_SCH_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2502) //scheduler internal error
#define TSDB_CODE_SCH_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2502) //scheduler internal error
//parser
#define TSDB_CODE_PARSER_INVALID_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2601) //invalid column name
#define TSDB_CODE_PARSER_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x2602) //table not exist
#define TSDB_CODE_PARSER_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603) //ambiguous column
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/client/src/clientHb.c
浏览文件 @
3b5828c0
...
@@ -41,19 +41,14 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
...
@@ -41,19 +41,14 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
tscDebug
(
"hb db rsp, db:%s, vgVersion:%d, uid:%"
PRIx64
,
rsp
->
db
,
rsp
->
vgVersion
,
rsp
->
uid
);
tscDebug
(
"hb db rsp, db:%s, vgVersion:%d, uid:%"
PRIx64
,
rsp
->
db
,
rsp
->
vgVersion
,
rsp
->
uid
);
if
(
rsp
->
vgVersion
<
0
)
{
if
(
rsp
->
vgVersion
<
0
)
{
SDbVgVersion
dbInfo
;
code
=
catalogRemoveDB
(
pCatalog
,
rsp
->
db
,
rsp
->
uid
);
strcpy
(
dbInfo
.
dbName
,
rsp
->
db
);
dbInfo
.
dbId
=
rsp
->
uid
;
dbInfo
.
vgVersion
=
rsp
->
vgVersion
;
code
=
catalogRemoveDBVgroup
(
pCatalog
,
&
dbInfo
);
}
else
{
}
else
{
SDBVgroupInfo
vgInfo
=
{
0
};
SDBVgroupInfo
vgInfo
=
{
0
};
vgInfo
.
dbId
=
rsp
->
uid
;
vgInfo
.
dbId
=
rsp
->
uid
;
vgInfo
.
vgVersion
=
rsp
->
vgVersion
;
vgInfo
.
vgVersion
=
rsp
->
vgVersion
;
vgInfo
.
hashMethod
=
rsp
->
hashMethod
;
vgInfo
.
hashMethod
=
rsp
->
hashMethod
;
vgInfo
.
vg
Info
=
taosHashInit
(
rsp
->
vgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
vgInfo
.
vg
Hash
=
taosHashInit
(
rsp
->
vgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
vgInfo
.
vg
Info
)
{
if
(
NULL
==
vgInfo
.
vg
Hash
)
{
tscError
(
"hash init[%d] failed"
,
rsp
->
vgNum
);
tscError
(
"hash init[%d] failed"
,
rsp
->
vgNum
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
...
@@ -67,16 +62,16 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
...
@@ -67,16 +62,16 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
rsp
->
vgroupInfo
[
i
].
epset
.
eps
[
n
].
port
=
ntohs
(
rsp
->
vgroupInfo
[
i
].
epset
.
eps
[
n
].
port
);
rsp
->
vgroupInfo
[
i
].
epset
.
eps
[
n
].
port
=
ntohs
(
rsp
->
vgroupInfo
[
i
].
epset
.
eps
[
n
].
port
);
}
}
if
(
0
!=
taosHashPut
(
vgInfo
.
vg
Info
,
&
rsp
->
vgroupInfo
[
i
].
vgId
,
sizeof
(
rsp
->
vgroupInfo
[
i
].
vgId
),
&
rsp
->
vgroupInfo
[
i
],
sizeof
(
rsp
->
vgroupInfo
[
i
])))
{
if
(
0
!=
taosHashPut
(
vgInfo
.
vg
Hash
,
&
rsp
->
vgroupInfo
[
i
].
vgId
,
sizeof
(
rsp
->
vgroupInfo
[
i
].
vgId
),
&
rsp
->
vgroupInfo
[
i
],
sizeof
(
rsp
->
vgroupInfo
[
i
])))
{
tscError
(
"hash push failed, errno:%d"
,
errno
);
tscError
(
"hash push failed, errno:%d"
,
errno
);
taosHashCleanup
(
vgInfo
.
vg
Info
);
taosHashCleanup
(
vgInfo
.
vg
Hash
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
}
}
code
=
catalogUpdateDBVgroup
(
pCatalog
,
rsp
->
db
,
&
vgInfo
);
code
=
catalogUpdateDBVgroup
(
pCatalog
,
rsp
->
db
,
&
vgInfo
);
if
(
code
)
{
if
(
code
)
{
taosHashCleanup
(
vgInfo
.
vg
Info
);
taosHashCleanup
(
vgInfo
.
vg
Hash
);
}
}
}
}
...
@@ -90,6 +85,75 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
...
@@ -90,6 +85,75 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
hbProcessStbInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
)
{
int32_t
msgLen
=
0
;
int32_t
code
=
0
;
int32_t
schemaNum
=
0
;
while
(
msgLen
<
valueLen
)
{
STableMetaRsp
*
rsp
=
(
STableMetaRsp
*
)((
char
*
)
value
+
msgLen
);
rsp
->
numOfColumns
=
ntohl
(
rsp
->
numOfColumns
);
rsp
->
suid
=
be64toh
(
rsp
->
suid
);
if
(
rsp
->
numOfColumns
<
0
)
{
schemaNum
=
0
;
tscDebug
(
"hb remove stb, db:%s, stb:%s"
,
rsp
->
dbFName
,
rsp
->
stbName
);
code
=
catalogRemoveSTableMeta
(
pCatalog
,
rsp
->
dbFName
,
rsp
->
stbName
,
rsp
->
suid
);
}
else
{
rsp
->
numOfTags
=
ntohl
(
rsp
->
numOfTags
);
schemaNum
=
rsp
->
numOfColumns
+
rsp
->
numOfTags
;
/*
rsp->vgNum = ntohl(rsp->vgNum);
rsp->uid = be64toh(rsp->uid);
SDBVgroupInfo vgInfo = {0};
vgInfo.dbId = rsp->uid;
vgInfo.vgVersion = rsp->vgVersion;
vgInfo.hashMethod = rsp->hashMethod;
vgInfo.vgHash = taosHashInit(rsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
if (NULL == vgInfo.vgHash) {
tscError("hash init[%d] failed", rsp->vgNum);
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
for (int32_t i = 0; i < rsp->vgNum; ++i) {
rsp->vgroupInfo[i].vgId = ntohl(rsp->vgroupInfo[i].vgId);
rsp->vgroupInfo[i].hashBegin = ntohl(rsp->vgroupInfo[i].hashBegin);
rsp->vgroupInfo[i].hashEnd = ntohl(rsp->vgroupInfo[i].hashEnd);
for (int32_t n = 0; n < rsp->vgroupInfo[i].epset.numOfEps; ++n) {
rsp->vgroupInfo[i].epset.eps[n].port = ntohs(rsp->vgroupInfo[i].epset.eps[n].port);
}
if (0 != taosHashPut(vgInfo.vgHash, &rsp->vgroupInfo[i].vgId, sizeof(rsp->vgroupInfo[i].vgId), &rsp->vgroupInfo[i], sizeof(rsp->vgroupInfo[i]))) {
tscError("hash push failed, errno:%d", errno);
taosHashCleanup(vgInfo.vgHash);
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
}
code = catalogUpdateDBVgroup(pCatalog, rsp->db, &vgInfo);
if (code) {
taosHashCleanup(vgInfo.vgHash);
}
*/
}
if
(
code
)
{
return
code
;
}
msgLen
+=
sizeof
(
STableMetaRsp
)
+
schemaNum
*
sizeof
(
SSchema
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
hbQueryHbRspHandle
(
struct
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
static
int32_t
hbQueryHbRspHandle
(
struct
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
SHbConnInfo
*
info
=
taosHashGet
(
pAppHbMgr
->
connInfo
,
&
pRsp
->
connKey
,
sizeof
(
SClientHbKey
));
SHbConnInfo
*
info
=
taosHashGet
(
pAppHbMgr
->
connInfo
,
&
pRsp
->
connKey
,
sizeof
(
SClientHbKey
));
if
(
NULL
==
info
)
{
if
(
NULL
==
info
)
{
...
@@ -122,9 +186,24 @@ static int32_t hbQueryHbRspHandle(struct SAppHbMgr *pAppHbMgr, SClientHbRsp* pRs
...
@@ -122,9 +186,24 @@ static int32_t hbQueryHbRspHandle(struct SAppHbMgr *pAppHbMgr, SClientHbRsp* pRs
hbProcessDBInfoRsp
(
kv
->
value
,
kv
->
valueLen
,
pCatalog
);
hbProcessDBInfoRsp
(
kv
->
value
,
kv
->
valueLen
,
pCatalog
);
break
;
break
;
}
}
case
HEARTBEAT_KEY_STBINFO
:
case
HEARTBEAT_KEY_STBINFO
:{
if
(
kv
->
valueLen
<=
0
||
NULL
==
kv
->
value
)
{
tscError
(
"invalid hb stb info, len:%d, value:%p"
,
kv
->
valueLen
,
kv
->
value
);
break
;
}
int64_t
*
clusterId
=
(
int64_t
*
)
info
->
param
;
struct
SCatalog
*
pCatalog
=
NULL
;
int32_t
code
=
catalogGetHandle
(
*
clusterId
,
&
pCatalog
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscWarn
(
"catalogGetHandle failed, clusterId:%"
PRIx64
", error:%s"
,
*
clusterId
,
tstrerror
(
code
));
break
;
}
hbProcessStbInfoRsp
(
kv
->
value
,
kv
->
valueLen
,
pCatalog
);
break
;
break
;
}
default:
default:
tscError
(
"invalid hb key type:%d"
,
kv
->
key
);
tscError
(
"invalid hb key type:%d"
,
kv
->
key
);
break
;
break
;
...
@@ -157,7 +236,7 @@ static int32_t hbMqAsyncCallBack(void* param, const SDataBuf* pMsg, int32_t code
...
@@ -157,7 +236,7 @@ static int32_t hbMqAsyncCallBack(void* param, const SDataBuf* pMsg, int32_t code
tfree
(
param
);
tfree
(
param
);
if
(
rspNum
)
{
if
(
rspNum
)
{
tscDebug
(
"hb got %d rsp, %d empty rsp
prior
"
,
rspNum
,
atomic_val_compare_exchange_32
(
&
emptyRspNum
,
emptyRspNum
,
0
));
tscDebug
(
"hb got %d rsp, %d empty rsp
received before
"
,
rspNum
,
atomic_val_compare_exchange_32
(
&
emptyRspNum
,
emptyRspNum
,
0
));
}
else
{
}
else
{
atomic_add_fetch_32
(
&
emptyRspNum
,
1
);
atomic_add_fetch_32
(
&
emptyRspNum
,
1
);
}
}
...
@@ -204,6 +283,37 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
...
@@ -204,6 +283,37 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
hbGetExpiredStbInfo
(
SClientHbKey
*
connKey
,
struct
SCatalog
*
pCatalog
,
SClientHbReq
*
req
)
{
SSTableMetaVersion
*
stbs
=
NULL
;
uint32_t
stbNum
=
0
;
int32_t
code
=
0
;
code
=
catalogGetExpiredSTables
(
pCatalog
,
&
stbs
,
&
stbNum
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
if
(
stbNum
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
}
for
(
int32_t
i
=
0
;
i
<
stbNum
;
++
i
)
{
SSTableMetaVersion
*
stb
=
&
stbs
[
i
];
stb
->
suid
=
htobe64
(
stb
->
suid
);
stb
->
sversion
=
htons
(
stb
->
sversion
);
stb
->
tversion
=
htons
(
stb
->
tversion
);
}
SKv
kv
=
{.
key
=
HEARTBEAT_KEY_STBINFO
,
.
valueLen
=
sizeof
(
SSTableMetaVersion
)
*
stbNum
,
.
value
=
stbs
};
tscDebug
(
"hb got %d expired stb, valueLen:%d"
,
stbNum
,
kv
.
valueLen
);
taosHashPut
(
req
->
info
,
&
kv
.
key
,
sizeof
(
kv
.
key
),
&
kv
,
sizeof
(
kv
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
hbQueryHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{
int32_t
hbQueryHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{
int64_t
*
clusterId
=
(
int64_t
*
)
param
;
int64_t
*
clusterId
=
(
int64_t
*
)
param
;
struct
SCatalog
*
pCatalog
=
NULL
;
struct
SCatalog
*
pCatalog
=
NULL
;
...
@@ -219,6 +329,11 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void* param, SClientHbReq *req
...
@@ -219,6 +329,11 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void* param, SClientHbReq *req
return
code
;
return
code
;
}
}
code
=
hbGetExpiredStbInfo
(
connKey
,
pCatalog
,
req
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -389,7 +504,6 @@ static void hbStopThread() {
...
@@ -389,7 +504,6 @@ static void hbStopThread() {
}
}
SAppHbMgr
*
appHbMgrInit
(
SAppInstInfo
*
pAppInstInfo
,
char
*
key
)
{
SAppHbMgr
*
appHbMgrInit
(
SAppInstInfo
*
pAppInstInfo
,
char
*
key
)
{
return
NULL
;
hbMgrInit
();
hbMgrInit
();
SAppHbMgr
*
pAppHbMgr
=
malloc
(
sizeof
(
SAppHbMgr
));
SAppHbMgr
*
pAppHbMgr
=
malloc
(
sizeof
(
SAppHbMgr
));
if
(
pAppHbMgr
==
NULL
)
{
if
(
pAppHbMgr
==
NULL
)
{
...
@@ -447,7 +561,6 @@ void appHbMgrCleanup(void) {
...
@@ -447,7 +561,6 @@ void appHbMgrCleanup(void) {
}
}
int
hbMgrInit
()
{
int
hbMgrInit
()
{
return
0
;
// init once
// init once
int8_t
old
=
atomic_val_compare_exchange_8
(
&
clientHbMgr
.
inited
,
0
,
1
);
int8_t
old
=
atomic_val_compare_exchange_8
(
&
clientHbMgr
.
inited
,
0
,
1
);
if
(
old
==
1
)
return
0
;
if
(
old
==
1
)
return
0
;
...
@@ -504,7 +617,6 @@ int hbRegisterConnImpl(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, SHbConnInfo *
...
@@ -504,7 +617,6 @@ int hbRegisterConnImpl(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, SHbConnInfo *
}
}
int
hbRegisterConn
(
SAppHbMgr
*
pAppHbMgr
,
int32_t
connId
,
int64_t
clusterId
,
int32_t
hbType
)
{
int
hbRegisterConn
(
SAppHbMgr
*
pAppHbMgr
,
int32_t
connId
,
int64_t
clusterId
,
int32_t
hbType
)
{
return
0
;
SClientHbKey
connKey
=
{.
connId
=
connId
,
.
hbType
=
HEARTBEAT_TYPE_QUERY
};
SClientHbKey
connKey
=
{.
connId
=
connId
,
.
hbType
=
HEARTBEAT_TYPE_QUERY
};
SHbConnInfo
info
=
{
0
};
SHbConnInfo
info
=
{
0
};
...
...
source/client/src/clientImpl.c
浏览文件 @
3b5828c0
...
@@ -105,11 +105,12 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
...
@@ -105,11 +105,12 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
pthread_mutex_lock
(
&
appInfo
.
mutex
);
pthread_mutex_lock
(
&
appInfo
.
mutex
);
pInst
=
taosHashGet
(
appInfo
.
pInstMap
,
key
,
strlen
(
key
));
pInst
=
taosHashGet
(
appInfo
.
pInstMap
,
key
,
strlen
(
key
));
SAppInstInfo
*
p
=
NULL
;
if
(
pInst
==
NULL
)
{
if
(
pInst
==
NULL
)
{
SAppInstInfo
*
p
=
calloc
(
1
,
sizeof
(
struct
SAppInstInfo
));
p
=
calloc
(
1
,
sizeof
(
struct
SAppInstInfo
));
p
->
mgmtEp
=
epSet
;
p
->
mgmtEp
=
epSet
;
p
->
pTransporter
=
openTransporter
(
user
,
secretEncrypt
,
tsNumOfCores
);
p
->
pTransporter
=
openTransporter
(
user
,
secretEncrypt
,
tsNumOfCores
);
/*p->pAppHbMgr = appHbMgrInit(p, key);*/
p
->
pAppHbMgr
=
appHbMgrInit
(
p
,
key
);
taosHashPut
(
appInfo
.
pInstMap
,
key
,
strlen
(
key
),
&
p
,
POINTER_BYTES
);
taosHashPut
(
appInfo
.
pInstMap
,
key
,
strlen
(
key
),
&
p
,
POINTER_BYTES
);
pInst
=
&
p
;
pInst
=
&
p
;
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
3b5828c0
...
@@ -76,7 +76,7 @@ int processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -76,7 +76,7 @@ int processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) {
pTscObj
->
connType
=
HEARTBEAT_TYPE_QUERY
;
pTscObj
->
connType
=
HEARTBEAT_TYPE_QUERY
;
/*hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, pConnect->connId, pConnect->clusterId, HEARTBEAT_TYPE_QUERY);*/
hbRegisterConn
(
pTscObj
->
pAppInfo
->
pAppHbMgr
,
pConnect
->
connId
,
pConnect
->
clusterId
,
HEARTBEAT_TYPE_QUERY
);
// pRequest->body.resInfo.pRspMsg = pMsg->pData;
// pRequest->body.resInfo.pRspMsg = pMsg->pData;
tscDebug
(
"0x%"
PRIx64
" clusterId:%"
PRId64
", totalConn:%"
PRId64
,
pRequest
->
requestId
,
pConnect
->
clusterId
,
tscDebug
(
"0x%"
PRIx64
" clusterId:%"
PRId64
", totalConn:%"
PRId64
,
pRequest
->
requestId
,
pConnect
->
clusterId
,
...
@@ -302,15 +302,12 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -302,15 +302,12 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
SDropDbRsp
*
rsp
=
(
SDropDbRsp
*
)
pMsg
->
pData
;
SDropDbRsp
*
rsp
=
(
SDropDbRsp
*
)
pMsg
->
pData
;
SDbVgVersion
dbVer
=
{
0
};
struct
SCatalog
*
pCatalog
=
NULL
;
struct
SCatalog
*
pCatalog
=
NULL
;
rsp
->
uid
=
be64toh
(
rsp
->
uid
);
strncpy
(
dbVer
.
dbName
,
rsp
->
db
,
sizeof
(
dbVer
.
dbName
));
dbVer
.
dbId
=
be64toh
(
rsp
->
uid
);
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
catalogRemoveDB
Vgroup
(
pCatalog
,
&
dbVer
);
catalogRemoveDB
(
pCatalog
,
rsp
->
db
,
rsp
->
uid
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
code
;
return
code
;
...
...
source/client/test/CMakeLists.txt
浏览文件 @
3b5828c0
...
@@ -5,14 +5,26 @@ MESSAGE(STATUS "build parser unit test")
...
@@ -5,14 +5,26 @@ MESSAGE(STATUS "build parser unit test")
SET
(
CMAKE_CXX_STANDARD 11
)
SET
(
CMAKE_CXX_STANDARD 11
)
AUX_SOURCE_DIRECTORY
(
${
CMAKE_CURRENT_SOURCE_DIR
}
SOURCE_LIST
)
AUX_SOURCE_DIRECTORY
(
${
CMAKE_CURRENT_SOURCE_DIR
}
SOURCE_LIST
)
ADD_EXECUTABLE
(
clientTest
${
SOURCE_LIST
}
)
ADD_EXECUTABLE
(
clientTest
clientTests.cpp
)
TARGET_LINK_LIBRARIES
(
TARGET_LINK_LIBRARIES
(
clientTest
clientTest
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
)
)
ADD_EXECUTABLE
(
tmqTest tmqTest.cpp
)
TARGET_LINK_LIBRARIES
(
tmqTest
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
)
TARGET_INCLUDE_DIRECTORIES
(
TARGET_INCLUDE_DIRECTORIES
(
clientTest
clientTest
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/client/"
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/client/"
PRIVATE
"
${
CMAKE_SOURCE_DIR
}
/source/libs/client/inc"
PRIVATE
"
${
CMAKE_SOURCE_DIR
}
/source/libs/client/inc"
)
)
TARGET_INCLUDE_DIRECTORIES
(
tmqTest
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/client/"
PRIVATE
"
${
CMAKE_SOURCE_DIR
}
/source/libs/client/inc"
)
source/client/test/clientTests.cpp
浏览文件 @
3b5828c0
...
@@ -564,119 +564,6 @@ TEST(testCase, insert_test) {
...
@@ -564,119 +564,6 @@ TEST(testCase, insert_test) {
}
}
#endif
#endif
TEST
(
testCase
,
create_topic_ctb_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
//taos_free_result(pRes);
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
ASSERT_TRUE
(
pFields
==
nullptr
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
ASSERT_EQ
(
numOfFields
,
0
);
taos_free_result
(
pRes
);
char
*
sql
=
"select * from tu"
;
pRes
=
tmq_create_topic
(
pConn
,
"test_ctb_topic_1"
,
sql
,
strlen
(
sql
));
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
TEST
(
testCase
,
create_topic_stb_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
//taos_free_result(pRes);
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
ASSERT_TRUE
(
pFields
==
nullptr
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
ASSERT_EQ
(
numOfFields
,
0
);
taos_free_result
(
pRes
);
char
*
sql
=
"select * from st1"
;
pRes
=
tmq_create_topic
(
pConn
,
"test_stb_topic_1"
,
sql
,
strlen
(
sql
));
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
#if 0
TEST(testCase, tmq_subscribe_ctb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "use abc1");
if (taos_errno(pRes) != 0) {
printf("error in use db, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes);
tmq_conf_t* conf = tmq_conf_new();
tmq_conf_set(conf, "group.id", "tg1");
tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0);
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append(topic_list, "test_ctb_topic_1");
tmq_subscribe(tmq, topic_list);
while (1) {
tmq_message_t* msg = tmq_consumer_poll(tmq, 1000);
tmq_message_destroy(msg);
//printf("get msg\n");
//if (msg == NULL) break;
}
}
#endif
TEST
(
testCase
,
tmq_subscribe_stb_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
taos_free_result
(
pRes
);
tmq_conf_t
*
conf
=
tmq_conf_new
();
tmq_conf_set
(
conf
,
"group.id"
,
"tg2"
);
tmq_t
*
tmq
=
tmq_consumer_new
(
pConn
,
conf
,
NULL
,
0
);
tmq_list_t
*
topic_list
=
tmq_list_new
();
tmq_list_append
(
topic_list
,
"test_stb_topic_1"
);
tmq_subscribe
(
tmq
,
topic_list
);
int
cnt
=
1
;
while
(
1
)
{
tmq_message_t
*
msg
=
tmq_consumer_poll
(
tmq
,
1000
);
if
(
msg
==
NULL
)
continue
;
tmqShowMsg
(
msg
);
if
(
cnt
++
%
10
==
0
){
tmq_commit
(
tmq
,
NULL
,
0
);
}
//tmq_commit(tmq, NULL, 0);
tmq_message_destroy
(
msg
);
//printf("get msg\n");
}
}
TEST
(
testCase
,
tmq_consume_Test
)
{
}
TEST
(
testCase
,
tmq_commit_TEST
)
{
}
#if 0
#if 0
TEST(testCase, projection_query_tables) {
TEST(testCase, projection_query_tables) {
...
...
source/client/test/tmqTest.cpp
0 → 100644
浏览文件 @
3b5828c0
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtest/gtest.h>
#include <taoserror.h>
#include <tglobal.h>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "../inc/clientInt.h"
#include "taos.h"
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
TEST
(
testCase
,
driverInit_Test
)
{
taosInitGlobalCfg
();
// taos_init();
}
TEST
(
testCase
,
create_topic_ctb_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
//taos_free_result(pRes);
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
ASSERT_TRUE
(
pFields
==
nullptr
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
ASSERT_EQ
(
numOfFields
,
0
);
taos_free_result
(
pRes
);
char
*
sql
=
"select * from tu"
;
pRes
=
tmq_create_topic
(
pConn
,
"test_ctb_topic_1"
,
sql
,
strlen
(
sql
));
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
TEST
(
testCase
,
create_topic_stb_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
//taos_free_result(pRes);
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
ASSERT_TRUE
(
pFields
==
nullptr
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
ASSERT_EQ
(
numOfFields
,
0
);
taos_free_result
(
pRes
);
char
*
sql
=
"select * from st1"
;
pRes
=
tmq_create_topic
(
pConn
,
"test_stb_topic_1"
,
sql
,
strlen
(
sql
));
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
#if 0
TEST(testCase, tmq_subscribe_ctb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "use abc1");
if (taos_errno(pRes) != 0) {
printf("error in use db, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes);
tmq_conf_t* conf = tmq_conf_new();
tmq_conf_set(conf, "group.id", "tg1");
tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0);
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append(topic_list, "test_ctb_topic_1");
tmq_subscribe(tmq, topic_list);
while (1) {
tmq_message_t* msg = tmq_consumer_poll(tmq, 1000);
tmq_message_destroy(msg);
//printf("get msg\n");
//if (msg == NULL) break;
}
}
TEST(testCase, tmq_subscribe_stb_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
TAOS_RES* pRes = taos_query(pConn, "use abc1");
if (taos_errno(pRes) != 0) {
printf("error in use db, reason:%s\n", taos_errstr(pRes));
}
taos_free_result(pRes);
tmq_conf_t* conf = tmq_conf_new();
tmq_conf_set(conf, "group.id", "tg2");
tmq_t* tmq = tmq_consumer_new(pConn, conf, NULL, 0);
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append(topic_list, "test_stb_topic_1");
tmq_subscribe(tmq, topic_list);
int cnt = 1;
while (1) {
tmq_message_t* msg = tmq_consumer_poll(tmq, 1000);
if (msg == NULL) continue;
tmqShowMsg(msg);
if (cnt++ % 10 == 0){
tmq_commit(tmq, NULL, 0);
}
//tmq_commit(tmq, NULL, 0);
tmq_message_destroy(msg);
//printf("get msg\n");
}
}
TEST(testCase, tmq_consume_Test) {
}
TEST(testCase, tmq_commit_Test) {
}
#endif
source/dnode/mgmt/impl/test/sut/src/sut.cpp
浏览文件 @
3b5828c0
...
@@ -125,7 +125,7 @@ const char* Testbase::GetMetaName(int32_t index) {
...
@@ -125,7 +125,7 @@ const char* Testbase::GetMetaName(int32_t index) {
int32_t
Testbase
::
GetMetaNum
()
{
return
pMeta
->
numOfColumns
;
}
int32_t
Testbase
::
GetMetaNum
()
{
return
pMeta
->
numOfColumns
;
}
const
char
*
Testbase
::
GetMetaTbName
()
{
return
pMeta
->
tb
Fn
ame
;
}
const
char
*
Testbase
::
GetMetaTbName
()
{
return
pMeta
->
tb
N
ame
;
}
void
Testbase
::
SendShowRetrieveReq
()
{
void
Testbase
::
SendShowRetrieveReq
()
{
int32_t
contLen
=
sizeof
(
SRetrieveTableReq
);
int32_t
contLen
=
sizeof
(
SRetrieveTableReq
);
...
@@ -144,7 +144,7 @@ void Testbase::SendShowRetrieveReq() {
...
@@ -144,7 +144,7 @@ void Testbase::SendShowRetrieveReq() {
pos
=
0
;
pos
=
0
;
}
}
const
char
*
Testbase
::
GetShowName
()
{
return
pMeta
->
tb
Fn
ame
;
}
const
char
*
Testbase
::
GetShowName
()
{
return
pMeta
->
tb
N
ame
;
}
int8_t
Testbase
::
GetShowInt8
()
{
int8_t
Testbase
::
GetShowInt8
()
{
int8_t
data
=
*
((
int8_t
*
)(
pData
+
pos
));
int8_t
data
=
*
((
int8_t
*
)(
pData
+
pos
));
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
3b5828c0
...
@@ -619,7 +619,7 @@ typedef struct SMqTopicObj {
...
@@ -619,7 +619,7 @@ typedef struct SMqTopicObj {
int64_t
createTime
;
int64_t
createTime
;
int64_t
updateTime
;
int64_t
updateTime
;
uint64_t
uid
;
uint64_t
uid
;
uint64_t
dbUid
;
int64_t
dbUid
;
int32_t
version
;
int32_t
version
;
SRWLatch
lock
;
SRWLatch
lock
;
int32_t
sqlLen
;
int32_t
sqlLen
;
...
...
source/dnode/mnode/impl/inc/mndStb.h
浏览文件 @
3b5828c0
...
@@ -28,6 +28,9 @@ void mndCleanupStb(SMnode *pMnode);
...
@@ -28,6 +28,9 @@ void mndCleanupStb(SMnode *pMnode);
SStbObj
*
mndAcquireStb
(
SMnode
*
pMnode
,
char
*
stbName
);
SStbObj
*
mndAcquireStb
(
SMnode
*
pMnode
,
char
*
stbName
);
void
mndReleaseStb
(
SMnode
*
pMnode
,
SStbObj
*
pStb
);
void
mndReleaseStb
(
SMnode
*
pMnode
,
SStbObj
*
pStb
);
int32_t
mndValidateStbInfo
(
SMnode
*
pMnode
,
SSTableMetaVersion
*
stbs
,
int32_t
num
,
void
**
rsp
,
int32_t
*
rspLen
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
3b5828c0
...
@@ -426,7 +426,7 @@ static int32_t mndGetBnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
...
@@ -426,7 +426,7 @@ static int32_t mndGetBnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_BNODE
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_BNODE
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndCluster.c
浏览文件 @
3b5828c0
...
@@ -186,7 +186,7 @@ static int32_t mndGetClusterMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaRsp
...
@@ -186,7 +186,7 @@ static int32_t mndGetClusterMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaRsp
cols
++
;
cols
++
;
pMeta
->
numOfColumns
=
htonl
(
cols
);
pMeta
->
numOfColumns
=
htonl
(
cols
);
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
pShow
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
pShow
->
offset
[
0
]
=
0
;
...
@@ -196,7 +196,7 @@ static int32_t mndGetClusterMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaRsp
...
@@ -196,7 +196,7 @@ static int32_t mndGetClusterMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaRsp
pShow
->
numOfRows
=
1
;
pShow
->
numOfRows
=
1
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
3b5828c0
...
@@ -907,9 +907,9 @@ int32_t mndValidateDBInfo(SMnode *pMnode, SDbVgVersion *dbs, int32_t num, void *
...
@@ -907,9 +907,9 @@ int32_t mndValidateDBInfo(SMnode *pMnode, SDbVgVersion *dbs, int32_t num, void *
len
=
0
;
len
=
0
;
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
db
->
dbName
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
db
->
db
F
Name
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
mInfo
(
"db %s not exist"
,
db
->
dbName
);
mInfo
(
"db %s not exist"
,
db
->
db
F
Name
);
len
=
sizeof
(
SUseDbRsp
);
len
=
sizeof
(
SUseDbRsp
);
}
else
if
(
pDb
->
uid
!=
db
->
dbId
||
db
->
vgVersion
<
pDb
->
vgVersion
)
{
}
else
if
(
pDb
->
uid
!=
db
->
dbId
||
db
->
vgVersion
<
pDb
->
vgVersion
)
{
...
@@ -929,7 +929,7 @@ int32_t mndValidateDBInfo(SMnode *pMnode, SDbVgVersion *dbs, int32_t num, void *
...
@@ -929,7 +929,7 @@ int32_t mndValidateDBInfo(SMnode *pMnode, SDbVgVersion *dbs, int32_t num, void *
}
}
pRsp
=
(
SUseDbRsp
*
)((
char
*
)
buf
+
bufOffset
);
pRsp
=
(
SUseDbRsp
*
)((
char
*
)
buf
+
bufOffset
);
memcpy
(
pRsp
->
db
,
db
->
dbName
,
TSDB_DB_FNAME_LEN
);
memcpy
(
pRsp
->
db
,
db
->
db
F
Name
,
TSDB_DB_FNAME_LEN
);
if
(
pDb
)
{
if
(
pDb
)
{
int32_t
vgNum
=
0
;
int32_t
vgNum
=
0
;
mndBuildDBVgroupInfo
(
pDb
,
pMnode
,
pRsp
->
vgroupInfo
,
&
vgNum
);
mndBuildDBVgroupInfo
(
pDb
,
pMnode
,
pRsp
->
vgroupInfo
,
&
vgNum
);
...
@@ -1113,7 +1113,7 @@ static int32_t mndGetDbMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMe
...
@@ -1113,7 +1113,7 @@ static int32_t mndGetDbMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMe
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_DB
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_DB
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
3b5828c0
...
@@ -608,7 +608,7 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
...
@@ -608,7 +608,7 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
pShow
->
numOfRows
=
TSDB_CONFIG_NUMBER
;
pShow
->
numOfRows
=
TSDB_CONFIG_NUMBER
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
@@ -715,7 +715,7 @@ static int32_t mndGetDnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
...
@@ -715,7 +715,7 @@ static int32_t mndGetDnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_DNODE
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_DNODE
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
3b5828c0
...
@@ -482,7 +482,7 @@ static int32_t mndGetFuncMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *p
...
@@ -482,7 +482,7 @@ static int32_t mndGetFuncMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *p
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_FUNC
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_FUNC
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
3b5828c0
...
@@ -624,7 +624,7 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
...
@@ -624,7 +624,7 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_MNODE
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_MNODE
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
mndUpdateMnodeRole
(
pMnode
);
mndUpdateMnodeRole
(
pMnode
);
return
0
;
return
0
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
3b5828c0
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "mndProfile.h"
#include "mndProfile.h"
//#include "mndConsumer.h"
//#include "mndConsumer.h"
#include "mndDb.h"
#include "mndDb.h"
#include "mndStb.h"
#include "mndMnode.h"
#include "mndMnode.h"
#include "mndShow.h"
#include "mndShow.h"
//#include "mndTopic.h"
//#include "mndTopic.h"
...
@@ -376,9 +377,16 @@ static int32_t mndProcessHeartBeatReq(SMnodeMsg *pReq) {
...
@@ -376,9 +377,16 @@ static int32_t mndProcessHeartBeatReq(SMnodeMsg *pReq) {
}
}
break
;
break
;
}
}
case
HEARTBEAT_KEY_STBINFO
:
case
HEARTBEAT_KEY_STBINFO
:
{
void
*
rspMsg
=
NULL
;
int32_t
rspLen
=
0
;
mndValidateStbInfo
(
pMnode
,
(
SSTableMetaVersion
*
)
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SSTableMetaVersion
),
&
rspMsg
,
&
rspLen
);
if
(
rspMsg
&&
rspLen
>
0
)
{
SKv
kv
=
{.
key
=
HEARTBEAT_KEY_STBINFO
,
.
valueLen
=
rspLen
,
.
value
=
rspMsg
};
taosArrayPush
(
hbRsp
.
info
,
&
kv
);
}
break
;
break
;
}
default:
default:
mError
(
"invalid kv key:%d"
,
kv
->
key
);
mError
(
"invalid kv key:%d"
,
kv
->
key
);
hbRsp
.
status
=
TSDB_CODE_MND_APP_ERROR
;
hbRsp
.
status
=
TSDB_CODE_MND_APP_ERROR
;
...
@@ -623,7 +631,7 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
...
@@ -623,7 +631,7 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
pShow
->
numOfRows
=
taosHashGetSize
(
pMgmt
->
cache
->
pHashTable
);
pShow
->
numOfRows
=
taosHashGetSize
(
pMgmt
->
cache
->
pHashTable
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
@@ -792,7 +800,7 @@ static int32_t mndGetQueryMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
...
@@ -792,7 +800,7 @@ static int32_t mndGetQueryMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
pShow
->
numOfRows
=
1000000
;
pShow
->
numOfRows
=
1000000
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
3b5828c0
...
@@ -426,7 +426,7 @@ static int32_t mndGetQnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
...
@@ -426,7 +426,7 @@ static int32_t mndGetQnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_QNODE
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_QNODE
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
3b5828c0
...
@@ -428,7 +428,7 @@ static int32_t mndGetSnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
...
@@ -428,7 +428,7 @@ static int32_t mndGetSnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_SNODE
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_SNODE
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
3b5828c0
...
@@ -769,20 +769,23 @@ static int32_t mndProcessStbMetaReq(SMnodeMsg *pReq) {
...
@@ -769,20 +769,23 @@ static int32_t mndProcessStbMetaReq(SMnodeMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
STableInfoReq
*
pInfo
=
pReq
->
rpcMsg
.
pCont
;
STableInfoReq
*
pInfo
=
pReq
->
rpcMsg
.
pCont
;
mDebug
(
"stb:%s, start to retrieve meta"
,
pInfo
->
tableFname
);
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
pInfo
->
dbFName
,
pInfo
->
tbName
);
SDbObj
*
pDb
=
mndAcquireDbByStb
(
pMnode
,
pInfo
->
tableFname
);
mDebug
(
"stb:%s, start to retrieve meta"
,
tbFName
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pInfo
->
dbFName
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
mError
(
"stb:%s, failed to retrieve meta since %s"
,
pInfo
->
tableFn
ame
,
terrstr
());
mError
(
"stb:%s, failed to retrieve meta since %s"
,
tbFN
ame
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
pInfo
->
tableFn
ame
);
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFN
ame
);
if
(
pStb
==
NULL
)
{
if
(
pStb
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
terrno
=
TSDB_CODE_MND_INVALID_STB
;
terrno
=
TSDB_CODE_MND_INVALID_STB
;
mError
(
"stb:%s, failed to get meta since %s"
,
pInfo
->
tableFn
ame
,
terrstr
());
mError
(
"stb:%s, failed to get meta since %s"
,
tbFN
ame
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -796,11 +799,13 @@ static int32_t mndProcessStbMetaReq(SMnodeMsg *pReq) {
...
@@ -796,11 +799,13 @@ static int32_t mndProcessStbMetaReq(SMnodeMsg *pReq) {
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseStb
(
pMnode
,
pStb
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"stb:%s, failed to get meta since %s"
,
pInfo
->
tableFn
ame
,
terrstr
());
mError
(
"stb:%s, failed to get meta since %s"
,
tbFN
ame
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
memcpy
(
pMeta
->
tbFname
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
strcpy
(
pMeta
->
dbFName
,
pStb
->
db
);
strcpy
(
pMeta
->
tbName
,
pInfo
->
tbName
);
strcpy
(
pMeta
->
stbName
,
pInfo
->
tbName
);
pMeta
->
numOfTags
=
htonl
(
pStb
->
numOfTags
);
pMeta
->
numOfTags
=
htonl
(
pStb
->
numOfTags
);
pMeta
->
numOfColumns
=
htonl
(
pStb
->
numOfColumns
);
pMeta
->
numOfColumns
=
htonl
(
pStb
->
numOfColumns
);
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
...
@@ -835,10 +840,113 @@ static int32_t mndProcessStbMetaReq(SMnodeMsg *pReq) {
...
@@ -835,10 +840,113 @@ static int32_t mndProcessStbMetaReq(SMnodeMsg *pReq) {
pReq
->
pCont
=
pMeta
;
pReq
->
pCont
=
pMeta
;
pReq
->
contLen
=
contLen
;
pReq
->
contLen
=
contLen
;
mDebug
(
"stb:%s, meta is retrieved, cols:%d tags:%d"
,
pInfo
->
tableFname
,
pStb
->
numOfColumns
,
pStb
->
numOfTags
);
mDebug
(
"stb:%s, meta is retrieved, cols:%d tags:%d"
,
tbFName
,
pStb
->
numOfColumns
,
pStb
->
numOfTags
);
return
0
;
}
int32_t
mndValidateStbInfo
(
SMnode
*
pMnode
,
SSTableMetaVersion
*
stbs
,
int32_t
num
,
void
**
rsp
,
int32_t
*
rspLen
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
bufSize
=
num
*
(
sizeof
(
STableMetaRsp
)
+
4
*
sizeof
(
SSchema
));
void
*
buf
=
malloc
(
bufSize
);
int32_t
len
=
0
;
int32_t
contLen
=
0
;
STableMetaRsp
*
pRsp
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SSTableMetaVersion
*
stb
=
&
stbs
[
i
];
stb
->
suid
=
be64toh
(
stb
->
suid
);
stb
->
sversion
=
ntohs
(
stb
->
sversion
);
stb
->
tversion
=
ntohs
(
stb
->
tversion
);
if
((
contLen
+
sizeof
(
STableMetaRsp
))
>
bufSize
)
{
bufSize
=
contLen
+
(
num
-
i
)
*
(
sizeof
(
STableMetaRsp
)
+
4
*
sizeof
(
SSchema
));
buf
=
realloc
(
buf
,
bufSize
);
}
pRsp
=
(
STableMetaRsp
*
)((
char
*
)
buf
+
contLen
);
strcpy
(
pRsp
->
dbFName
,
stb
->
dbFName
);
strcpy
(
pRsp
->
tbName
,
stb
->
stbName
);
strcpy
(
pRsp
->
stbName
,
stb
->
stbName
);
mDebug
(
"start to retrieve meta, db:%s, stb:%s"
,
stb
->
dbFName
,
stb
->
stbName
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
stb
->
dbFName
);
if
(
pDb
==
NULL
)
{
pRsp
->
numOfColumns
=
-
1
;
pRsp
->
suid
=
htobe64
(
stb
->
suid
);
contLen
+=
sizeof
(
STableMetaRsp
);
mWarn
(
"db:%s, failed to require db since %s"
,
stb
->
dbFName
,
terrstr
());
continue
;
}
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
stb
->
dbFName
,
stb
->
stbName
);
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFName
);
if
(
pStb
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
pRsp
->
numOfColumns
=
-
1
;
pRsp
->
suid
=
htobe64
(
stb
->
suid
);
contLen
+=
sizeof
(
STableMetaRsp
);
mWarn
(
"stb:%s, failed to get meta since %s"
,
tbFName
,
terrstr
());
continue
;
}
taosRLockLatch
(
&
pStb
->
lock
);
if
(
stb
->
suid
==
pStb
->
uid
&&
stb
->
sversion
==
pStb
->
version
)
{
taosRUnLockLatch
(
&
pStb
->
lock
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
continue
;
}
int32_t
totalCols
=
pStb
->
numOfColumns
+
pStb
->
numOfTags
;
int32_t
len
=
totalCols
*
sizeof
(
SSchema
);
contLen
+=
sizeof
(
STableMetaRsp
)
+
len
;
if
(
contLen
>
bufSize
)
{
bufSize
=
contLen
+
(
num
-
i
-
1
)
*
(
sizeof
(
STableMetaRsp
)
+
4
*
sizeof
(
SSchema
));
buf
=
realloc
(
buf
,
bufSize
);
}
pRsp
->
numOfTags
=
htonl
(
pStb
->
numOfTags
);
pRsp
->
numOfColumns
=
htonl
(
pStb
->
numOfColumns
);
pRsp
->
precision
=
pDb
->
cfg
.
precision
;
pRsp
->
tableType
=
TSDB_SUPER_TABLE
;
pRsp
->
update
=
pDb
->
cfg
.
update
;
pRsp
->
sversion
=
htonl
(
pStb
->
version
);
pRsp
->
suid
=
htobe64
(
pStb
->
uid
);
pRsp
->
tuid
=
htobe64
(
pStb
->
uid
);
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
i
];
SSchema
*
pSrcSchema
=
&
pStb
->
pSchema
[
i
];
memcpy
(
pSchema
->
name
,
pSrcSchema
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
type
=
pSrcSchema
->
type
;
pSchema
->
colId
=
htonl
(
pSrcSchema
->
colId
);
pSchema
->
bytes
=
htonl
(
pSrcSchema
->
bytes
);
}
taosRUnLockLatch
(
&
pStb
->
lock
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
}
if
(
contLen
>
0
)
{
*
rsp
=
buf
;
*
rspLen
=
contLen
;
}
else
{
*
rsp
=
NULL
;
tfree
(
buf
);
*
rspLen
=
0
;
}
return
0
;
return
0
;
}
}
static
int32_t
mndGetNumOfStbs
(
SMnode
*
pMnode
,
char
*
dbName
,
int32_t
*
pNumOfStbs
)
{
static
int32_t
mndGetNumOfStbs
(
SMnode
*
pMnode
,
char
*
dbName
,
int32_t
*
pNumOfStbs
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
@@ -911,7 +1019,7 @@ static int32_t mndGetStbMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pM
...
@@ -911,7 +1019,7 @@ static int32_t mndGetStbMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pM
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_STB
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_STB
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
3b5828c0
...
@@ -745,7 +745,7 @@ static int32_t mndProcessConsumerMetaMsg(SMnodeMsg *pMsg) {
...
@@ -745,7 +745,7 @@ static int32_t mndProcessConsumerMetaMsg(SMnodeMsg *pMsg) {
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
STableInfoReq
*
pInfo
=
pMsg
->
rpcMsg
.
pCont
;
STableInfoReq
*
pInfo
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"subscribe:%s, start to retrieve meta"
,
pInfo
->
t
ableFn
ame
);
mDebug
(
"subscribe:%s, start to retrieve meta"
,
pInfo
->
t
bN
ame
);
#if 0
#if 0
SDbObj *pDb = mndAcquireDbByConsumer(pMnode, pInfo->tableFname);
SDbObj *pDb = mndAcquireDbByConsumer(pMnode, pInfo->tableFname);
...
@@ -876,7 +876,7 @@ static int32_t mndGetConsumerMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaRs
...
@@ -876,7 +876,7 @@ static int32_t mndGetConsumerMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaRs
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_CONSUMER
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_CONSUMER
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
3b5828c0
...
@@ -338,7 +338,7 @@ static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg) {
...
@@ -338,7 +338,7 @@ static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg) {
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMnode
*
pMnode
=
pMsg
->
pMnode
;
STableInfoReq
*
pInfo
=
pMsg
->
rpcMsg
.
pCont
;
STableInfoReq
*
pInfo
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"topic:%s, start to retrieve meta"
,
pInfo
->
t
ableFn
ame
);
mDebug
(
"topic:%s, start to retrieve meta"
,
pInfo
->
t
bN
ame
);
#if 0
#if 0
SDbObj *pDb = mndAcquireDbByTopic(pMnode, pInfo->tableFname);
SDbObj *pDb = mndAcquireDbByTopic(pMnode, pInfo->tableFname);
...
@@ -469,7 +469,7 @@ static int32_t mndGetTopicMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaRsp *
...
@@ -469,7 +469,7 @@ static int32_t mndGetTopicMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaRsp *
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_TOPIC
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_TOPIC
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
3b5828c0
...
@@ -474,7 +474,7 @@ static int32_t mndGetUserMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *p
...
@@ -474,7 +474,7 @@ static int32_t mndGetUserMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *p
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_USER
);
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_USER
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
3b5828c0
...
@@ -525,7 +525,7 @@ static int32_t mndGetVgroupMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
...
@@ -525,7 +525,7 @@ static int32_t mndGetVgroupMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp
}
}
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
@@ -638,7 +638,7 @@ static int32_t mndGetVnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
...
@@ -638,7 +638,7 @@ static int32_t mndGetVnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
pShow
->
replica
=
dnodeId
;
pShow
->
replica
=
dnodeId
;
pShow
->
numOfRows
=
mndGetVnodesNum
(
pMnode
,
dnodeId
);
pShow
->
numOfRows
=
mndGetVnodesNum
(
pMnode
,
dnodeId
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tb
Fn
ame
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tb
N
ame
,
mndShowStr
(
pShow
->
type
));
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/test/show/show.cpp
浏览文件 @
3b5828c0
...
@@ -64,7 +64,7 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
...
@@ -64,7 +64,7 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_CONNS
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_CONNS
,
""
);
STableMetaRsp
*
pMeta
=
test
.
GetShowMeta
();
STableMetaRsp
*
pMeta
=
test
.
GetShowMeta
();
EXPECT_STREQ
(
pMeta
->
tb
Fn
ame
,
"show connections"
);
EXPECT_STREQ
(
pMeta
->
tb
N
ame
,
"show connections"
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
7
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
7
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
3b5828c0
...
@@ -126,7 +126,8 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -126,7 +126,8 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
int32_t
contLen
=
sizeof
(
STableInfoReq
);
int32_t
contLen
=
sizeof
(
STableInfoReq
);
STableInfoReq
*
pReq
=
(
STableInfoReq
*
)
rpcMallocCont
(
contLen
);
STableInfoReq
*
pReq
=
(
STableInfoReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
tableFname
,
"1.d1.stb"
);
strcpy
(
pReq
->
dbFName
,
"1.d1"
);
strcpy
(
pReq
->
tbName
,
"stb"
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_STB_META
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_STB_META
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
...
@@ -146,8 +147,9 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -146,8 +147,9 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
}
}
EXPECT_STREQ
(
pRsp
->
tbFname
,
"1.d1.stb"
);
EXPECT_STREQ
(
pRsp
->
dbFName
,
"1.d1"
);
EXPECT_STREQ
(
pRsp
->
stbFname
,
""
);
EXPECT_STREQ
(
pRsp
->
tbName
,
"stb"
);
EXPECT_STREQ
(
pRsp
->
stbName
,
"stb"
);
EXPECT_EQ
(
pRsp
->
numOfColumns
,
2
);
EXPECT_EQ
(
pRsp
->
numOfColumns
,
2
);
EXPECT_EQ
(
pRsp
->
numOfTags
,
3
);
EXPECT_EQ
(
pRsp
->
numOfTags
,
3
);
EXPECT_EQ
(
pRsp
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
EXPECT_EQ
(
pRsp
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
3b5828c0
...
@@ -84,7 +84,7 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -84,7 +84,7 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
int
msgLen
=
0
;
int
msgLen
=
0
;
int32_t
code
=
TSDB_CODE_VND_APP_ERROR
;
int32_t
code
=
TSDB_CODE_VND_APP_ERROR
;
pTbCfg
=
metaGetTbInfoByName
(
pVnode
->
pMeta
,
pReq
->
t
ableFn
ame
,
&
uid
);
pTbCfg
=
metaGetTbInfoByName
(
pVnode
->
pMeta
,
pReq
->
t
bN
ame
,
&
uid
);
if
(
pTbCfg
==
NULL
)
{
if
(
pTbCfg
==
NULL
)
{
code
=
TSDB_CODE_VND_TB_NOT_EXIST
;
code
=
TSDB_CODE_VND_TB_NOT_EXIST
;
goto
_exit
;
goto
_exit
;
...
@@ -119,13 +119,13 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -119,13 +119,13 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
goto
_exit
;
goto
_exit
;
}
}
memcpy
(
pTbMetaMsg
->
dbF
name
,
pReq
->
dbFname
,
sizeof
(
pTbMetaMsg
->
dbFn
ame
));
memcpy
(
pTbMetaMsg
->
dbF
Name
,
pReq
->
dbFName
,
sizeof
(
pTbMetaMsg
->
dbFN
ame
));
strcpy
(
pTbMetaMsg
->
tb
Fname
,
pTbCfg
->
n
ame
);
strcpy
(
pTbMetaMsg
->
tb
Name
,
pReq
->
tbN
ame
);
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
strcpy
(
pTbMetaMsg
->
stb
Fn
ame
,
pStbCfg
->
name
);
strcpy
(
pTbMetaMsg
->
stb
N
ame
,
pStbCfg
->
name
);
pTbMetaMsg
->
suid
=
htobe64
(
pTbCfg
->
ctbCfg
.
suid
);
pTbMetaMsg
->
suid
=
htobe64
(
pTbCfg
->
ctbCfg
.
suid
);
}
else
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
}
else
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
strcpy
(
pTbMetaMsg
->
stb
Fn
ame
,
pTbCfg
->
name
);
strcpy
(
pTbMetaMsg
->
stb
N
ame
,
pTbCfg
->
name
);
pTbMetaMsg
->
suid
=
htobe64
(
uid
);
pTbMetaMsg
->
suid
=
htobe64
(
uid
);
}
}
pTbMetaMsg
->
numOfTags
=
htonl
(
nTagCols
);
pTbMetaMsg
->
numOfTags
=
htonl
(
nTagCols
);
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
3b5828c0
...
@@ -27,7 +27,7 @@ extern "C" {
...
@@ -27,7 +27,7 @@ extern "C" {
#define CTG_DEFAULT_CACHE_CLUSTER_NUMBER 6
#define CTG_DEFAULT_CACHE_CLUSTER_NUMBER 6
#define CTG_DEFAULT_CACHE_VGROUP_NUMBER 100
#define CTG_DEFAULT_CACHE_VGROUP_NUMBER 100
#define CTG_DEFAULT_CACHE_DB_NUMBER 20
#define CTG_DEFAULT_CACHE_DB_NUMBER 20
#define CTG_DEFAULT_CACHE_TABLEMETA_NUMBER 10000
0
#define CTG_DEFAULT_CACHE_TABLEMETA_NUMBER 10000
#define CTG_DEFAULT_RENT_SECOND 10
#define CTG_DEFAULT_RENT_SECOND 10
#define CTG_DEFAULT_RENT_SLOT_SIZE 10
#define CTG_DEFAULT_RENT_SLOT_SIZE 10
...
@@ -47,55 +47,52 @@ enum {
...
@@ -47,55 +47,52 @@ enum {
CTG_RENT_STABLE
,
CTG_RENT_STABLE
,
};
};
typedef
struct
SC
TG
Debug
{
typedef
struct
SC
tg
Debug
{
int32_t
lockDebug
;
int32_t
lockDebug
;
}
SC
TG
Debug
;
}
SC
tg
Debug
;
typedef
struct
SVgroupListCache
{
typedef
struct
SCtgTbMetaCache
{
int32_t
vgroupVersion
;
SRWLatch
stbLock
;
SHashObj
*
cache
;
// key:vgId, value:SVgroupInfo
SHashObj
*
cache
;
//key:tbname, value:STableMeta
}
SVgroupListCache
;
SHashObj
*
stbCache
;
//key:suid, value:STableMeta*
}
SCtgTbMetaCache
;
typedef
struct
SDBVgroupCache
{
typedef
struct
SCtgDBCache
{
SHashObj
*
cache
;
//key:dbname, value:SDBVgroupInfo
SRWLatch
vgLock
;
}
SDBVgroupCache
;
int8_t
deleted
;
SDBVgroupInfo
*
vgInfo
;
SCtgTbMetaCache
tbCache
;
}
SCtgDBCache
;
typedef
struct
STableMetaCache
{
typedef
struct
SCtgRentSlot
{
SRWLatch
stableLock
;
SHashObj
*
cache
;
//key:fulltablename, value:STableMeta
SHashObj
*
stableCache
;
//key:suid, value:STableMeta*
}
STableMetaCache
;
typedef
struct
SRentSlotInfo
{
SRWLatch
lock
;
SRWLatch
lock
;
bool
needSort
;
bool
needSort
;
SArray
*
meta
;
// element is SDbVgVersion or SSTableMetaVersion
SArray
*
meta
;
// element is SDbVgVersion or SSTableMetaVersion
}
S
RentSlotInfo
;
}
S
CtgRentSlot
;
typedef
struct
S
Meta
RentMgmt
{
typedef
struct
S
Ctg
RentMgmt
{
int8_t
type
;
int8_t
type
;
uint16_t
slotNum
;
uint16_t
slotNum
;
uint16_t
slotRIdx
;
uint16_t
slotRIdx
;
int64_t
lastReadMsec
;
int64_t
lastReadMsec
;
S
RentSlotInfo
*
slots
;
S
CtgRentSlot
*
slots
;
}
S
Meta
RentMgmt
;
}
S
Ctg
RentMgmt
;
typedef
struct
SCatalog
{
typedef
struct
SCatalog
{
uint64_t
clusterId
;
uint64_t
clusterId
;
SDBVgroupCache
dbCache
;
SHashObj
*
dbCache
;
//key:dbname, value:SCtgDBCache
STableMetaCache
tableCache
;
SCtgRentMgmt
dbRent
;
SMetaRentMgmt
dbRent
;
SCtgRentMgmt
stbRent
;
SMetaRentMgmt
stableRent
;
}
SCatalog
;
}
SCatalog
;
typedef
struct
SCtgApiStat
{
typedef
struct
SCtgApiStat
{
}
SCtgApiStat
;
}
SCtgApiStat
;
typedef
struct
SCtgR
esourc
eStat
{
typedef
struct
SCtgR
untim
eStat
{
}
SCtgR
esourc
eStat
;
}
SCtgR
untim
eStat
;
typedef
struct
SCtgCacheStat
{
typedef
struct
SCtgCacheStat
{
...
@@ -103,7 +100,7 @@ typedef struct SCtgCacheStat {
...
@@ -103,7 +100,7 @@ typedef struct SCtgCacheStat {
typedef
struct
SCatalogStat
{
typedef
struct
SCatalogStat
{
SCtgApiStat
api
;
SCtgApiStat
api
;
SCtgR
esourceStat
resourc
e
;
SCtgR
untimeStat
runtim
e
;
SCtgCacheStat
cache
;
SCtgCacheStat
cache
;
}
SCatalogStat
;
}
SCatalogStat
;
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
3b5828c0
...
@@ -20,31 +20,106 @@
...
@@ -20,31 +20,106 @@
SCatalogMgmt
ctgMgmt
=
{
0
};
SCatalogMgmt
ctgMgmt
=
{
0
};
SC
TG
Debug
gCTGDebug
=
{
0
};
SC
tg
Debug
gCTGDebug
=
{
0
};
int32_t
ctgGetDBVgroupFromCache
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
**
dbInfo
,
bool
*
inCache
)
{
void
ctgFreeMetaRent
(
SCtgRentMgmt
*
mgmt
)
{
if
(
NULL
==
pCatalog
->
dbCache
.
cache
)
{
if
(
NULL
==
mgmt
->
slots
)
{
return
;
}
for
(
int32_t
i
=
0
;
i
<
mgmt
->
slotNum
;
++
i
)
{
SCtgRentSlot
*
slot
=
&
mgmt
->
slots
[
i
];
if
(
slot
->
meta
)
{
taosArrayDestroy
(
slot
->
meta
);
slot
->
meta
=
NULL
;
}
}
tfree
(
mgmt
->
slots
);
}
void
ctgFreeTableMetaCache
(
SCtgTbMetaCache
*
table
)
{
CTG_LOCK
(
CTG_WRITE
,
&
table
->
stbLock
);
if
(
table
->
stbCache
)
{
taosHashCleanup
(
table
->
stbCache
);
table
->
stbCache
=
NULL
;
}
CTG_UNLOCK
(
CTG_WRITE
,
&
table
->
stbLock
);
if
(
table
->
cache
)
{
taosHashCleanup
(
table
->
cache
);
table
->
cache
=
NULL
;
}
}
void
ctgFreeDbCache
(
SCtgDBCache
*
dbCache
)
{
if
(
NULL
==
dbCache
)
{
return
;
}
atomic_store_8
(
&
dbCache
->
deleted
,
1
);
SDBVgroupInfo
*
dbInfo
=
NULL
;
if
(
dbCache
->
vgInfo
)
{
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
if
(
dbCache
->
vgInfo
->
vgHash
)
{
taosHashCleanup
(
dbCache
->
vgInfo
->
vgHash
);
dbCache
->
vgInfo
->
vgHash
=
NULL
;
}
tfree
(
dbCache
->
vgInfo
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
}
ctgFreeTableMetaCache
(
&
dbCache
->
tbCache
);
}
void
ctgFreeHandle
(
struct
SCatalog
*
pCatalog
)
{
ctgFreeMetaRent
(
&
pCatalog
->
dbRent
);
ctgFreeMetaRent
(
&
pCatalog
->
stbRent
);
if
(
pCatalog
->
dbCache
)
{
void
*
pIter
=
taosHashIterate
(
pCatalog
->
dbCache
,
NULL
);
while
(
pIter
)
{
SCtgDBCache
*
dbCache
=
pIter
;
ctgFreeDbCache
(
dbCache
);
pIter
=
taosHashIterate
(
pCatalog
->
dbCache
,
pIter
);
}
taosHashCleanup
(
pCatalog
->
dbCache
);
}
free
(
pCatalog
);
}
int32_t
ctgGetDBVgroupFromCache
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SCtgDBCache
**
dbCache
,
bool
*
inCache
)
{
if
(
NULL
==
pCatalog
->
dbCache
)
{
*
inCache
=
false
;
*
inCache
=
false
;
ctgWarn
(
"empty db cache, dbName:%s"
,
dbName
);
ctgWarn
(
"empty db cache, dbName:%s"
,
dbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
S
DBVgroupInfo
*
info
=
NULL
;
S
CtgDBCache
*
cache
=
NULL
;
while
(
true
)
{
while
(
true
)
{
info
=
taosHashAcquire
(
pCatalog
->
dbCache
.
c
ache
,
dbName
,
strlen
(
dbName
));
cache
=
taosHashAcquire
(
pCatalog
->
dbC
ache
,
dbName
,
strlen
(
dbName
));
if
(
NULL
==
info
)
{
if
(
NULL
==
cache
)
{
*
inCache
=
false
;
*
inCache
=
false
;
ctgWarn
(
"not in db vgroup cache, dbName:%s"
,
dbName
);
ctgWarn
(
"not in db vgroup cache, dbName:%s"
,
dbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
CTG_LOCK
(
CTG_READ
,
&
info
->
l
ock
);
CTG_LOCK
(
CTG_READ
,
&
cache
->
vgL
ock
);
if
(
NULL
==
info
->
vgInfo
)
{
if
(
NULL
==
cache
->
vgInfo
)
{
CTG_UNLOCK
(
CTG_READ
,
&
info
->
l
ock
);
CTG_UNLOCK
(
CTG_READ
,
&
cache
->
vgL
ock
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
info
);
taosHashRelease
(
pCatalog
->
dbCache
,
cache
);
ctgWarn
(
"db cache vgInfo is NULL, dbName:%s"
,
dbName
);
ctgWarn
(
"db cache vgInfo is NULL, dbName:%s"
,
dbName
);
continue
;
continue
;
...
@@ -53,7 +128,7 @@ int32_t ctgGetDBVgroupFromCache(struct SCatalog* pCatalog, const char *dbName, S
...
@@ -53,7 +128,7 @@ int32_t ctgGetDBVgroupFromCache(struct SCatalog* pCatalog, const char *dbName, S
break
;
break
;
}
}
*
db
Info
=
info
;
*
db
Cache
=
cache
;
*
inCache
=
true
;
*
inCache
=
true
;
ctgDebug
(
"Got db vgroup from cache, dbName:%s"
,
dbName
);
ctgDebug
(
"Got db vgroup from cache, dbName:%s"
,
dbName
);
...
@@ -98,48 +173,73 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp
...
@@ -98,48 +173,73 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgIsTableMetaExistInCache
(
struct
SCatalog
*
pCatalog
,
c
onst
char
*
tbFull
Name
,
int32_t
*
exist
)
{
int32_t
ctgIsTableMetaExistInCache
(
struct
SCatalog
*
pCatalog
,
c
har
*
dbFName
,
char
*
tb
Name
,
int32_t
*
exist
)
{
if
(
NULL
==
pCatalog
->
tableCache
.
c
ache
)
{
if
(
NULL
==
pCatalog
->
dbC
ache
)
{
*
exist
=
0
;
*
exist
=
0
;
ctgWarn
(
"empty
tablemeta cache, tbName:%s"
,
tbFull
Name
);
ctgWarn
(
"empty
db cache, dbFName:%s, tbName:%s"
,
dbFName
,
tb
Name
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
size_t
sz
=
0
;
SCtgDBCache
*
dbCache
=
taosHashAcquire
(
pCatalog
->
dbCache
,
dbFName
,
strlen
(
dbFName
));
STableMeta
*
tbMeta
=
taosHashGet
(
pCatalog
->
tableCache
.
cache
,
tbFullName
,
strlen
(
tbFullName
));
if
(
NULL
==
dbCache
)
{
*
exist
=
0
;
ctgWarn
(
"db not exist in cache, dbFName:%s"
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
}
size_t
sz
=
0
;
STableMeta
*
tbMeta
=
taosHashGet
(
dbCache
->
tbCache
.
cache
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
tbMeta
)
{
if
(
NULL
==
tbMeta
)
{
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
*
exist
=
0
;
*
exist
=
0
;
ctgDebug
(
"t
ablemeta not in cache, tbName:%s"
,
tbFull
Name
);
ctgDebug
(
"t
bmeta not in cache, dbFName:%s, tbName:%s"
,
dbFName
,
tb
Name
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
*
exist
=
1
;
*
exist
=
1
;
ctgDebug
(
"tablemeta is in cache, tbName:%s"
,
tbFullName
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
ctgDebug
(
"tbmeta is in cache, dbFName:%s, tbName:%s"
,
dbFName
,
tbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetTableMetaFromCache
(
struct
SCatalog
*
pCatalog
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
*
exist
)
{
int32_t
ctgGetTableMetaFromCache
(
struct
SCatalog
*
pCatalog
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
*
exist
)
{
if
(
NULL
==
pCatalog
->
tableCache
.
c
ache
)
{
if
(
NULL
==
pCatalog
->
dbC
ache
)
{
*
exist
=
0
;
*
exist
=
0
;
ctgWarn
(
"empty t
able
meta cache, tbName:%s"
,
pTableName
->
tname
);
ctgWarn
(
"empty t
b
meta cache, tbName:%s"
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
]
;
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
}
;
tName
ExtractFullName
(
pTableName
,
tbFullName
);
tName
GetFullDbName
(
pTableName
,
db
);
*
pTableMeta
=
NULL
;
*
pTableMeta
=
NULL
;
size_t
sz
=
0
;
SCtgDBCache
*
dbCache
=
taosHashAcquire
(
pCatalog
->
dbCache
,
db
,
strlen
(
db
));
STableMeta
*
tbMeta
=
taosHashGetCloneExt
(
pCatalog
->
tableCache
.
cache
,
tbFullName
,
strlen
(
tbFullName
),
NULL
,
(
void
**
)
pTableMeta
,
&
sz
);
if
(
NULL
==
dbCache
)
{
*
exist
=
0
;
ctgWarn
(
"no db cache, dbFName:%s, tbName:%s"
,
db
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
if
(
NULL
==
dbCache
->
tbCache
.
cache
)
{
*
exist
=
0
;
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
ctgWarn
(
"empty tbmeta cache, dbFName:%s, tbName:%s"
,
db
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
size_t
sz
=
0
;
STableMeta
*
tbMeta
=
taosHashGetCloneExt
(
dbCache
->
tbCache
.
cache
,
pTableName
->
tname
,
strlen
(
pTableName
->
tname
),
NULL
,
(
void
**
)
pTableMeta
,
&
sz
);
if
(
NULL
==
*
pTableMeta
)
{
if
(
NULL
==
*
pTableMeta
)
{
*
exist
=
0
;
*
exist
=
0
;
ctgDebug
(
"tablemeta not in cache, tbName:%s"
,
tbFullName
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
ctgDebug
(
"tbmeta not in cache, dbFName:%s, tbName:%s"
,
db
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -148,80 +248,91 @@ int32_t ctgGetTableMetaFromCache(struct SCatalog* pCatalog, const SName* pTableN
...
@@ -148,80 +248,91 @@ int32_t ctgGetTableMetaFromCache(struct SCatalog* pCatalog, const SName* pTableN
tbMeta
=
*
pTableMeta
;
tbMeta
=
*
pTableMeta
;
if
(
tbMeta
->
tableType
!=
TSDB_CHILD_TABLE
)
{
if
(
tbMeta
->
tableType
!=
TSDB_CHILD_TABLE
)
{
ctgDebug
(
"Got tablemeta from cache, tbName:%s"
,
tbFullNam
e
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCach
e
);
ctgDebug
(
"Got tbmeta from cache, type:%d, dbFName:%s, tbName:%s"
,
tbMeta
->
tableType
,
db
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
CTG_LOCK
(
CTG_READ
,
&
pCatalog
->
tableCache
.
stable
Lock
);
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stb
Lock
);
STableMeta
**
stbMeta
=
taosHashGet
(
pCatalog
->
tableCache
.
stable
Cache
,
&
tbMeta
->
suid
,
sizeof
(
tbMeta
->
suid
));
STableMeta
**
stbMeta
=
taosHashGet
(
dbCache
->
tbCache
.
stb
Cache
,
&
tbMeta
->
suid
,
sizeof
(
tbMeta
->
suid
));
if
(
NULL
==
stbMeta
||
NULL
==
*
stbMeta
)
{
if
(
NULL
==
stbMeta
||
NULL
==
*
stbMeta
)
{
CTG_UNLOCK
(
CTG_READ
,
&
pCatalog
->
tableCache
.
stableLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
ctgError
(
"stable not in stableCache, suid:%"
PRIx64
,
tbMeta
->
suid
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
ctgError
(
"stable not in stbCache, suid:%"
PRIx64
,
tbMeta
->
suid
);
tfree
(
*
pTableMeta
);
tfree
(
*
pTableMeta
);
*
exist
=
0
;
*
exist
=
0
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
((
*
stbMeta
)
->
suid
!=
tbMeta
->
suid
)
{
if
((
*
stbMeta
)
->
suid
!=
tbMeta
->
suid
)
{
CTG_UNLOCK
(
CTG_READ
,
&
pCatalog
->
tableCache
.
stableLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
tfree
(
*
pTableMeta
);
tfree
(
*
pTableMeta
);
ctgError
(
"stable suid in st
able
Cache mis-match, expected suid:%"
PRIx64
",actual suid:%"
PRIx64
,
tbMeta
->
suid
,
(
*
stbMeta
)
->
suid
);
ctgError
(
"stable suid in st
b
Cache mis-match, expected suid:%"
PRIx64
",actual suid:%"
PRIx64
,
tbMeta
->
suid
,
(
*
stbMeta
)
->
suid
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
int32_t
metaSize
=
sizeof
(
STableMeta
)
+
((
*
stbMeta
)
->
tableInfo
.
numOfTags
+
(
*
stbMeta
)
->
tableInfo
.
numOfColumns
)
*
sizeof
(
SSchema
);
int32_t
metaSize
=
sizeof
(
STableMeta
)
+
((
*
stbMeta
)
->
tableInfo
.
numOfTags
+
(
*
stbMeta
)
->
tableInfo
.
numOfColumns
)
*
sizeof
(
SSchema
);
*
pTableMeta
=
realloc
(
*
pTableMeta
,
metaSize
);
*
pTableMeta
=
realloc
(
*
pTableMeta
,
metaSize
);
if
(
NULL
==
*
pTableMeta
)
{
if
(
NULL
==
*
pTableMeta
)
{
CTG_UNLOCK
(
CTG_READ
,
&
pCatalog
->
tableCache
.
stableLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
ctgError
(
"realloc size[%d] failed"
,
metaSize
);
ctgError
(
"realloc size[%d] failed"
,
metaSize
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
memcpy
(
&
(
*
pTableMeta
)
->
sversion
,
&
(
*
stbMeta
)
->
sversion
,
metaSize
-
sizeof
(
SCTableMeta
));
memcpy
(
&
(
*
pTableMeta
)
->
sversion
,
&
(
*
stbMeta
)
->
sversion
,
metaSize
-
sizeof
(
SCTableMeta
));
CTG_UNLOCK
(
CTG_READ
,
&
pCatalog
->
tableCache
.
stableLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
stbLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
ctgDebug
(
"Got t
ablemeta from cache, tbName:%s"
,
tbFullN
ame
);
ctgDebug
(
"Got t
bmeta from cache, dbFName:%s, tbName:%s"
,
db
,
pTableName
->
tn
ame
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetTableTypeFromCache
(
struct
SCatalog
*
pCatalog
,
const
SName
*
pTableName
,
int32_t
*
tbType
)
{
int32_t
ctgGetTableTypeFromCache
(
struct
SCatalog
*
pCatalog
,
const
SName
*
pTableName
,
int32_t
*
tbType
)
{
if
(
NULL
==
pCatalog
->
tableCache
.
c
ache
)
{
if
(
NULL
==
pCatalog
->
dbC
ache
)
{
ctgWarn
(
"empty
tablemeta
cache, tbName:%s"
,
pTableName
->
tname
);
ctgWarn
(
"empty
db
cache, tbName:%s"
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
char
dbName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameExtractFullName
(
pTableName
,
tbFullName
);
tNameGetFullDbName
(
pTableName
,
dbName
);
size_t
sz
=
0
;
STableMeta
*
pTableMeta
=
NULL
;
taosHashGetCloneExt
(
pCatalog
->
tableCache
.
cache
,
tbFullName
,
strlen
(
tbFullName
),
NULL
,
(
void
**
)
&
pTableMeta
,
&
sz
);
SCtgDBCache
*
dbCache
=
taosHashAcquire
(
pCatalog
->
dbCache
,
dbName
,
strlen
(
dbName
));
if
(
NULL
==
dbCache
)
{
ctgInfo
(
"db not in cache, dbFName:%s"
,
dbName
);
return
TSDB_CODE_SUCCESS
;
}
STableMeta
*
pTableMeta
=
(
STableMeta
*
)
taosHashAcquire
(
dbCache
->
tbCache
.
cache
,
pTableName
->
tname
,
strlen
(
pTableName
->
tname
));
if
(
NULL
==
pTableMeta
)
{
if
(
NULL
==
pTableMeta
)
{
ctgWarn
(
"tablemeta not in cache, tbName:%s"
,
tbFullName
);
ctgWarn
(
"tbmeta not in cache, dbFName:%s, tbName:%s"
,
dbName
,
pTableName
->
tname
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
*
tbType
=
pTableMeta
->
tableType
;
*
tbType
=
atomic_load_8
(
&
pTableMeta
->
tableType
);
taosHashRelease
(
dbCache
->
tbCache
.
cache
,
dbCache
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
ctgDebug
(
"Got t
abletype from cache, tbName:%s, type:%d"
,
tbFullN
ame
,
*
tbType
);
ctgDebug
(
"Got t
btype from cache, dbFName:%s, tbName:%s, type:%d"
,
dbName
,
pTableName
->
tn
ame
,
*
tbType
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetTableMetaFromMnodeImpl
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
char
*
tbFull
Name
,
STableMetaOutput
*
output
)
{
int32_t
ctgGetTableMetaFromMnodeImpl
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
char
*
dbFName
,
char
*
tb
Name
,
STableMetaOutput
*
output
)
{
SBuildTableMetaInput
bInput
=
{.
vgId
=
0
,
.
db
Name
=
NULL
,
.
tableFullName
=
tbFull
Name
};
SBuildTableMetaInput
bInput
=
{.
vgId
=
0
,
.
db
FName
=
dbFName
,
.
tbName
=
tb
Name
};
char
*
msg
=
NULL
;
char
*
msg
=
NULL
;
SEpSet
*
pVnodeEpSet
=
NULL
;
SEpSet
*
pVnodeEpSet
=
NULL
;
int32_t
msgLen
=
0
;
int32_t
msgLen
=
0
;
ctgDebug
(
"try to get table meta from mnode,
tbName:%s"
,
tbFull
Name
);
ctgDebug
(
"try to get table meta from mnode,
dbFName:%s, tbName:%s"
,
dbFName
,
tb
Name
);
int32_t
code
=
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_STB_META
)](
&
bInput
,
&
msg
,
0
,
&
msgLen
);
int32_t
code
=
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_STB_META
)](
&
bInput
,
&
msg
,
0
,
&
msgLen
);
if
(
code
)
{
if
(
code
)
{
...
@@ -242,30 +353,30 @@ int32_t ctgGetTableMetaFromMnodeImpl(struct SCatalog* pCatalog, void *pTransport
...
@@ -242,30 +353,30 @@ int32_t ctgGetTableMetaFromMnodeImpl(struct SCatalog* pCatalog, void *pTransport
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
CTG_TABLE_NOT_EXIST
(
rpcRsp
.
code
))
{
if
(
CTG_TABLE_NOT_EXIST
(
rpcRsp
.
code
))
{
SET_META_TYPE_NULL
(
output
->
metaType
);
SET_META_TYPE_NULL
(
output
->
metaType
);
ctgDebug
(
"stablemeta not exist in mnode,
tbName:%s"
,
tbFull
Name
);
ctgDebug
(
"stablemeta not exist in mnode,
dbFName:%s, tbName:%s"
,
dbFName
,
tb
Name
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
ctgError
(
"error rsp for stablemeta from mnode, code:%s,
tbName:%s"
,
tstrerror
(
rpcRsp
.
code
),
tbFull
Name
);
ctgError
(
"error rsp for stablemeta from mnode, code:%s,
dbFName:%s, tbName:%s"
,
tstrerror
(
rpcRsp
.
code
),
dbFName
,
tb
Name
);
CTG_ERR_RET
(
rpcRsp
.
code
);
CTG_ERR_RET
(
rpcRsp
.
code
);
}
}
code
=
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_STB_META
)](
output
,
rpcRsp
.
pCont
,
rpcRsp
.
contLen
);
code
=
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_MND_STB_META
)](
output
,
rpcRsp
.
pCont
,
rpcRsp
.
contLen
);
if
(
code
)
{
if
(
code
)
{
ctgError
(
"Process mnode stablemeta rsp failed, code:%x,
tbName:%s"
,
code
,
tbFull
Name
);
ctgError
(
"Process mnode stablemeta rsp failed, code:%x,
dbFName:%s, tbName:%s"
,
code
,
dbFName
,
tb
Name
);
CTG_ERR_RET
(
code
);
CTG_ERR_RET
(
code
);
}
}
ctgDebug
(
"Got table meta from mnode,
tbName:%s"
,
tbFull
Name
);
ctgDebug
(
"Got table meta from mnode,
dbFName:%s, tbName:%s"
,
dbFName
,
tb
Name
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetTableMetaFromMnode
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMetaOutput
*
output
)
{
int32_t
ctgGetTableMetaFromMnode
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMetaOutput
*
output
)
{
char
tbFullName
[
TSDB_TABLE
_FNAME_LEN
];
char
dbFName
[
TSDB_DB
_FNAME_LEN
];
tName
ExtractFullName
(
pTableName
,
tbFull
Name
);
tName
GetFullDbName
(
pTableName
,
dbF
Name
);
return
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
tbFullN
ame
,
output
);
return
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
dbFName
,
(
char
*
)
pTableName
->
tn
ame
,
output
);
}
}
int32_t
ctgGetTableMetaFromVnode
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableMetaOutput
*
output
)
{
int32_t
ctgGetTableMetaFromVnode
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableMetaOutput
*
output
)
{
...
@@ -273,18 +384,18 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pTransporter,
...
@@ -273,18 +384,18 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pTransporter,
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
char
dbF
ull
Name
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pTableName
,
dbF
ull
Name
);
tNameGetFullDbName
(
pTableName
,
dbFName
);
ctgDebug
(
"try to get table meta from vnode, db
:%s, tbName:%s"
,
dbFull
Name
,
tNameGetTableName
(
pTableName
));
ctgDebug
(
"try to get table meta from vnode, db
FName:%s, tbName:%s"
,
dbF
Name
,
tNameGetTableName
(
pTableName
));
SBuildTableMetaInput
bInput
=
{.
vgId
=
vgroupInfo
->
vgId
,
.
db
Name
=
dbFullName
,
.
tableFull
Name
=
(
char
*
)
tNameGetTableName
(
pTableName
)};
SBuildTableMetaInput
bInput
=
{.
vgId
=
vgroupInfo
->
vgId
,
.
db
FName
=
dbFName
,
.
tb
Name
=
(
char
*
)
tNameGetTableName
(
pTableName
)};
char
*
msg
=
NULL
;
char
*
msg
=
NULL
;
int32_t
msgLen
=
0
;
int32_t
msgLen
=
0
;
int32_t
code
=
queryBuildMsg
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)](
&
bInput
,
&
msg
,
0
,
&
msgLen
);
int32_t
code
=
queryBuildMsg
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)](
&
bInput
,
&
msg
,
0
,
&
msgLen
);
if
(
code
)
{
if
(
code
)
{
ctgError
(
"Build vnode tablemeta msg failed, code:%x,
tbName:%s"
,
cod
e
,
tNameGetTableName
(
pTableName
));
ctgError
(
"Build vnode tablemeta msg failed, code:%x,
dbFName:%s, tbName:%s"
,
code
,
dbFNam
e
,
tNameGetTableName
(
pTableName
));
CTG_ERR_RET
(
code
);
CTG_ERR_RET
(
code
);
}
}
...
@@ -300,21 +411,21 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pTransporter,
...
@@ -300,21 +411,21 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pTransporter,
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
CTG_TABLE_NOT_EXIST
(
rpcRsp
.
code
))
{
if
(
CTG_TABLE_NOT_EXIST
(
rpcRsp
.
code
))
{
SET_META_TYPE_NULL
(
output
->
metaType
);
SET_META_TYPE_NULL
(
output
->
metaType
);
ctgDebug
(
"tablemeta not exist in vnode,
tbName:%s"
,
tNameGetTableName
(
pTableName
));
ctgDebug
(
"tablemeta not exist in vnode,
dbFName:%s, tbName:%s"
,
dbFName
,
tNameGetTableName
(
pTableName
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
ctgError
(
"error rsp for table meta from vnode, code:%s,
tbName:%s"
,
tstrerror
(
rpcRsp
.
code
)
,
tNameGetTableName
(
pTableName
));
ctgError
(
"error rsp for table meta from vnode, code:%s,
dbFName:%s, tbName:%s"
,
tstrerror
(
rpcRsp
.
code
),
dbFName
,
tNameGetTableName
(
pTableName
));
CTG_ERR_RET
(
rpcRsp
.
code
);
CTG_ERR_RET
(
rpcRsp
.
code
);
}
}
code
=
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)](
output
,
rpcRsp
.
pCont
,
rpcRsp
.
contLen
);
code
=
queryProcessMsgRsp
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)](
output
,
rpcRsp
.
pCont
,
rpcRsp
.
contLen
);
if
(
code
)
{
if
(
code
)
{
ctgError
(
"Process vnode tablemeta rsp failed, code:%s,
tbName:%s"
,
tstrerror
(
code
)
,
tNameGetTableName
(
pTableName
));
ctgError
(
"Process vnode tablemeta rsp failed, code:%s,
dbFName:%s, tbName:%s"
,
tstrerror
(
code
),
dbFName
,
tNameGetTableName
(
pTableName
));
CTG_ERR_RET
(
code
);
CTG_ERR_RET
(
code
);
}
}
ctgDebug
(
"Got table meta from vnode, db
:%s, tbName:%s"
,
dbFull
Name
,
tNameGetTableName
(
pTableName
));
ctgDebug
(
"Got table meta from vnode, db
FName:%s, tbName:%s"
,
dbF
Name
,
tNameGetTableName
(
pTableName
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -334,7 +445,7 @@ int32_t ctgGetVgInfoFromDB(struct SCatalog *pCatalog, void *pRpc, const SEpSet *
...
@@ -334,7 +445,7 @@ int32_t ctgGetVgInfoFromDB(struct SCatalog *pCatalog, void *pRpc, const SEpSet *
SVgroupInfo
*
vgInfo
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
vgNum
=
taosHashGetSize
(
dbInfo
->
vg
Info
);
int32_t
vgNum
=
taosHashGetSize
(
dbInfo
->
vg
Hash
);
vgList
=
taosArrayInit
(
vgNum
,
sizeof
(
SVgroupInfo
));
vgList
=
taosArrayInit
(
vgNum
,
sizeof
(
SVgroupInfo
));
if
(
NULL
==
vgList
)
{
if
(
NULL
==
vgList
)
{
...
@@ -342,7 +453,7 @@ int32_t ctgGetVgInfoFromDB(struct SCatalog *pCatalog, void *pRpc, const SEpSet *
...
@@ -342,7 +453,7 @@ int32_t ctgGetVgInfoFromDB(struct SCatalog *pCatalog, void *pRpc, const SEpSet *
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vg
Info
,
NULL
);
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vg
Hash
,
NULL
);
while
(
pIter
)
{
while
(
pIter
)
{
vgInfo
=
pIter
;
vgInfo
=
pIter
;
...
@@ -351,7 +462,7 @@ int32_t ctgGetVgInfoFromDB(struct SCatalog *pCatalog, void *pRpc, const SEpSet *
...
@@ -351,7 +462,7 @@ int32_t ctgGetVgInfoFromDB(struct SCatalog *pCatalog, void *pRpc, const SEpSet *
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
pIter
=
taosHashIterate
(
dbInfo
->
vg
Info
,
pIter
);
pIter
=
taosHashIterate
(
dbInfo
->
vg
Hash
,
pIter
);
vgInfo
=
NULL
;
vgInfo
=
NULL
;
}
}
...
@@ -374,7 +485,7 @@ _return:
...
@@ -374,7 +485,7 @@ _return:
int32_t
ctgGetVgInfoFromHashValue
(
struct
SCatalog
*
pCatalog
,
SDBVgroupInfo
*
dbInfo
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
int32_t
ctgGetVgInfoFromHashValue
(
struct
SCatalog
*
pCatalog
,
SDBVgroupInfo
*
dbInfo
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
vgNum
=
taosHashGetSize
(
dbInfo
->
vg
Info
);
int32_t
vgNum
=
taosHashGetSize
(
dbInfo
->
vg
Hash
);
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
db
);
tNameGetFullDbName
(
pTableName
,
db
);
...
@@ -386,40 +497,39 @@ int32_t ctgGetVgInfoFromHashValue(struct SCatalog *pCatalog, SDBVgroupInfo *dbIn
...
@@ -386,40 +497,39 @@ int32_t ctgGetVgInfoFromHashValue(struct SCatalog *pCatalog, SDBVgroupInfo *dbIn
tableNameHashFp
fp
=
NULL
;
tableNameHashFp
fp
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
CTG_ERR_
J
RET
(
ctgGetHashFunction
(
dbInfo
->
hashMethod
,
&
fp
));
CTG_ERR_RET
(
ctgGetHashFunction
(
dbInfo
->
hashMethod
,
&
fp
));
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
pTableName
,
tbFullName
);
tNameExtractFullName
(
pTableName
,
tbFullName
);
uint32_t
hashValue
=
(
*
fp
)(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
));
uint32_t
hashValue
=
(
*
fp
)(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
));
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vg
Info
,
NULL
);
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vg
Hash
,
NULL
);
while
(
pIter
)
{
while
(
pIter
)
{
vgInfo
=
pIter
;
vgInfo
=
pIter
;
if
(
hashValue
>=
vgInfo
->
hashBegin
&&
hashValue
<=
vgInfo
->
hashEnd
)
{
if
(
hashValue
>=
vgInfo
->
hashBegin
&&
hashValue
<=
vgInfo
->
hashEnd
)
{
taosHashCancelIterate
(
dbInfo
->
vg
Info
,
pIter
);
taosHashCancelIterate
(
dbInfo
->
vg
Hash
,
pIter
);
break
;
break
;
}
}
pIter
=
taosHashIterate
(
dbInfo
->
vg
Info
,
pIter
);
pIter
=
taosHashIterate
(
dbInfo
->
vg
Hash
,
pIter
);
vgInfo
=
NULL
;
vgInfo
=
NULL
;
}
}
if
(
NULL
==
vgInfo
)
{
if
(
NULL
==
vgInfo
)
{
ctgError
(
"no hash range found for hash value [%u], db:%s, numOfVgId:%d"
,
hashValue
,
db
,
taosHashGetSize
(
dbInfo
->
vg
Info
));
ctgError
(
"no hash range found for hash value [%u], db:%s, numOfVgId:%d"
,
hashValue
,
db
,
taosHashGetSize
(
dbInfo
->
vg
Hash
));
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
*
pVgroup
=
*
vgInfo
;
*
pVgroup
=
*
vgInfo
;
_return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgSTableVersionCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
int32_t
ctgSTableVersionCompare
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
((
SSTableMetaVersion
*
)
key1
)
->
suid
<
((
SSTableMetaVersion
*
)
key2
)
->
suid
)
{
if
(
*
(
uint64_t
*
)
key1
<
((
SSTableMetaVersion
*
)
key2
)
->
suid
)
{
return
-
1
;
return
-
1
;
}
else
if
(
((
SSTableMetaVersion
*
)
key1
)
->
suid
>
((
SSTableMetaVersion
*
)
key2
)
->
suid
)
{
}
else
if
(
*
(
uint64_t
*
)
key1
>
((
SSTableMetaVersion
*
)
key2
)
->
suid
)
{
return
1
;
return
1
;
}
else
{
}
else
{
return
0
;
return
0
;
...
@@ -437,17 +547,17 @@ int32_t ctgDbVgVersionCompare(const void* key1, const void* key2) {
...
@@ -437,17 +547,17 @@ int32_t ctgDbVgVersionCompare(const void* key1, const void* key2) {
}
}
int32_t
ctgMetaRentInit
(
S
Meta
RentMgmt
*
mgmt
,
uint32_t
rentSec
,
int8_t
type
)
{
int32_t
ctgMetaRentInit
(
S
Ctg
RentMgmt
*
mgmt
,
uint32_t
rentSec
,
int8_t
type
)
{
mgmt
->
slotRIdx
=
0
;
mgmt
->
slotRIdx
=
0
;
mgmt
->
slotNum
=
rentSec
/
CTG_RENT_SLOT_SECOND
;
mgmt
->
slotNum
=
rentSec
/
CTG_RENT_SLOT_SECOND
;
mgmt
->
type
=
type
;
mgmt
->
type
=
type
;
size_t
msgSize
=
sizeof
(
S
RentSlotInfo
)
*
mgmt
->
slotNum
;
size_t
msgSize
=
sizeof
(
S
CtgRentSlot
)
*
mgmt
->
slotNum
;
mgmt
->
slots
=
calloc
(
1
,
msgSize
);
mgmt
->
slots
=
calloc
(
1
,
msgSize
);
if
(
NULL
==
mgmt
->
slots
)
{
if
(
NULL
==
mgmt
->
slots
)
{
qError
(
"calloc %d failed"
,
(
int32_t
)
msgSize
);
qError
(
"calloc %d failed"
,
(
int32_t
)
msgSize
);
return
TSDB_CODE_CTG_MEM_ERROR
;
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
)
;
}
}
qDebug
(
"meta rent initialized, type:%d, slotNum:%d"
,
type
,
mgmt
->
slotNum
);
qDebug
(
"meta rent initialized, type:%d, slotNum:%d"
,
type
,
mgmt
->
slotNum
);
...
@@ -456,10 +566,10 @@ int32_t ctgMetaRentInit(SMetaRentMgmt *mgmt, uint32_t rentSec, int8_t type) {
...
@@ -456,10 +566,10 @@ int32_t ctgMetaRentInit(SMetaRentMgmt *mgmt, uint32_t rentSec, int8_t type) {
}
}
int32_t
ctgMetaRentAdd
(
S
Meta
RentMgmt
*
mgmt
,
void
*
meta
,
int64_t
id
,
int32_t
size
)
{
int32_t
ctgMetaRentAdd
(
S
Ctg
RentMgmt
*
mgmt
,
void
*
meta
,
int64_t
id
,
int32_t
size
)
{
int16_t
widx
=
abs
(
id
%
mgmt
->
slotNum
);
int16_t
widx
=
abs
(
id
%
mgmt
->
slotNum
);
S
RentSlotInfo
*
slot
=
&
mgmt
->
slots
[
widx
];
S
CtgRentSlot
*
slot
=
&
mgmt
->
slots
[
widx
];
int32_t
code
=
0
;
int32_t
code
=
0
;
CTG_LOCK
(
CTG_WRITE
,
&
slot
->
lock
);
CTG_LOCK
(
CTG_WRITE
,
&
slot
->
lock
);
...
@@ -486,10 +596,10 @@ _return:
...
@@ -486,10 +596,10 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgMetaRentUpdate
(
S
Meta
RentMgmt
*
mgmt
,
void
*
meta
,
int64_t
id
,
int32_t
size
,
__compar_fn_t
compare
)
{
int32_t
ctgMetaRentUpdate
(
S
Ctg
RentMgmt
*
mgmt
,
void
*
meta
,
int64_t
id
,
int32_t
size
,
__compar_fn_t
compare
)
{
int16_t
widx
=
abs
(
id
%
mgmt
->
slotNum
);
int16_t
widx
=
abs
(
id
%
mgmt
->
slotNum
);
S
RentSlotInfo
*
slot
=
&
mgmt
->
slots
[
widx
];
S
CtgRentSlot
*
slot
=
&
mgmt
->
slots
[
widx
];
int32_t
code
=
0
;
int32_t
code
=
0
;
CTG_LOCK
(
CTG_WRITE
,
&
slot
->
lock
);
CTG_LOCK
(
CTG_WRITE
,
&
slot
->
lock
);
...
@@ -526,10 +636,10 @@ _return:
...
@@ -526,10 +636,10 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgMetaRentRemove
(
S
Meta
RentMgmt
*
mgmt
,
int64_t
id
,
__compar_fn_t
compare
)
{
int32_t
ctgMetaRentRemove
(
S
Ctg
RentMgmt
*
mgmt
,
int64_t
id
,
__compar_fn_t
compare
)
{
int16_t
widx
=
abs
(
id
%
mgmt
->
slotNum
);
int16_t
widx
=
abs
(
id
%
mgmt
->
slotNum
);
S
RentSlotInfo
*
slot
=
&
mgmt
->
slots
[
widx
];
S
CtgRentSlot
*
slot
=
&
mgmt
->
slots
[
widx
];
int32_t
code
=
0
;
int32_t
code
=
0
;
CTG_LOCK
(
CTG_WRITE
,
&
slot
->
lock
);
CTG_LOCK
(
CTG_WRITE
,
&
slot
->
lock
);
...
@@ -562,14 +672,14 @@ _return:
...
@@ -562,14 +672,14 @@ _return:
}
}
int32_t
ctgMetaRentGetImpl
(
S
Meta
RentMgmt
*
mgmt
,
void
**
res
,
uint32_t
*
num
,
int32_t
size
)
{
int32_t
ctgMetaRentGetImpl
(
S
Ctg
RentMgmt
*
mgmt
,
void
**
res
,
uint32_t
*
num
,
int32_t
size
)
{
int16_t
ridx
=
atomic_add_fetch_16
(
&
mgmt
->
slotRIdx
,
1
);
int16_t
ridx
=
atomic_add_fetch_16
(
&
mgmt
->
slotRIdx
,
1
);
if
(
ridx
>=
mgmt
->
slotNum
)
{
if
(
ridx
>=
mgmt
->
slotNum
)
{
ridx
%=
mgmt
->
slotNum
;
ridx
%=
mgmt
->
slotNum
;
atomic_store_16
(
&
mgmt
->
slotRIdx
,
ridx
);
atomic_store_16
(
&
mgmt
->
slotRIdx
,
ridx
);
}
}
S
RentSlotInfo
*
slot
=
&
mgmt
->
slots
[
ridx
];
S
CtgRentSlot
*
slot
=
&
mgmt
->
slots
[
ridx
];
int32_t
code
=
0
;
int32_t
code
=
0
;
CTG_LOCK
(
CTG_READ
,
&
slot
->
lock
);
CTG_LOCK
(
CTG_READ
,
&
slot
->
lock
);
...
@@ -608,7 +718,7 @@ _return:
...
@@ -608,7 +718,7 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgMetaRentGet
(
S
Meta
RentMgmt
*
mgmt
,
void
**
res
,
uint32_t
*
num
,
int32_t
size
)
{
int32_t
ctgMetaRentGet
(
S
Ctg
RentMgmt
*
mgmt
,
void
**
res
,
uint32_t
*
num
,
int32_t
size
)
{
while
(
true
)
{
while
(
true
)
{
int64_t
msec
=
taosGetTimestampMs
();
int64_t
msec
=
taosGetTimestampMs
();
int64_t
lsec
=
atomic_load_64
(
&
mgmt
->
lastReadMsec
);
int64_t
lsec
=
atomic_load_64
(
&
mgmt
->
lastReadMsec
);
...
@@ -635,52 +745,79 @@ int32_t ctgMetaRentGet(SMetaRentMgmt *mgmt, void **res, uint32_t *num, int32_t s
...
@@ -635,52 +745,79 @@ int32_t ctgMetaRentGet(SMetaRentMgmt *mgmt, void **res, uint32_t *num, int32_t s
int32_t
ctgUpdateTableMetaCache
(
struct
SCatalog
*
pCatalog
,
STableMetaOutput
*
output
)
{
int32_t
ctgUpdateTableMetaCache
(
struct
SCatalog
*
pCatalog
,
STableMetaOutput
*
output
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SCtgDBCache
*
dbCache
=
NULL
;
if
((
!
CTG_IS_META_CTABLE
(
output
->
metaType
))
&&
NULL
==
output
->
tbMeta
)
{
if
((
!
CTG_IS_META_CTABLE
(
output
->
metaType
))
&&
NULL
==
output
->
tbMeta
)
{
ctgError
(
"no valid t
able meta got from meta rsp, tbName:%s"
,
output
->
tbFn
ame
);
ctgError
(
"no valid t
bmeta got from meta rsp, dbFName:%s, tbName:%s"
,
output
->
dbFName
,
output
->
tbN
ame
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
if
(
NULL
==
pCatalog
->
dbCache
)
{
SHashObj
*
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxDBCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
cache
)
{
ctgError
(
"taosHashInit %d failed"
,
CTG_DEFAULT_CACHE_DB_NUMBER
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
if
(
NULL
!=
atomic_val_compare_exchange_ptr
(
&
pCatalog
->
dbCache
,
NULL
,
cache
))
{
taosHashCleanup
(
cache
);
}
}
while
(
true
)
{
dbCache
=
(
SCtgDBCache
*
)
taosHashAcquire
(
pCatalog
->
dbCache
,
output
->
dbFName
,
strlen
(
output
->
dbFName
));
if
(
dbCache
)
{
break
;
}
SCtgDBCache
newDbCache
=
{
0
};
if
(
taosHashPut
(
pCatalog
->
dbCache
,
output
->
dbFName
,
strlen
(
output
->
dbFName
),
&
newDbCache
,
sizeof
(
newDbCache
)))
{
ctgError
(
"taosHashPut db to cache failed, db:%s"
,
output
->
dbFName
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
if
(
NULL
==
dbCache
->
tbCache
.
cache
)
{
SHashObj
*
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
SHashObj
*
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
cache
)
{
if
(
NULL
==
cache
)
{
ctgError
(
"taosHashInit failed, num:%d"
,
ctgMgmt
.
cfg
.
maxTblCacheNum
);
ctgError
(
"taosHashInit failed, num:%d"
,
ctgMgmt
.
cfg
.
maxTblCacheNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
if
(
NULL
!=
atomic_val_compare_exchange_ptr
(
&
pCatalog
->
table
Cache
.
cache
,
NULL
,
cache
))
{
if
(
NULL
!=
atomic_val_compare_exchange_ptr
(
&
dbCache
->
tb
Cache
.
cache
,
NULL
,
cache
))
{
taosHashCleanup
(
cache
);
taosHashCleanup
(
cache
);
}
}
}
}
if
(
NULL
==
pCatalog
->
tableCache
.
stable
Cache
)
{
if
(
NULL
==
dbCache
->
tbCache
.
stb
Cache
)
{
SHashObj
*
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
true
,
HASH_ENTRY_LOCK
);
SHashObj
*
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
cache
)
{
if
(
NULL
==
cache
)
{
ctgError
(
"taosHashInit failed, num:%d"
,
ctgMgmt
.
cfg
.
maxTblCacheNum
);
ctgError
(
"taosHashInit failed, num:%d"
,
ctgMgmt
.
cfg
.
maxTblCacheNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
if
(
NULL
!=
atomic_val_compare_exchange_ptr
(
&
pCatalog
->
tableCache
.
stable
Cache
,
NULL
,
cache
))
{
if
(
NULL
!=
atomic_val_compare_exchange_ptr
(
&
dbCache
->
tbCache
.
stb
Cache
,
NULL
,
cache
))
{
taosHashCleanup
(
cache
);
taosHashCleanup
(
cache
);
}
}
}
}
if
(
CTG_IS_META_CTABLE
(
output
->
metaType
)
||
CTG_IS_META_BOTH
(
output
->
metaType
))
{
if
(
CTG_IS_META_CTABLE
(
output
->
metaType
)
||
CTG_IS_META_BOTH
(
output
->
metaType
))
{
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
ctbFname
,
strlen
(
output
->
ctbFn
ame
),
&
output
->
ctbMeta
,
sizeof
(
output
->
ctbMeta
))
!=
0
)
{
if
(
taosHashPut
(
dbCache
->
tbCache
.
cache
,
output
->
ctbName
,
strlen
(
output
->
ctbN
ame
),
&
output
->
ctbMeta
,
sizeof
(
output
->
ctbMeta
))
!=
0
)
{
ctgError
(
"taosHashPut ct
ablemeta to cache failed, ctbName:%s"
,
output
->
ctbFn
ame
);
ctgError
(
"taosHashPut ct
bmeta to cache failed, ctbName:%s"
,
output
->
ctbN
ame
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
ctgDebug
(
"
update child tablemeta to cache, tbName:%s"
,
output
->
ctbFn
ame
);
ctgDebug
(
"
ctbmeta updated to cache, ctbName:%s"
,
output
->
ctbN
ame
);
}
}
if
(
CTG_IS_META_CTABLE
(
output
->
metaType
))
{
if
(
CTG_IS_META_CTABLE
(
output
->
metaType
))
{
return
TSDB_CODE_SUCCESS
;
goto
_return
;
}
}
if
(
CTG_IS_META_BOTH
(
output
->
metaType
)
&&
TSDB_SUPER_TABLE
!=
output
->
tbMeta
->
tableType
)
{
if
(
CTG_IS_META_BOTH
(
output
->
metaType
)
&&
TSDB_SUPER_TABLE
!=
output
->
tbMeta
->
tableType
)
{
ctgError
(
"table type error, expected:%d, actual:%d"
,
TSDB_SUPER_TABLE
,
output
->
tbMeta
->
tableType
);
ctgError
(
"table type error, expected:%d, actual:%d"
,
TSDB_SUPER_TABLE
,
output
->
tbMeta
->
tableType
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
int32_t
tbSize
=
sizeof
(
*
output
->
tbMeta
)
+
sizeof
(
SSchema
)
*
(
output
->
tbMeta
->
tableInfo
.
numOfColumns
+
output
->
tbMeta
->
tableInfo
.
numOfTags
);
int32_t
tbSize
=
sizeof
(
*
output
->
tbMeta
)
+
sizeof
(
SSchema
)
*
(
output
->
tbMeta
->
tableInfo
.
numOfColumns
+
output
->
tbMeta
->
tableInfo
.
numOfTags
);
...
@@ -688,45 +825,53 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
...
@@ -688,45 +825,53 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
if
(
TSDB_SUPER_TABLE
==
output
->
tbMeta
->
tableType
)
{
if
(
TSDB_SUPER_TABLE
==
output
->
tbMeta
->
tableType
)
{
bool
newAdded
=
false
;
bool
newAdded
=
false
;
SSTableMetaVersion
metaRent
=
{.
suid
=
output
->
tbMeta
->
suid
,
.
sversion
=
output
->
tbMeta
->
sversion
,
.
tversion
=
output
->
tbMeta
->
tversion
};
SSTableMetaVersion
metaRent
=
{.
suid
=
output
->
tbMeta
->
suid
,
.
sversion
=
output
->
tbMeta
->
sversion
,
.
tversion
=
output
->
tbMeta
->
tversion
};
strcpy
(
metaRent
.
dbFName
,
output
->
dbFName
);
strcpy
(
metaRent
.
stbName
,
output
->
tbName
);
CTG_LOCK
(
CTG_WRITE
,
&
pCatalog
->
tableCache
.
stable
Lock
);
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stb
Lock
);
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
tbFname
,
strlen
(
output
->
tbFn
ame
),
output
->
tbMeta
,
tbSize
)
!=
0
)
{
if
(
taosHashPut
(
dbCache
->
tbCache
.
cache
,
output
->
tbName
,
strlen
(
output
->
tbN
ame
),
output
->
tbMeta
,
tbSize
)
!=
0
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
pCatalog
->
tableCache
.
stable
Lock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stb
Lock
);
ctgError
(
"taosHashPut tablemeta to cache failed,
tbName:%s"
,
output
->
tbFn
ame
);
ctgError
(
"taosHashPut tablemeta to cache failed,
dbFName:%s, tbName:%s"
,
output
->
dbFName
,
output
->
tbN
ame
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
STableMeta
*
tbMeta
=
taosHashGet
(
pCatalog
->
tableCache
.
cache
,
output
->
tbFname
,
strlen
(
output
->
tbFn
ame
));
STableMeta
*
tbMeta
=
taosHashGet
(
dbCache
->
tbCache
.
cache
,
output
->
tbName
,
strlen
(
output
->
tbN
ame
));
if
(
taosHashPutExt
(
pCatalog
->
tableCache
.
stable
Cache
,
&
output
->
tbMeta
->
suid
,
sizeof
(
output
->
tbMeta
->
suid
),
&
tbMeta
,
POINTER_BYTES
,
&
newAdded
)
!=
0
)
{
if
(
taosHashPutExt
(
dbCache
->
tbCache
.
stb
Cache
,
&
output
->
tbMeta
->
suid
,
sizeof
(
output
->
tbMeta
->
suid
),
&
tbMeta
,
POINTER_BYTES
,
&
newAdded
)
!=
0
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
pCatalog
->
tableCache
.
stable
Lock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stb
Lock
);
ctgError
(
"taosHashPutExt stable to stable cache failed, suid:%"
PRIx64
,
output
->
tbMeta
->
suid
);
ctgError
(
"taosHashPutExt stable to stable cache failed, suid:%"
PRIx64
,
output
->
tbMeta
->
suid
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
CTG_UNLOCK
(
CTG_WRITE
,
&
pCatalog
->
tableCache
.
stable
Lock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stb
Lock
);
ctgDebug
(
"update stable to cache, suid:%"
PRIx64
,
output
->
tbMeta
->
suid
);
ctgDebug
(
"update stable to cache, suid:%"
PRIx64
,
output
->
tbMeta
->
suid
);
if
(
newAdded
)
{
if
(
newAdded
)
{
CTG_ERR_
RET
(
ctgMetaRentAdd
(
&
pCatalog
->
stable
Rent
,
&
metaRent
,
metaRent
.
suid
,
sizeof
(
SSTableMetaVersion
)));
CTG_ERR_
JRET
(
ctgMetaRentAdd
(
&
pCatalog
->
stb
Rent
,
&
metaRent
,
metaRent
.
suid
,
sizeof
(
SSTableMetaVersion
)));
}
else
{
}
else
{
CTG_ERR_
RET
(
ctgMetaRentUpdate
(
&
pCatalog
->
stable
Rent
,
&
metaRent
,
metaRent
.
suid
,
sizeof
(
SSTableMetaVersion
),
ctgSTableVersionCompare
));
CTG_ERR_
JRET
(
ctgMetaRentUpdate
(
&
pCatalog
->
stb
Rent
,
&
metaRent
,
metaRent
.
suid
,
sizeof
(
SSTableMetaVersion
),
ctgSTableVersionCompare
));
}
}
}
else
{
}
else
{
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
tbFname
,
strlen
(
output
->
tbFn
ame
),
output
->
tbMeta
,
tbSize
)
!=
0
)
{
if
(
taosHashPut
(
dbCache
->
tbCache
.
cache
,
output
->
tbName
,
strlen
(
output
->
tbN
ame
),
output
->
tbMeta
,
tbSize
)
!=
0
)
{
ctgError
(
"taosHashPut tablemeta to cache failed,
tbName:%s"
,
output
->
tbFn
ame
);
ctgError
(
"taosHashPut tablemeta to cache failed,
dbFName:%s, tbName:%s"
,
output
->
dbFName
,
output
->
tbN
ame
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_
J
RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
}
}
ctgDebug
(
"update tablemeta to cache, tbName:%s"
,
output
->
tbFname
);
ctgDebug
(
"update tablemeta to cache, dbFName:%s, tbName:%s"
,
output
->
dbFName
,
output
->
tbName
);
_return:
if
(
dbCache
)
{
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
}
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbName
,
bool
forceUpdate
,
S
DBVgroupInfo
**
dbInfo
)
{
int32_t
ctgGetDBVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
char
*
dbName
,
bool
forceUpdate
,
S
CtgDBCache
**
dbCache
)
{
bool
inCache
=
false
;
bool
inCache
=
false
;
if
(
!
forceUpdate
)
{
if
(
!
forceUpdate
)
{
CTG_ERR_RET
(
ctgGetDBVgroupFromCache
(
pCatalog
,
dbName
,
db
Info
,
&
inCache
));
CTG_ERR_RET
(
ctgGetDBVgroupFromCache
(
pCatalog
,
dbName
,
db
Cache
,
&
inCache
));
if
(
inCache
)
{
if
(
inCache
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -742,8 +887,8 @@ int32_t ctgGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgm
...
@@ -742,8 +887,8 @@ int32_t ctgGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgm
while
(
true
)
{
while
(
true
)
{
CTG_ERR_RET
(
ctgGetDBVgroupFromMnode
(
pCatalog
,
pRpc
,
pMgmtEps
,
&
input
,
&
DbOut
));
CTG_ERR_RET
(
ctgGetDBVgroupFromMnode
(
pCatalog
,
pRpc
,
pMgmtEps
,
&
input
,
&
DbOut
));
CTG_ERR_RET
(
catalogUpdateDBVgroup
(
pCatalog
,
dbName
,
&
DbOut
.
dbVgroup
));
CTG_ERR_RET
(
catalogUpdateDBVgroup
(
pCatalog
,
dbName
,
DbOut
.
dbVgroup
));
CTG_ERR_RET
(
ctgGetDBVgroupFromCache
(
pCatalog
,
dbName
,
db
Info
,
&
inCache
));
CTG_ERR_RET
(
ctgGetDBVgroupFromCache
(
pCatalog
,
dbName
,
db
Cache
,
&
inCache
));
if
(
!
inCache
)
{
if
(
!
inCache
)
{
ctgWarn
(
"can't get db vgroup from cache, will retry, db:%s"
,
dbName
);
ctgWarn
(
"can't get db vgroup from cache, will retry, db:%s"
,
dbName
);
...
@@ -757,66 +902,83 @@ int32_t ctgGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgm
...
@@ -757,66 +902,83 @@ int32_t ctgGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgm
}
}
int32_t
ctgValidateAndFreeDbInfo
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
SDBVgroupInfo
*
dbInfo
)
{
int32_t
ctgValidateAndRemoveDb
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
uint64_t
dbId
,
bool
*
removed
)
{
SDBVgroupInfo
*
oldInfo
=
(
SDBVgroupInfo
*
)
taosHashAcquire
(
pCatalog
->
dbCache
.
cache
,
dbName
,
strlen
(
dbName
));
*
removed
=
false
;
if
(
oldInfo
)
{
CTG_LOCK
(
CTG_WRITE
,
&
oldInfo
->
lock
);
if
(
dbInfo
->
vgVersion
<=
oldInfo
->
vgVersion
)
{
ctgInfo
(
"db vgVersion is not new, db:%s, vgVersion:%d, current:%d"
,
dbName
,
dbInfo
->
vgVersion
,
oldInfo
->
vgVersion
);
CTG_UNLOCK
(
CTG_WRITE
,
&
oldInfo
->
lock
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
oldInfo
);
SCtgDBCache
*
dbCache
=
(
SCtgDBCache
*
)
taosHashAcquire
(
pCatalog
->
dbCache
,
dbName
,
strlen
(
dbName
));
if
(
NULL
==
dbCache
)
{
ctgInfo
(
"db not exist in dbCache, may be removed, db:%s"
,
dbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
oldInfo
->
vgInfo
)
{
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
ctgInfo
(
"cleanup db vgInfo, db:%s"
,
dbName
);
taosHashCleanup
(
oldInfo
->
vgInfo
);
if
(
NULL
==
dbCache
->
vgInfo
)
{
oldInfo
->
vgInfo
=
NULL
;
ctgInfo
(
"db vgInfo not in dbCache, may be removed, db:%s, dbId:%"
PRIx64
,
dbName
,
dbId
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
return
TSDB_CODE_SUCCESS
;
}
if
(
dbCache
->
vgInfo
->
dbId
!=
dbId
)
{
ctgInfo
(
"db id already updated, db:%s, dbId:%"
PRIx64
", targetId:%"
PRIx64
,
dbName
,
dbCache
->
vgInfo
->
dbId
,
dbId
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
return
TSDB_CODE_SUCCESS
;
}
}
CTG_UNLOCK
(
CTG_WRITE
,
&
oldInfo
->
lock
);
if
(
dbCache
->
vgInfo
->
vgHash
)
{
ctgInfo
(
"cleanup db vgInfo, db:%s, dbId:%"
PRIx64
,
dbName
,
dbId
);
taosHashCleanup
(
dbCache
->
vgInfo
->
vgHash
);
tfree
(
dbCache
->
vgInfo
);
}
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
oldInfo
);
if
(
taosHashRemove
(
pCatalog
->
dbCache
,
dbName
,
strlen
(
dbName
)))
{
ctgError
(
"taosHashRemove from dbCache failed, db:%s"
,
dbName
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
dbCache
->
deleted
=
true
;
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
ctgFreeTableMetaCache
(
&
dbCache
->
tbCache
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
*
removed
=
true
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgValidateAndRemove
DbInfo
(
struct
SCatalog
*
pCatalog
,
SDbVgVersion
*
target
,
bool
*
removed
)
{
int32_t
ctgValidateAndRemove
StbMeta
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
const
char
*
stbName
,
uint64_t
suid
,
bool
*
removed
)
{
*
removed
=
false
;
*
removed
=
false
;
S
DBVgroupInfo
*
info
=
(
SDBVgroupInfo
*
)
taosHashAcquire
(
pCatalog
->
dbCache
.
cache
,
target
->
dbName
,
strlen
(
target
->
dbName
));
S
CtgDBCache
*
dbCache
=
(
SCtgDBCache
*
)
taosHashAcquire
(
pCatalog
->
dbCache
,
dbName
,
strlen
(
dbName
));
if
(
NULL
==
info
)
{
if
(
NULL
==
dbCache
)
{
ctgInfo
(
"db not exist in dbCache, may be removed, db:%s"
,
target
->
dbName
);
ctgInfo
(
"db not exist in dbCache, may be removed, db:%s"
,
dbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
CTG_LOCK
(
CTG_WRITE
,
&
info
->
lock
);
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stbLock
);
if
(
taosHashRemove
(
dbCache
->
tbCache
.
stbCache
,
&
suid
,
sizeof
(
suid
)))
{
if
(
info
->
dbId
!=
target
->
dbId
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stbLock
);
ctgInfo
(
"db id already updated, db:%s, dbId:%"
PRIx64
", targetId:%"
PRIx64
,
target
->
dbName
,
info
->
dbId
,
target
->
dbId
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
CTG_UNLOCK
(
CTG_WRITE
,
&
info
->
lock
);
ctgInfo
(
"stb not exist in stbCache, may be removed, db:%s, stb:%s, suid:%"
PRIx64
,
dbName
,
stbName
,
suid
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
info
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
info
->
vgInfo
)
{
if
(
taosHashRemove
(
dbCache
->
tbCache
.
cache
,
stbName
,
strlen
(
stbName
)))
{
ctgInfo
(
"cleanup db vgInfo, db:%s"
,
target
->
dbName
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stbLock
);
taosHashCleanup
(
info
->
vgInfo
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
info
->
vgInfo
=
NULL
;
ctgError
(
"stb not exist in cache, db:%s, stb:%s, suid:%"
PRIx64
,
dbName
,
stbName
,
suid
);
}
if
(
taosHashRemove
(
pCatalog
->
dbCache
.
cache
,
target
->
dbName
,
strlen
(
target
->
dbName
)))
{
ctgError
(
"taosHashRemove from dbCache failed, db:%s"
,
target
->
dbName
);
CTG_UNLOCK
(
CTG_WRITE
,
&
info
->
lock
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
info
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
tbCache
.
stbLock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
info
->
lock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
info
);
*
removed
=
true
;
*
removed
=
true
;
...
@@ -824,6 +986,7 @@ int32_t ctgValidateAndRemoveDbInfo(struct SCatalog* pCatalog, SDbVgVersion* targ
...
@@ -824,6 +986,7 @@ int32_t ctgValidateAndRemoveDbInfo(struct SCatalog* pCatalog, SDbVgVersion* targ
}
}
int32_t
ctgRenewTableMetaImpl
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
int32_t
isSTable
)
{
int32_t
ctgRenewTableMetaImpl
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
int32_t
isSTable
)
{
if
(
NULL
==
pCatalog
||
NULL
==
pTransporter
||
NULL
==
pMgmtEps
||
NULL
==
pTableName
)
{
if
(
NULL
==
pCatalog
||
NULL
==
pTransporter
||
NULL
==
pMgmtEps
||
NULL
==
pTableName
)
{
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
...
@@ -839,7 +1002,7 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
...
@@ -839,7 +1002,7 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
STableMetaOutput
*
output
=
&
voutput
;
STableMetaOutput
*
output
=
&
voutput
;
if
(
CTG_IS_STABLE
(
isSTable
))
{
if
(
CTG_IS_STABLE
(
isSTable
))
{
ctgDebug
(
"will renew t
able meta, supposed to be stable
, tbName:%s"
,
tNameGetTableName
(
pTableName
));
ctgDebug
(
"will renew t
bmeta, supposed to be stb
, tbName:%s"
,
tNameGetTableName
(
pTableName
));
// if get from mnode failed, will not try vnode
// if get from mnode failed, will not try vnode
CTG_ERR_JRET
(
ctgGetTableMetaFromMnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
moutput
));
CTG_ERR_JRET
(
ctgGetTableMetaFromMnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
moutput
));
...
@@ -850,15 +1013,15 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
...
@@ -850,15 +1013,15 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
output
=
&
moutput
;
output
=
&
moutput
;
}
}
}
else
{
}
else
{
ctgDebug
(
"will renew t
able meta, not supposed to be stable
, tbName:%s, isStable:%d"
,
tNameGetTableName
(
pTableName
),
isSTable
);
ctgDebug
(
"will renew t
bmeta, not supposed to be stb
, tbName:%s, isStable:%d"
,
tNameGetTableName
(
pTableName
),
isSTable
);
// if get from vnode failed or no table meta, will not try mnode
// if get from vnode failed or no table meta, will not try mnode
CTG_ERR_JRET
(
ctgGetTableMetaFromVnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
vgroupInfo
,
&
voutput
));
CTG_ERR_JRET
(
ctgGetTableMetaFromVnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
vgroupInfo
,
&
voutput
));
if
(
CTG_IS_META_TABLE
(
voutput
.
metaType
)
&&
TSDB_SUPER_TABLE
==
voutput
.
tbMeta
->
tableType
)
{
if
(
CTG_IS_META_TABLE
(
voutput
.
metaType
)
&&
TSDB_SUPER_TABLE
==
voutput
.
tbMeta
->
tableType
)
{
ctgDebug
(
"will continue to renew t
able meta since got stable
, tbName:%s, metaType:%d"
,
tNameGetTableName
(
pTableName
),
voutput
.
metaType
);
ctgDebug
(
"will continue to renew t
bmeta since got stb
, tbName:%s, metaType:%d"
,
tNameGetTableName
(
pTableName
),
voutput
.
metaType
);
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
voutput
.
tbFn
ame
,
&
moutput
));
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
voutput
.
dbFName
,
voutput
.
tbN
ame
,
&
moutput
));
voutput
.
metaType
=
moutput
.
metaType
;
voutput
.
metaType
=
moutput
.
metaType
;
...
@@ -867,9 +1030,9 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
...
@@ -867,9 +1030,9 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
moutput
.
tbMeta
=
NULL
;
moutput
.
tbMeta
=
NULL
;
}
else
if
(
CTG_IS_META_BOTH
(
voutput
.
metaType
))
{
}
else
if
(
CTG_IS_META_BOTH
(
voutput
.
metaType
))
{
int32_t
exist
=
0
;
int32_t
exist
=
0
;
CTG_ERR_JRET
(
ctgIsTableMetaExistInCache
(
pCatalog
,
voutput
.
tbFn
ame
,
&
exist
));
CTG_ERR_JRET
(
ctgIsTableMetaExistInCache
(
pCatalog
,
voutput
.
dbFName
,
voutput
.
tbN
ame
,
&
exist
));
if
(
0
==
exist
)
{
if
(
0
==
exist
)
{
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
voutput
.
tbFn
ame
,
&
moutput
));
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
voutput
.
dbFName
,
voutput
.
tbN
ame
,
&
moutput
));
if
(
CTG_IS_META_NULL
(
moutput
.
metaType
))
{
if
(
CTG_IS_META_NULL
(
moutput
.
metaType
))
{
SET_META_TYPE_NULL
(
voutput
.
metaType
);
SET_META_TYPE_NULL
(
voutput
.
metaType
);
...
@@ -934,68 +1097,10 @@ int32_t ctgGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMg
...
@@ -934,68 +1097,10 @@ int32_t ctgGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMg
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
ctgFreeMetaRent
(
SMetaRentMgmt
*
mgmt
)
{
if
(
NULL
==
mgmt
->
slots
)
{
return
;
}
for
(
int32_t
i
=
0
;
i
<
mgmt
->
slotNum
;
++
i
)
{
SRentSlotInfo
*
slot
=
&
mgmt
->
slots
[
i
];
if
(
slot
->
meta
)
{
taosArrayDestroy
(
slot
->
meta
);
slot
->
meta
=
NULL
;
}
}
tfree
(
mgmt
->
slots
);
}
void
ctgFreeDbCache
(
SDBVgroupCache
*
db
)
{
if
(
NULL
==
db
->
cache
)
{
return
;
}
SDBVgroupInfo
*
dbInfo
=
NULL
;
void
*
pIter
=
taosHashIterate
(
db
->
cache
,
NULL
);
while
(
pIter
)
{
dbInfo
=
pIter
;
if
(
dbInfo
->
vgInfo
)
{
taosHashCleanup
(
dbInfo
->
vgInfo
);
dbInfo
->
vgInfo
=
NULL
;
}
pIter
=
taosHashIterate
(
db
->
cache
,
pIter
);
}
taosHashCleanup
(
db
->
cache
);
db
->
cache
=
NULL
;
}
void
ctgFreeTableMetaCache
(
STableMetaCache
*
table
)
{
if
(
table
->
stableCache
)
{
taosHashCleanup
(
table
->
stableCache
);
table
->
stableCache
=
NULL
;
}
if
(
table
->
cache
)
{
taosHashCleanup
(
table
->
cache
);
table
->
cache
=
NULL
;
}
}
void
ctgFreeHandle
(
struct
SCatalog
*
pCatalog
)
{
ctgFreeMetaRent
(
&
pCatalog
->
dbRent
);
ctgFreeMetaRent
(
&
pCatalog
->
stableRent
);
ctgFreeDbCache
(
&
pCatalog
->
dbCache
);
ctgFreeTableMetaCache
(
&
pCatalog
->
tableCache
);
free
(
pCatalog
);
}
int32_t
catalogInit
(
SCatalogCfg
*
cfg
)
{
int32_t
catalogInit
(
SCatalogCfg
*
cfg
)
{
if
(
ctgMgmt
.
pCluster
)
{
if
(
ctgMgmt
.
pCluster
)
{
qError
(
"catalog already init"
);
qError
(
"catalog already init
ialized
"
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
...
@@ -1014,14 +1119,14 @@ int32_t catalogInit(SCatalogCfg *cfg) {
...
@@ -1014,14 +1119,14 @@ int32_t catalogInit(SCatalogCfg *cfg) {
ctgMgmt
.
cfg
.
dbRentSec
=
CTG_DEFAULT_RENT_SECOND
;
ctgMgmt
.
cfg
.
dbRentSec
=
CTG_DEFAULT_RENT_SECOND
;
}
}
if
(
ctgMgmt
.
cfg
.
st
able
RentSec
==
0
)
{
if
(
ctgMgmt
.
cfg
.
st
b
RentSec
==
0
)
{
ctgMgmt
.
cfg
.
st
able
RentSec
=
CTG_DEFAULT_RENT_SECOND
;
ctgMgmt
.
cfg
.
st
b
RentSec
=
CTG_DEFAULT_RENT_SECOND
;
}
}
}
else
{
}
else
{
ctgMgmt
.
cfg
.
maxDBCacheNum
=
CTG_DEFAULT_CACHE_DB_NUMBER
;
ctgMgmt
.
cfg
.
maxDBCacheNum
=
CTG_DEFAULT_CACHE_DB_NUMBER
;
ctgMgmt
.
cfg
.
maxTblCacheNum
=
CTG_DEFAULT_CACHE_TABLEMETA_NUMBER
;
ctgMgmt
.
cfg
.
maxTblCacheNum
=
CTG_DEFAULT_CACHE_TABLEMETA_NUMBER
;
ctgMgmt
.
cfg
.
dbRentSec
=
CTG_DEFAULT_RENT_SECOND
;
ctgMgmt
.
cfg
.
dbRentSec
=
CTG_DEFAULT_RENT_SECOND
;
ctgMgmt
.
cfg
.
st
able
RentSec
=
CTG_DEFAULT_RENT_SECOND
;
ctgMgmt
.
cfg
.
st
b
RentSec
=
CTG_DEFAULT_RENT_SECOND
;
}
}
ctgMgmt
.
pCluster
=
taosHashInit
(
CTG_DEFAULT_CACHE_CLUSTER_NUMBER
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_ENTRY_LOCK
);
ctgMgmt
.
pCluster
=
taosHashInit
(
CTG_DEFAULT_CACHE_CLUSTER_NUMBER
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_ENTRY_LOCK
);
...
@@ -1030,7 +1135,7 @@ int32_t catalogInit(SCatalogCfg *cfg) {
...
@@ -1030,7 +1135,7 @@ int32_t catalogInit(SCatalogCfg *cfg) {
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
qDebug
(
"catalog initialized, maxDb:%u, maxTbl:%u, dbRentSec:%u, st
ableRentSec:%u"
,
ctgMgmt
.
cfg
.
maxDBCacheNum
,
ctgMgmt
.
cfg
.
maxTblCacheNum
,
ctgMgmt
.
cfg
.
dbRentSec
,
ctgMgmt
.
cfg
.
stable
RentSec
);
qDebug
(
"catalog initialized, maxDb:%u, maxTbl:%u, dbRentSec:%u, st
bRentSec:%u"
,
ctgMgmt
.
cfg
.
maxDBCacheNum
,
ctgMgmt
.
cfg
.
maxTblCacheNum
,
ctgMgmt
.
cfg
.
dbRentSec
,
ctgMgmt
.
cfg
.
stb
RentSec
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1041,7 +1146,7 @@ int32_t catalogGetHandle(uint64_t clusterId, struct SCatalog** catalogHandle) {
...
@@ -1041,7 +1146,7 @@ int32_t catalogGetHandle(uint64_t clusterId, struct SCatalog** catalogHandle) {
}
}
if
(
NULL
==
ctgMgmt
.
pCluster
)
{
if
(
NULL
==
ctgMgmt
.
pCluster
)
{
qError
(
"cluster cache are not ready, clusterId:%"
PRIx64
,
clusterId
);
qError
(
"c
atalog c
luster cache are not ready, clusterId:%"
PRIx64
,
clusterId
);
CTG_ERR_RET
(
TSDB_CODE_CTG_NOT_READY
);
CTG_ERR_RET
(
TSDB_CODE_CTG_NOT_READY
);
}
}
...
@@ -1066,7 +1171,7 @@ int32_t catalogGetHandle(uint64_t clusterId, struct SCatalog** catalogHandle) {
...
@@ -1066,7 +1171,7 @@ int32_t catalogGetHandle(uint64_t clusterId, struct SCatalog** catalogHandle) {
clusterCtg
->
clusterId
=
clusterId
;
clusterCtg
->
clusterId
=
clusterId
;
CTG_ERR_JRET
(
ctgMetaRentInit
(
&
clusterCtg
->
dbRent
,
ctgMgmt
.
cfg
.
dbRentSec
,
CTG_RENT_DB
));
CTG_ERR_JRET
(
ctgMetaRentInit
(
&
clusterCtg
->
dbRent
,
ctgMgmt
.
cfg
.
dbRentSec
,
CTG_RENT_DB
));
CTG_ERR_JRET
(
ctgMetaRentInit
(
&
clusterCtg
->
st
ableRent
,
ctgMgmt
.
cfg
.
stable
RentSec
,
CTG_RENT_STABLE
));
CTG_ERR_JRET
(
ctgMetaRentInit
(
&
clusterCtg
->
st
bRent
,
ctgMgmt
.
cfg
.
stb
RentSec
,
CTG_RENT_STABLE
));
code
=
taosHashPut
(
ctgMgmt
.
pCluster
,
&
clusterId
,
sizeof
(
clusterId
),
&
clusterCtg
,
POINTER_BYTES
);
code
=
taosHashPut
(
ctgMgmt
.
pCluster
,
&
clusterId
,
sizeof
(
clusterId
),
&
clusterCtg
,
POINTER_BYTES
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1117,21 +1222,33 @@ int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName,
...
@@ -1117,21 +1222,33 @@ int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName,
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
if
(
NULL
==
pCatalog
->
dbCache
.
cache
)
{
if
(
NULL
==
pCatalog
->
dbCache
)
{
*
version
=
CTG_DEFAULT_INVALID_VERSION
;
*
version
=
CTG_DEFAULT_INVALID_VERSION
;
ctgInfo
(
"empty db cache, dbName:%s"
,
dbName
);
ctgInfo
(
"empty db cache, dbName:%s"
,
dbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SDBVgroupInfo
*
dbInfo
=
taosHashAcquire
(
pCatalog
->
dbCache
.
cache
,
dbName
,
strlen
(
dbName
));
SCtgDBCache
*
db
=
taosHashAcquire
(
pCatalog
->
dbCache
,
dbName
,
strlen
(
dbName
));
if
(
NULL
==
dbInfo
)
{
if
(
NULL
==
db
)
{
*
version
=
CTG_DEFAULT_INVALID_VERSION
;
ctgInfo
(
"db not in cache, dbName:%s"
,
dbName
);
return
TSDB_CODE_SUCCESS
;
}
CTG_LOCK
(
CTG_READ
,
&
db
->
vgLock
);
if
(
NULL
==
db
->
vgInfo
)
{
CTG_UNLOCK
(
CTG_READ
,
&
db
->
vgLock
);
*
version
=
CTG_DEFAULT_INVALID_VERSION
;
*
version
=
CTG_DEFAULT_INVALID_VERSION
;
ctgInfo
(
"db not in cache, dbName:%s"
,
dbName
);
ctgInfo
(
"db not in cache, dbName:%s"
,
dbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
*
version
=
dbInfo
->
vgVersion
;
*
version
=
db
->
vgInfo
->
vgVersion
;
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
dbInfo
);
CTG_UNLOCK
(
CTG_READ
,
&
db
->
vgLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
db
);
ctgDebug
(
"Got db vgVersion from cache, dbName:%s, vgVersion:%d"
,
dbName
,
*
version
);
ctgDebug
(
"Got db vgVersion from cache, dbName:%s, vgVersion:%d"
,
dbName
,
*
version
);
...
@@ -1143,29 +1260,31 @@ int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet*
...
@@ -1143,29 +1260,31 @@ int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet*
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
S
DBVgroupInfo
*
db
=
NULL
;
S
CtgDBCache
*
dbCache
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgroup
(
pCatalog
,
pRpc
,
pMgmtEps
,
dbName
,
forceUpdate
,
&
db
));
CTG_ERR_JRET
(
ctgGetDBVgroup
(
pCatalog
,
pRpc
,
pMgmtEps
,
dbName
,
forceUpdate
,
&
db
Cache
));
vgList
=
taosArrayInit
(
taosHashGetSize
(
db
->
vgInfo
),
sizeof
(
SVgroupInfo
));
int32_t
vgNum
=
(
int32_t
)
taosHashGetSize
(
dbCache
->
vgInfo
->
vgHash
);
vgList
=
taosArrayInit
(
vgNum
,
sizeof
(
SVgroupInfo
));
if
(
NULL
==
vgList
)
{
if
(
NULL
==
vgList
)
{
ctgError
(
"taosArrayInit %d failed"
,
taosHashGetSize
(
db
->
vgInfo
)
);
ctgError
(
"taosArrayInit %d failed"
,
vgNum
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
void
*
pIter
=
taosHashIterate
(
db
->
vgInfo
,
NULL
);
void
*
pIter
=
taosHashIterate
(
db
Cache
->
vgInfo
->
vgHash
,
NULL
);
while
(
pIter
)
{
while
(
pIter
)
{
vgInfo
=
pIter
;
vgInfo
=
pIter
;
if
(
NULL
==
taosArrayPush
(
vgList
,
vgInfo
))
{
if
(
NULL
==
taosArrayPush
(
vgList
,
vgInfo
))
{
ctgError
(
"taosArrayPush failed, vgId:%d"
,
vgInfo
->
vgId
);
ctgError
(
"taosArrayPush failed, vgId:%d"
,
vgInfo
->
vgId
);
taosHashCancelIterate
(
dbCache
->
vgInfo
->
vgHash
,
pIter
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
pIter
=
taosHashIterate
(
db
->
vgInfo
,
pIter
);
pIter
=
taosHashIterate
(
db
Cache
->
vgInfo
->
vgHash
,
pIter
);
vgInfo
=
NULL
;
vgInfo
=
NULL
;
}
}
...
@@ -1173,9 +1292,10 @@ int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet*
...
@@ -1173,9 +1292,10 @@ int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet*
vgList
=
NULL
;
vgList
=
NULL
;
_return:
_return:
if
(
db
)
{
CTG_UNLOCK
(
CTG_READ
,
&
db
->
lock
);
if
(
dbCache
)
{
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
db
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
vgLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
}
}
if
(
vgList
)
{
if
(
vgList
)
{
...
@@ -1194,80 +1314,143 @@ int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDB
...
@@ -1194,80 +1314,143 @@ int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDB
CTG_ERR_JRET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
if
(
NULL
==
dbInfo
->
vg
Info
||
dbInfo
->
vgVersion
<
0
||
taosHashGetSize
(
dbInfo
->
vgInfo
)
<=
0
)
{
if
(
NULL
==
dbInfo
->
vg
Hash
||
dbInfo
->
vgVersion
<
0
||
taosHashGetSize
(
dbInfo
->
vgHash
)
<=
0
)
{
ctgError
(
"invalid db vgInfo, dbName:%s, vg
Info:%p, vgVersion:%d"
,
dbName
,
dbInfo
->
vgInfo
,
dbInfo
->
vgVersion
);
ctgError
(
"invalid db vgInfo, dbName:%s, vg
Hash:%p, vgVersion:%d"
,
dbName
,
dbInfo
->
vgHash
,
dbInfo
->
vgVersion
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
if
(
NULL
==
pCatalog
->
dbCache
.
cache
)
{
if
(
NULL
==
pCatalog
->
dbCache
)
{
SHashObj
*
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxDBCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
SHashObj
*
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxDBCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
cache
)
{
if
(
NULL
==
cache
)
{
ctgError
(
"taosHashInit %d failed"
,
CTG_DEFAULT_CACHE_DB_NUMBER
);
ctgError
(
"taosHashInit %d failed"
,
CTG_DEFAULT_CACHE_DB_NUMBER
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
if
(
NULL
!=
atomic_val_compare_exchange_ptr
(
&
pCatalog
->
dbCache
.
cache
,
NULL
,
cache
))
{
if
(
NULL
!=
atomic_val_compare_exchange_ptr
(
&
pCatalog
->
dbCache
,
NULL
,
cache
))
{
taosHashCleanup
(
cache
);
taosHashCleanup
(
cache
);
}
}
}
else
{
CTG_ERR_JRET
(
ctgValidateAndFreeDbInfo
(
pCatalog
,
dbName
,
dbInfo
));
}
}
bool
newAdded
=
false
;
bool
newAdded
=
false
;
SDbVgVersion
vgVersion
=
{.
dbId
=
dbInfo
->
dbId
,
.
vgVersion
=
dbInfo
->
vgVersion
};
SCtgDBCache
*
dbCache
=
(
SCtgDBCache
*
)
taosHashAcquire
(
pCatalog
->
dbCache
,
dbName
,
strlen
(
dbName
));
if
(
dbCache
)
{
CTG_LOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
if
(
NULL
==
dbCache
->
vgInfo
)
{
newAdded
=
true
;
dbCache
->
vgInfo
=
dbInfo
;
}
else
{
if
(
dbCache
->
vgInfo
->
dbId
!=
dbInfo
->
dbId
)
{
ctgMetaRentRemove
(
&
pCatalog
->
dbRent
,
dbCache
->
vgInfo
->
dbId
,
ctgDbVgVersionCompare
);
newAdded
=
true
;
}
else
if
(
dbInfo
->
vgVersion
<=
dbCache
->
vgInfo
->
vgVersion
)
{
ctgInfo
(
"db vgVersion is old, db:%s, vgVersion:%d, current:%d"
,
dbName
,
dbInfo
->
vgVersion
,
dbCache
->
vgInfo
->
vgVersion
);
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
goto
_return
;
}
if
(
dbCache
->
vgInfo
->
vgHash
)
{
ctgInfo
(
"cleanup db vgHash, db:%s"
,
dbName
);
taosHashCleanup
(
dbCache
->
vgInfo
->
vgHash
);
dbCache
->
vgInfo
->
vgHash
=
NULL
;
}
dbInfo
->
lock
=
0
;
tfree
(
dbCache
->
vgInfo
);
if
(
taosHashPutExt
(
pCatalog
->
dbCache
.
cache
,
dbName
,
strlen
(
dbName
),
dbInfo
,
sizeof
(
*
dbInfo
),
&
newAdded
)
!=
0
)
{
dbCache
->
vgInfo
=
dbInfo
;
ctgError
(
"taosHashPutExt db vgroup to cache failed, db:%s"
,
dbName
);
}
CTG_UNLOCK
(
CTG_WRITE
,
&
dbCache
->
vgLock
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
}
else
{
SCtgDBCache
newDBCache
=
{
0
};
newDBCache
.
vgInfo
=
dbInfo
;
if
(
taosHashPut
(
pCatalog
->
dbCache
,
dbName
,
strlen
(
dbName
),
&
newDBCache
,
sizeof
(
newDBCache
))
!=
0
)
{
ctgError
(
"taosHashPut db & db vgroup to cache failed, db:%s"
,
dbName
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
dbInfo
->
vgInfo
=
NULL
;
newAdded
=
true
;
}
SDbVgVersion
vgVersion
=
{.
dbId
=
dbInfo
->
dbId
,
.
vgVersion
=
dbInfo
->
vgVersion
};
dbInfo
=
NULL
;
strncpy
(
vgVersion
.
dbName
,
dbName
,
sizeof
(
vgVersion
.
dbName
));
strncpy
(
vgVersion
.
dbFName
,
dbName
,
sizeof
(
vgVersion
.
dbFName
));
if
(
newAdded
)
{
if
(
newAdded
)
{
CTG_ERR_JRET
(
ctgMetaRentAdd
(
&
pCatalog
->
dbRent
,
&
vgVersion
,
dbInfo
->
dbId
,
sizeof
(
SDbVgVersion
)));
CTG_ERR_JRET
(
ctgMetaRentAdd
(
&
pCatalog
->
dbRent
,
&
vgVersion
,
vgVersion
.
dbId
,
sizeof
(
SDbVgVersion
)));
}
else
{
}
else
{
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
pCatalog
->
dbRent
,
&
vgVersion
,
dbInfo
->
dbId
,
sizeof
(
SDbVgVersion
),
ctgDbVgVersionCompare
));
CTG_ERR_JRET
(
ctgMetaRentUpdate
(
&
pCatalog
->
dbRent
,
&
vgVersion
,
vgVersion
.
dbId
,
sizeof
(
SDbVgVersion
),
ctgDbVgVersionCompare
));
}
}
ctgDebug
(
"dbName:%s vgroup updated, vgVersion:%d"
,
dbName
,
dbInfo
->
vgVersion
);
ctgDebug
(
"dbName:%s vgroup updated, vgVersion:%d"
,
dbName
,
vgVersion
.
vgVersion
);
_return:
_return:
if
(
dbInfo
&&
dbInfo
->
vgInfo
)
{
if
(
dbInfo
)
{
taosHashCleanup
(
dbInfo
->
vgInfo
);
taosHashCleanup
(
dbInfo
->
vgHash
);
dbInfo
->
vgInfo
=
NULL
;
dbInfo
->
vgHash
=
NULL
;
tfree
(
dbInfo
);
}
}
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
catalogRemoveDB
Vgroup
(
struct
SCatalog
*
pCatalog
,
SDbVgVersion
*
dbInfo
)
{
int32_t
catalogRemoveDB
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
uint64_t
dbId
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
bool
removed
=
false
;
bool
removed
=
false
;
if
(
NULL
==
pCatalog
||
NULL
==
db
Info
)
{
if
(
NULL
==
pCatalog
||
NULL
==
db
Name
)
{
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
if
(
NULL
==
pCatalog
->
dbCache
.
cache
)
{
if
(
NULL
==
pCatalog
->
dbCache
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
CTG_ERR_RET
(
ctgValidateAndRemoveDb
Info
(
pCatalog
,
dbInfo
,
&
removed
));
CTG_ERR_RET
(
ctgValidateAndRemoveDb
(
pCatalog
,
dbName
,
dbId
,
&
removed
));
if
(
!
removed
)
{
if
(
!
removed
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
ctgInfo
(
"db removed from cache, db:%s
"
,
dbInfo
->
dbName
);
ctgInfo
(
"db removed from cache, db:%s
, uid:%"
PRIx64
,
dbName
,
dbId
);
CTG_ERR_RET
(
ctgMetaRentRemove
(
&
pCatalog
->
dbRent
,
dbI
nfo
->
dbI
d
,
ctgDbVgVersionCompare
));
CTG_ERR_RET
(
ctgMetaRentRemove
(
&
pCatalog
->
dbRent
,
dbId
,
ctgDbVgVersionCompare
));
ctgDebug
(
"db removed from rent, db:%s"
,
dbInfo
->
dbName
);
ctgDebug
(
"db removed from rent, db:%s, uid:%"
PRIx64
,
dbName
,
dbId
);
CTG_RET
(
code
);
}
int32_t
catalogRemoveSTableMeta
(
struct
SCatalog
*
pCatalog
,
const
char
*
dbName
,
const
char
*
stbName
,
uint64_t
suid
)
{
int32_t
code
=
0
;
bool
removed
=
false
;
if
(
NULL
==
pCatalog
||
NULL
==
dbName
||
NULL
==
stbName
)
{
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
if
(
NULL
==
pCatalog
->
dbCache
)
{
return
TSDB_CODE_SUCCESS
;
}
CTG_ERR_RET
(
ctgValidateAndRemoveStbMeta
(
pCatalog
,
dbName
,
stbName
,
suid
,
&
removed
));
if
(
!
removed
)
{
return
TSDB_CODE_SUCCESS
;
}
ctgInfo
(
"stb removed from cache, db:%s, stbName:%s, suid:%"
PRIx64
,
dbName
,
stbName
,
suid
);
CTG_ERR_RET
(
ctgMetaRentRemove
(
&
pCatalog
->
stbRent
,
suid
,
ctgSTableVersionCompare
));
ctgDebug
(
"stb removed from rent, db:%s, stbName:%s, suid:%"
PRIx64
,
dbName
,
stbName
,
suid
);
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
...
@@ -1301,7 +1484,7 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
...
@@ -1301,7 +1484,7 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
STableMeta
*
tbMeta
=
NULL
;
STableMeta
*
tbMeta
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SVgroupInfo
vgroupInfo
=
{
0
};
SVgroupInfo
vgroupInfo
=
{
0
};
S
DBVgroupInfo
*
dbVgroup
=
NULL
;
S
CtgDBCache
*
dbCache
=
NULL
;
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
*
pVgroupList
=
NULL
;
*
pVgroupList
=
NULL
;
...
@@ -1310,7 +1493,7 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
...
@@ -1310,7 +1493,7 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
db
);
tNameGetFullDbName
(
pTableName
,
db
);
CTG_ERR_JRET
(
ctgGetDBVgroup
(
pCatalog
,
pRpc
,
pMgmtEps
,
db
,
false
,
&
db
Vgroup
));
CTG_ERR_JRET
(
ctgGetDBVgroup
(
pCatalog
,
pRpc
,
pMgmtEps
,
db
,
false
,
&
db
Cache
));
// REMOEV THIS ....
// REMOEV THIS ....
if
(
0
==
tbMeta
->
vgId
)
{
if
(
0
==
tbMeta
->
vgId
)
{
...
@@ -1323,10 +1506,10 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
...
@@ -1323,10 +1506,10 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
// REMOVE THIS ....
// REMOVE THIS ....
if
(
tbMeta
->
tableType
==
TSDB_SUPER_TABLE
)
{
if
(
tbMeta
->
tableType
==
TSDB_SUPER_TABLE
)
{
CTG_ERR_JRET
(
ctgGetVgInfoFromDB
(
pCatalog
,
pRpc
,
pMgmtEps
,
db
Vgroup
,
pVgroupList
));
CTG_ERR_JRET
(
ctgGetVgInfoFromDB
(
pCatalog
,
pRpc
,
pMgmtEps
,
db
Cache
->
vgInfo
,
pVgroupList
));
}
else
{
}
else
{
int32_t
vgId
=
tbMeta
->
vgId
;
int32_t
vgId
=
tbMeta
->
vgId
;
if
(
NULL
==
taosHashGetClone
(
db
Vgroup
->
vgInfo
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
))
{
if
(
NULL
==
taosHashGetClone
(
db
Cache
->
vgInfo
->
vgHash
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
))
{
ctgError
(
"table's vgId not found in vgroup list, vgId:%d, tbName:%s"
,
vgId
,
tNameGetTableName
(
pTableName
));
ctgError
(
"table's vgId not found in vgroup list, vgId:%d, tbName:%s"
,
vgId
,
tNameGetTableName
(
pTableName
));
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
...
@@ -1349,9 +1532,9 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
...
@@ -1349,9 +1532,9 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S
_return:
_return:
tfree
(
tbMeta
);
tfree
(
tbMeta
);
if
(
db
Vgroup
)
{
if
(
db
Cache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
db
Vgroup
->
l
ock
);
CTG_UNLOCK
(
CTG_READ
,
&
db
Cache
->
vgL
ock
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
dbVgroup
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
}
}
if
(
vgList
)
{
if
(
vgList
)
{
...
@@ -1364,21 +1547,21 @@ _return:
...
@@ -1364,21 +1547,21 @@ _return:
int32_t
catalogGetTableHashVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
int32_t
catalogGetTableHashVgroup
(
struct
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
S
DBVgroupInfo
*
dbInfo
=
NULL
;
S
CtgDBCache
*
dbCache
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
db
);
tNameGetFullDbName
(
pTableName
,
db
);
CTG_ERR_RET
(
ctgGetDBVgroup
(
pCatalog
,
pTransporter
,
pMgmtEps
,
db
,
false
,
&
db
Info
));
CTG_ERR_RET
(
ctgGetDBVgroup
(
pCatalog
,
pTransporter
,
pMgmtEps
,
db
,
false
,
&
db
Cache
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCatalog
,
dbInfo
,
pTableName
,
pVgroup
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCatalog
,
db
Cache
->
vg
Info
,
pTableName
,
pVgroup
));
_return:
_return:
if
(
db
Info
)
{
if
(
db
Cache
)
{
CTG_UNLOCK
(
CTG_READ
,
&
db
Info
->
l
ock
);
CTG_UNLOCK
(
CTG_READ
,
&
db
Cache
->
vgL
ock
);
taosHashRelease
(
pCatalog
->
dbCache
.
cache
,
dbInfo
);
taosHashRelease
(
pCatalog
->
dbCache
,
dbCache
);
}
}
CTG_RET
(
code
);
CTG_RET
(
code
);
...
@@ -1422,6 +1605,7 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pTransporter, const S
...
@@ -1422,6 +1605,7 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pTransporter, const S
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_return:
_return:
if
(
pRsp
->
pTableMeta
)
{
if
(
pRsp
->
pTableMeta
)
{
int32_t
aSize
=
taosArrayGetSize
(
pRsp
->
pTableMeta
);
int32_t
aSize
=
taosArrayGetSize
(
pRsp
->
pTableMeta
);
for
(
int32_t
i
=
0
;
i
<
aSize
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
aSize
;
++
i
)
{
...
@@ -1451,7 +1635,7 @@ int32_t catalogGetExpiredSTables(struct SCatalog* pCatalog, SSTableMetaVersion *
...
@@ -1451,7 +1635,7 @@ int32_t catalogGetExpiredSTables(struct SCatalog* pCatalog, SSTableMetaVersion *
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
CTG_RET
(
ctgMetaRentGet
(
&
pCatalog
->
st
able
Rent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTableMetaVersion
)));
CTG_RET
(
ctgMetaRentGet
(
&
pCatalog
->
st
b
Rent
,
(
void
**
)
stables
,
num
,
sizeof
(
SSTableMetaVersion
)));
}
}
int32_t
catalogGetExpiredDBs
(
struct
SCatalog
*
pCatalog
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
)
{
int32_t
catalogGetExpiredDBs
(
struct
SCatalog
*
pCatalog
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
)
{
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
3b5828c0
...
@@ -128,15 +128,14 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
...
@@ -128,15 +128,14 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
strcpy
(
sn
.
dbname
,
"db1"
);
strcpy
(
sn
.
dbname
,
"db1"
);
strcpy
(
sn
.
tname
,
ctgTestSTablename
);
strcpy
(
sn
.
tname
,
ctgTestSTablename
);
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
]
;
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
}
;
tName
ExtractFullName
(
&
cn
,
tbFullName
);
tName
GetFullDbName
(
&
cn
,
db
);
strcpy
(
output
->
dbFName
,
db
);
SET_META_TYPE_BOTH_TABLE
(
output
->
metaType
);
SET_META_TYPE_BOTH_TABLE
(
output
->
metaType
);
strcpy
(
output
->
ctbFname
,
tbFullName
);
strcpy
(
output
->
ctbName
,
cn
.
tname
);
strcpy
(
output
->
tbName
,
sn
.
tname
);
tNameExtractFullName
(
&
cn
,
tbFullName
);
strcpy
(
output
->
tbFname
,
tbFullName
);
output
->
ctbMeta
.
vgId
=
9
;
output
->
ctbMeta
.
vgId
=
9
;
output
->
ctbMeta
.
tableType
=
TSDB_CHILD_TABLE
;
output
->
ctbMeta
.
tableType
=
TSDB_CHILD_TABLE
;
...
@@ -175,10 +174,11 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
...
@@ -175,10 +174,11 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
strcpy
(
s
->
name
,
"tag1s"
);
strcpy
(
s
->
name
,
"tag1s"
);
}
}
void
ctgTestBuildDBVgroup
(
SDBVgroupInfo
*
dbVgroup
)
{
void
ctgTestBuildDBVgroup
(
SDBVgroupInfo
*
*
p
dbVgroup
)
{
static
int32_t
vgVersion
=
ctgTestVgVersion
+
1
;
static
int32_t
vgVersion
=
ctgTestVgVersion
+
1
;
int32_t
vgNum
=
0
;
int32_t
vgNum
=
0
;
SVgroupInfo
vgInfo
=
{
0
};
SVgroupInfo
vgInfo
=
{
0
};
SDBVgroupInfo
*
dbVgroup
=
(
SDBVgroupInfo
*
)
calloc
(
1
,
sizeof
(
SDBVgroupInfo
));
dbVgroup
->
vgVersion
=
vgVersion
++
;
dbVgroup
->
vgVersion
=
vgVersion
++
;
...
@@ -186,7 +186,7 @@ void ctgTestBuildDBVgroup(SDBVgroupInfo *dbVgroup) {
...
@@ -186,7 +186,7 @@ void ctgTestBuildDBVgroup(SDBVgroupInfo *dbVgroup) {
dbVgroup
->
hashMethod
=
0
;
dbVgroup
->
hashMethod
=
0
;
dbVgroup
->
dbId
=
ctgTestDbId
;
dbVgroup
->
dbId
=
ctgTestDbId
;
dbVgroup
->
vg
Info
=
taosHashInit
(
ctgTestVgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
dbVgroup
->
vg
Hash
=
taosHashInit
(
ctgTestVgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
vgNum
=
ctgTestGetVgNumFromVgVersion
(
dbVgroup
->
vgVersion
);
vgNum
=
ctgTestGetVgNumFromVgVersion
(
dbVgroup
->
vgVersion
);
uint32_t
hashUnit
=
UINT32_MAX
/
vgNum
;
uint32_t
hashUnit
=
UINT32_MAX
/
vgNum
;
...
@@ -203,8 +203,10 @@ void ctgTestBuildDBVgroup(SDBVgroupInfo *dbVgroup) {
...
@@ -203,8 +203,10 @@ void ctgTestBuildDBVgroup(SDBVgroupInfo *dbVgroup) {
addr
->
port
=
htons
(
n
+
22
);
addr
->
port
=
htons
(
n
+
22
);
}
}
taosHashPut
(
dbVgroup
->
vg
Info
,
&
vgInfo
.
vgId
,
sizeof
(
vgInfo
.
vgId
),
&
vgInfo
,
sizeof
(
vgInfo
));
taosHashPut
(
dbVgroup
->
vg
Hash
,
&
vgInfo
.
vgId
,
sizeof
(
vgInfo
.
vgId
),
&
vgInfo
,
sizeof
(
vgInfo
));
}
}
*
pdbVgroup
=
dbVgroup
;
}
}
void
ctgTestPrepareDbVgroups
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
void
ctgTestPrepareDbVgroups
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
...
@@ -250,7 +252,8 @@ void ctgTestPrepareTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcM
...
@@ -250,7 +252,8 @@ void ctgTestPrepareTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcM
pRsp
->
contLen
=
sizeof
(
STableMetaRsp
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
contLen
=
sizeof
(
STableMetaRsp
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
rspMsg
=
(
STableMetaRsp
*
)
pRsp
->
pCont
;
rspMsg
=
(
STableMetaRsp
*
)
pRsp
->
pCont
;
sprintf
(
rspMsg
->
tbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestTablename
);
strcpy
(
rspMsg
->
dbFName
,
ctgTestDbname
);
strcpy
(
rspMsg
->
tbName
,
ctgTestTablename
);
rspMsg
->
numOfTags
=
0
;
rspMsg
->
numOfTags
=
0
;
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
precision
=
1
;
rspMsg
->
precision
=
1
;
...
@@ -285,8 +288,9 @@ void ctgTestPrepareCTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpc
...
@@ -285,8 +288,9 @@ void ctgTestPrepareCTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpc
pRsp
->
contLen
=
sizeof
(
STableMetaRsp
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
contLen
=
sizeof
(
STableMetaRsp
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
rspMsg
=
(
STableMetaRsp
*
)
pRsp
->
pCont
;
rspMsg
=
(
STableMetaRsp
*
)
pRsp
->
pCont
;
sprintf
(
rspMsg
->
tbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestCTablename
);
strcpy
(
rspMsg
->
dbFName
,
ctgTestDbname
);
sprintf
(
rspMsg
->
stbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestSTablename
);
strcpy
(
rspMsg
->
tbName
,
ctgTestCTablename
);
strcpy
(
rspMsg
->
stbName
,
ctgTestSTablename
);
rspMsg
->
numOfTags
=
htonl
(
ctgTestTagNum
);
rspMsg
->
numOfTags
=
htonl
(
ctgTestTagNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
precision
=
1
;
rspMsg
->
precision
=
1
;
...
@@ -327,8 +331,9 @@ void ctgTestPrepareSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpc
...
@@ -327,8 +331,9 @@ void ctgTestPrepareSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpc
pRsp
->
contLen
=
sizeof
(
STableMetaRsp
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
contLen
=
sizeof
(
STableMetaRsp
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
rspMsg
=
(
STableMetaRsp
*
)
pRsp
->
pCont
;
rspMsg
=
(
STableMetaRsp
*
)
pRsp
->
pCont
;
sprintf
(
rspMsg
->
tbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestSTablename
);
strcpy
(
rspMsg
->
dbFName
,
ctgTestDbname
);
sprintf
(
rspMsg
->
stbFname
,
"%s.%s"
,
ctgTestDbname
,
ctgTestSTablename
);
strcpy
(
rspMsg
->
tbName
,
ctgTestSTablename
);
strcpy
(
rspMsg
->
stbName
,
ctgTestSTablename
);
rspMsg
->
numOfTags
=
htonl
(
ctgTestTagNum
);
rspMsg
->
numOfTags
=
htonl
(
ctgTestTagNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
precision
=
1
;
rspMsg
->
precision
=
1
;
...
@@ -370,8 +375,9 @@ void ctgTestPrepareMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg,
...
@@ -370,8 +375,9 @@ void ctgTestPrepareMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg,
pRsp
->
contLen
=
sizeof
(
STableMetaRsp
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
contLen
=
sizeof
(
STableMetaRsp
)
+
(
ctgTestColNum
+
ctgTestTagNum
)
*
sizeof
(
SSchema
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
pRsp
->
pCont
=
calloc
(
1
,
pRsp
->
contLen
);
rspMsg
=
(
STableMetaRsp
*
)
pRsp
->
pCont
;
rspMsg
=
(
STableMetaRsp
*
)
pRsp
->
pCont
;
sprintf
(
rspMsg
->
tbFname
,
"%s.%s_%d"
,
ctgTestDbname
,
ctgTestSTablename
,
idx
);
strcpy
(
rspMsg
->
dbFName
,
ctgTestDbname
);
sprintf
(
rspMsg
->
stbFname
,
"%s.%s_%d"
,
ctgTestDbname
,
ctgTestSTablename
,
idx
);
sprintf
(
rspMsg
->
tbName
,
"%s_%d"
,
ctgTestSTablename
,
idx
);
sprintf
(
rspMsg
->
stbName
,
"%s_%d"
,
ctgTestSTablename
,
idx
);
rspMsg
->
numOfTags
=
htonl
(
ctgTestTagNum
);
rspMsg
->
numOfTags
=
htonl
(
ctgTestTagNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
numOfColumns
=
htonl
(
ctgTestColNum
);
rspMsg
->
precision
=
1
;
rspMsg
->
precision
=
1
;
...
@@ -589,12 +595,12 @@ void *ctgTestGetDbVgroupThread(void *param) {
...
@@ -589,12 +595,12 @@ void *ctgTestGetDbVgroupThread(void *param) {
void
*
ctgTestSetDbVgroupThread
(
void
*
param
)
{
void
*
ctgTestSetDbVgroupThread
(
void
*
param
)
{
struct
SCatalog
*
pCtg
=
(
struct
SCatalog
*
)
param
;
struct
SCatalog
*
pCtg
=
(
struct
SCatalog
*
)
param
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SDBVgroupInfo
dbVgroup
=
{
0
}
;
SDBVgroupInfo
*
dbVgroup
=
NULL
;
int32_t
n
=
0
;
int32_t
n
=
0
;
while
(
!
ctgTestStop
)
{
while
(
!
ctgTestStop
)
{
ctgTestBuildDBVgroup
(
&
dbVgroup
);
ctgTestBuildDBVgroup
(
&
dbVgroup
);
code
=
catalogUpdateDBVgroup
(
pCtg
,
ctgTestDbname
,
&
dbVgroup
);
code
=
catalogUpdateDBVgroup
(
pCtg
,
ctgTestDbname
,
dbVgroup
);
if
(
code
)
{
if
(
code
)
{
assert
(
0
);
assert
(
0
);
}
}
...
@@ -669,6 +675,7 @@ void *ctgTestSetCtableMetaThread(void *param) {
...
@@ -669,6 +675,7 @@ void *ctgTestSetCtableMetaThread(void *param) {
return
NULL
;
return
NULL
;
}
}
TEST
(
tableMeta
,
normalTable
)
{
TEST
(
tableMeta
,
normalTable
)
{
struct
SCatalog
*
pCtg
=
NULL
;
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
void
*
mockPointer
=
(
void
*
)
0x1
;
...
@@ -741,7 +748,7 @@ TEST(tableMeta, normalTable) {
...
@@ -741,7 +748,7 @@ TEST(tableMeta, normalTable) {
}
}
if
(
stbNum
)
{
if
(
stbNum
)
{
printf
(
"got expired stb,suid:%"
PRId64
"
\n
"
,
stb
->
suid
);
printf
(
"got expired stb,suid:%"
PRId64
"
,dbFName:%s, stbName:%s
\n
"
,
stb
->
suid
,
stb
->
dbFName
,
stb
->
stbName
);
free
(
stb
);
free
(
stb
);
stb
=
NULL
;
stb
=
NULL
;
}
else
{
}
else
{
...
@@ -837,7 +844,7 @@ TEST(tableMeta, childTableCase) {
...
@@ -837,7 +844,7 @@ TEST(tableMeta, childTableCase) {
}
}
if
(
stbNum
)
{
if
(
stbNum
)
{
printf
(
"got expired stb,suid:%"
PRId64
"
\n
"
,
stb
->
suid
);
printf
(
"got expired stb,suid:%"
PRId64
"
,dbFName:%s, stbName:%s
\n
"
,
stb
->
suid
,
stb
->
dbFName
,
stb
->
stbName
);
free
(
stb
);
free
(
stb
);
stb
=
NULL
;
stb
=
NULL
;
}
else
{
}
else
{
...
@@ -938,7 +945,8 @@ TEST(tableMeta, superTableCase) {
...
@@ -938,7 +945,8 @@ TEST(tableMeta, superTableCase) {
}
}
if
(
stbNum
)
{
if
(
stbNum
)
{
printf
(
"got expired stb,suid:%"
PRId64
"
\n
"
,
stb
->
suid
);
printf
(
"got expired stb,suid:%"
PRId64
",dbFName:%s, stbName:%s
\n
"
,
stb
->
suid
,
stb
->
dbFName
,
stb
->
stbName
);
free
(
stb
);
free
(
stb
);
stb
=
NULL
;
stb
=
NULL
;
}
else
{
}
else
{
...
@@ -1062,9 +1070,11 @@ TEST(dbVgroup, getSetDbVgroupCase) {
...
@@ -1062,9 +1070,11 @@ TEST(dbVgroup, getSetDbVgroupCase) {
void
*
mockPointer
=
(
void
*
)
0x1
;
void
*
mockPointer
=
(
void
*
)
0x1
;
SVgroupInfo
vgInfo
=
{
0
};
SVgroupInfo
vgInfo
=
{
0
};
SVgroupInfo
*
pvgInfo
=
NULL
;
SVgroupInfo
*
pvgInfo
=
NULL
;
SDBVgroupInfo
dbVgroup
=
{
0
}
;
SDBVgroupInfo
*
dbVgroup
=
NULL
;
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
ctgTestInitLogFile
();
ctgTestSetPrepareDbVgroupsAndNormalMeta
();
ctgTestSetPrepareDbVgroupsAndNormalMeta
();
initQueryModuleMsgHandle
();
initQueryModuleMsgHandle
();
...
@@ -1099,7 +1109,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
...
@@ -1099,7 +1109,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
taosArrayDestroy
(
vgList
);
taosArrayDestroy
(
vgList
);
ctgTestBuildDBVgroup
(
&
dbVgroup
);
ctgTestBuildDBVgroup
(
&
dbVgroup
);
code
=
catalogUpdateDBVgroup
(
pCtg
,
ctgTestDbname
,
&
dbVgroup
);
code
=
catalogUpdateDBVgroup
(
pCtg
,
ctgTestDbname
,
dbVgroup
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetTableHashVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
vgInfo
);
code
=
catalogGetTableHashVgroup
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
vgInfo
);
...
@@ -1169,6 +1179,7 @@ TEST(multiThread, getSetDbVgroupCase) {
...
@@ -1169,6 +1179,7 @@ TEST(multiThread, getSetDbVgroupCase) {
catalogDestroy
();
catalogDestroy
();
}
}
TEST
(
multiThread
,
ctableMeta
)
{
TEST
(
multiThread
,
ctableMeta
)
{
struct
SCatalog
*
pCtg
=
NULL
;
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
void
*
mockPointer
=
(
void
*
)
0x1
;
...
@@ -1178,6 +1189,8 @@ TEST(multiThread, ctableMeta) {
...
@@ -1178,6 +1189,8 @@ TEST(multiThread, ctableMeta) {
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
ctgTestStop
=
false
;
ctgTestStop
=
false
;
ctgTestInitLogFile
();
ctgTestSetPrepareDbVgroupsAndChildMeta
();
ctgTestSetPrepareDbVgroupsAndChildMeta
();
initQueryModuleMsgHandle
();
initQueryModuleMsgHandle
();
...
@@ -1212,11 +1225,13 @@ TEST(multiThread, ctableMeta) {
...
@@ -1212,11 +1225,13 @@ TEST(multiThread, ctableMeta) {
}
}
ctgTestStop
=
true
;
ctgTestStop
=
true
;
sleep
(
1
);
sleep
(
2
);
catalogDestroy
();
catalogDestroy
();
}
}
TEST
(
rentTest
,
allRent
)
{
TEST
(
rentTest
,
allRent
)
{
struct
SCatalog
*
pCtg
=
NULL
;
struct
SCatalog
*
pCtg
=
NULL
;
void
*
mockPointer
=
(
void
*
)
0x1
;
void
*
mockPointer
=
(
void
*
)
0x1
;
...
@@ -1229,6 +1244,8 @@ TEST(rentTest, allRent) {
...
@@ -1229,6 +1244,8 @@ TEST(rentTest, allRent) {
SSTableMetaVersion
*
stable
=
NULL
;
SSTableMetaVersion
*
stable
=
NULL
;
uint32_t
num
=
0
;
uint32_t
num
=
0
;
ctgTestInitLogFile
();
ctgTestSetPrepareDbVgroupsAndMultiSuperMeta
();
ctgTestSetPrepareDbVgroupsAndMultiSuperMeta
();
initQueryModuleMsgHandle
();
initQueryModuleMsgHandle
();
...
@@ -1273,7 +1290,7 @@ TEST(rentTest, allRent) {
...
@@ -1273,7 +1290,7 @@ TEST(rentTest, allRent) {
printf
(
"%d - expired stableNum:%d
\n
"
,
i
,
num
);
printf
(
"%d - expired stableNum:%d
\n
"
,
i
,
num
);
if
(
stable
)
{
if
(
stable
)
{
for
(
int32_t
n
=
0
;
n
<
num
;
++
n
)
{
for
(
int32_t
n
=
0
;
n
<
num
;
++
n
)
{
printf
(
"suid:%"
PRId64
",
sversion:%d, tversion:%d
\n
"
,
stable
[
n
].
suid
,
stable
[
n
].
sversion
,
stable
[
n
].
tversion
);
printf
(
"suid:%"
PRId64
",
dbFName:%s, stbName:%s, sversion:%d, tversion:%d
\n
"
,
stable
[
n
].
suid
,
stable
[
n
].
dbFName
,
stable
[
n
].
stbName
,
stable
[
n
].
sversion
,
stable
[
n
].
tversion
);
}
}
free
(
stable
);
free
(
stable
);
stable
=
NULL
;
stable
=
NULL
;
...
...
source/libs/parser/inc/astCreateFuncs.h
浏览文件 @
3b5828c0
...
@@ -30,7 +30,7 @@ extern SToken nil_token;
...
@@ -30,7 +30,7 @@ extern SToken nil_token;
SNodeList
*
createNodeList
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
);
SNodeList
*
createNodeList
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
);
SNodeList
*
addNodeToList
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
,
SNode
*
pNode
);
SNodeList
*
addNodeToList
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
,
SNode
*
pNode
);
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pTable
Name
,
const
SToken
*
pColumnName
);
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pTable
Alias
,
const
SToken
*
pColumnName
);
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
);
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
);
SNode
*
createDurationValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
);
SNode
*
createDurationValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
);
SNode
*
addMinusSign
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
);
SNode
*
addMinusSign
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
);
...
...
source/libs/parser/inc/new_sql.y
浏览文件 @
3b5828c0
...
@@ -187,7 +187,7 @@ table_reference(A) ::= joined_table(B).
...
@@ -187,7 +187,7 @@ table_reference(A) ::= joined_table(B).
table_primary(A) ::= table_name(B) alias_opt(C). { PARSER_TRACE; A = createRealTableNode(pCxt, NULL, &B, &C); }
table_primary(A) ::= table_name(B) alias_opt(C). { PARSER_TRACE; A = createRealTableNode(pCxt, NULL, &B, &C); }
table_primary(A) ::= db_name(B) NK_DOT table_name(C) alias_opt(D). { PARSER_TRACE; A = createRealTableNode(pCxt, &B, &C, &D); }
table_primary(A) ::= db_name(B) NK_DOT table_name(C) alias_opt(D). { PARSER_TRACE; A = createRealTableNode(pCxt, &B, &C, &D); }
table_primary(A) ::= subquery(B) alias_opt(C). { PARSER_TRACE; A = createTempTableNode(pCxt, B, &C); }
table_primary(A) ::= subquery(B) alias_opt(C). { PARSER_TRACE; A = createTempTableNode(pCxt, B, &C); }
table_primary
::= parenthesized_joined_table.
table_primary
(A) ::= parenthesized_joined_table(B). { PARSER_TRACE; A = B; }
%type alias_opt { SToken }
%type alias_opt { SToken }
%destructor alias_opt { PARSER_DESTRUCTOR_TRACE; }
%destructor alias_opt { PARSER_DESTRUCTOR_TRACE; }
...
@@ -297,9 +297,9 @@ query_expression_body(A) ::=
...
@@ -297,9 +297,9 @@ query_expression_body(A) ::=
query_expression_body(B) UNION ALL query_expression_body(D). { PARSER_TRACE; A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, D); }
query_expression_body(B) UNION ALL query_expression_body(D). { PARSER_TRACE; A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, D); }
query_primary(A) ::= query_specification(B). { PARSER_TRACE; A = B; }
query_primary(A) ::= query_specification(B). { PARSER_TRACE; A = B; }
query_primary(A) ::=
//
query_primary(A) ::=
NK_LP query_expression_body(B)
//
NK_LP query_expression_body(B)
order_by_clause_opt limit_clause_opt s
limit_clause_opt NK_RP. { PARSER_TRACE; A = B;}
// order_by_clause_opt slimit_clause_opt
limit_clause_opt NK_RP. { PARSER_TRACE; A = B;}
%type order_by_clause_opt { SNodeList* }
%type order_by_clause_opt { SNodeList* }
%destructor order_by_clause_opt { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
%destructor order_by_clause_opt { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); }
...
@@ -317,7 +317,7 @@ limit_clause_opt(A) ::= LIMIT NK_INTEGER(B) OFFSET NK_INTEGER(C).
...
@@ -317,7 +317,7 @@ limit_clause_opt(A) ::= LIMIT NK_INTEGER(B) OFFSET NK_INTEGER(C).
limit_clause_opt(A) ::= LIMIT NK_INTEGER(C) NK_COMMA NK_INTEGER(B). { PARSER_TRACE; A = createLimitNode(pCxt, &B, &C); }
limit_clause_opt(A) ::= LIMIT NK_INTEGER(C) NK_COMMA NK_INTEGER(B). { PARSER_TRACE; A = createLimitNode(pCxt, &B, &C); }
/************************************************ subquery ************************************************************/
/************************************************ subquery ************************************************************/
subquery(A) ::= NK_L
R
query_expression(B) NK_RP. { PARSER_TRACE; A = B; }
subquery(A) ::= NK_L
P
query_expression(B) NK_RP. { PARSER_TRACE; A = B; }
/************************************************ search_condition ****************************************************/
/************************************************ search_condition ****************************************************/
search_condition(A) ::= boolean_value_expression(B). { PARSER_TRACE; A = B; }
search_condition(A) ::= boolean_value_expression(B). { PARSER_TRACE; A = B; }
...
...
source/libs/parser/inc/parserImpl.h
浏览文件 @
3b5828c0
...
@@ -28,6 +28,7 @@ typedef struct SQuery {
...
@@ -28,6 +28,7 @@ typedef struct SQuery {
}
SQuery
;
}
SQuery
;
int32_t
doParse
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
int32_t
doParse
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
int32_t
doTranslate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/parser/src/astCreateFuncs.c
浏览文件 @
3b5828c0
...
@@ -60,14 +60,14 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode
...
@@ -60,14 +60,14 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode
return
nodesListAppend
(
pList
,
pNode
);
return
nodesListAppend
(
pList
,
pNode
);
}
}
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pTable
Name
,
const
SToken
*
pColumnName
)
{
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pTable
Alias
,
const
SToken
*
pColumnName
)
{
if
(
!
checkTableName
(
pCxt
,
pTable
Name
)
||
!
checkColumnName
(
pCxt
,
pColumnName
))
{
if
(
!
checkTableName
(
pCxt
,
pTable
Alias
)
||
!
checkColumnName
(
pCxt
,
pColumnName
))
{
return
NULL
;
return
NULL
;
}
}
SColumnNode
*
col
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
SColumnNode
*
col
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
CHECK_OUT_OF_MEM
(
col
);
CHECK_OUT_OF_MEM
(
col
);
if
(
NULL
!=
pTable
Name
)
{
if
(
NULL
!=
pTable
Alias
)
{
strncpy
(
col
->
table
Name
,
pTableName
->
z
,
pTableName
->
n
);
strncpy
(
col
->
table
Alias
,
pTableAlias
->
z
,
pTableAlias
->
n
);
}
}
strncpy
(
col
->
colName
,
pColumnName
->
z
,
pColumnName
->
n
);
strncpy
(
col
->
colName
,
pColumnName
->
z
,
pColumnName
->
n
);
return
(
SNode
*
)
col
;
return
(
SNode
*
)
col
;
...
@@ -150,7 +150,14 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, const SToken* pDbName, const
...
@@ -150,7 +150,14 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, const SToken* pDbName, const
SRealTableNode
*
realTable
=
(
SRealTableNode
*
)
nodesMakeNode
(
QUERY_NODE_REAL_TABLE
);
SRealTableNode
*
realTable
=
(
SRealTableNode
*
)
nodesMakeNode
(
QUERY_NODE_REAL_TABLE
);
CHECK_OUT_OF_MEM
(
realTable
);
CHECK_OUT_OF_MEM
(
realTable
);
if
(
NULL
!=
pDbName
)
{
if
(
NULL
!=
pDbName
)
{
strncpy
(
realTable
->
dbName
,
pDbName
->
z
,
pDbName
->
n
);
strncpy
(
realTable
->
table
.
dbName
,
pDbName
->
z
,
pDbName
->
n
);
}
else
{
strcpy
(
realTable
->
table
.
dbName
,
pCxt
->
pQueryCxt
->
db
);
}
if
(
NULL
!=
pTableAlias
&&
TK_NIL
!=
pTableAlias
->
type
)
{
strncpy
(
realTable
->
table
.
tableAlias
,
pTableAlias
->
z
,
pTableAlias
->
n
);
}
else
{
strncpy
(
realTable
->
table
.
tableAlias
,
pTableName
->
z
,
pTableName
->
n
);
}
}
strncpy
(
realTable
->
table
.
tableName
,
pTableName
->
z
,
pTableName
->
n
);
strncpy
(
realTable
->
table
.
tableName
,
pTableName
->
z
,
pTableName
->
n
);
return
(
SNode
*
)
realTable
;
return
(
SNode
*
)
realTable
;
...
@@ -160,6 +167,9 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
...
@@ -160,6 +167,9 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
STempTableNode
*
tempTable
=
(
STempTableNode
*
)
nodesMakeNode
(
QUERY_NODE_TEMP_TABLE
);
STempTableNode
*
tempTable
=
(
STempTableNode
*
)
nodesMakeNode
(
QUERY_NODE_TEMP_TABLE
);
CHECK_OUT_OF_MEM
(
tempTable
);
CHECK_OUT_OF_MEM
(
tempTable
);
tempTable
->
pSubquery
=
pSubquery
;
tempTable
->
pSubquery
=
pSubquery
;
if
(
NULL
!=
pTableAlias
&&
TK_NIL
!=
pTableAlias
->
type
)
{
strncpy
(
tempTable
->
table
.
tableAlias
,
pTableAlias
->
z
,
pTableAlias
->
n
);
}
return
(
SNode
*
)
tempTable
;
return
(
SNode
*
)
tempTable
;
}
}
...
@@ -288,9 +298,6 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr
...
@@ -288,9 +298,6 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr
SSelectStmt
*
select
=
(
SSelectStmt
*
)
nodesMakeNode
(
QUERY_NODE_SELECT_STMT
);
SSelectStmt
*
select
=
(
SSelectStmt
*
)
nodesMakeNode
(
QUERY_NODE_SELECT_STMT
);
CHECK_OUT_OF_MEM
(
select
);
CHECK_OUT_OF_MEM
(
select
);
select
->
isDistinct
=
isDistinct
;
select
->
isDistinct
=
isDistinct
;
if
(
NULL
==
pProjectionList
)
{
select
->
isStar
=
true
;
}
select
->
pProjectionList
=
pProjectionList
;
select
->
pProjectionList
=
pProjectionList
;
select
->
pFromTable
=
pTable
;
select
->
pFromTable
=
pTable
;
return
(
SNode
*
)
select
;
return
(
SNode
*
)
select
;
...
...
source/libs/parser/src/astTranslate.c
已删除
100644 → 0
浏览文件 @
a2162892
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// int32_t doTranslate() {
// }
source/libs/parser/src/new_sql.c
浏览文件 @
3b5828c0
...
@@ -109,21 +109,21 @@
...
@@ -109,21 +109,21 @@
#endif
#endif
/************* Begin control #defines *****************************************/
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned char
#define YYCODETYPE unsigned char
#define YYNOCODE 12
5
#define YYNOCODE 12
4
#define YYACTIONTYPE unsigned short int
#define YYACTIONTYPE unsigned short int
#define NewParseTOKENTYPE SToken
#define NewParseTOKENTYPE SToken
typedef
union
{
typedef
union
{
int
yyinit
;
int
yyinit
;
NewParseTOKENTYPE
yy0
;
NewParseTOKENTYPE
yy0
;
EO
peratorType
yy4
0
;
EO
rder
yy1
0
;
EFillMode
yy
4
4
;
EFillMode
yy
1
4
;
S
Token
yy79
;
S
Node
*
yy168
;
ENullOrder
yy1
0
7
;
ENullOrder
yy1
7
7
;
EJoinType
yy16
2
;
SNodeList
*
yy19
2
;
SNodeList
*
yy174
;
bool
yy209
;
EO
rder
yy18
8
;
EO
peratorType
yy22
8
;
SNode
*
yy212
;
EJoinType
yy229
;
bool
yy237
;
SToken
yy241
;
}
YYMINORTYPE
;
}
YYMINORTYPE
;
#ifndef YYSTACKDEPTH
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
#define YYSTACKDEPTH 100
...
@@ -138,17 +138,17 @@ typedef union {
...
@@ -138,17 +138,17 @@ typedef union {
#define NewParseCTX_PARAM
#define NewParseCTX_PARAM
#define NewParseCTX_FETCH
#define NewParseCTX_FETCH
#define NewParseCTX_STORE
#define NewParseCTX_STORE
#define YYNSTATE 14
9
#define YYNSTATE 14
3
#define YYNRULE 13
5
#define YYNRULE 13
4
#define YYNTOKEN 7
3
#define YYNTOKEN 7
2
#define YY_MAX_SHIFT 14
8
#define YY_MAX_SHIFT 14
2
#define YY_MIN_SHIFTREDUCE 2
45
#define YY_MIN_SHIFTREDUCE 2
38
#define YY_MAX_SHIFTREDUCE 37
9
#define YY_MAX_SHIFTREDUCE 37
1
#define YY_ERROR_ACTION 3
80
#define YY_ERROR_ACTION 3
72
#define YY_ACCEPT_ACTION 3
81
#define YY_ACCEPT_ACTION 3
73
#define YY_NO_ACTION 3
82
#define YY_NO_ACTION 3
74
#define YY_MIN_REDUCE 3
83
#define YY_MIN_REDUCE 3
75
#define YY_MAX_REDUCE 5
17
#define YY_MAX_REDUCE 5
08
/************* End control #defines *******************************************/
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
...
@@ -215,199 +215,202 @@ typedef union {
...
@@ -215,199 +215,202 @@ typedef union {
** yy_default[] Default action for each state.
** yy_default[] Default action for each state.
**
**
*********** Begin parsing tables **********************************************/
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (
656
)
#define YY_ACTTAB_COUNT (
705
)
static
const
YYACTIONTYPE
yy_action
[]
=
{
static
const
YYACTIONTYPE
yy_action
[]
=
{
/* 0 */
392
,
390
,
94
,
494
,
20
,
67
,
393
,
390
,
27
,
25
,
/* 0 */
384
,
382
,
89
,
22
,
64
,
385
,
382
,
458
,
29
,
27
,
/* 10 */
23
,
22
,
21
,
400
,
390
,
321
,
52
,
131
,
414
,
144
,
/* 10 */
25
,
24
,
23
,
392
,
382
,
137
,
406
,
126
,
406
,
138
,
/* 20 */
492
,
74
,
46
,
401
,
266
,
403
,
19
,
89
,
98
,
119
,
/* 20 */
71
,
109
,
44
,
393
,
259
,
395
,
21
,
84
,
93
,
142
,
/* 30 */
284
,
285
,
286
,
287
,
288
,
289
,
290
,
292
,
293
,
294
,
/* 30 */
277
,
278
,
279
,
280
,
281
,
282
,
283
,
285
,
286
,
287
,
/* 40 */
27
,
25
,
23
,
22
,
21
,
23
,
22
,
21
,
346
,
465
,
/* 40 */
29
,
27
,
25
,
24
,
23
,
25
,
24
,
23
,
125
,
9
,
/* 50 */
463
,
247
,
248
,
249
,
250
,
145
,
253
,
320
,
19
,
89
,
/* 50 */
456
,
240
,
241
,
242
,
243
,
139
,
246
,
106
,
21
,
84
,
/* 60 */
98
,
132
,
284
,
285
,
286
,
287
,
288
,
289
,
290
,
292
,
/* 60 */
93
,
51
,
277
,
278
,
279
,
280
,
281
,
282
,
283
,
285
,
/* 70 */
293
,
294
,
26
,
24
,
110
,
344
,
345
,
347
,
348
,
247
,
/* 70 */
286
,
287
,
127
,
392
,
382
,
137
,
406
,
137
,
406
,
138
,
/* 80 */
248
,
249
,
250
,
145
,
253
,
260
,
103
,
6
,
400
,
390
,
/* 80 */
315
,
113
,
38
,
393
,
114
,
395
,
431
,
253
,
28
,
26
,
/* 90 */
494
,
8
,
143
,
414
,
144
,
3
,
317
,
41
,
401
,
111
,
/* 90 */
83
,
427
,
487
,
443
,
131
,
240
,
241
,
242
,
243
,
139
,
/* 100 */
403
,
439
,
36
,
53
,
70
,
96
,
435
,
492
,
400
,
390
,
/* 100 */
246
,
487
,
98
,
1
,
340
,
486
,
67
,
10
,
51
,
485
,
/* 110 */
143
,
414
,
143
,
414
,
144
,
469
,
114
,
41
,
401
,
128
,
/* 110 */
440
,
392
,
382
,
60
,
50
,
137
,
406
,
138
,
485
,
123
,
/* 120 */
403
,
439
,
450
,
148
,
54
,
96
,
435
,
450
,
143
,
414
,
/* 120 */
39
,
393
,
314
,
395
,
431
,
51
,
125
,
9
,
91
,
427
,
/* 130 */
494
,
34
,
63
,
36
,
118
,
490
,
400
,
390
,
137
,
448
,
/* 130 */
105
,
338
,
339
,
341
,
342
,
392
,
382
,
132
,
462
,
137
,
/* 140 */
143
,
414
,
144
,
493
,
447
,
41
,
401
,
492
,
403
,
439
,
/* 140 */
406
,
138
,
4
,
311
,
39
,
393
,
407
,
395
,
431
,
51
,
/* 150 */
26
,
24
,
322
,
96
,
435
,
54
,
17
,
247
,
248
,
249
,
/* 150 */
443
,
443
,
91
,
427
,
29
,
27
,
25
,
24
,
23
,
323
,
/* 160 */
250
,
145
,
253
,
454
,
103
,
28
,
291
,
400
,
390
,
295
,
/* 160 */
392
,
382
,
483
,
73
,
137
,
406
,
138
,
439
,
438
,
39
,
/* 170 */
136
,
143
,
414
,
144
,
5
,
4
,
41
,
401
,
329
,
403
,
/* 170 */
393
,
251
,
395
,
431
,
389
,
18
,
387
,
91
,
427
,
7
,
/* 180 */
439
,
138
,
400
,
390
,
438
,
435
,
143
,
414
,
144
,
415
,
/* 180 */
6
,
29
,
27
,
25
,
24
,
23
,
134
,
447
,
127
,
392
,
/* 190 */
258
,
41
,
401
,
76
,
403
,
439
,
120
,
115
,
113
,
123
,
/* 190 */
382
,
7
,
6
,
137
,
406
,
138
,
28
,
26
,
77
,
393
,
/* 200 */
435
,
400
,
390
,
377
,
378
,
143
,
414
,
144
,
78
,
34
,
/* 200 */
8
,
395
,
295
,
240
,
241
,
242
,
243
,
139
,
246
,
107
,
/* 210 */
40
,
401
,
42
,
403
,
439
,
343
,
400
,
390
,
88
,
435
,
/* 210 */
98
,
1
,
28
,
26
,
469
,
10
,
104
,
487
,
52
,
240
,
/* 220 */
131
,
414
,
144
,
26
,
24
,
46
,
401
,
7
,
403
,
134
,
/* 220 */
241
,
242
,
243
,
139
,
246
,
246
,
98
,
5
,
102
,
40
,
/* 230 */
247
,
248
,
249
,
250
,
145
,
253
,
112
,
103
,
6
,
476
,
/* 230 */
50
,
135
,
337
,
19
,
485
,
392
,
382
,
130
,
468
,
137
,
/* 240 */
27
,
25
,
23
,
22
,
21
,
109
,
72
,
26
,
24
,
130
,
/* 240 */
406
,
138
,
103
,
284
,
39
,
393
,
288
,
395
,
431
,
51
,
/* 250 */
31
,
140
,
104
,
462
,
247
,
248
,
249
,
250
,
145
,
253
,
/* 250 */
56
,
54
,
430
,
427
,
57
,
370
,
371
,
29
,
27
,
25
,
/* 260 */
450
,
103
,
28
,
400
,
390
,
55
,
253
,
143
,
414
,
144
,
/* 260 */
24
,
23
,
30
,
392
,
382
,
289
,
90
,
137
,
406
,
138
,
/* 270 */
107
,
57
,
41
,
401
,
60
,
403
,
439
,
446
,
124
,
108
,
/* 270 */
3
,
254
,
39
,
393
,
117
,
395
,
431
,
28
,
26
,
316
,
/* 280 */
281
,
436
,
34
,
400
,
390
,
475
,
95
,
143
,
414
,
144
,
/* 280 */
118
,
427
,
47
,
449
,
240
,
241
,
242
,
243
,
139
,
246
,
/* 290 */
5
,
4
,
47
,
401
,
34
,
403
,
141
,
59
,
400
,
390
,
/* 290 */
70
,
98
,
5
,
101
,
392
,
382
,
129
,
127
,
126
,
406
,
/* 300 */
374
,
375
,
143
,
414
,
144
,
2
,
34
,
86
,
401
,
105
,
/* 300 */
138
,
122
,
43
,
44
,
393
,
119
,
395
,
274
,
30
,
59
,
/* 310 */
403
,
400
,
390
,
302
,
456
,
143
,
414
,
144
,
16
,
122
,
/* 310 */
41
,
257
,
2
,
29
,
27
,
25
,
24
,
23
,
61
,
65
,
/* 320 */
86
,
401
,
121
,
403
,
27
,
25
,
23
,
22
,
21
,
133
,
/* 320 */
436
,
121
,
15
,
120
,
69
,
311
,
487
,
20
,
413
,
250
,
/* 330 */
508
,
400
,
390
,
62
,
106
,
143
,
414
,
144
,
49
,
1
,
/* 330 */
99
,
455
,
42
,
29
,
27
,
25
,
24
,
23
,
253
,
50
,
/* 340 */
86
,
401
,
97
,
403
,
400
,
390
,
64
,
317
,
143
,
414
,
/* 340 */
28
,
26
,
444
,
485
,
31
,
62
,
254
,
240
,
241
,
242
,
/* 350 */
144
,
13
,
29
,
47
,
401
,
296
,
403
,
400
,
390
,
421
,
/* 350 */
243
,
139
,
246
,
459
,
98
,
1
,
392
,
382
,
94
,
502
,
/* 360 */
257
,
143
,
414
,
144
,
44
,
260
,
86
,
401
,
102
,
403
,
/* 360 */
137
,
406
,
138
,
136
,
484
,
39
,
393
,
72
,
395
,
431
,
/* 370 */
451
,
400
,
390
,
30
,
65
,
143
,
414
,
144
,
261
,
29
,
/* 370 */
28
,
26
,
367
,
368
,
428
,
133
,
251
,
240
,
241
,
242
,
/* 380 */
83
,
401
,
264
,
403
,
400
,
390
,
510
,
466
,
143
,
414
,
/* 380 */
243
,
139
,
246
,
13
,
98
,
5
,
29
,
27
,
25
,
24
,
/* 390 */
144
,
509
,
139
,
80
,
401
,
99
,
403
,
400
,
390
,
135
,
/* 390 */
23
,
115
,
110
,
108
,
392
,
382
,
12
,
30
,
137
,
406
,
/* 400 */
142
,
143
,
414
,
144
,
258
,
77
,
84
,
401
,
397
,
403
,
/* 400 */
138
,
53
,
259
,
45
,
393
,
334
,
395
,
55
,
34
,
336
,
/* 410 */
395
,
400
,
390
,
75
,
491
,
143
,
414
,
144
,
10
,
29
,
/* 410 */
330
,
46
,
58
,
35
,
392
,
382
,
373
,
140
,
137
,
406
,
/* 420 */
81
,
401
,
11
,
403
,
400
,
390
,
35
,
56
,
143
,
414
,
/* 420 */
138
,
329
,
111
,
81
,
393
,
100
,
395
,
392
,
382
,
112
,
/* 430 */
144
,
340
,
58
,
85
,
401
,
342
,
403
,
400
,
390
,
336
,
/* 430 */
387
,
137
,
406
,
138
,
36
,
6
,
81
,
393
,
116
,
395
,
/* 440 */
48
,
143
,
414
,
144
,
61
,
38
,
411
,
401
,
335
,
403
,
/* 440 */
128
,
500
,
14
,
392
,
382
,
275
,
487
,
137
,
406
,
138
,
/* 450 */
116
,
400
,
390
,
117
,
39
,
143
,
414
,
144
,
395
,
12
,
/* 450 */
309
,
308
,
81
,
393
,
92
,
395
,
392
,
382
,
33
,
50
,
/* 460 */
410
,
401
,
4
,
403
,
400
,
390
,
282
,
315
,
143
,
414
,
/* 460 */
137
,
406
,
138
,
485
,
66
,
45
,
393
,
32
,
395
,
392
,
/* 470 */
144
,
314
,
32
,
409
,
401
,
69
,
403
,
400
,
390
,
33
,
/* 470 */
382
,
386
,
49
,
137
,
406
,
138
,
361
,
16
,
81
,
393
,
/* 480 */
394
,
143
,
414
,
144
,
51
,
368
,
92
,
401
,
14
,
403
,
/* 480 */
97
,
395
,
37
,
11
,
356
,
355
,
74
,
95
,
360
,
392
,
/* 490 */
9
,
400
,
390
,
37
,
357
,
143
,
414
,
144
,
363
,
79
,
/* 490 */
382
,
359
,
96
,
137
,
406
,
138
,
244
,
17
,
78
,
393
,
/* 500 */
91
,
401
,
362
,
403
,
400
,
390
,
100
,
367
,
143
,
414
,
/* 500 */
376
,
395
,
375
,
501
,
374
,
141
,
392
,
382
,
374
,
374
,
/* 510 */
144
,
366
,
101
,
93
,
401
,
251
,
403
,
400
,
390
,
384
,
/* 510 */
137
,
406
,
138
,
374
,
374
,
75
,
393
,
374
,
395
,
392
,
/* 520 */
383
,
143
,
414
,
144
,
15
,
147
,
90
,
401
,
382
,
403
,
/* 520 */
382
,
374
,
374
,
137
,
406
,
138
,
374
,
374
,
79
,
393
,
/* 530 */
382
,
400
,
390
,
382
,
382
,
143
,
414
,
144
,
382
,
382
,
/* 530 */
374
,
395
,
392
,
382
,
374
,
374
,
137
,
406
,
138
,
374
,
/* 540 */
82
,
401
,
382
,
403
,
400
,
390
,
382
,
382
,
143
,
414
,
/* 540 */
374
,
76
,
393
,
374
,
395
,
392
,
382
,
374
,
374
,
137
,
/* 550 */
144
,
382
,
382
,
87
,
401
,
382
,
403
,
127
,
45
,
382
,
/* 550 */
406
,
138
,
374
,
374
,
80
,
393
,
374
,
395
,
374
,
374
,
/* 560 */
382
,
382
,
127
,
45
,
382
,
382
,
43
,
382
,
382
,
382
,
/* 560 */
374
,
374
,
374
,
374
,
392
,
382
,
374
,
374
,
137
,
406
,
/* 570 */
382
,
43
,
382
,
382
,
129
,
66
,
444
,
445
,
382
,
444
,
/* 570 */
138
,
374
,
374
,
403
,
393
,
374
,
395
,
374
,
392
,
382
,
/* 580 */
68
,
444
,
126
,
382
,
125
,
382
,
382
,
127
,
45
,
382
,
/* 580 */
374
,
374
,
137
,
406
,
138
,
374
,
374
,
402
,
393
,
374
,
/* 590 */
382
,
382
,
127
,
45
,
382
,
382
,
43
,
382
,
382
,
382
,
/* 590 */
395
,
392
,
382
,
374
,
374
,
137
,
406
,
138
,
374
,
374
,
/* 600 */
382
,
43
,
382
,
381
,
146
,
50
,
444
,
445
,
382
,
444
,
/* 600 */
401
,
393
,
374
,
395
,
392
,
382
,
374
,
374
,
137
,
406
,
/* 610 */
71
,
444
,
445
,
382
,
444
,
27
,
25
,
23
,
22
,
21
,
/* 610 */
138
,
374
,
374
,
87
,
393
,
374
,
395
,
392
,
382
,
374
,
/* 620 */
27
,
25
,
23
,
22
,
21
,
382
,
382
,
382
,
382
,
261
,
/* 620 */
374
,
137
,
406
,
138
,
374
,
374
,
86
,
393
,
374
,
395
,
/* 630 */
382
,
382
,
18
,
494
,
382
,
382
,
266
,
382
,
27
,
25
,
/* 630 */
392
,
382
,
374
,
374
,
137
,
406
,
138
,
374
,
374
,
88
,
/* 640 */
23
,
22
,
21
,
382
,
382
,
382
,
53
,
382
,
73
,
382
,
/* 640 */
393
,
374
,
395
,
392
,
382
,
374
,
374
,
137
,
406
,
138
,
/* 650 */
492
,
27
,
25
,
23
,
22
,
21
,
/* 650 */
374
,
374
,
85
,
393
,
374
,
395
,
374
,
392
,
382
,
374
,
/* 660 */
374
,
137
,
406
,
138
,
374
,
374
,
82
,
393
,
374
,
395
,
/* 670 */
122
,
43
,
374
,
374
,
374
,
122
,
43
,
374
,
374
,
41
,
/* 680 */
374
,
374
,
122
,
43
,
41
,
374
,
374
,
124
,
63
,
436
,
/* 690 */
437
,
41
,
441
,
48
,
436
,
437
,
374
,
441
,
374
,
374
,
/* 700 */
68
,
436
,
437
,
374
,
441
,
};
};
static
const
YYCODETYPE
yy_lookahead
[]
=
{
static
const
YYCODETYPE
yy_lookahead
[]
=
{
/* 0 */
7
5
,
76
,
77
,
103
,
89
,
90
,
75
,
76
,
8
,
9
,
/* 0 */
7
4
,
75
,
76
,
88
,
89
,
74
,
75
,
82
,
8
,
9
,
/* 10 */
10
,
11
,
12
,
7
5
,
76
,
4
,
116
,
79
,
80
,
81
,
/* 10 */
10
,
11
,
12
,
7
4
,
75
,
78
,
79
,
78
,
79
,
80
,
/* 20 */
12
0
,
123
,
84
,
85
,
24
,
87
,
26
,
27
,
28
,
22
,
/* 20 */
12
2
,
84
,
83
,
84
,
24
,
86
,
26
,
27
,
28
,
13
,
/* 30 */
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
/* 30 */
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
/* 40 */
8
,
9
,
10
,
11
,
12
,
10
,
11
,
12
,
29
,
83
,
/* 40 */
8
,
9
,
10
,
11
,
12
,
10
,
11
,
12
,
22
,
23
,
/* 50 */
112
,
15
,
16
,
17
,
18
,
19
,
20
,
46
,
26
,
27
,
/* 50 */
111
,
15
,
16
,
17
,
18
,
19
,
20
,
114
,
26
,
27
,
/* 60 */
28
,
74
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
/* 60 */
28
,
45
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
/* 70 */
38
,
39
,
8
,
9
,
55
,
56
,
57
,
58
,
59
,
15
,
/* 70 */
38
,
39
,
73
,
74
,
75
,
78
,
79
,
78
,
79
,
80
,
/* 80 */
16
,
17
,
18
,
19
,
20
,
22
,
22
,
23
,
75
,
76
,
/* 80 */
4
,
84
,
83
,
84
,
22
,
86
,
87
,
22
,
8
,
9
,
/* 90 */
103
,
27
,
79
,
80
,
81
,
43
,
44
,
84
,
85
,
115
,
/* 90 */
91
,
92
,
102
,
81
,
21
,
15
,
16
,
17
,
18
,
19
,
/* 100 */
87
,
88
,
23
,
116
,
41
,
92
,
93
,
120
,
75
,
76
,
/* 100 */
20
,
102
,
22
,
23
,
29
,
115
,
41
,
27
,
45
,
119
,
/* 110 */
79
,
80
,
79
,
80
,
81
,
102
,
85
,
84
,
85
,
101
,
/* 110 */
98
,
74
,
75
,
107
,
115
,
78
,
79
,
80
,
119
,
100
,
/* 120 */
87
,
88
,
82
,
13
,
45
,
92
,
93
,
82
,
79
,
80
,
/* 120 */
83
,
84
,
46
,
86
,
87
,
45
,
22
,
23
,
91
,
92
,
/* 130 */
103
,
67
,
108
,
23
,
85
,
102
,
75
,
76
,
21
,
99
,
/* 130 */
55
,
56
,
57
,
58
,
59
,
74
,
75
,
64
,
101
,
78
,
/* 140 */
79
,
80
,
81
,
116
,
99
,
84
,
85
,
120
,
87
,
88
,
/* 140 */
79
,
80
,
43
,
44
,
83
,
84
,
79
,
86
,
87
,
45
,
/* 150 */
8
,
9
,
10
,
92
,
93
,
45
,
26
,
15
,
16
,
17
,
/* 150 */
81
,
81
,
91
,
92
,
8
,
9
,
10
,
11
,
12
,
10
,
/* 160 */
18
,
19
,
20
,
102
,
22
,
23
,
36
,
75
,
76
,
39
,
/* 160 */
74
,
75
,
101
,
116
,
78
,
79
,
80
,
98
,
98
,
83
,
/* 170 */
3
,
79
,
80
,
81
,
1
,
2
,
84
,
85
,
10
,
87
,
/* 170 */
84
,
22
,
86
,
87
,
23
,
2
,
25
,
91
,
92
,
1
,
/* 180 */
88
,
64
,
75
,
76
,
92
,
93
,
79
,
80
,
81
,
80
,
/* 180 */
2
,
8
,
9
,
10
,
11
,
12
,
21
,
101
,
73
,
74
,
/* 190 */
22
,
84
,
85
,
117
,
87
,
88
,
50
,
51
,
52
,
92
,
/* 190 */
75
,
1
,
2
,
78
,
79
,
80
,
8
,
9
,
83
,
84
,
/* 200 */
93
,
75
,
76
,
71
,
72
,
79
,
80
,
81
,
117
,
67
,
/* 200 */
103
,
86
,
24
,
15
,
16
,
17
,
18
,
19
,
20
,
54
,
/* 210 */
84
,
85
,
21
,
87
,
88
,
24
,
75
,
76
,
92
,
93
,
/* 210 */
22
,
23
,
8
,
9
,
113
,
27
,
53
,
102
,
112
,
15
,
/* 220 */
79
,
80
,
81
,
8
,
9
,
84
,
85
,
104
,
87
,
62
,
/* 220 */
16
,
17
,
18
,
19
,
20
,
20
,
22
,
23
,
75
,
21
,
/* 230 */
15
,
16
,
17
,
18
,
19
,
20
,
54
,
22
,
23
,
114
,
/* 230 */
115
,
66
,
24
,
26
,
119
,
74
,
75
,
3
,
113
,
78
,
/* 240 */
8
,
9
,
10
,
11
,
12
,
53
,
105
,
8
,
9
,
22
,
/* 240 */
79
,
80
,
75
,
36
,
83
,
84
,
39
,
86
,
87
,
45
,
/* 250 */
23
,
21
,
111
,
112
,
15
,
16
,
17
,
18
,
19
,
20
,
/* 250 */
112
,
21
,
91
,
92
,
24
,
70
,
71
,
8
,
9
,
10
,
/* 260 */
82
,
22
,
23
,
75
,
76
,
113
,
20
,
79
,
80
,
81
,
/* 260 */
11
,
12
,
21
,
74
,
75
,
24
,
75
,
78
,
79
,
80
,
/* 270 */
76
,
21
,
84
,
85
,
24
,
87
,
88
,
99
,
27
,
76
,
/* 270 */
61
,
22
,
83
,
84
,
60
,
86
,
87
,
8
,
9
,
10
,
/* 280 */
29
,
93
,
67
,
75
,
76
,
114
,
76
,
79
,
80
,
81
,
/* 280 */
91
,
92
,
106
,
109
,
15
,
16
,
17
,
18
,
19
,
20
,
/* 290 */
1
,
2
,
84
,
85
,
67
,
87
,
66
,
113
,
75
,
76
,
/* 290 */
41
,
22
,
23
,
48
,
74
,
75
,
62
,
73
,
78
,
79
,
/* 300 */
68
,
69
,
79
,
80
,
81
,
61
,
67
,
84
,
85
,
86
,
/* 300 */
80
,
77
,
78
,
83
,
84
,
27
,
86
,
29
,
21
,
108
,
/* 310 */
87
,
75
,
76
,
24
,
110
,
79
,
80
,
81
,
2
,
60
,
/* 310 */
86
,
24
,
47
,
8
,
9
,
10
,
11
,
12
,
105
,
95
,
/* 320 */
84
,
85
,
86
,
87
,
8
,
9
,
10
,
11
,
12
,
121
,
/* 320 */
96
,
97
,
23
,
99
,
104
,
44
,
102
,
2
,
90
,
22
,
/* 330 */
122
,
75
,
76
,
109
,
48
,
79
,
80
,
81
,
107
,
47
,
/* 330 */
110
,
111
,
78
,
8
,
9
,
10
,
11
,
12
,
22
,
115
,
/* 340 */
84
,
85
,
86
,
87
,
75
,
76
,
106
,
44
,
79
,
80
,
/* 340 */
8
,
9
,
81
,
119
,
40
,
93
,
22
,
15
,
16
,
17
,
/* 350 */
81
,
23
,
21
,
84
,
85
,
24
,
87
,
75
,
76
,
91
,
/* 350 */
18
,
19
,
20
,
82
,
22
,
23
,
74
,
75
,
69
,
123
,
/* 360 */
22
,
79
,
80
,
81
,
79
,
22
,
84
,
85
,
86
,
87
,
/* 360 */
78
,
79
,
80
,
65
,
118
,
83
,
84
,
117
,
86
,
87
,
/* 370 */
82
,
75
,
76
,
40
,
94
,
79
,
80
,
81
,
22
,
21
,
/* 370 */
8
,
9
,
67
,
68
,
92
,
63
,
22
,
15
,
16
,
17
,
/* 380 */
84
,
85
,
24
,
87
,
75
,
76
,
124
,
83
,
79
,
80
,
/* 380 */
18
,
19
,
20
,
49
,
22
,
23
,
8
,
9
,
10
,
11
,
/* 390 */
81
,
122
,
63
,
84
,
85
,
70
,
87
,
75
,
76
,
118
,
/* 390 */
12
,
50
,
51
,
52
,
74
,
75
,
21
,
21
,
78
,
79
,
/* 400 */
65
,
79
,
80
,
81
,
22
,
118
,
84
,
85
,
23
,
87
,
/* 400 */
80
,
24
,
24
,
83
,
84
,
24
,
86
,
23
,
21
,
24
,
/* 410 */
25
,
75
,
76
,
119
,
119
,
79
,
80
,
81
,
21
,
21
,
/* 410 */
24
,
23
,
23
,
23
,
74
,
75
,
72
,
73
,
78
,
79
,
/* 420 */
84
,
85
,
49
,
87
,
75
,
76
,
21
,
24
,
79
,
80
,
/* 420 */
80
,
24
,
15
,
83
,
84
,
85
,
86
,
74
,
75
,
21
,
/* 430 */
81
,
24
,
23
,
84
,
85
,
24
,
87
,
75
,
76
,
24
,
/* 430 */
25
,
78
,
79
,
80
,
23
,
2
,
83
,
84
,
85
,
86
,
/* 440 */
23
,
79
,
80
,
81
,
23
,
23
,
84
,
85
,
24
,
87
,
/* 440 */
120
,
121
,
49
,
74
,
75
,
29
,
102
,
78
,
79
,
80
,
/* 450 */
15
,
75
,
76
,
21
,
23
,
79
,
80
,
81
,
25
,
49
,
/* 450 */
24
,
24
,
83
,
84
,
85
,
86
,
74
,
75
,
21
,
115
,
/* 460 */
84
,
85
,
2
,
87
,
75
,
76
,
29
,
24
,
79
,
80
,
/* 460 */
78
,
79
,
80
,
119
,
25
,
83
,
84
,
42
,
86
,
74
,
/* 470 */
81
,
24
,
42
,
84
,
85
,
25
,
87
,
75
,
76
,
21
,
/* 470 */
75
,
25
,
25
,
78
,
79
,
80
,
24
,
21
,
83
,
84
,
/* 480 */
25
,
79
,
80
,
81
,
25
,
24
,
84
,
85
,
21
,
87
,
/* 480 */
85
,
86
,
4
,
49
,
15
,
15
,
25
,
15
,
15
,
74
,
/* 490 */
49
,
75
,
76
,
4
,
24
,
79
,
80
,
81
,
15
,
25
,
/* 490 */
75
,
15
,
15
,
78
,
79
,
80
,
17
,
23
,
83
,
84
,
/* 500 */
84
,
85
,
15
,
87
,
75
,
76
,
15
,
15
,
79
,
80
,
/* 500 */
0
,
86
,
0
,
121
,
124
,
14
,
74
,
75
,
124
,
124
,
/* 510 */
81
,
15
,
15
,
84
,
85
,
17
,
87
,
75
,
76
,
0
,
/* 510 */
78
,
79
,
80
,
124
,
124
,
83
,
84
,
124
,
86
,
74
,
/* 520 */
0
,
79
,
80
,
81
,
23
,
14
,
84
,
85
,
125
,
87
,
/* 520 */
75
,
124
,
124
,
78
,
79
,
80
,
124
,
124
,
83
,
84
,
/* 530 */
125
,
75
,
76
,
125
,
125
,
79
,
80
,
81
,
125
,
125
,
/* 530 */
124
,
86
,
74
,
75
,
124
,
124
,
78
,
79
,
80
,
124
,
/* 540 */
84
,
85
,
125
,
87
,
75
,
76
,
125
,
125
,
79
,
80
,
/* 540 */
124
,
83
,
84
,
124
,
86
,
74
,
75
,
124
,
124
,
78
,
/* 550 */
81
,
125
,
125
,
84
,
85
,
125
,
87
,
78
,
79
,
125
,
/* 550 */
79
,
80
,
124
,
124
,
83
,
84
,
124
,
86
,
124
,
124
,
/* 560 */
125
,
125
,
78
,
79
,
125
,
125
,
87
,
125
,
125
,
125
,
/* 560 */
124
,
124
,
124
,
124
,
74
,
75
,
124
,
124
,
78
,
79
,
/* 570 */
125
,
87
,
125
,
125
,
95
,
96
,
97
,
98
,
125
,
100
,
/* 570 */
80
,
124
,
124
,
83
,
84
,
124
,
86
,
124
,
74
,
75
,
/* 580 */
96
,
97
,
98
,
125
,
100
,
125
,
125
,
78
,
79
,
125
,
/* 580 */
124
,
124
,
78
,
79
,
80
,
124
,
124
,
83
,
84
,
124
,
/* 590 */
125
,
125
,
78
,
79
,
125
,
125
,
87
,
125
,
125
,
125
,
/* 590 */
86
,
74
,
75
,
124
,
124
,
78
,
79
,
80
,
124
,
124
,
/* 600 */
125
,
87
,
125
,
73
,
74
,
96
,
97
,
98
,
125
,
100
,
/* 600 */
83
,
84
,
124
,
86
,
74
,
75
,
124
,
124
,
78
,
79
,
/* 610 */
96
,
97
,
98
,
125
,
100
,
8
,
9
,
10
,
11
,
12
,
/* 610 */
80
,
124
,
124
,
83
,
84
,
124
,
86
,
74
,
75
,
124
,
/* 620 */
8
,
9
,
10
,
11
,
12
,
125
,
125
,
125
,
125
,
22
,
/* 620 */
124
,
78
,
79
,
80
,
124
,
124
,
83
,
84
,
124
,
86
,
/* 630 */
125
,
125
,
2
,
103
,
125
,
125
,
24
,
125
,
8
,
9
,
/* 630 */
74
,
75
,
124
,
124
,
78
,
79
,
80
,
124
,
124
,
83
,
/* 640 */
10
,
11
,
12
,
125
,
125
,
125
,
116
,
125
,
41
,
125
,
/* 640 */
84
,
124
,
86
,
74
,
75
,
124
,
124
,
78
,
79
,
80
,
/* 650 */
120
,
8
,
9
,
10
,
11
,
12
,
125
,
125
,
125
,
125
,
/* 650 */
124
,
124
,
83
,
84
,
124
,
86
,
124
,
74
,
75
,
124
,
/* 660 */
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
/* 660 */
124
,
78
,
79
,
80
,
124
,
124
,
83
,
84
,
124
,
86
,
/* 670 */
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
/* 670 */
77
,
78
,
124
,
124
,
124
,
77
,
78
,
124
,
124
,
86
,
/* 680 */
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
/* 680 */
124
,
124
,
77
,
78
,
86
,
124
,
124
,
94
,
95
,
96
,
/* 690 */
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
/* 690 */
97
,
86
,
99
,
95
,
96
,
97
,
124
,
99
,
124
,
124
,
/* 700 */
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
/* 700 */
95
,
96
,
97
,
124
,
99
,
/* 710 */
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
125
,
/* 720 */
125
,
125
,
125
,
125
,
125
,
};
};
#define YY_SHIFT_COUNT (14
8
)
#define YY_SHIFT_COUNT (14
2
)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (
643
)
#define YY_SHIFT_MAX (
502
)
static
const
unsigned
short
int
yy_shift_ofst
[]
=
{
static
const
unsigned
short
int
yy_shift_ofst
[]
=
{
/* 0 */
110
,
64
,
64
,
64
,
64
,
64
,
64
,
142
,
215
,
239
,
/* 0 */
16
,
80
,
188
,
188
,
188
,
204
,
188
,
188
,
269
,
104
,
/* 10 */
239
,
239
,
239
,
239
,
239
,
239
,
239
,
239
,
239
,
239
,
/* 10 */
332
,
362
,
362
,
362
,
362
,
362
,
362
,
362
,
362
,
362
,
/* 20 */
239
,
239
,
239
,
239
,
239
,
239
,
239
,
239
,
239
,
239
,
/* 20 */
362
,
362
,
362
,
362
,
362
,
362
,
362
,
362
,
362
,
362
,
/* 30 */
227
,
227
,
227
,
227
,
79
,
36
,
79
,
79
,
7
,
7
,
/* 30 */
362
,
26
,
26
,
26
,
36
,
62
,
62
,
63
,
0
,
32
,
/* 40 */
0
,
32
,
36
,
63
,
63
,
63
,
607
,
232
,
19
,
146
,
/* 40 */
36
,
65
,
65
,
65
,
249
,
305
,
75
,
341
,
99
,
149
,
/* 50 */
52
,
168
,
167
,
167
,
11
,
182
,
192
,
246
,
246
,
182
,
/* 50 */
234
,
76
,
155
,
163
,
205
,
205
,
155
,
163
,
205
,
209
,
/* 60 */
192
,
246
,
244
,
259
,
286
,
292
,
303
,
328
,
303
,
338
,
/* 60 */
214
,
245
,
265
,
281
,
299
,
281
,
307
,
316
,
281
,
304
,
/* 70 */
3
43
,
303
,
333
,
356
,
325
,
329
,
335
,
335
,
329
,
382
,
/* 70 */
3
24
,
289
,
298
,
312
,
354
,
173
,
325
,
378
,
146
,
146
,
/* 80 */
316
,
630
,
612
,
643
,
643
,
643
,
643
,
643
,
289
,
130
,
/* 80 */
146
,
146
,
146
,
178
,
207
,
35
,
35
,
35
,
35
,
208
,
/* 90 */
35
,
35
,
35
,
35
,
191
,
250
,
173
,
331
,
251
,
132
,
/* 90 */
230
,
190
,
241
,
278
,
185
,
73
,
165
,
287
,
151
,
375
,
/* 100 */
117
,
230
,
358
,
385
,
397
,
398
,
373
,
403
,
407
,
409
,
/* 100 */
376
,
334
,
377
,
381
,
384
,
387
,
385
,
388
,
389
,
386
,
/* 110 */
405
,
411
,
417
,
421
,
415
,
422
,
424
,
435
,
432
,
433
,
/* 110 */
390
,
397
,
407
,
408
,
405
,
411
,
376
,
393
,
433
,
416
,
/* 120 */
4
31
,
398
,
410
,
460
,
437
,
443
,
447
,
450
,
430
,
458
,
/* 120 */
4
26
,
427
,
439
,
425
,
437
,
446
,
447
,
452
,
456
,
434
,
/* 130 */
4
55
,
459
,
461
,
467
,
441
,
470
,
489
,
483
,
487
,
491
,
/* 130 */
4
78
,
469
,
470
,
472
,
473
,
476
,
477
,
461
,
474
,
479
,
/* 140 */
492
,
496
,
497
,
474
,
501
,
498
,
519
,
520
,
51
1
,
/* 140 */
500
,
502
,
49
1
,
};
};
#define YY_REDUCE_COUNT (7
9
)
#define YY_REDUCE_COUNT (7
4
)
#define YY_REDUCE_MIN (-102)
#define YY_REDUCE_MIN (-102)
#define YY_REDUCE_MAX (
530
)
#define YY_REDUCE_MAX (
605
)
static
const
short
yy_reduce_ofst
[]
=
{
static
const
short
yy_reduce_ofst
[]
=
{
/* 0 */
530
,
13
,
33
,
61
,
92
,
107
,
126
,
141
,
188
,
208
,
/* 0 */
344
,
-
1
,
37
,
61
,
86
,
115
,
161
,
189
,
220
,
224
,
/* 10 */
-
62
,
223
,
236
,
256
,
269
,
282
,
296
,
309
,
322
,
336
,
/* 10 */
282
,
320
,
-
61
,
340
,
353
,
369
,
382
,
395
,
415
,
432
,
/* 20 */
349
,
362
,
376
,
389
,
402
,
416
,
429
,
442
,
456
,
4
69
,
/* 20 */
445
,
458
,
471
,
490
,
504
,
517
,
530
,
543
,
556
,
5
69
,
/* 30 */
479
,
484
,
509
,
514
,
-
13
,
-
75
,
-
100
,
27
,
31
,
49
,
/* 30 */
583
,
593
,
598
,
605
,
-
74
,
-
63
,
-
3
,
-
10
,
-
85
,
-
85
,
/* 40 */
-
85
,
-
85
,
-
69
,
40
,
45
,
178
,
-
34
,
-
102
,
-
16
,
24
,
/* 40 */
-
69
,
12
,
69
,
70
,
-
75
,
-
102
,
-
57
,
6
,
19
,
67
,
/* 50 */
18
,
109
,
76
,
91
,
123
,
125
,
152
,
194
,
203
,
171
,
/* 50 */
47
,
97
,
101
,
106
,
153
,
167
,
125
,
138
,
191
,
174
,
/* 60 */
184
,
210
,
204
,
224
,
231
,
240
,
18
,
268
,
18
,
285
,
/* 60 */
201
,
176
,
213
,
19
,
238
,
19
,
254
,
261
,
19
,
252
,
/* 70 */
2
88
,
18
,
280
,
304
,
262
,
281
,
294
,
295
,
287
,
109
,
/* 70 */
2
71
,
236
,
246
,
250
,
67
,
};
};
static
const
YYACTIONTYPE
yy_default
[]
=
{
static
const
YYACTIONTYPE
yy_default
[]
=
{
/* 0 */
3
80
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
/* 0 */
3
72
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
/* 10 */
3
80
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
/* 10 */
3
72
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
/* 20 */
3
80
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
/* 20 */
3
72
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
/* 30 */
3
80
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
/* 30 */
3
72
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
/* 40 */
3
80
,
380
,
380
,
449
,
449
,
449
,
464
,
511
,
380
,
4
72
,
/* 40 */
3
72
,
442
,
442
,
442
,
457
,
503
,
372
,
465
,
372
,
3
72
,
/* 50 */
380
,
380
,
496
,
496
,
457
,
479
,
477
,
380
,
380
,
479
,
/* 50 */
488
,
450
,
472
,
470
,
372
,
372
,
472
,
470
,
372
,
482
,
/* 60 */
4
77
,
380
,
489
,
487
,
470
,
468
,
442
,
380
,
380
,
380
,
/* 60 */
4
80
,
463
,
461
,
434
,
372
,
372
,
372
,
372
,
435
,
372
,
/* 70 */
3
80
,
443
,
380
,
380
,
514
,
498
,
502
,
502
,
498
,
380
,
/* 70 */
3
72
,
506
,
494
,
490
,
372
,
372
,
372
,
372
,
410
,
409
,
/* 80 */
380
,
380
,
380
,
418
,
417
,
416
,
412
,
413
,
380
,
380
,
/* 80 */
408
,
404
,
405
,
372
,
372
,
399
,
400
,
398
,
397
,
372
,
/* 90 */
407
,
408
,
406
,
405
,
380
,
380
,
507
,
380
,
380
,
380
,
/* 90 */
372
,
499
,
372
,
372
,
372
,
491
,
495
,
372
,
388
,
454
,
/* 100 */
4
99
,
503
,
380
,
396
,
461
,
471
,
380
,
380
,
380
,
380
,
/* 100 */
4
64
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
/* 110 */
3
80
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
396
,
/* 110 */
3
72
,
372
,
372
,
372
,
388
,
372
,
481
,
372
,
429
,
372
,
/* 120 */
380
,
488
,
380
,
437
,
380
,
517
,
445
,
380
,
380
,
441
,
/* 120 */
441
,
437
,
372
,
372
,
433
,
387
,
372
,
372
,
489
,
372
,
/* 130 */
3
95
,
380
,
380
,
497
,
380
,
380
,
380
,
380
,
380
,
380
,
/* 130 */
3
72
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
372
,
/* 140 */
3
80
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
380
,
/* 140 */
3
72
,
372
,
372
,
};
};
/********** End of lemon-generated parsing tables *****************************/
/********** End of lemon-generated parsing tables *****************************/
...
@@ -581,64 +584,63 @@ static const char *const yyTokenName[] = {
...
@@ -581,64 +584,63 @@ static const char *const yyTokenName[] = {
/* 64 */
"SOFFSET"
,
/* 64 */
"SOFFSET"
,
/* 65 */
"LIMIT"
,
/* 65 */
"LIMIT"
,
/* 66 */
"OFFSET"
,
/* 66 */
"OFFSET"
,
/* 67 */
"NK_LR"
,
/* 67 */
"ASC"
,
/* 68 */
"ASC"
,
/* 68 */
"DESC"
,
/* 69 */
"DESC"
,
/* 69 */
"NULLS"
,
/* 70 */
"NULLS"
,
/* 70 */
"FIRST"
,
/* 71 */
"FIRST"
,
/* 71 */
"LAST"
,
/* 72 */
"LAST"
,
/* 72 */
"cmd"
,
/* 73 */
"cmd"
,
/* 73 */
"query_expression"
,
/* 74 */
"query_expression"
,
/* 74 */
"literal"
,
/* 75 */
"literal"
,
/* 75 */
"duration_literal"
,
/* 76 */
"duration_literal"
,
/* 76 */
"literal_list"
,
/* 77 */
"literal_list"
,
/* 77 */
"db_name"
,
/* 78 */
"db_name"
,
/* 78 */
"table_name"
,
/* 79 */
"table_name"
,
/* 79 */
"column_name"
,
/* 80 */
"column_name"
,
/* 80 */
"function_name"
,
/* 81 */
"function_name"
,
/* 81 */
"table_alias"
,
/* 82 */
"table_alias"
,
/* 82 */
"column_alias"
,
/* 83 */
"column_alias"
,
/* 83 */
"expression"
,
/* 84 */
"expression"
,
/* 84 */
"column_reference"
,
/* 85 */
"column_reference"
,
/* 85 */
"expression_list"
,
/* 86 */
"expression_list"
,
/* 86 */
"subquery"
,
/* 87 */
"subquery"
,
/* 87 */
"predicate"
,
/* 88 */
"predicate"
,
/* 88 */
"compare_op"
,
/* 89 */
"compare_op"
,
/* 89 */
"in_op"
,
/* 90 */
"in_op"
,
/* 90 */
"in_predicate_value"
,
/* 91 */
"in_predicate_value"
,
/* 91 */
"boolean_value_expression"
,
/* 92 */
"boolean_value_expression"
,
/* 92 */
"boolean_primary"
,
/* 93 */
"boolean_primary"
,
/* 93 */
"from_clause"
,
/* 94 */
"from_clause"
,
/* 94 */
"table_reference_list"
,
/* 95 */
"table_reference_list"
,
/* 95 */
"table_reference"
,
/* 96 */
"table_reference"
,
/* 96 */
"table_primary"
,
/* 97 */
"table_primary"
,
/* 97 */
"joined_table"
,
/* 98 */
"joined_table"
,
/* 98 */
"alias_opt"
,
/* 99 */
"alias_opt"
,
/* 99 */
"parenthesized_joined_table"
,
/* 100 */
"parenthesized_joined_table"
,
/* 100 */
"join_type"
,
/* 101 */
"join_type"
,
/* 101 */
"search_condition"
,
/* 102 */
"search_condition"
,
/* 102 */
"query_specification"
,
/* 103 */
"query_specification"
,
/* 103 */
"set_quantifier_opt"
,
/* 104 */
"set_quantifier_opt"
,
/* 104 */
"select_list"
,
/* 105 */
"select_list"
,
/* 105 */
"where_clause_opt"
,
/* 106 */
"where_clause_opt"
,
/* 106 */
"partition_by_clause_opt"
,
/* 107 */
"partition_by_clause_opt"
,
/* 107 */
"twindow_clause_opt"
,
/* 108 */
"twindow_clause_opt"
,
/* 108 */
"group_by_clause_opt"
,
/* 109 */
"group_by_clause_opt"
,
/* 109 */
"having_clause_opt"
,
/* 110 */
"having_clause_opt"
,
/* 110 */
"select_sublist"
,
/* 111 */
"select_sublist"
,
/* 111 */
"select_item"
,
/* 112 */
"select_item"
,
/* 112 */
"sliding_opt"
,
/* 113 */
"sliding_opt"
,
/* 113 */
"fill_opt"
,
/* 114 */
"fill_opt"
,
/* 114 */
"fill_mode"
,
/* 115 */
"fill_mode"
,
/* 115 */
"query_expression_body"
,
/* 116 */
"query_expression_body"
,
/* 116 */
"order_by_clause_opt"
,
/* 117 */
"order_by_clause_opt"
,
/* 117 */
"slimit_clause_opt"
,
/* 118 */
"slimit_clause_opt"
,
/* 118 */
"limit_clause_opt"
,
/* 119 */
"limit_clause_opt"
,
/* 119 */
"query_primary"
,
/* 120 */
"query_primary"
,
/* 120 */
"sort_specification_list"
,
/* 121 */
"sort_specification_list"
,
/* 121 */
"sort_specification"
,
/* 122 */
"sort_specification"
,
/* 122 */
"ordering_specification_opt"
,
/* 123 */
"ordering_specification_opt"
,
/* 123 */
"null_ordering_opt"
,
/* 124 */
"null_ordering_opt"
,
};
};
#endif
/* defined(YYCOVERAGE) || !defined(NDEBUG) */
#endif
/* defined(YYCOVERAGE) || !defined(NDEBUG) */
...
@@ -712,53 +714,53 @@ static const char *const yyRuleName[] = {
...
@@ -712,53 +714,53 @@ static const char *const yyRuleName[] = {
/* 63 */
"table_primary ::= table_name alias_opt"
,
/* 63 */
"table_primary ::= table_name alias_opt"
,
/* 64 */
"table_primary ::= db_name NK_DOT table_name alias_opt"
,
/* 64 */
"table_primary ::= db_name NK_DOT table_name alias_opt"
,
/* 65 */
"table_primary ::= subquery alias_opt"
,
/* 65 */
"table_primary ::= subquery alias_opt"
,
/* 66 */
"
alias_opt ::=
"
,
/* 66 */
"
table_primary ::= parenthesized_joined_table
"
,
/* 67 */
"alias_opt ::=
table_alias
"
,
/* 67 */
"alias_opt ::="
,
/* 68 */
"alias_opt ::=
AS
table_alias"
,
/* 68 */
"alias_opt ::= table_alias"
,
/* 69 */
"
parenthesized_joined_table ::= NK_LP joined_table NK_RP
"
,
/* 69 */
"
alias_opt ::= AS table_alias
"
,
/* 70 */
"parenthesized_joined_table ::= NK_LP
parenthesized_
joined_table NK_RP"
,
/* 70 */
"parenthesized_joined_table ::= NK_LP joined_table NK_RP"
,
/* 71 */
"
joined_table ::= table_reference join_type JOIN table_reference ON search_condition
"
,
/* 71 */
"
parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP
"
,
/* 72 */
"join
_type ::= INNER
"
,
/* 72 */
"join
ed_table ::= table_reference join_type JOIN table_reference ON search_condition
"
,
/* 73 */
"
query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt
"
,
/* 73 */
"
join_type ::= INNER
"
,
/* 74 */
"
set_quantifier_opt ::=
"
,
/* 74 */
"
query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt
"
,
/* 75 */
"set_quantifier_opt ::=
DISTINCT
"
,
/* 75 */
"set_quantifier_opt ::="
,
/* 76 */
"set_quantifier_opt ::=
ALL
"
,
/* 76 */
"set_quantifier_opt ::=
DISTINCT
"
,
/* 77 */
"se
lect_list ::= NK_STAR
"
,
/* 77 */
"se
t_quantifier_opt ::= ALL
"
,
/* 78 */
"select_list ::=
select_sublist
"
,
/* 78 */
"select_list ::=
NK_STAR
"
,
/* 79 */
"select_
sublist ::= select_item
"
,
/* 79 */
"select_
list ::= select_sublist
"
,
/* 80 */
"select_sublist ::= select_
sublist NK_COMMA select_
item"
,
/* 80 */
"select_sublist ::= select_item"
,
/* 81 */
"select_
item ::= expression
"
,
/* 81 */
"select_
sublist ::= select_sublist NK_COMMA select_item
"
,
/* 82 */
"select_item ::= expression
column_alias
"
,
/* 82 */
"select_item ::= expression"
,
/* 83 */
"select_item ::= expression
AS
column_alias"
,
/* 83 */
"select_item ::= expression column_alias"
,
/* 84 */
"select_item ::=
table_name NK_DOT NK_STAR
"
,
/* 84 */
"select_item ::=
expression AS column_alias
"
,
/* 85 */
"
where_clause_opt ::=
"
,
/* 85 */
"
select_item ::= table_name NK_DOT NK_STAR
"
,
/* 86 */
"where_clause_opt ::=
WHERE search_condition
"
,
/* 86 */
"where_clause_opt ::="
,
/* 87 */
"
partition_by_clause_opt ::=
"
,
/* 87 */
"
where_clause_opt ::= WHERE search_condition
"
,
/* 88 */
"partition_by_clause_opt ::=
PARTITION BY expression_list
"
,
/* 88 */
"partition_by_clause_opt ::="
,
/* 89 */
"
twindow_clause_opt ::=
"
,
/* 89 */
"
partition_by_clause_opt ::= PARTITION BY expression_list
"
,
/* 90 */
"twindow_clause_opt ::=
SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP
"
,
/* 90 */
"twindow_clause_opt ::="
,
/* 91 */
"twindow_clause_opt ::= S
TATE_WINDOW NK_LP column_reference
NK_RP"
,
/* 91 */
"twindow_clause_opt ::= S
ESSION NK_LP column_reference NK_COMMA NK_INTEGER
NK_RP"
,
/* 92 */
"twindow_clause_opt ::=
INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt
"
,
/* 92 */
"twindow_clause_opt ::=
STATE_WINDOW NK_LP column_reference NK_RP
"
,
/* 93 */
"twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_
COMMA duration_literal NK_
RP sliding_opt fill_opt"
,
/* 93 */
"twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt"
,
/* 94 */
"
sliding_opt ::=
"
,
/* 94 */
"
twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt
"
,
/* 95 */
"sliding_opt ::=
SLIDING NK_LP duration_literal NK_RP
"
,
/* 95 */
"sliding_opt ::="
,
/* 96 */
"
fill_opt ::=
"
,
/* 96 */
"
sliding_opt ::= SLIDING NK_LP duration_literal NK_RP
"
,
/* 97 */
"fill_opt ::=
FILL NK_LP fill_mode NK_RP
"
,
/* 97 */
"fill_opt ::="
,
/* 98 */
"fill_opt ::= FILL NK_LP
VALUE NK_COMMA literal_list
NK_RP"
,
/* 98 */
"fill_opt ::= FILL NK_LP
fill_mode
NK_RP"
,
/* 99 */
"fill_
mode ::= NONE
"
,
/* 99 */
"fill_
opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP
"
,
/* 100 */
"fill_mode ::=
PREV
"
,
/* 100 */
"fill_mode ::=
NONE
"
,
/* 101 */
"fill_mode ::=
NULL
"
,
/* 101 */
"fill_mode ::=
PREV
"
,
/* 102 */
"fill_mode ::=
LINEAR
"
,
/* 102 */
"fill_mode ::=
NULL
"
,
/* 103 */
"fill_mode ::=
NEXT
"
,
/* 103 */
"fill_mode ::=
LINEAR
"
,
/* 104 */
"
group_by_clause_opt ::=
"
,
/* 104 */
"
fill_mode ::= NEXT
"
,
/* 105 */
"group_by_clause_opt ::=
GROUP BY expression_list
"
,
/* 105 */
"group_by_clause_opt ::="
,
/* 106 */
"
having_clause_opt ::=
"
,
/* 106 */
"
group_by_clause_opt ::= GROUP BY expression_list
"
,
/* 107 */
"having_clause_opt ::=
HAVING search_condition
"
,
/* 107 */
"having_clause_opt ::="
,
/* 108 */
"
query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt
"
,
/* 108 */
"
having_clause_opt ::= HAVING search_condition
"
,
/* 109 */
"query_expression
_body ::= query_primary
"
,
/* 109 */
"query_expression
::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt
"
,
/* 110 */
"query_expression_body ::= query_
expression_body UNION ALL query_expression_bod
y"
,
/* 110 */
"query_expression_body ::= query_
primar
y"
,
/* 111 */
"query_
primary ::= query_specification
"
,
/* 111 */
"query_
expression_body ::= query_expression_body UNION ALL query_expression_body
"
,
/* 112 */
"query_primary ::=
NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP
"
,
/* 112 */
"query_primary ::=
query_specification
"
,
/* 113 */
"order_by_clause_opt ::="
,
/* 113 */
"order_by_clause_opt ::="
,
/* 114 */
"order_by_clause_opt ::= ORDER BY sort_specification_list"
,
/* 114 */
"order_by_clause_opt ::= ORDER BY sort_specification_list"
,
/* 115 */
"slimit_clause_opt ::="
,
/* 115 */
"slimit_clause_opt ::="
,
...
@@ -769,7 +771,7 @@ static const char *const yyRuleName[] = {
...
@@ -769,7 +771,7 @@ static const char *const yyRuleName[] = {
/* 120 */
"limit_clause_opt ::= LIMIT NK_INTEGER"
,
/* 120 */
"limit_clause_opt ::= LIMIT NK_INTEGER"
,
/* 121 */
"limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER"
,
/* 121 */
"limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER"
,
/* 122 */
"limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER"
,
/* 122 */
"limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER"
,
/* 123 */
"subquery ::= NK_L
R
query_expression NK_RP"
,
/* 123 */
"subquery ::= NK_L
P
query_expression NK_RP"
,
/* 124 */
"search_condition ::= boolean_value_expression"
,
/* 124 */
"search_condition ::= boolean_value_expression"
,
/* 125 */
"sort_specification_list ::= sort_specification"
,
/* 125 */
"sort_specification_list ::= sort_specification"
,
/* 126 */
"sort_specification_list ::= sort_specification_list NK_COMMA sort_specification"
,
/* 126 */
"sort_specification_list ::= sort_specification_list NK_COMMA sort_specification"
,
...
@@ -780,7 +782,6 @@ static const char *const yyRuleName[] = {
...
@@ -780,7 +782,6 @@ static const char *const yyRuleName[] = {
/* 131 */
"null_ordering_opt ::="
,
/* 131 */
"null_ordering_opt ::="
,
/* 132 */
"null_ordering_opt ::= NULLS FIRST"
,
/* 132 */
"null_ordering_opt ::= NULLS FIRST"
,
/* 133 */
"null_ordering_opt ::= NULLS LAST"
,
/* 133 */
"null_ordering_opt ::= NULLS LAST"
,
/* 134 */
"table_primary ::= parenthesized_joined_table"
,
};
};
#endif
/* NDEBUG */
#endif
/* NDEBUG */
...
@@ -907,90 +908,90 @@ static void yy_destructor(
...
@@ -907,90 +908,90 @@ static void yy_destructor(
*/
*/
/********* Begin destructor definitions ***************************************/
/********* Begin destructor definitions ***************************************/
/* Default NON-TERMINAL Destructor */
/* Default NON-TERMINAL Destructor */
case
7
3
:
/* cmd */
case
7
2
:
/* cmd */
case
7
4
:
/* query_expression */
case
7
3
:
/* query_expression */
case
7
5
:
/* literal */
case
7
4
:
/* literal */
case
7
6
:
/* duration_literal */
case
7
5
:
/* duration_literal */
case
8
4
:
/* expression */
case
8
3
:
/* expression */
case
8
5
:
/* column_reference */
case
8
4
:
/* column_reference */
case
8
7
:
/* subquery */
case
8
6
:
/* subquery */
case
8
8
:
/* predicate */
case
8
7
:
/* predicate */
case
9
1
:
/* in_predicate_value */
case
9
0
:
/* in_predicate_value */
case
9
2
:
/* boolean_value_expression */
case
9
1
:
/* boolean_value_expression */
case
9
3
:
/* boolean_primary */
case
9
2
:
/* boolean_primary */
case
9
4
:
/* from_clause */
case
9
3
:
/* from_clause */
case
9
5
:
/* table_reference_list */
case
9
4
:
/* table_reference_list */
case
9
6
:
/* table_reference */
case
9
5
:
/* table_reference */
case
9
7
:
/* table_primary */
case
9
6
:
/* table_primary */
case
9
8
:
/* joined_table */
case
9
7
:
/* joined_table */
case
100
:
/* parenthesized_joined_table */
case
99
:
/* parenthesized_joined_table */
case
10
2
:
/* search_condition */
case
10
1
:
/* search_condition */
case
10
3
:
/* query_specification */
case
10
2
:
/* query_specification */
case
10
6
:
/* where_clause_opt */
case
10
5
:
/* where_clause_opt */
case
10
8
:
/* twindow_clause_opt */
case
10
7
:
/* twindow_clause_opt */
case
1
10
:
/* having_clause_opt */
case
1
09
:
/* having_clause_opt */
case
11
2
:
/* select_item */
case
11
1
:
/* select_item */
case
11
3
:
/* sliding_opt */
case
11
2
:
/* sliding_opt */
case
11
4
:
/* fill_opt */
case
11
3
:
/* fill_opt */
case
11
6
:
/* query_expression_body */
case
11
5
:
/* query_expression_body */
case
11
8
:
/* slimit_clause_opt */
case
11
7
:
/* slimit_clause_opt */
case
11
9
:
/* limit_clause_opt */
case
11
8
:
/* limit_clause_opt */
case
1
20
:
/* query_primary */
case
1
19
:
/* query_primary */
case
12
2
:
/* sort_specification */
case
12
1
:
/* sort_specification */
{
{
PARSER_DESTRUCTOR_TRACE
;
nodesDestroyNode
((
yypminor
->
yy
212
));
PARSER_DESTRUCTOR_TRACE
;
nodesDestroyNode
((
yypminor
->
yy
168
));
}
}
break
;
break
;
case
7
7
:
/* literal_list */
case
7
6
:
/* literal_list */
case
8
6
:
/* expression_list */
case
8
5
:
/* expression_list */
case
10
5
:
/* select_list */
case
10
4
:
/* select_list */
case
10
7
:
/* partition_by_clause_opt */
case
10
6
:
/* partition_by_clause_opt */
case
10
9
:
/* group_by_clause_opt */
case
10
8
:
/* group_by_clause_opt */
case
11
1
:
/* select_sublist */
case
11
0
:
/* select_sublist */
case
11
7
:
/* order_by_clause_opt */
case
11
6
:
/* order_by_clause_opt */
case
12
1
:
/* sort_specification_list */
case
12
0
:
/* sort_specification_list */
{
{
PARSER_DESTRUCTOR_TRACE
;
nodesDestroyList
((
yypminor
->
yy1
74
));
PARSER_DESTRUCTOR_TRACE
;
nodesDestroyList
((
yypminor
->
yy1
92
));
}
}
break
;
break
;
case
7
8
:
/* db_name */
case
7
7
:
/* db_name */
case
7
9
:
/* table_name */
case
7
8
:
/* table_name */
case
80
:
/* column_name */
case
79
:
/* column_name */
case
8
1
:
/* function_name */
case
8
0
:
/* function_name */
case
8
2
:
/* table_alias */
case
8
1
:
/* table_alias */
case
8
3
:
/* column_alias */
case
8
2
:
/* column_alias */
case
9
9
:
/* alias_opt */
case
9
8
:
/* alias_opt */
{
{
PARSER_DESTRUCTOR_TRACE
;
PARSER_DESTRUCTOR_TRACE
;
}
}
break
;
break
;
case
8
9
:
/* compare_op */
case
8
8
:
/* compare_op */
case
90
:
/* in_op */
case
89
:
/* in_op */
{
{
PARSER_DESTRUCTOR_TRACE
;
PARSER_DESTRUCTOR_TRACE
;
}
}
break
;
break
;
case
10
1
:
/* join_type */
case
10
0
:
/* join_type */
{
{
PARSER_DESTRUCTOR_TRACE
;
PARSER_DESTRUCTOR_TRACE
;
}
}
break
;
break
;
case
10
4
:
/* set_quantifier_opt */
case
10
3
:
/* set_quantifier_opt */
{
{
PARSER_DESTRUCTOR_TRACE
;
PARSER_DESTRUCTOR_TRACE
;
}
}
break
;
break
;
case
11
5
:
/* fill_mode */
case
11
4
:
/* fill_mode */
{
{
PARSER_DESTRUCTOR_TRACE
;
PARSER_DESTRUCTOR_TRACE
;
}
}
break
;
break
;
case
12
3
:
/* ordering_specification_opt */
case
12
2
:
/* ordering_specification_opt */
{
{
PARSER_DESTRUCTOR_TRACE
;
PARSER_DESTRUCTOR_TRACE
;
}
}
break
;
break
;
case
12
4
:
/* null_ordering_opt */
case
12
3
:
/* null_ordering_opt */
{
{
PARSER_DESTRUCTOR_TRACE
;
PARSER_DESTRUCTOR_TRACE
;
}
}
...
@@ -1289,141 +1290,140 @@ static const struct {
...
@@ -1289,141 +1290,140 @@ static const struct {
YYCODETYPE
lhs
;
/* Symbol on the left-hand side of the rule */
YYCODETYPE
lhs
;
/* Symbol on the left-hand side of the rule */
signed
char
nrhs
;
/* Negative of the number of RHS symbols in the rule */
signed
char
nrhs
;
/* Negative of the number of RHS symbols in the rule */
}
yyRuleInfo
[]
=
{
}
yyRuleInfo
[]
=
{
{
73
,
-
2
},
/* (0) cmd ::= SHOW DATABASES */
{
72
,
-
2
},
/* (0) cmd ::= SHOW DATABASES */
{
73
,
-
1
},
/* (1) cmd ::= query_expression */
{
72
,
-
1
},
/* (1) cmd ::= query_expression */
{
75
,
-
1
},
/* (2) literal ::= NK_INTEGER */
{
74
,
-
1
},
/* (2) literal ::= NK_INTEGER */
{
75
,
-
1
},
/* (3) literal ::= NK_FLOAT */
{
74
,
-
1
},
/* (3) literal ::= NK_FLOAT */
{
75
,
-
1
},
/* (4) literal ::= NK_STRING */
{
74
,
-
1
},
/* (4) literal ::= NK_STRING */
{
75
,
-
1
},
/* (5) literal ::= NK_BOOL */
{
74
,
-
1
},
/* (5) literal ::= NK_BOOL */
{
75
,
-
2
},
/* (6) literal ::= TIMESTAMP NK_STRING */
{
74
,
-
2
},
/* (6) literal ::= TIMESTAMP NK_STRING */
{
75
,
-
1
},
/* (7) literal ::= duration_literal */
{
74
,
-
1
},
/* (7) literal ::= duration_literal */
{
76
,
-
1
},
/* (8) duration_literal ::= NK_VARIABLE */
{
75
,
-
1
},
/* (8) duration_literal ::= NK_VARIABLE */
{
77
,
-
1
},
/* (9) literal_list ::= literal */
{
76
,
-
1
},
/* (9) literal_list ::= literal */
{
77
,
-
3
},
/* (10) literal_list ::= literal_list NK_COMMA literal */
{
76
,
-
3
},
/* (10) literal_list ::= literal_list NK_COMMA literal */
{
78
,
-
1
},
/* (11) db_name ::= NK_ID */
{
77
,
-
1
},
/* (11) db_name ::= NK_ID */
{
79
,
-
1
},
/* (12) table_name ::= NK_ID */
{
78
,
-
1
},
/* (12) table_name ::= NK_ID */
{
80
,
-
1
},
/* (13) column_name ::= NK_ID */
{
79
,
-
1
},
/* (13) column_name ::= NK_ID */
{
81
,
-
1
},
/* (14) function_name ::= NK_ID */
{
80
,
-
1
},
/* (14) function_name ::= NK_ID */
{
82
,
-
1
},
/* (15) table_alias ::= NK_ID */
{
81
,
-
1
},
/* (15) table_alias ::= NK_ID */
{
83
,
-
1
},
/* (16) column_alias ::= NK_ID */
{
82
,
-
1
},
/* (16) column_alias ::= NK_ID */
{
84
,
-
1
},
/* (17) expression ::= literal */
{
83
,
-
1
},
/* (17) expression ::= literal */
{
84
,
-
1
},
/* (18) expression ::= column_reference */
{
83
,
-
1
},
/* (18) expression ::= column_reference */
{
84
,
-
4
},
/* (19) expression ::= function_name NK_LP expression_list NK_RP */
{
83
,
-
4
},
/* (19) expression ::= function_name NK_LP expression_list NK_RP */
{
84
,
-
1
},
/* (20) expression ::= subquery */
{
83
,
-
1
},
/* (20) expression ::= subquery */
{
84
,
-
3
},
/* (21) expression ::= NK_LP expression NK_RP */
{
83
,
-
3
},
/* (21) expression ::= NK_LP expression NK_RP */
{
84
,
-
2
},
/* (22) expression ::= NK_PLUS expression */
{
83
,
-
2
},
/* (22) expression ::= NK_PLUS expression */
{
84
,
-
2
},
/* (23) expression ::= NK_MINUS expression */
{
83
,
-
2
},
/* (23) expression ::= NK_MINUS expression */
{
84
,
-
3
},
/* (24) expression ::= expression NK_PLUS expression */
{
83
,
-
3
},
/* (24) expression ::= expression NK_PLUS expression */
{
84
,
-
3
},
/* (25) expression ::= expression NK_MINUS expression */
{
83
,
-
3
},
/* (25) expression ::= expression NK_MINUS expression */
{
84
,
-
3
},
/* (26) expression ::= expression NK_STAR expression */
{
83
,
-
3
},
/* (26) expression ::= expression NK_STAR expression */
{
84
,
-
3
},
/* (27) expression ::= expression NK_SLASH expression */
{
83
,
-
3
},
/* (27) expression ::= expression NK_SLASH expression */
{
84
,
-
3
},
/* (28) expression ::= expression NK_REM expression */
{
83
,
-
3
},
/* (28) expression ::= expression NK_REM expression */
{
86
,
-
1
},
/* (29) expression_list ::= expression */
{
85
,
-
1
},
/* (29) expression_list ::= expression */
{
86
,
-
3
},
/* (30) expression_list ::= expression_list NK_COMMA expression */
{
85
,
-
3
},
/* (30) expression_list ::= expression_list NK_COMMA expression */
{
85
,
-
1
},
/* (31) column_reference ::= column_name */
{
84
,
-
1
},
/* (31) column_reference ::= column_name */
{
85
,
-
3
},
/* (32) column_reference ::= table_name NK_DOT column_name */
{
84
,
-
3
},
/* (32) column_reference ::= table_name NK_DOT column_name */
{
88
,
-
3
},
/* (33) predicate ::= expression compare_op expression */
{
87
,
-
3
},
/* (33) predicate ::= expression compare_op expression */
{
88
,
-
5
},
/* (34) predicate ::= expression BETWEEN expression AND expression */
{
87
,
-
5
},
/* (34) predicate ::= expression BETWEEN expression AND expression */
{
88
,
-
6
},
/* (35) predicate ::= expression NOT BETWEEN expression AND expression */
{
87
,
-
6
},
/* (35) predicate ::= expression NOT BETWEEN expression AND expression */
{
88
,
-
3
},
/* (36) predicate ::= expression IS NULL */
{
87
,
-
3
},
/* (36) predicate ::= expression IS NULL */
{
88
,
-
4
},
/* (37) predicate ::= expression IS NOT NULL */
{
87
,
-
4
},
/* (37) predicate ::= expression IS NOT NULL */
{
88
,
-
3
},
/* (38) predicate ::= expression in_op in_predicate_value */
{
87
,
-
3
},
/* (38) predicate ::= expression in_op in_predicate_value */
{
89
,
-
1
},
/* (39) compare_op ::= NK_LT */
{
88
,
-
1
},
/* (39) compare_op ::= NK_LT */
{
89
,
-
1
},
/* (40) compare_op ::= NK_GT */
{
88
,
-
1
},
/* (40) compare_op ::= NK_GT */
{
89
,
-
1
},
/* (41) compare_op ::= NK_LE */
{
88
,
-
1
},
/* (41) compare_op ::= NK_LE */
{
89
,
-
1
},
/* (42) compare_op ::= NK_GE */
{
88
,
-
1
},
/* (42) compare_op ::= NK_GE */
{
89
,
-
1
},
/* (43) compare_op ::= NK_NE */
{
88
,
-
1
},
/* (43) compare_op ::= NK_NE */
{
89
,
-
1
},
/* (44) compare_op ::= NK_EQ */
{
88
,
-
1
},
/* (44) compare_op ::= NK_EQ */
{
89
,
-
1
},
/* (45) compare_op ::= LIKE */
{
88
,
-
1
},
/* (45) compare_op ::= LIKE */
{
89
,
-
2
},
/* (46) compare_op ::= NOT LIKE */
{
88
,
-
2
},
/* (46) compare_op ::= NOT LIKE */
{
89
,
-
1
},
/* (47) compare_op ::= MATCH */
{
88
,
-
1
},
/* (47) compare_op ::= MATCH */
{
89
,
-
1
},
/* (48) compare_op ::= NMATCH */
{
88
,
-
1
},
/* (48) compare_op ::= NMATCH */
{
90
,
-
1
},
/* (49) in_op ::= IN */
{
89
,
-
1
},
/* (49) in_op ::= IN */
{
90
,
-
2
},
/* (50) in_op ::= NOT IN */
{
89
,
-
2
},
/* (50) in_op ::= NOT IN */
{
91
,
-
3
},
/* (51) in_predicate_value ::= NK_LP expression_list NK_RP */
{
90
,
-
3
},
/* (51) in_predicate_value ::= NK_LP expression_list NK_RP */
{
92
,
-
1
},
/* (52) boolean_value_expression ::= boolean_primary */
{
91
,
-
1
},
/* (52) boolean_value_expression ::= boolean_primary */
{
92
,
-
2
},
/* (53) boolean_value_expression ::= NOT boolean_primary */
{
91
,
-
2
},
/* (53) boolean_value_expression ::= NOT boolean_primary */
{
92
,
-
3
},
/* (54) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{
91
,
-
3
},
/* (54) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{
92
,
-
3
},
/* (55) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{
91
,
-
3
},
/* (55) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{
93
,
-
1
},
/* (56) boolean_primary ::= predicate */
{
92
,
-
1
},
/* (56) boolean_primary ::= predicate */
{
93
,
-
3
},
/* (57) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
{
92
,
-
3
},
/* (57) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
{
94
,
-
2
},
/* (58) from_clause ::= FROM table_reference_list */
{
93
,
-
2
},
/* (58) from_clause ::= FROM table_reference_list */
{
95
,
-
1
},
/* (59) table_reference_list ::= table_reference */
{
94
,
-
1
},
/* (59) table_reference_list ::= table_reference */
{
95
,
-
3
},
/* (60) table_reference_list ::= table_reference_list NK_COMMA table_reference */
{
94
,
-
3
},
/* (60) table_reference_list ::= table_reference_list NK_COMMA table_reference */
{
96
,
-
1
},
/* (61) table_reference ::= table_primary */
{
95
,
-
1
},
/* (61) table_reference ::= table_primary */
{
96
,
-
1
},
/* (62) table_reference ::= joined_table */
{
95
,
-
1
},
/* (62) table_reference ::= joined_table */
{
97
,
-
2
},
/* (63) table_primary ::= table_name alias_opt */
{
96
,
-
2
},
/* (63) table_primary ::= table_name alias_opt */
{
97
,
-
4
},
/* (64) table_primary ::= db_name NK_DOT table_name alias_opt */
{
96
,
-
4
},
/* (64) table_primary ::= db_name NK_DOT table_name alias_opt */
{
97
,
-
2
},
/* (65) table_primary ::= subquery alias_opt */
{
96
,
-
2
},
/* (65) table_primary ::= subquery alias_opt */
{
99
,
0
},
/* (66) alias_opt ::= */
{
96
,
-
1
},
/* (66) table_primary ::= parenthesized_joined_table */
{
99
,
-
1
},
/* (67) alias_opt ::= table_alias */
{
98
,
0
},
/* (67) alias_opt ::= */
{
99
,
-
2
},
/* (68) alias_opt ::= AS table_alias */
{
98
,
-
1
},
/* (68) alias_opt ::= table_alias */
{
100
,
-
3
},
/* (69) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
{
98
,
-
2
},
/* (69) alias_opt ::= AS table_alias */
{
100
,
-
3
},
/* (70) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
{
99
,
-
3
},
/* (70) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
{
98
,
-
6
},
/* (71) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{
99
,
-
3
},
/* (71) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
{
101
,
-
1
},
/* (72) join_type ::= INNER */
{
97
,
-
6
},
/* (72) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{
103
,
-
9
},
/* (73) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
100
,
-
1
},
/* (73) join_type ::= INNER */
{
104
,
0
},
/* (74) set_quantifier_opt ::= */
{
102
,
-
9
},
/* (74) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
104
,
-
1
},
/* (75) set_quantifier_opt ::= DISTINCT */
{
103
,
0
},
/* (75) set_quantifier_opt ::= */
{
104
,
-
1
},
/* (76) set_quantifier_opt ::= ALL */
{
103
,
-
1
},
/* (76) set_quantifier_opt ::= DISTINCT */
{
105
,
-
1
},
/* (77) select_list ::= NK_STAR */
{
103
,
-
1
},
/* (77) set_quantifier_opt ::= ALL */
{
105
,
-
1
},
/* (78) select_list ::= select_sublist */
{
104
,
-
1
},
/* (78) select_list ::= NK_STAR */
{
111
,
-
1
},
/* (79) select_sublist ::= select_item */
{
104
,
-
1
},
/* (79) select_list ::= select_sublist */
{
111
,
-
3
},
/* (80) select_sublist ::= select_sublist NK_COMMA select_item */
{
110
,
-
1
},
/* (80) select_sublist ::= select_item */
{
112
,
-
1
},
/* (81) select_item ::= expression */
{
110
,
-
3
},
/* (81) select_sublist ::= select_sublist NK_COMMA select_item */
{
112
,
-
2
},
/* (82) select_item ::= expression column_alias */
{
111
,
-
1
},
/* (82) select_item ::= expression */
{
112
,
-
3
},
/* (83) select_item ::= expression AS column_alias */
{
111
,
-
2
},
/* (83) select_item ::= expression column_alias */
{
112
,
-
3
},
/* (84) select_item ::= table_name NK_DOT NK_STAR */
{
111
,
-
3
},
/* (84) select_item ::= expression AS column_alias */
{
106
,
0
},
/* (85) where_clause_opt ::= */
{
111
,
-
3
},
/* (85) select_item ::= table_name NK_DOT NK_STAR */
{
106
,
-
2
},
/* (86) where_clause_opt ::= WHERE search_condition */
{
105
,
0
},
/* (86) where_clause_opt ::= */
{
107
,
0
},
/* (87) partition_by_clause_opt ::= */
{
105
,
-
2
},
/* (87) where_clause_opt ::= WHERE search_condition */
{
107
,
-
3
},
/* (88) partition_by_clause_opt ::= PARTITION BY expression_list */
{
106
,
0
},
/* (88) partition_by_clause_opt ::= */
{
108
,
0
},
/* (89) twindow_clause_opt ::= */
{
106
,
-
3
},
/* (89) partition_by_clause_opt ::= PARTITION BY expression_list */
{
108
,
-
6
},
/* (90) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
{
107
,
0
},
/* (90) twindow_clause_opt ::= */
{
108
,
-
4
},
/* (91) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{
107
,
-
6
},
/* (91) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
{
108
,
-
6
},
/* (92) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{
107
,
-
4
},
/* (92) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{
108
,
-
8
},
/* (93) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{
107
,
-
6
},
/* (93) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{
113
,
0
},
/* (94) sliding_opt ::= */
{
107
,
-
8
},
/* (94) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{
113
,
-
4
},
/* (95) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{
112
,
0
},
/* (95) sliding_opt ::= */
{
114
,
0
},
/* (96) fill_opt ::= */
{
112
,
-
4
},
/* (96) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{
114
,
-
4
},
/* (97) fill_opt ::= FILL NK_LP fill_mode NK_RP */
{
113
,
0
},
/* (97) fill_opt ::= */
{
114
,
-
6
},
/* (98) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{
113
,
-
4
},
/* (98) fill_opt ::= FILL NK_LP fill_mode NK_RP */
{
115
,
-
1
},
/* (99) fill_mode ::= NONE */
{
113
,
-
6
},
/* (99) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{
115
,
-
1
},
/* (100) fill_mode ::= PREV */
{
114
,
-
1
},
/* (100) fill_mode ::= NONE */
{
115
,
-
1
},
/* (101) fill_mode ::= NULL */
{
114
,
-
1
},
/* (101) fill_mode ::= PREV */
{
115
,
-
1
},
/* (102) fill_mode ::= LINEAR */
{
114
,
-
1
},
/* (102) fill_mode ::= NULL */
{
115
,
-
1
},
/* (103) fill_mode ::= NEXT */
{
114
,
-
1
},
/* (103) fill_mode ::= LINEAR */
{
109
,
0
},
/* (104) group_by_clause_opt ::= */
{
114
,
-
1
},
/* (104) fill_mode ::= NEXT */
{
109
,
-
3
},
/* (105) group_by_clause_opt ::= GROUP BY expression_list */
{
108
,
0
},
/* (105) group_by_clause_opt ::= */
{
110
,
0
},
/* (106) having_clause_opt ::= */
{
108
,
-
3
},
/* (106) group_by_clause_opt ::= GROUP BY expression_list */
{
110
,
-
2
},
/* (107) having_clause_opt ::= HAVING search_condition */
{
109
,
0
},
/* (107) having_clause_opt ::= */
{
74
,
-
4
},
/* (108) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{
109
,
-
2
},
/* (108) having_clause_opt ::= HAVING search_condition */
{
116
,
-
1
},
/* (109) query_expression_body ::= query_primary */
{
73
,
-
4
},
/* (109) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{
116
,
-
4
},
/* (110) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{
115
,
-
1
},
/* (110) query_expression_body ::= query_primary */
{
120
,
-
1
},
/* (111) query_primary ::= query_specification */
{
115
,
-
4
},
/* (111) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{
120
,
-
6
},
/* (112) query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP */
{
119
,
-
1
},
/* (112) query_primary ::= query_specification */
{
117
,
0
},
/* (113) order_by_clause_opt ::= */
{
116
,
0
},
/* (113) order_by_clause_opt ::= */
{
117
,
-
3
},
/* (114) order_by_clause_opt ::= ORDER BY sort_specification_list */
{
116
,
-
3
},
/* (114) order_by_clause_opt ::= ORDER BY sort_specification_list */
{
118
,
0
},
/* (115) slimit_clause_opt ::= */
{
117
,
0
},
/* (115) slimit_clause_opt ::= */
{
118
,
-
2
},
/* (116) slimit_clause_opt ::= SLIMIT NK_INTEGER */
{
117
,
-
2
},
/* (116) slimit_clause_opt ::= SLIMIT NK_INTEGER */
{
118
,
-
4
},
/* (117) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
{
117
,
-
4
},
/* (117) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
{
118
,
-
4
},
/* (118) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{
117
,
-
4
},
/* (118) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{
119
,
0
},
/* (119) limit_clause_opt ::= */
{
118
,
0
},
/* (119) limit_clause_opt ::= */
{
119
,
-
2
},
/* (120) limit_clause_opt ::= LIMIT NK_INTEGER */
{
118
,
-
2
},
/* (120) limit_clause_opt ::= LIMIT NK_INTEGER */
{
119
,
-
4
},
/* (121) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
{
118
,
-
4
},
/* (121) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
{
119
,
-
4
},
/* (122) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{
118
,
-
4
},
/* (122) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{
87
,
-
3
},
/* (123) subquery ::= NK_LR query_expression NK_RP */
{
86
,
-
3
},
/* (123) subquery ::= NK_LP query_expression NK_RP */
{
102
,
-
1
},
/* (124) search_condition ::= boolean_value_expression */
{
101
,
-
1
},
/* (124) search_condition ::= boolean_value_expression */
{
121
,
-
1
},
/* (125) sort_specification_list ::= sort_specification */
{
120
,
-
1
},
/* (125) sort_specification_list ::= sort_specification */
{
121
,
-
3
},
/* (126) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
{
120
,
-
3
},
/* (126) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
{
122
,
-
3
},
/* (127) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
{
121
,
-
3
},
/* (127) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
{
123
,
0
},
/* (128) ordering_specification_opt ::= */
{
122
,
0
},
/* (128) ordering_specification_opt ::= */
{
123
,
-
1
},
/* (129) ordering_specification_opt ::= ASC */
{
122
,
-
1
},
/* (129) ordering_specification_opt ::= ASC */
{
123
,
-
1
},
/* (130) ordering_specification_opt ::= DESC */
{
122
,
-
1
},
/* (130) ordering_specification_opt ::= DESC */
{
124
,
0
},
/* (131) null_ordering_opt ::= */
{
123
,
0
},
/* (131) null_ordering_opt ::= */
{
124
,
-
2
},
/* (132) null_ordering_opt ::= NULLS FIRST */
{
123
,
-
2
},
/* (132) null_ordering_opt ::= NULLS FIRST */
{
124
,
-
2
},
/* (133) null_ordering_opt ::= NULLS LAST */
{
123
,
-
2
},
/* (133) null_ordering_opt ::= NULLS LAST */
{
97
,
-
1
},
/* (134) table_primary ::= parenthesized_joined_table */
};
};
static
void
yy_accept
(
yyParser
*
);
/* Forward Declaration */
static
void
yy_accept
(
yyParser
*
);
/* Forward Declaration */
...
@@ -1514,26 +1514,26 @@ static YYACTIONTYPE yy_reduce(
...
@@ -1514,26 +1514,26 @@ static YYACTIONTYPE yy_reduce(
{
PARSER_TRACE
;
createShowStmt
(
pCxt
,
SHOW_TYPE_DATABASE
);
}
{
PARSER_TRACE
;
createShowStmt
(
pCxt
,
SHOW_TYPE_DATABASE
);
}
break
;
break
;
case
1
:
/* cmd ::= query_expression */
case
1
:
/* cmd ::= query_expression */
{
PARSER_TRACE
;
pCxt
->
pRootNode
=
yymsp
[
0
].
minor
.
yy
212
;
}
{
PARSER_TRACE
;
pCxt
->
pRootNode
=
yymsp
[
0
].
minor
.
yy
168
;
}
break
;
break
;
case
2
:
/* literal ::= NK_INTEGER */
case
2
:
/* literal ::= NK_INTEGER */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BIGINT
,
&
yymsp
[
0
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BIGINT
,
&
yymsp
[
0
].
minor
.
yy0
);
}
yymsp
[
0
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
0
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
3
:
/* literal ::= NK_FLOAT */
case
3
:
/* literal ::= NK_FLOAT */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_DOUBLE
,
&
yymsp
[
0
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_DOUBLE
,
&
yymsp
[
0
].
minor
.
yy0
);
}
yymsp
[
0
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
0
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
4
:
/* literal ::= NK_STRING */
case
4
:
/* literal ::= NK_STRING */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BINARY
,
&
yymsp
[
0
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BINARY
,
&
yymsp
[
0
].
minor
.
yy0
);
}
yymsp
[
0
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
0
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
5
:
/* literal ::= NK_BOOL */
case
5
:
/* literal ::= NK_BOOL */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BOOL
,
&
yymsp
[
0
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BOOL
,
&
yymsp
[
0
].
minor
.
yy0
);
}
yymsp
[
0
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
0
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
6
:
/* literal ::= TIMESTAMP NK_STRING */
case
6
:
/* literal ::= TIMESTAMP NK_STRING */
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
212
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_TIMESTAMP
,
&
yymsp
[
0
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
168
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_TIMESTAMP
,
&
yymsp
[
0
].
minor
.
yy0
);
}
break
;
break
;
case
7
:
/* literal ::= duration_literal */
case
7
:
/* literal ::= duration_literal */
case
17
:
/* expression ::= literal */
yytestcase
(
yyruleno
==
17
);
case
17
:
/* expression ::= literal */
yytestcase
(
yyruleno
==
17
);
...
@@ -1544,30 +1544,31 @@ static YYACTIONTYPE yy_reduce(
...
@@ -1544,30 +1544,31 @@ static YYACTIONTYPE yy_reduce(
case
59
:
/* table_reference_list ::= table_reference */
yytestcase
(
yyruleno
==
59
);
case
59
:
/* table_reference_list ::= table_reference */
yytestcase
(
yyruleno
==
59
);
case
61
:
/* table_reference ::= table_primary */
yytestcase
(
yyruleno
==
61
);
case
61
:
/* table_reference ::= table_primary */
yytestcase
(
yyruleno
==
61
);
case
62
:
/* table_reference ::= joined_table */
yytestcase
(
yyruleno
==
62
);
case
62
:
/* table_reference ::= joined_table */
yytestcase
(
yyruleno
==
62
);
case
81
:
/* select_item ::= expression */
yytestcase
(
yyruleno
==
81
);
case
66
:
/* table_primary ::= parenthesized_joined_table */
yytestcase
(
yyruleno
==
66
);
case
109
:
/* query_expression_body ::= query_primary */
yytestcase
(
yyruleno
==
109
);
case
82
:
/* select_item ::= expression */
yytestcase
(
yyruleno
==
82
);
case
111
:
/* query_primary ::= query_specification */
yytestcase
(
yyruleno
==
111
);
case
110
:
/* query_expression_body ::= query_primary */
yytestcase
(
yyruleno
==
110
);
case
112
:
/* query_primary ::= query_specification */
yytestcase
(
yyruleno
==
112
);
case
124
:
/* search_condition ::= boolean_value_expression */
yytestcase
(
yyruleno
==
124
);
case
124
:
/* search_condition ::= boolean_value_expression */
yytestcase
(
yyruleno
==
124
);
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
yymsp
[
0
].
minor
.
yy212
;
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
yymsp
[
0
].
minor
.
yy168
;
}
yymsp
[
0
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
0
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
8
:
/* duration_literal ::= NK_VARIABLE */
case
8
:
/* duration_literal ::= NK_VARIABLE */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createDurationValueNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createDurationValueNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
);
}
yymsp
[
0
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
0
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
9
:
/* literal_list ::= literal */
case
9
:
/* literal_list ::= literal */
case
29
:
/* expression_list ::= expression */
yytestcase
(
yyruleno
==
29
);
case
29
:
/* expression_list ::= expression */
yytestcase
(
yyruleno
==
29
);
case
79
:
/* select_sublist ::= select_item */
yytestcase
(
yyruleno
==
79
);
case
80
:
/* select_sublist ::= select_item */
yytestcase
(
yyruleno
==
80
);
case
125
:
/* sort_specification_list ::= sort_specification */
yytestcase
(
yyruleno
==
125
);
case
125
:
/* sort_specification_list ::= sort_specification */
yytestcase
(
yyruleno
==
125
);
{
PARSER_TRACE
;
yylhsminor
.
yy1
74
=
createNodeList
(
pCxt
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy1
92
=
createNodeList
(
pCxt
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
0
].
minor
.
yy1
74
=
yylhsminor
.
yy174
;
yymsp
[
0
].
minor
.
yy1
92
=
yylhsminor
.
yy192
;
break
;
break
;
case
10
:
/* literal_list ::= literal_list NK_COMMA literal */
case
10
:
/* literal_list ::= literal_list NK_COMMA literal */
case
30
:
/* expression_list ::= expression_list NK_COMMA expression */
yytestcase
(
yyruleno
==
30
);
case
30
:
/* expression_list ::= expression_list NK_COMMA expression */
yytestcase
(
yyruleno
==
30
);
case
8
0
:
/* select_sublist ::= select_sublist NK_COMMA select_item */
yytestcase
(
yyruleno
==
80
);
case
8
1
:
/* select_sublist ::= select_sublist NK_COMMA select_item */
yytestcase
(
yyruleno
==
81
);
case
126
:
/* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
yytestcase
(
yyruleno
==
126
);
case
126
:
/* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
yytestcase
(
yyruleno
==
126
);
{
PARSER_TRACE
;
yylhsminor
.
yy1
74
=
addNodeToList
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy174
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy1
92
=
addNodeToList
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy192
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
2
].
minor
.
yy1
74
=
yylhsminor
.
yy174
;
yymsp
[
-
2
].
minor
.
yy1
92
=
yylhsminor
.
yy192
;
break
;
break
;
case
11
:
/* db_name ::= NK_ID */
case
11
:
/* db_name ::= NK_ID */
case
12
:
/* table_name ::= NK_ID */
yytestcase
(
yyruleno
==
12
);
case
12
:
/* table_name ::= NK_ID */
yytestcase
(
yyruleno
==
12
);
...
@@ -1575,313 +1576,301 @@ static YYACTIONTYPE yy_reduce(
...
@@ -1575,313 +1576,301 @@ static YYACTIONTYPE yy_reduce(
case
14
:
/* function_name ::= NK_ID */
yytestcase
(
yyruleno
==
14
);
case
14
:
/* function_name ::= NK_ID */
yytestcase
(
yyruleno
==
14
);
case
15
:
/* table_alias ::= NK_ID */
yytestcase
(
yyruleno
==
15
);
case
15
:
/* table_alias ::= NK_ID */
yytestcase
(
yyruleno
==
15
);
case
16
:
/* column_alias ::= NK_ID */
yytestcase
(
yyruleno
==
16
);
case
16
:
/* column_alias ::= NK_ID */
yytestcase
(
yyruleno
==
16
);
{
PARSER_TRACE
;
yylhsminor
.
yy
79
=
yymsp
[
0
].
minor
.
yy0
;
}
{
PARSER_TRACE
;
yylhsminor
.
yy
241
=
yymsp
[
0
].
minor
.
yy0
;
}
yymsp
[
0
].
minor
.
yy
79
=
yylhsminor
.
yy79
;
yymsp
[
0
].
minor
.
yy
241
=
yylhsminor
.
yy241
;
break
;
break
;
case
19
:
/* expression ::= function_name NK_LP expression_list NK_RP */
case
19
:
/* expression ::= function_name NK_LP expression_list NK_RP */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createFunctionNode
(
pCxt
,
&
yymsp
[
-
3
].
minor
.
yy79
,
yymsp
[
-
1
].
minor
.
yy174
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createFunctionNode
(
pCxt
,
&
yymsp
[
-
3
].
minor
.
yy241
,
yymsp
[
-
1
].
minor
.
yy192
);
}
yymsp
[
-
3
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
3
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
21
:
/* expression ::= NK_LP expression NK_RP */
case
21
:
/* expression ::= NK_LP expression NK_RP */
case
57
:
/* boolean_primary ::= NK_LP boolean_value_expression NK_RP */
yytestcase
(
yyruleno
==
57
);
case
57
:
/* boolean_primary ::= NK_LP boolean_value_expression NK_RP */
yytestcase
(
yyruleno
==
57
);
case
69
:
/* parenthesized_joined_table ::= NK_LP joined_table NK_RP */
yytestcase
(
yyruleno
==
69
);
case
70
:
/* parenthesized_joined_table ::= NK_LP joined_table NK_RP */
yytestcase
(
yyruleno
==
70
);
case
7
0
:
/* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
yytestcase
(
yyruleno
==
70
);
case
7
1
:
/* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
yytestcase
(
yyruleno
==
71
);
case
123
:
/* subquery ::= NK_L
R
query_expression NK_RP */
yytestcase
(
yyruleno
==
123
);
case
123
:
/* subquery ::= NK_L
P
query_expression NK_RP */
yytestcase
(
yyruleno
==
123
);
{
PARSER_TRACE
;
yymsp
[
-
2
].
minor
.
yy
212
=
yymsp
[
-
1
].
minor
.
yy212
;
}
{
PARSER_TRACE
;
yymsp
[
-
2
].
minor
.
yy
168
=
yymsp
[
-
1
].
minor
.
yy168
;
}
break
;
break
;
case
22
:
/* expression ::= NK_PLUS expression */
case
22
:
/* expression ::= NK_PLUS expression */
case
58
:
/* from_clause ::= FROM table_reference_list */
yytestcase
(
yyruleno
==
58
);
case
58
:
/* from_clause ::= FROM table_reference_list */
yytestcase
(
yyruleno
==
58
);
case
8
6
:
/* where_clause_opt ::= WHERE search_condition */
yytestcase
(
yyruleno
==
86
);
case
8
7
:
/* where_clause_opt ::= WHERE search_condition */
yytestcase
(
yyruleno
==
87
);
case
10
7
:
/* having_clause_opt ::= HAVING search_condition */
yytestcase
(
yyruleno
==
107
);
case
10
8
:
/* having_clause_opt ::= HAVING search_condition */
yytestcase
(
yyruleno
==
108
);
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
212
=
yymsp
[
0
].
minor
.
yy212
;
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
168
=
yymsp
[
0
].
minor
.
yy168
;
}
break
;
break
;
case
23
:
/* expression ::= NK_MINUS expression */
case
23
:
/* expression ::= NK_MINUS expression */
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
212
=
createOperatorNode
(
pCxt
,
OP_TYPE_SUB
,
yymsp
[
0
].
minor
.
yy212
,
NULL
);
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
168
=
createOperatorNode
(
pCxt
,
OP_TYPE_SUB
,
yymsp
[
0
].
minor
.
yy168
,
NULL
);
}
break
;
break
;
case
24
:
/* expression ::= expression NK_PLUS expression */
case
24
:
/* expression ::= expression NK_PLUS expression */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createOperatorNode
(
pCxt
,
OP_TYPE_ADD
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createOperatorNode
(
pCxt
,
OP_TYPE_ADD
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
25
:
/* expression ::= expression NK_MINUS expression */
case
25
:
/* expression ::= expression NK_MINUS expression */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createOperatorNode
(
pCxt
,
OP_TYPE_SUB
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createOperatorNode
(
pCxt
,
OP_TYPE_SUB
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
26
:
/* expression ::= expression NK_STAR expression */
case
26
:
/* expression ::= expression NK_STAR expression */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createOperatorNode
(
pCxt
,
OP_TYPE_MULTI
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createOperatorNode
(
pCxt
,
OP_TYPE_MULTI
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
27
:
/* expression ::= expression NK_SLASH expression */
case
27
:
/* expression ::= expression NK_SLASH expression */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createOperatorNode
(
pCxt
,
OP_TYPE_DIV
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createOperatorNode
(
pCxt
,
OP_TYPE_DIV
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
28
:
/* expression ::= expression NK_REM expression */
case
28
:
/* expression ::= expression NK_REM expression */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createOperatorNode
(
pCxt
,
OP_TYPE_MOD
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createOperatorNode
(
pCxt
,
OP_TYPE_MOD
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
31
:
/* column_reference ::= column_name */
case
31
:
/* column_reference ::= column_name */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createColumnNode
(
pCxt
,
NULL
,
&
yymsp
[
0
].
minor
.
yy79
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createColumnNode
(
pCxt
,
NULL
,
&
yymsp
[
0
].
minor
.
yy241
);
}
yymsp
[
0
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
0
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
32
:
/* column_reference ::= table_name NK_DOT column_name */
case
32
:
/* column_reference ::= table_name NK_DOT column_name */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createColumnNode
(
pCxt
,
&
yymsp
[
-
2
].
minor
.
yy79
,
&
yymsp
[
0
].
minor
.
yy79
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createColumnNode
(
pCxt
,
&
yymsp
[
-
2
].
minor
.
yy241
,
&
yymsp
[
0
].
minor
.
yy241
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
33
:
/* predicate ::= expression compare_op expression */
case
33
:
/* predicate ::= expression compare_op expression */
case
38
:
/* predicate ::= expression in_op in_predicate_value */
yytestcase
(
yyruleno
==
38
);
case
38
:
/* predicate ::= expression in_op in_predicate_value */
yytestcase
(
yyruleno
==
38
);
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createOperatorNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy40
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createOperatorNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy228
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
34
:
/* predicate ::= expression BETWEEN expression AND expression */
case
34
:
/* predicate ::= expression BETWEEN expression AND expression */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createBetweenAnd
(
pCxt
,
yymsp
[
-
4
].
minor
.
yy212
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createBetweenAnd
(
pCxt
,
yymsp
[
-
4
].
minor
.
yy168
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
4
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
4
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
35
:
/* predicate ::= expression NOT BETWEEN expression AND expression */
case
35
:
/* predicate ::= expression NOT BETWEEN expression AND expression */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createNotBetweenAnd
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
-
5
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createNotBetweenAnd
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
-
5
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
5
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
5
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
36
:
/* predicate ::= expression IS NULL */
case
36
:
/* predicate ::= expression IS NULL */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createIsNullCondNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy212
,
true
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createIsNullCondNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy168
,
true
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
37
:
/* predicate ::= expression IS NOT NULL */
case
37
:
/* predicate ::= expression IS NOT NULL */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createIsNullCondNode
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy212
,
false
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createIsNullCondNode
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy168
,
false
);
}
yymsp
[
-
3
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
3
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
39
:
/* compare_op ::= NK_LT */
case
39
:
/* compare_op ::= NK_LT */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_LOWER_THAN
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_LOWER_THAN
;
}
break
;
break
;
case
40
:
/* compare_op ::= NK_GT */
case
40
:
/* compare_op ::= NK_GT */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_GREATER_THAN
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_GREATER_THAN
;
}
break
;
break
;
case
41
:
/* compare_op ::= NK_LE */
case
41
:
/* compare_op ::= NK_LE */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_LOWER_EQUAL
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_LOWER_EQUAL
;
}
break
;
break
;
case
42
:
/* compare_op ::= NK_GE */
case
42
:
/* compare_op ::= NK_GE */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_GREATER_EQUAL
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_GREATER_EQUAL
;
}
break
;
break
;
case
43
:
/* compare_op ::= NK_NE */
case
43
:
/* compare_op ::= NK_NE */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_NOT_EQUAL
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_NOT_EQUAL
;
}
break
;
break
;
case
44
:
/* compare_op ::= NK_EQ */
case
44
:
/* compare_op ::= NK_EQ */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_EQUAL
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_EQUAL
;
}
break
;
break
;
case
45
:
/* compare_op ::= LIKE */
case
45
:
/* compare_op ::= LIKE */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_LIKE
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_LIKE
;
}
break
;
break
;
case
46
:
/* compare_op ::= NOT LIKE */
case
46
:
/* compare_op ::= NOT LIKE */
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
40
=
OP_TYPE_NOT_LIKE
;
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
228
=
OP_TYPE_NOT_LIKE
;
}
break
;
break
;
case
47
:
/* compare_op ::= MATCH */
case
47
:
/* compare_op ::= MATCH */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_MATCH
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_MATCH
;
}
break
;
break
;
case
48
:
/* compare_op ::= NMATCH */
case
48
:
/* compare_op ::= NMATCH */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_NMATCH
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_NMATCH
;
}
break
;
break
;
case
49
:
/* in_op ::= IN */
case
49
:
/* in_op ::= IN */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
40
=
OP_TYPE_IN
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
228
=
OP_TYPE_IN
;
}
break
;
break
;
case
50
:
/* in_op ::= NOT IN */
case
50
:
/* in_op ::= NOT IN */
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
40
=
OP_TYPE_NOT_IN
;
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
228
=
OP_TYPE_NOT_IN
;
}
break
;
break
;
case
51
:
/* in_predicate_value ::= NK_LP expression_list NK_RP */
case
51
:
/* in_predicate_value ::= NK_LP expression_list NK_RP */
{
PARSER_TRACE
;
yymsp
[
-
2
].
minor
.
yy
212
=
createNodeListNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy174
);
}
{
PARSER_TRACE
;
yymsp
[
-
2
].
minor
.
yy
168
=
createNodeListNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy192
);
}
break
;
break
;
case
53
:
/* boolean_value_expression ::= NOT boolean_primary */
case
53
:
/* boolean_value_expression ::= NOT boolean_primary */
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
212
=
createLogicConditionNode
(
pCxt
,
LOGIC_COND_TYPE_NOT
,
yymsp
[
0
].
minor
.
yy212
,
NULL
);
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
168
=
createLogicConditionNode
(
pCxt
,
LOGIC_COND_TYPE_NOT
,
yymsp
[
0
].
minor
.
yy168
,
NULL
);
}
break
;
break
;
case
54
:
/* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
case
54
:
/* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createLogicConditionNode
(
pCxt
,
LOGIC_COND_TYPE_OR
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createLogicConditionNode
(
pCxt
,
LOGIC_COND_TYPE_OR
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
55
:
/* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
case
55
:
/* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createLogicConditionNode
(
pCxt
,
LOGIC_COND_TYPE_AND
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createLogicConditionNode
(
pCxt
,
LOGIC_COND_TYPE_AND
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
60
:
/* table_reference_list ::= table_reference_list NK_COMMA table_reference */
case
60
:
/* table_reference_list ::= table_reference_list NK_COMMA table_reference */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createJoinTableNode
(
pCxt
,
JOIN_TYPE_INNER
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
,
NULL
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createJoinTableNode
(
pCxt
,
JOIN_TYPE_INNER
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
,
NULL
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
63
:
/* table_primary ::= table_name alias_opt */
case
63
:
/* table_primary ::= table_name alias_opt */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createRealTableNode
(
pCxt
,
NULL
,
&
yymsp
[
-
1
].
minor
.
yy79
,
&
yymsp
[
0
].
minor
.
yy79
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createRealTableNode
(
pCxt
,
NULL
,
&
yymsp
[
-
1
].
minor
.
yy241
,
&
yymsp
[
0
].
minor
.
yy241
);
}
yymsp
[
-
1
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
1
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
64
:
/* table_primary ::= db_name NK_DOT table_name alias_opt */
case
64
:
/* table_primary ::= db_name NK_DOT table_name alias_opt */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createRealTableNode
(
pCxt
,
&
yymsp
[
-
3
].
minor
.
yy79
,
&
yymsp
[
-
1
].
minor
.
yy79
,
&
yymsp
[
0
].
minor
.
yy79
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createRealTableNode
(
pCxt
,
&
yymsp
[
-
3
].
minor
.
yy241
,
&
yymsp
[
-
1
].
minor
.
yy241
,
&
yymsp
[
0
].
minor
.
yy241
);
}
yymsp
[
-
3
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
3
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
65
:
/* table_primary ::= subquery alias_opt */
case
65
:
/* table_primary ::= subquery alias_opt */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createTempTableNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy212
,
&
yymsp
[
0
].
minor
.
yy79
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createTempTableNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy168
,
&
yymsp
[
0
].
minor
.
yy241
);
}
yymsp
[
-
1
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
1
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
6
6
:
/* alias_opt ::= */
case
6
7
:
/* alias_opt ::= */
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy
79
=
nil_token
;
}
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy
241
=
nil_token
;
}
break
;
break
;
case
6
7
:
/* alias_opt ::= table_alias */
case
6
8
:
/* alias_opt ::= table_alias */
{
PARSER_TRACE
;
yylhsminor
.
yy
79
=
yymsp
[
0
].
minor
.
yy79
;
}
{
PARSER_TRACE
;
yylhsminor
.
yy
241
=
yymsp
[
0
].
minor
.
yy241
;
}
yymsp
[
0
].
minor
.
yy
79
=
yylhsminor
.
yy79
;
yymsp
[
0
].
minor
.
yy
241
=
yylhsminor
.
yy241
;
break
;
break
;
case
6
8
:
/* alias_opt ::= AS table_alias */
case
6
9
:
/* alias_opt ::= AS table_alias */
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
79
=
yymsp
[
0
].
minor
.
yy79
;
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
241
=
yymsp
[
0
].
minor
.
yy241
;
}
break
;
break
;
case
7
1
:
/* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
case
7
2
:
/* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createJoinTableNode
(
pCxt
,
yymsp
[
-
4
].
minor
.
yy162
,
yymsp
[
-
5
].
minor
.
yy212
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createJoinTableNode
(
pCxt
,
yymsp
[
-
4
].
minor
.
yy229
,
yymsp
[
-
5
].
minor
.
yy168
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
5
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
5
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
7
2
:
/* join_type ::= INNER */
case
7
3
:
/* join_type ::= INNER */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
162
=
JOIN_TYPE_INNER
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
229
=
JOIN_TYPE_INNER
;
}
break
;
break
;
case
7
3
:
/* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
case
7
4
:
/* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
{
PARSER_TRACE
;
PARSER_TRACE
;
yymsp
[
-
8
].
minor
.
yy
212
=
createSelectStmt
(
pCxt
,
yymsp
[
-
7
].
minor
.
yy237
,
yymsp
[
-
6
].
minor
.
yy174
,
yymsp
[
-
5
].
minor
.
yy212
);
yymsp
[
-
8
].
minor
.
yy
168
=
createSelectStmt
(
pCxt
,
yymsp
[
-
7
].
minor
.
yy209
,
yymsp
[
-
6
].
minor
.
yy192
,
yymsp
[
-
5
].
minor
.
yy168
);
yymsp
[
-
8
].
minor
.
yy
212
=
addWhereClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy212
,
yymsp
[
-
4
].
minor
.
yy212
);
yymsp
[
-
8
].
minor
.
yy
168
=
addWhereClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy168
,
yymsp
[
-
4
].
minor
.
yy168
);
yymsp
[
-
8
].
minor
.
yy
212
=
addPartitionByClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy212
,
yymsp
[
-
3
].
minor
.
yy174
);
yymsp
[
-
8
].
minor
.
yy
168
=
addPartitionByClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy168
,
yymsp
[
-
3
].
minor
.
yy192
);
yymsp
[
-
8
].
minor
.
yy
212
=
addWindowClauseClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy212
,
yymsp
[
-
2
].
minor
.
yy212
);
yymsp
[
-
8
].
minor
.
yy
168
=
addWindowClauseClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy168
,
yymsp
[
-
2
].
minor
.
yy168
);
yymsp
[
-
8
].
minor
.
yy
212
=
addGroupByClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy212
,
yymsp
[
-
1
].
minor
.
yy174
);
yymsp
[
-
8
].
minor
.
yy
168
=
addGroupByClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy168
,
yymsp
[
-
1
].
minor
.
yy192
);
yymsp
[
-
8
].
minor
.
yy
212
=
addHavingClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
yymsp
[
-
8
].
minor
.
yy
168
=
addHavingClause
(
pCxt
,
yymsp
[
-
8
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
}
break
;
break
;
case
7
4
:
/* set_quantifier_opt ::= */
case
7
5
:
/* set_quantifier_opt ::= */
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy2
37
=
false
;
}
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy2
09
=
false
;
}
break
;
break
;
case
7
5
:
/* set_quantifier_opt ::= DISTINCT */
case
7
6
:
/* set_quantifier_opt ::= DISTINCT */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy2
37
=
true
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy2
09
=
true
;
}
break
;
break
;
case
7
6
:
/* set_quantifier_opt ::= ALL */
case
7
7
:
/* set_quantifier_opt ::= ALL */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy2
37
=
false
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy2
09
=
false
;
}
break
;
break
;
case
7
7
:
/* select_list ::= NK_STAR */
case
7
8
:
/* select_list ::= NK_STAR */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy1
74
=
NULL
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy1
92
=
NULL
;
}
break
;
break
;
case
7
8
:
/* select_list ::= select_sublist */
case
7
9
:
/* select_list ::= select_sublist */
{
PARSER_TRACE
;
yylhsminor
.
yy1
74
=
yymsp
[
0
].
minor
.
yy174
;
}
{
PARSER_TRACE
;
yylhsminor
.
yy1
92
=
yymsp
[
0
].
minor
.
yy192
;
}
yymsp
[
0
].
minor
.
yy1
74
=
yylhsminor
.
yy174
;
yymsp
[
0
].
minor
.
yy1
92
=
yylhsminor
.
yy192
;
break
;
break
;
case
8
2
:
/* select_item ::= expression column_alias */
case
8
3
:
/* select_item ::= expression column_alias */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
setProjectionAlias
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy212
,
&
yymsp
[
0
].
minor
.
yy79
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
setProjectionAlias
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy168
,
&
yymsp
[
0
].
minor
.
yy241
);
}
yymsp
[
-
1
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
1
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
8
3
:
/* select_item ::= expression AS column_alias */
case
8
4
:
/* select_item ::= expression AS column_alias */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
setProjectionAlias
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy212
,
&
yymsp
[
0
].
minor
.
yy79
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
setProjectionAlias
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy168
,
&
yymsp
[
0
].
minor
.
yy241
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
8
4
:
/* select_item ::= table_name NK_DOT NK_STAR */
case
8
5
:
/* select_item ::= table_name NK_DOT NK_STAR */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createColumnNode
(
pCxt
,
&
yymsp
[
-
2
].
minor
.
yy79
,
&
yymsp
[
0
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createColumnNode
(
pCxt
,
&
yymsp
[
-
2
].
minor
.
yy241
,
&
yymsp
[
0
].
minor
.
yy0
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
8
5
:
/* where_clause_opt ::= */
case
8
6
:
/* where_clause_opt ::= */
case
89
:
/* twindow_clause_opt ::= */
yytestcase
(
yyruleno
==
89
);
case
90
:
/* twindow_clause_opt ::= */
yytestcase
(
yyruleno
==
90
);
case
9
4
:
/* sliding_opt ::= */
yytestcase
(
yyruleno
==
94
);
case
9
5
:
/* sliding_opt ::= */
yytestcase
(
yyruleno
==
95
);
case
9
6
:
/* fill_opt ::= */
yytestcase
(
yyruleno
==
96
);
case
9
7
:
/* fill_opt ::= */
yytestcase
(
yyruleno
==
97
);
case
10
6
:
/* having_clause_opt ::= */
yytestcase
(
yyruleno
==
106
);
case
10
7
:
/* having_clause_opt ::= */
yytestcase
(
yyruleno
==
107
);
case
115
:
/* slimit_clause_opt ::= */
yytestcase
(
yyruleno
==
115
);
case
115
:
/* slimit_clause_opt ::= */
yytestcase
(
yyruleno
==
115
);
case
119
:
/* limit_clause_opt ::= */
yytestcase
(
yyruleno
==
119
);
case
119
:
/* limit_clause_opt ::= */
yytestcase
(
yyruleno
==
119
);
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy
212
=
NULL
;
}
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy
168
=
NULL
;
}
break
;
break
;
case
8
7
:
/* partition_by_clause_opt ::= */
case
8
8
:
/* partition_by_clause_opt ::= */
case
10
4
:
/* group_by_clause_opt ::= */
yytestcase
(
yyruleno
==
104
);
case
10
5
:
/* group_by_clause_opt ::= */
yytestcase
(
yyruleno
==
105
);
case
113
:
/* order_by_clause_opt ::= */
yytestcase
(
yyruleno
==
113
);
case
113
:
/* order_by_clause_opt ::= */
yytestcase
(
yyruleno
==
113
);
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy1
74
=
NULL
;
}
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy1
92
=
NULL
;
}
break
;
break
;
case
8
8
:
/* partition_by_clause_opt ::= PARTITION BY expression_list */
case
8
9
:
/* partition_by_clause_opt ::= PARTITION BY expression_list */
case
10
5
:
/* group_by_clause_opt ::= GROUP BY expression_list */
yytestcase
(
yyruleno
==
105
);
case
10
6
:
/* group_by_clause_opt ::= GROUP BY expression_list */
yytestcase
(
yyruleno
==
106
);
case
114
:
/* order_by_clause_opt ::= ORDER BY sort_specification_list */
yytestcase
(
yyruleno
==
114
);
case
114
:
/* order_by_clause_opt ::= ORDER BY sort_specification_list */
yytestcase
(
yyruleno
==
114
);
{
PARSER_TRACE
;
yymsp
[
-
2
].
minor
.
yy1
74
=
yymsp
[
0
].
minor
.
yy174
;
}
{
PARSER_TRACE
;
yymsp
[
-
2
].
minor
.
yy1
92
=
yymsp
[
0
].
minor
.
yy192
;
}
break
;
break
;
case
9
0
:
/* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
case
9
1
:
/* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */
{
PARSER_TRACE
;
yymsp
[
-
5
].
minor
.
yy
212
=
createSessionWindowNode
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy212
,
&
yymsp
[
-
1
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yymsp
[
-
5
].
minor
.
yy
168
=
createSessionWindowNode
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy168
,
&
yymsp
[
-
1
].
minor
.
yy0
);
}
break
;
break
;
case
9
1
:
/* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
case
9
2
:
/* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
212
=
createStateWindowNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
168
=
createStateWindowNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy168
);
}
break
;
break
;
case
9
2
:
/* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
case
9
3
:
/* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{
PARSER_TRACE
;
yymsp
[
-
5
].
minor
.
yy
212
=
createIntervalWindowNode
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy212
,
NULL
,
yymsp
[
-
1
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yymsp
[
-
5
].
minor
.
yy
168
=
createIntervalWindowNode
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy168
,
NULL
,
yymsp
[
-
1
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
break
;
break
;
case
9
3
:
/* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
case
9
4
:
/* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{
PARSER_TRACE
;
yymsp
[
-
7
].
minor
.
yy
212
=
createIntervalWindowNode
(
pCxt
,
yymsp
[
-
5
].
minor
.
yy212
,
yymsp
[
-
3
].
minor
.
yy212
,
yymsp
[
-
1
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yymsp
[
-
7
].
minor
.
yy
168
=
createIntervalWindowNode
(
pCxt
,
yymsp
[
-
5
].
minor
.
yy168
,
yymsp
[
-
3
].
minor
.
yy168
,
yymsp
[
-
1
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
break
;
break
;
case
9
5
:
/* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
case
9
6
:
/* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
212
=
yymsp
[
-
1
].
minor
.
yy212
;
}
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
168
=
yymsp
[
-
1
].
minor
.
yy168
;
}
break
;
break
;
case
9
7
:
/* fill_opt ::= FILL NK_LP fill_mode NK_RP */
case
9
8
:
/* fill_opt ::= FILL NK_LP fill_mode NK_RP */
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
212
=
createFillNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy4
4
,
NULL
);
}
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
168
=
createFillNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy1
4
,
NULL
);
}
break
;
break
;
case
9
8
:
/* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
case
9
9
:
/* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{
PARSER_TRACE
;
yymsp
[
-
5
].
minor
.
yy
212
=
createFillNode
(
pCxt
,
FILL_MODE_VALUE
,
createNodeListNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy174
));
}
{
PARSER_TRACE
;
yymsp
[
-
5
].
minor
.
yy
168
=
createFillNode
(
pCxt
,
FILL_MODE_VALUE
,
createNodeListNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy192
));
}
break
;
break
;
case
99
:
/* fill_mode ::= NONE */
case
100
:
/* fill_mode ::= NONE */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
4
4
=
FILL_MODE_NONE
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
1
4
=
FILL_MODE_NONE
;
}
break
;
break
;
case
10
0
:
/* fill_mode ::= PREV */
case
10
1
:
/* fill_mode ::= PREV */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
4
4
=
FILL_MODE_PREV
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
1
4
=
FILL_MODE_PREV
;
}
break
;
break
;
case
10
1
:
/* fill_mode ::= NULL */
case
10
2
:
/* fill_mode ::= NULL */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
4
4
=
FILL_MODE_NULL
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
1
4
=
FILL_MODE_NULL
;
}
break
;
break
;
case
10
2
:
/* fill_mode ::= LINEAR */
case
10
3
:
/* fill_mode ::= LINEAR */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
4
4
=
FILL_MODE_LINEAR
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
1
4
=
FILL_MODE_LINEAR
;
}
break
;
break
;
case
10
3
:
/* fill_mode ::= NEXT */
case
10
4
:
/* fill_mode ::= NEXT */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
4
4
=
FILL_MODE_NEXT
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy
1
4
=
FILL_MODE_NEXT
;
}
break
;
break
;
case
10
8
:
/* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
case
10
9
:
/* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{
{
PARSER_TRACE
;
PARSER_TRACE
;
yylhsminor
.
yy
212
=
addOrderByClause
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy212
,
yymsp
[
-
2
].
minor
.
yy174
);
yylhsminor
.
yy
168
=
addOrderByClause
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy168
,
yymsp
[
-
2
].
minor
.
yy192
);
yylhsminor
.
yy
212
=
addSlimitClause
(
pCxt
,
yylhsminor
.
yy212
,
yymsp
[
-
1
].
minor
.
yy212
);
yylhsminor
.
yy
168
=
addSlimitClause
(
pCxt
,
yylhsminor
.
yy168
,
yymsp
[
-
1
].
minor
.
yy168
);
yylhsminor
.
yy
212
=
addLimitClause
(
pCxt
,
yylhsminor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
yylhsminor
.
yy
168
=
addLimitClause
(
pCxt
,
yylhsminor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
}
yymsp
[
-
3
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
3
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
110
:
/* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
case
111
:
/* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{
PARSER_TRACE
;
yylhsminor
.
yy212
=
createSetOperator
(
pCxt
,
SET_OP_TYPE_UNION_ALL
,
yymsp
[
-
3
].
minor
.
yy212
,
yymsp
[
0
].
minor
.
yy212
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy168
=
createSetOperator
(
pCxt
,
SET_OP_TYPE_UNION_ALL
,
yymsp
[
-
3
].
minor
.
yy168
,
yymsp
[
0
].
minor
.
yy168
);
}
yymsp
[
-
3
].
minor
.
yy212
=
yylhsminor
.
yy212
;
yymsp
[
-
3
].
minor
.
yy168
=
yylhsminor
.
yy168
;
break
;
case
112
:
/* query_primary ::= NK_LP query_expression_body order_by_clause_opt limit_clause_opt slimit_clause_opt NK_RP */
{
PARSER_TRACE
;
yymsp
[
-
5
].
minor
.
yy212
=
yymsp
[
-
4
].
minor
.
yy212
;}
yy_destructor
(
yypParser
,
117
,
&
yymsp
[
-
3
].
minor
);
yy_destructor
(
yypParser
,
119
,
&
yymsp
[
-
2
].
minor
);
yy_destructor
(
yypParser
,
118
,
&
yymsp
[
-
1
].
minor
);
break
;
break
;
case
116
:
/* slimit_clause_opt ::= SLIMIT NK_INTEGER */
case
116
:
/* slimit_clause_opt ::= SLIMIT NK_INTEGER */
case
120
:
/* limit_clause_opt ::= LIMIT NK_INTEGER */
yytestcase
(
yyruleno
==
120
);
case
120
:
/* limit_clause_opt ::= LIMIT NK_INTEGER */
yytestcase
(
yyruleno
==
120
);
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
212
=
createLimitNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
,
NULL
);
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy
168
=
createLimitNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
,
NULL
);
}
break
;
break
;
case
117
:
/* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
case
117
:
/* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
case
121
:
/* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
yytestcase
(
yyruleno
==
121
);
case
121
:
/* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
yytestcase
(
yyruleno
==
121
);
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
212
=
createLimitNode
(
pCxt
,
&
yymsp
[
-
2
].
minor
.
yy0
,
&
yymsp
[
0
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
168
=
createLimitNode
(
pCxt
,
&
yymsp
[
-
2
].
minor
.
yy0
,
&
yymsp
[
0
].
minor
.
yy0
);
}
break
;
break
;
case
118
:
/* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
case
118
:
/* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
case
122
:
/* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
yytestcase
(
yyruleno
==
122
);
case
122
:
/* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
yytestcase
(
yyruleno
==
122
);
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
212
=
createLimitNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
,
&
yymsp
[
-
2
].
minor
.
yy0
);
}
{
PARSER_TRACE
;
yymsp
[
-
3
].
minor
.
yy
168
=
createLimitNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
,
&
yymsp
[
-
2
].
minor
.
yy0
);
}
break
;
break
;
case
127
:
/* sort_specification ::= expression ordering_specification_opt null_ordering_opt */
case
127
:
/* sort_specification ::= expression ordering_specification_opt null_ordering_opt */
{
PARSER_TRACE
;
yylhsminor
.
yy
212
=
createOrderByExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy212
,
yymsp
[
-
1
].
minor
.
yy188
,
yymsp
[
0
].
minor
.
yy10
7
);
}
{
PARSER_TRACE
;
yylhsminor
.
yy
168
=
createOrderByExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy168
,
yymsp
[
-
1
].
minor
.
yy10
,
yymsp
[
0
].
minor
.
yy17
7
);
}
yymsp
[
-
2
].
minor
.
yy
212
=
yylhsminor
.
yy212
;
yymsp
[
-
2
].
minor
.
yy
168
=
yylhsminor
.
yy168
;
break
;
break
;
case
128
:
/* ordering_specification_opt ::= */
case
128
:
/* ordering_specification_opt ::= */
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy1
88
=
ORDER_ASC
;
}
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy1
0
=
ORDER_ASC
;
}
break
;
break
;
case
129
:
/* ordering_specification_opt ::= ASC */
case
129
:
/* ordering_specification_opt ::= ASC */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy1
88
=
ORDER_ASC
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy1
0
=
ORDER_ASC
;
}
break
;
break
;
case
130
:
/* ordering_specification_opt ::= DESC */
case
130
:
/* ordering_specification_opt ::= DESC */
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy1
88
=
ORDER_DESC
;
}
{
PARSER_TRACE
;
yymsp
[
0
].
minor
.
yy1
0
=
ORDER_DESC
;
}
break
;
break
;
case
131
:
/* null_ordering_opt ::= */
case
131
:
/* null_ordering_opt ::= */
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy1
0
7
=
NULL_ORDER_DEFAULT
;
}
{
PARSER_TRACE
;
yymsp
[
1
].
minor
.
yy1
7
7
=
NULL_ORDER_DEFAULT
;
}
break
;
break
;
case
132
:
/* null_ordering_opt ::= NULLS FIRST */
case
132
:
/* null_ordering_opt ::= NULLS FIRST */
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy1
0
7
=
NULL_ORDER_FIRST
;
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy1
7
7
=
NULL_ORDER_FIRST
;
}
break
;
break
;
case
133
:
/* null_ordering_opt ::= NULLS LAST */
case
133
:
/* null_ordering_opt ::= NULLS LAST */
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy107
=
NULL_ORDER_LAST
;
}
{
PARSER_TRACE
;
yymsp
[
-
1
].
minor
.
yy177
=
NULL_ORDER_LAST
;
}
break
;
case
134
:
/* table_primary ::= parenthesized_joined_table */
{
yy_destructor
(
yypParser
,
100
,
&
yymsp
[
0
].
minor
);
{
}
}
break
;
break
;
default:
default:
break
;
break
;
...
...
source/libs/parser/src/parserImpl.c
浏览文件 @
3b5828c0
...
@@ -15,8 +15,9 @@
...
@@ -15,8 +15,9 @@
#include "parserImpl.h"
#include "parserImpl.h"
#include "ttoken.h"
#include "astCreateContext.h"
#include "astCreateContext.h"
#include "parserInt.h"
#include "ttoken.h"
typedef
void
*
(
*
FMalloc
)(
size_t
);
typedef
void
*
(
*
FMalloc
)(
size_t
);
typedef
void
(
*
FFree
)(
void
*
);
typedef
void
(
*
FFree
)(
void
*
);
...
@@ -24,9 +25,85 @@ typedef void (*FFree)(void*);
...
@@ -24,9 +25,85 @@ typedef void (*FFree)(void*);
extern
void
*
NewParseAlloc
(
FMalloc
);
extern
void
*
NewParseAlloc
(
FMalloc
);
extern
void
NewParse
(
void
*
,
int
,
SToken
,
void
*
);
extern
void
NewParse
(
void
*
,
int
,
SToken
,
void
*
);
extern
void
NewParseFree
(
void
*
,
FFree
);
extern
void
NewParseFree
(
void
*
,
FFree
);
extern
void
NewParseTrace
(
FILE
*
,
char
*
);
static
uint32_t
toNewTokenId
(
uint32_t
tokenId
)
{
// #define 1
// #define NEW_TK_AND 2
// #define NEW_TK_UNION 3
// #define NEW_TK_ALL 4
// #define NEW_TK_MINUS 5
// #define NEW_TK_EXCEPT 6
// #define NEW_TK_INTERSECT 7
// #define NEW_TK_NK_PLUS 8
// #define NEW_TK_NK_MINUS 9
// #define NEW_TK_NK_STAR 10
// #define NEW_TK_NK_SLASH 11
// #define NEW_TK_NK_REM 12
// #define NEW_TK_SHOW 13
// #define NEW_TK_DATABASES 14
// #define NEW_TK_NK_INTEGER 15
// #define NEW_TK_NK_FLOAT 16
// #define NEW_TK_NK_STRING 17
// #define NEW_TK_NK_BOOL 18
// #define NEW_TK_TIMESTAMP 19
// #define NEW_TK_NK_VARIABLE 20
// #define NEW_TK_NK_COMMA 21
// #define NEW_TK_NK_ID 22
// #define NEW_TK_NK_LP 23
// #define NEW_TK_NK_RP 24
// #define NEW_TK_NK_DOT 25
// #define NEW_TK_BETWEEN 26
// #define NEW_TK_NOT 27
// #define NEW_TK_IS 28
// #define NEW_TK_NULL 29
// #define NEW_TK_NK_LT 30
// #define NEW_TK_NK_GT 31
// #define NEW_TK_NK_LE 32
// #define NEW_TK_NK_GE 33
// #define NEW_TK_NK_NE 34
// #define 35
// #define NEW_TK_LIKE 36
// #define NEW_TK_MATCH 37
// #define NEW_TK_NMATCH 38
// #define NEW_TK_IN 39
// #define NEW_TK_FROM 40
// #define NEW_TK_AS 41
// #define NEW_TK_JOIN 42
// #define NEW_TK_ON 43
// #define NEW_TK_INNER 44
// #define NEW_TK_SELECT 45
// #define NEW_TK_DISTINCT 46
// #define 47
// #define NEW_TK_PARTITION 48
// #define NEW_TK_BY 49
// #define NEW_TK_SESSION 50
// #define NEW_TK_STATE_WINDOW 51
// #define NEW_TK_INTERVAL 52
// #define NEW_TK_SLIDING 53
// #define NEW_TK_FILL 54
// #define NEW_TK_VALUE 55
// #define NEW_TK_NONE 56
// #define NEW_TK_PREV 57
// #define NEW_TK_LINEAR 58
// #define NEW_TK_NEXT 59
// #define NEW_TK_GROUP 60
// #define NEW_TK_HAVING 61
// #define NEW_TK_ORDER 62
// #define NEW_TK_SLIMIT 63
// #define NEW_TK_SOFFSET 64
// #define NEW_TK_LIMIT 65
// #define NEW_TK_OFFSET 66
// #define NEW_TK_NK_LR 67
// #define NEW_TK_ASC 68
// #define NEW_TK_DESC 69
// #define NEW_TK_NULLS 70
// #define NEW_TK_FIRST 71
// #define NEW_TK_LAST 72
uint32_t
toNewTokenId
(
uint32_t
tokenId
)
{
switch
(
tokenId
)
{
switch
(
tokenId
)
{
case
TK_OR
:
return
NEW_TK_OR
;
case
TK_UNION
:
case
TK_UNION
:
return
NEW_TK_UNION
;
return
NEW_TK_UNION
;
case
TK_ALL
:
case
TK_ALL
:
...
@@ -53,10 +130,14 @@ uint32_t toNewTokenId(uint32_t tokenId) {
...
@@ -53,10 +130,14 @@ uint32_t toNewTokenId(uint32_t tokenId) {
return
NEW_TK_NK_COMMA
;
return
NEW_TK_NK_COMMA
;
case
TK_DOT
:
case
TK_DOT
:
return
NEW_TK_NK_DOT
;
return
NEW_TK_NK_DOT
;
case
TK_EQ
:
return
NEW_TK_NK_EQ
;
case
TK_SELECT
:
case
TK_SELECT
:
return
NEW_TK_SELECT
;
return
NEW_TK_SELECT
;
case
TK_DISTINCT
:
case
TK_DISTINCT
:
return
NEW_TK_DISTINCT
;
return
NEW_TK_DISTINCT
;
case
TK_WHERE
:
return
NEW_TK_WHERE
;
case
TK_AS
:
case
TK_AS
:
return
NEW_TK_AS
;
return
NEW_TK_AS
;
case
TK_FROM
:
case
TK_FROM
:
...
@@ -69,11 +150,15 @@ uint32_t toNewTokenId(uint32_t tokenId) {
...
@@ -69,11 +150,15 @@ uint32_t toNewTokenId(uint32_t tokenId) {
return
NEW_TK_ASC
;
return
NEW_TK_ASC
;
case
TK_DESC
:
case
TK_DESC
:
return
NEW_TK_DESC
;
return
NEW_TK_DESC
;
case
TK_SPACE
:
break
;
default:
printf
(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!tokenId = %d
\n
"
,
tokenId
);
}
}
return
tokenId
;
return
tokenId
;
}
}
uint32_t
getToken
(
const
char
*
z
,
uint32_t
*
tokenId
)
{
static
uint32_t
getToken
(
const
char
*
z
,
uint32_t
*
tokenId
)
{
uint32_t
n
=
tGetToken
(
z
,
tokenId
);
uint32_t
n
=
tGetToken
(
z
,
tokenId
);
*
tokenId
=
toNewTokenId
(
*
tokenId
);
*
tokenId
=
toNewTokenId
(
*
tokenId
);
return
n
;
return
n
;
...
@@ -124,6 +209,7 @@ int32_t doParse(SParseContext* pParseCxt, SQuery* pQuery) {
...
@@ -124,6 +209,7 @@ int32_t doParse(SParseContext* pParseCxt, SQuery* pQuery) {
default:
default:
NewParse
(
pParser
,
t0
.
type
,
t0
,
&
cxt
);
NewParse
(
pParser
,
t0
.
type
,
t0
,
&
cxt
);
// NewParseTrace(stdout, "");
if
(
!
cxt
.
valid
)
{
if
(
!
cxt
.
valid
)
{
goto
abort_parse
;
goto
abort_parse
;
}
}
...
@@ -137,3 +223,359 @@ abort_parse:
...
@@ -137,3 +223,359 @@ abort_parse:
pQuery
->
pRoot
=
cxt
.
pRootNode
;
pQuery
->
pRoot
=
cxt
.
pRootNode
;
return
cxt
.
valid
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_FAILED
;
return
cxt
.
valid
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_FAILED
;
}
}
// typedef struct SNamespace {
// int16_t level; // todo for correlated subquery
// char dbName[TSDB_DB_NAME_LEN];
// char tableAlias[TSDB_TABLE_NAME_LEN];
// SHashObj* pColHash; // key is colname, value is index of STableMeta.schema
// STableMeta* pMeta;
// } SNamespace;
typedef
enum
ESqlClause
{
SQL_CLAUSE_FROM
=
1
,
SQL_CLAUSE_WHERE
}
ESqlClause
;
typedef
struct
STranslateContext
{
SParseContext
*
pParseCxt
;
int32_t
errCode
;
SMsgBuf
msgBuf
;
SArray
*
pNsLevel
;
// element is SArray*, the element of this subarray is STableNode*
int32_t
currLevel
;
ESqlClause
currClause
;
}
STranslateContext
;
static
int32_t
translateSubquery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
char
*
getSyntaxErrFormat
(
int32_t
errCode
)
{
switch
(
errCode
)
{
case
TSDB_CODE_PARSER_INVALID_COLUMN
:
return
"Invalid column name : %s"
;
case
TSDB_CODE_PARSER_TABLE_NOT_EXIST
:
return
"Table does not exist : %s"
;
case
TSDB_CODE_PARSER_AMBIGUOUS_COLUMN
:
return
"Column ambiguously defined : %s"
;
default:
return
"Unknown error"
;
}
}
static
int32_t
generateSyntaxErrMsg
(
STranslateContext
*
pCxt
,
int32_t
errCode
,
const
char
*
additionalInfo
)
{
snprintf
(
pCxt
->
msgBuf
.
buf
,
pCxt
->
msgBuf
.
len
,
getSyntaxErrFormat
(
errCode
),
additionalInfo
);
pCxt
->
errCode
=
errCode
;
return
errCode
;
}
static
int32_t
addNamespace
(
STranslateContext
*
pCxt
,
void
*
pTable
)
{
size_t
currTotalLevel
=
taosArrayGetSize
(
pCxt
->
pNsLevel
);
if
(
currTotalLevel
>
pCxt
->
currLevel
)
{
SArray
*
pTables
=
taosArrayGetP
(
pCxt
->
pNsLevel
,
pCxt
->
currLevel
);
taosArrayPush
(
pTables
,
&
pTable
);
}
else
{
do
{
SArray
*
pTables
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
POINTER_BYTES
);
if
(
pCxt
->
currLevel
==
currTotalLevel
)
{
taosArrayPush
(
pTables
,
&
pTable
);
}
taosArrayPush
(
pCxt
->
pNsLevel
,
&
pTables
);
++
currTotalLevel
;
}
while
(
currTotalLevel
<=
pCxt
->
currLevel
);
}
return
TSDB_CODE_SUCCESS
;
}
static
SName
*
toName
(
int32_t
acctId
,
const
SRealTableNode
*
pRealTable
,
SName
*
pName
)
{
pName
->
type
=
TSDB_TABLE_NAME_T
;
pName
->
acctId
=
acctId
;
strcpy
(
pName
->
dbname
,
pRealTable
->
table
.
dbName
);
strcpy
(
pName
->
tname
,
pRealTable
->
table
.
tableName
);
return
pName
;
}
static
bool
belongTable
(
const
char
*
currentDb
,
const
SColumnNode
*
pCol
,
const
STableNode
*
pTable
)
{
int
cmp
=
0
;
if
(
'\0'
!=
pCol
->
dbName
[
0
])
{
cmp
=
strcmp
(
pCol
->
dbName
,
pTable
->
dbName
);
}
else
{
cmp
=
strcmp
(
currentDb
,
pTable
->
dbName
);
}
if
(
0
==
cmp
)
{
cmp
=
strcmp
(
pCol
->
tableAlias
,
pTable
->
tableAlias
);
}
return
(
0
==
cmp
);
}
static
SNodeList
*
getProjectList
(
SNode
*
pNode
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pNode
))
{
return
((
SSelectStmt
*
)
pNode
)
->
pProjectionList
;
}
return
NULL
;
}
static
void
setColumnInfoBySchema
(
const
STableNode
*
pTable
,
const
SSchema
*
pColSchema
,
SColumnNode
*
pCol
)
{
strcpy
(
pCol
->
dbName
,
pTable
->
dbName
);
strcpy
(
pCol
->
tableAlias
,
pTable
->
tableAlias
);
strcpy
(
pCol
->
tableName
,
pTable
->
tableName
);
strcpy
(
pCol
->
colName
,
pColSchema
->
name
);
if
(
'\0'
==
pCol
->
node
.
aliasName
[
0
])
{
strcpy
(
pCol
->
node
.
aliasName
,
pColSchema
->
name
);
}
pCol
->
colId
=
pColSchema
->
colId
;
pCol
->
colType
=
pColSchema
->
type
;
pCol
->
node
.
resType
.
bytes
=
pColSchema
->
bytes
;
}
static
void
setColumnInfoByExpr
(
const
STableNode
*
pTable
,
SExprNode
*
pExpr
,
SColumnNode
*
pCol
)
{
pCol
->
pProjectRef
=
(
SNode
*
)
pExpr
;
pExpr
->
pAssociationList
=
nodesListAppend
(
pExpr
->
pAssociationList
,
(
SNode
*
)
pCol
);
strcpy
(
pCol
->
tableAlias
,
pTable
->
tableAlias
);
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
pCol
->
node
.
resType
=
pExpr
->
resType
;
}
static
int32_t
createColumnNodeByTable
(
const
STableNode
*
pTable
,
SNodeList
*
pList
)
{
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
const
STableMeta
*
pMeta
=
((
SRealTableNode
*
)
pTable
)
->
pMeta
;
int32_t
nums
=
pMeta
->
tableInfo
.
numOfTags
+
pMeta
->
tableInfo
.
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
nums
;
++
i
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
setColumnInfoBySchema
(
pTable
,
pMeta
->
schema
+
i
,
pCol
);
nodesListAppend
(
pList
,
(
SNode
*
)
pCol
);
}
}
else
{
SNodeList
*
pProjectList
=
getProjectList
(((
STempTableNode
*
)
pTable
)
->
pSubquery
);
SNode
*
pNode
;
FOREACH
(
pNode
,
pProjectList
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
setColumnInfoByExpr
(
pTable
,
(
SExprNode
*
)
pNode
,
pCol
);
nodesListAppend
(
pList
,
(
SNode
*
)
pCol
);
}
}
}
static
bool
findAndSetColumn
(
SColumnNode
*
pCol
,
const
STableNode
*
pTable
)
{
bool
found
=
false
;
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
const
STableMeta
*
pMeta
=
((
SRealTableNode
*
)
pTable
)
->
pMeta
;
int32_t
nums
=
pMeta
->
tableInfo
.
numOfTags
+
pMeta
->
tableInfo
.
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
nums
;
++
i
)
{
if
(
0
==
strcmp
(
pCol
->
colName
,
pMeta
->
schema
[
i
].
name
))
{
setColumnInfoBySchema
(
pTable
,
pMeta
->
schema
+
i
,
pCol
);
found
=
true
;
break
;
}
}
}
else
{
SNodeList
*
pProjectList
=
getProjectList
(((
STempTableNode
*
)
pTable
)
->
pSubquery
);
SNode
*
pNode
;
FOREACH
(
pNode
,
pProjectList
)
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
if
(
0
==
strcmp
(
pCol
->
colName
,
pExpr
->
aliasName
))
{
setColumnInfoByExpr
(
pTable
,
pExpr
,
pCol
);
found
=
true
;
break
;
}
}
}
return
found
;
}
static
bool
translateColumnWithPrefix
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
)
{
SArray
*
pTables
=
taosArrayGetP
(
pCxt
->
pNsLevel
,
pCxt
->
currLevel
);
size_t
nums
=
taosArrayGetSize
(
pTables
);
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
if
(
belongTable
(
pCxt
->
pParseCxt
->
db
,
pCol
,
pTable
))
{
if
(
findAndSetColumn
(
pCol
,
pTable
))
{
break
;
}
generateSyntaxErrMsg
(
pCxt
,
TSDB_CODE_PARSER_INVALID_COLUMN
,
pCol
->
colName
);
return
false
;
}
}
return
true
;
}
static
bool
translateColumnWithoutPrefix
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
)
{
SArray
*
pTables
=
taosArrayGetP
(
pCxt
->
pNsLevel
,
pCxt
->
currLevel
);
size_t
nums
=
taosArrayGetSize
(
pTables
);
bool
found
=
false
;
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
if
(
findAndSetColumn
(
pCol
,
pTable
))
{
if
(
found
)
{
generateSyntaxErrMsg
(
pCxt
,
TSDB_CODE_PARSER_AMBIGUOUS_COLUMN
,
pCol
->
colName
);
return
false
;
}
found
=
true
;
}
}
if
(
!
found
)
{
generateSyntaxErrMsg
(
pCxt
,
TSDB_CODE_PARSER_INVALID_COLUMN
,
pCol
->
colName
);
return
false
;
}
return
true
;
}
static
bool
translateColumn
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
)
{
if
(
'\0'
!=
pCol
->
tableAlias
[
0
])
{
return
translateColumnWithPrefix
(
pCxt
,
pCol
);
}
return
translateColumnWithoutPrefix
(
pCxt
,
pCol
);
}
// check literal format
static
bool
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
return
true
;
}
static
bool
translateOperator
(
STranslateContext
*
pCxt
,
SOperatorNode
*
pOp
)
{
return
true
;
}
static
bool
translateFunction
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
)
{
return
true
;
}
static
bool
doTranslateExpr
(
SNode
*
pNode
,
void
*
pContext
)
{
STranslateContext
*
pCxt
=
(
STranslateContext
*
)
pContext
;
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
return
translateColumn
(
pCxt
,
(
SColumnNode
*
)
pNode
);
case
QUERY_NODE_VALUE
:
return
translateValue
(
pCxt
,
(
SValueNode
*
)
pNode
);
case
QUERY_NODE_OPERATOR
:
return
translateOperator
(
pCxt
,
(
SOperatorNode
*
)
pNode
);
case
QUERY_NODE_FUNCTION
:
return
translateFunction
(
pCxt
,
(
SFunctionNode
*
)
pNode
);
case
QUERY_NODE_TEMP_TABLE
:
return
translateSubquery
(
pCxt
,
((
STempTableNode
*
)
pNode
)
->
pSubquery
);
default:
break
;
}
return
true
;
}
static
int32_t
translateExpr
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
nodesWalkNodePostOrder
(
pNode
,
doTranslateExpr
,
pCxt
);
return
pCxt
->
errCode
;
}
static
int32_t
translateExprList
(
STranslateContext
*
pCxt
,
SNodeList
*
pList
)
{
nodesWalkListPostOrder
(
pList
,
doTranslateExpr
,
pCxt
);
return
pCxt
->
errCode
;
}
static
int32_t
translateTable
(
STranslateContext
*
pCxt
,
SNode
*
pTable
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pTable
))
{
case
QUERY_NODE_REAL_TABLE
:
{
SRealTableNode
*
pRealTable
=
(
SRealTableNode
*
)
pTable
;
SName
name
;
code
=
catalogGetTableMeta
(
pCxt
->
pParseCxt
->
pCatalog
,
pCxt
->
pParseCxt
->
pTransporter
,
&
(
pCxt
->
pParseCxt
->
mgmtEpSet
),
toName
(
pCxt
->
pParseCxt
->
acctId
,
pRealTable
,
&
name
),
&
(
pRealTable
->
pMeta
));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
generateSyntaxErrMsg
(
pCxt
,
TSDB_CODE_PARSER_TABLE_NOT_EXIST
,
pRealTable
->
table
.
tableName
);
}
code
=
addNamespace
(
pCxt
,
pRealTable
);
break
;
}
case
QUERY_NODE_TEMP_TABLE
:
{
STempTableNode
*
pTempTable
=
(
STempTableNode
*
)
pTable
;
code
=
translateSubquery
(
pCxt
,
pTempTable
->
pSubquery
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addNamespace
(
pCxt
,
pTempTable
);
}
break
;
}
case
QUERY_NODE_JOIN_TABLE
:
{
SJoinTableNode
*
pJoinTable
=
(
SJoinTableNode
*
)
pTable
;
code
=
translateTable
(
pCxt
,
pJoinTable
->
pLeft
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateTable
(
pCxt
,
pJoinTable
->
pRight
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateExpr
(
pCxt
,
pJoinTable
->
pOnCond
);
}
break
;
}
default:
break
;
}
return
code
;
}
static
int32_t
translateFrom
(
STranslateContext
*
pCxt
,
SNode
*
pTable
)
{
pCxt
->
currClause
=
SQL_CLAUSE_FROM
;
return
translateTable
(
pCxt
,
pTable
);
}
static
int32_t
translateStar
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
,
bool
*
pIsSelectStar
)
{
if
(
NULL
==
pSelect
->
pProjectionList
)
{
// select * ...
SArray
*
pTables
=
taosArrayGetP
(
pCxt
->
pNsLevel
,
pCxt
->
currLevel
);
size_t
nums
=
taosArrayGetSize
(
pTables
);
pSelect
->
pProjectionList
=
nodesMakeList
();
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
createColumnNodeByTable
(
pTable
,
pSelect
->
pProjectionList
);
}
*
pIsSelectStar
=
true
;
}
else
{
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateSelect
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
code
=
translateFrom
(
pCxt
,
pSelect
->
pFromTable
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateExpr
(
pCxt
,
pSelect
->
pWhere
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateExprList
(
pCxt
,
pSelect
->
pGroupByList
);
}
bool
isSelectStar
=
false
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateStar
(
pCxt
,
pSelect
,
&
isSelectStar
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
isSelectStar
)
{
code
=
translateExprList
(
pCxt
,
pSelect
->
pProjectionList
);
}
// printf("%s:%d code = %d\n", __FUNCTION__, __LINE__, code);
return
code
;
}
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_SELECT_STMT
:
code
=
translateSelect
(
pCxt
,
(
SSelectStmt
*
)
pNode
);
break
;
default:
break
;
}
return
code
;
}
static
int32_t
translateSubquery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
++
(
pCxt
->
currLevel
);
ESqlClause
currClause
=
pCxt
->
currClause
;
int32_t
code
=
translateQuery
(
pCxt
,
pNode
);
--
(
pCxt
->
currLevel
);
pCxt
->
currClause
=
currClause
;
return
code
;
}
int32_t
doTranslate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
)
{
STranslateContext
cxt
=
{
.
pParseCxt
=
pParseCxt
,
.
errCode
=
TSDB_CODE_SUCCESS
,
.
msgBuf
=
{
.
buf
=
pParseCxt
->
pMsg
,
.
len
=
pParseCxt
->
msgLen
},
.
pNsLevel
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
POINTER_BYTES
),
.
currLevel
=
0
,
.
currClause
=
0
};
return
translateQuery
(
&
cxt
,
pQuery
->
pRoot
);
}
source/libs/parser/test/newParserTest.cpp
浏览文件 @
3b5828c0
...
@@ -38,15 +38,38 @@ protected:
...
@@ -38,15 +38,38 @@ protected:
}
}
bool
run
(
int32_t
expect
Code
=
TSDB_CODE_SUCCESS
)
{
bool
run
(
int32_t
parseCode
=
TSDB_CODE_SUCCESS
,
int32_t
translate
Code
=
TSDB_CODE_SUCCESS
)
{
int32_t
code
=
doParse
(
&
cxt_
,
&
query_
);
int32_t
code
=
doParse
(
&
cxt_
,
&
query_
);
// cout << "doParse return " << code << endl;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] code:"
<<
tstrerror
(
code
)
<<
", msg:"
<<
errMagBuf_
<<
endl
;
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] code:"
<<
tstrerror
(
code
)
<<
", msg:"
<<
errMagBuf_
<<
endl
;
return
(
code
==
expectCode
);
return
(
TSDB_CODE_SUCCESS
!=
parseCode
);
}
if
(
TSDB_CODE_SUCCESS
!=
parseCode
)
{
return
false
;
}
code
=
doTranslate
(
&
cxt_
,
&
query_
);
// cout << "doTranslate return " << code << endl;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] code:"
<<
tstrerror
(
code
)
<<
", msg:"
<<
errMagBuf_
<<
endl
;
return
(
TSDB_CODE_SUCCESS
!=
translateCode
);
}
}
if
(
NULL
!=
query_
.
pRoot
&&
QUERY_NODE_SELECT_STMT
==
nodeType
(
query_
.
pRoot
))
{
if
(
NULL
!=
query_
.
pRoot
&&
QUERY_NODE_SELECT_STMT
==
nodeType
(
query_
.
pRoot
))
{
SSelectStmt
*
select
=
(
SSelectStmt
*
)
query_
.
pRoot
;
string
sql
;
string
sql
(
"SELECT "
);
selectToSql
(
query_
.
pRoot
,
sql
);
cout
<<
"input sql : ["
<<
cxt_
.
pSql
<<
"]"
<<
endl
;
cout
<<
"output sql : ["
<<
sql
<<
"]"
<<
endl
;
}
return
(
TSDB_CODE_SUCCESS
==
translateCode
);
}
private:
static
const
int
max_err_len
=
1024
;
static
const
int
max_sql_len
=
1024
*
1024
;
void
selectToSql
(
const
SNode
*
node
,
string
&
sql
)
{
SSelectStmt
*
select
=
(
SSelectStmt
*
)
node
;
sql
.
append
(
"SELECT "
);
if
(
select
->
isDistinct
)
{
if
(
select
->
isDistinct
)
{
sql
.
append
(
"DISTINCT "
);
sql
.
append
(
"DISTINCT "
);
}
}
...
@@ -54,30 +77,110 @@ protected:
...
@@ -54,30 +77,110 @@ protected:
sql
.
append
(
"* "
);
sql
.
append
(
"* "
);
}
else
{
}
else
{
nodeListToSql
(
select
->
pProjectionList
,
sql
);
nodeListToSql
(
select
->
pProjectionList
,
sql
);
sql
.
append
(
" "
);
}
}
sql
.
append
(
"FROM "
);
sql
.
append
(
"FROM "
);
tableToSql
(
select
->
pFromTable
,
sql
);
tableToSql
(
select
->
pFromTable
,
sql
);
cout
<<
sql
<<
endl
;
if
(
nullptr
!=
select
->
pWhere
)
{
sql
.
append
(
" WHERE "
);
nodeToSql
(
select
->
pWhere
,
sql
);
}
}
return
(
code
==
expectCode
);
}
}
private:
static
const
int
max_err_len
=
1024
;
static
const
int
max_sql_len
=
1024
*
1024
;
void
tableToSql
(
const
SNode
*
node
,
string
&
sql
)
{
void
tableToSql
(
const
SNode
*
node
,
string
&
sql
)
{
const
STableNode
*
table
=
(
const
STableNode
*
)
node
;
const
STableNode
*
table
=
(
const
STableNode
*
)
node
;
switch
(
nodeType
(
node
))
{
switch
(
nodeType
(
node
))
{
case
QUERY_NODE_REAL_TABLE
:
{
case
QUERY_NODE_REAL_TABLE
:
{
SRealTableNode
*
realTable
=
(
SRealTableNode
*
)
table
;
SRealTableNode
*
realTable
=
(
SRealTableNode
*
)
table
;
if
(
'\0'
!=
realTable
->
dbName
[
0
])
{
if
(
'\0'
!=
realTable
->
table
.
dbName
[
0
])
{
sql
.
append
(
realTable
->
dbName
);
sql
.
append
(
realTable
->
table
.
dbName
);
sql
.
append
(
"."
);
sql
.
append
(
"."
);
}
}
sql
.
append
(
realTable
->
table
.
tableName
);
sql
.
append
(
realTable
->
table
.
tableName
);
break
;
break
;
}
}
case
QUERY_NODE_TEMP_TABLE
:
{
STempTableNode
*
tempTable
=
(
STempTableNode
*
)
table
;
sql
.
append
(
"("
);
selectToSql
(
tempTable
->
pSubquery
,
sql
);
sql
.
append
(
") "
);
sql
.
append
(
tempTable
->
table
.
tableAlias
);
break
;
}
case
QUERY_NODE_JOIN_TABLE
:
{
SJoinTableNode
*
joinTable
=
(
SJoinTableNode
*
)
table
;
tableToSql
(
joinTable
->
pLeft
,
sql
);
sql
.
append
(
" JOIN "
);
tableToSql
(
joinTable
->
pRight
,
sql
);
if
(
nullptr
!=
joinTable
->
pOnCond
)
{
sql
.
append
(
" ON "
);
nodeToSql
(
joinTable
->
pOnCond
,
sql
);
}
break
;
}
default:
break
;
}
}
string
opTypeToSql
(
EOperatorType
type
)
{
switch
(
type
)
{
case
OP_TYPE_ADD
:
return
" + "
;
case
OP_TYPE_SUB
:
return
" - "
;
case
OP_TYPE_MULTI
:
case
OP_TYPE_DIV
:
case
OP_TYPE_MOD
:
case
OP_TYPE_GREATER_THAN
:
case
OP_TYPE_GREATER_EQUAL
:
case
OP_TYPE_LOWER_THAN
:
case
OP_TYPE_LOWER_EQUAL
:
case
OP_TYPE_EQUAL
:
return
" = "
;
case
OP_TYPE_NOT_EQUAL
:
case
OP_TYPE_IN
:
case
OP_TYPE_NOT_IN
:
case
OP_TYPE_LIKE
:
case
OP_TYPE_NOT_LIKE
:
case
OP_TYPE_MATCH
:
case
OP_TYPE_NMATCH
:
case
OP_TYPE_JSON_GET_VALUE
:
case
OP_TYPE_JSON_CONTAINS
:
default:
break
;
}
return
" unknown operator "
;
}
void
nodeToSql
(
const
SNode
*
node
,
string
&
sql
)
{
if
(
nullptr
==
node
)
{
return
;
}
switch
(
nodeType
(
node
))
{
case
QUERY_NODE_COLUMN
:
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
node
;
if
(
'\0'
!=
pCol
->
dbName
[
0
])
{
sql
.
append
(
pCol
->
dbName
);
sql
.
append
(
"."
);
}
if
(
'\0'
!=
pCol
->
tableAlias
[
0
])
{
sql
.
append
(
pCol
->
tableAlias
);
sql
.
append
(
"."
);
}
sql
.
append
(
pCol
->
colName
);
break
;
}
case
QUERY_NODE_VALUE
:
break
;
case
QUERY_NODE_OPERATOR
:
{
SOperatorNode
*
pOp
=
(
SOperatorNode
*
)
node
;
nodeToSql
(
pOp
->
pLeft
,
sql
);
sql
.
append
(
opTypeToSql
(
pOp
->
opType
));
nodeToSql
(
pOp
->
pRight
,
sql
);
break
;
}
default:
default:
break
;
break
;
}
}
...
@@ -91,14 +194,9 @@ private:
...
@@ -91,14 +194,9 @@ private:
sql
.
append
(
", "
);
sql
.
append
(
", "
);
}
}
firstNode
=
false
;
firstNode
=
false
;
switch
(
nodeType
(
node
))
{
nodeToSql
(
node
,
sql
);
case
QUERY_NODE_COLUMN
:
sql
.
append
(((
SColumnNode
*
)
node
)
->
colName
);
break
;
}
}
}
}
sql
.
append
(
" "
);
}
void
reset
()
{
void
reset
()
{
memset
(
&
cxt_
,
0
,
sizeof
(
cxt_
));
memset
(
&
cxt_
,
0
,
sizeof
(
cxt_
));
...
@@ -125,10 +223,13 @@ TEST_F(NewParserTest, selectStar) {
...
@@ -125,10 +223,13 @@ TEST_F(NewParserTest, selectStar) {
bind
(
"SELECT * FROM test.t1"
);
bind
(
"SELECT * FROM test.t1"
);
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
bind
(
"SELECT ts FROM t1"
);
bind
(
"SELECT ts, c1 FROM t1"
);
ASSERT_TRUE
(
run
());
bind
(
"SELECT ts, t.c1 FROM (SELECT * FROM t1) t"
);
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
bind
(
"SELECT
ts, tag1, c1 FROM t
1"
);
bind
(
"SELECT
* FROM t1 tt1, t1 tt2 WHERE tt1.c1 = tt2.c
1"
);
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
}
}
...
@@ -147,3 +248,16 @@ TEST_F(NewParserTest, syntaxError) {
...
@@ -147,3 +248,16 @@ TEST_F(NewParserTest, syntaxError) {
bind
(
"SELECT * FROM test.t1 t WHER"
);
bind
(
"SELECT * FROM test.t1 t WHER"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_FAILED
));
ASSERT_TRUE
(
run
(
TSDB_CODE_FAILED
));
}
}
TEST_F
(
NewParserTest
,
semanticError
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"SELECT * FROM t10"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_SUCCESS
,
TSDB_CODE_FAILED
));
bind
(
"SELECT c1, c3 FROM t1"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_SUCCESS
,
TSDB_CODE_FAILED
));
bind
(
"SELECT c2 FROM t1 tt1, t1 tt2 WHERE tt1.c1 = tt2.c1"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_SUCCESS
,
TSDB_CODE_FAILED
));
}
source/libs/qcom/src/querymsg.c
浏览文件 @
3b5828c0
...
@@ -45,11 +45,11 @@ int32_t queryBuildTableMetaReqMsg(void* input, char **msg, int32_t msgSize, int3
...
@@ -45,11 +45,11 @@ int32_t queryBuildTableMetaReqMsg(void* input, char **msg, int32_t msgSize, int3
bMsg
->
header
.
vgId
=
htonl
(
bInput
->
vgId
);
bMsg
->
header
.
vgId
=
htonl
(
bInput
->
vgId
);
if
(
bInput
->
dbName
)
{
if
(
bInput
->
db
F
Name
)
{
tstrncpy
(
bMsg
->
dbF
name
,
bInput
->
dbName
,
tListLen
(
bMsg
->
dbFn
ame
));
tstrncpy
(
bMsg
->
dbF
Name
,
bInput
->
dbFName
,
tListLen
(
bMsg
->
dbFN
ame
));
}
}
tstrncpy
(
bMsg
->
t
ableFname
,
bInput
->
tableFullName
,
tListLen
(
bMsg
->
tableFn
ame
));
tstrncpy
(
bMsg
->
t
bName
,
bInput
->
tbName
,
tListLen
(
bMsg
->
tbN
ame
));
*
msgLen
=
(
int32_t
)
sizeof
(
*
bMsg
);
*
msgLen
=
(
int32_t
)
sizeof
(
*
bMsg
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -113,12 +113,19 @@ int32_t queryProcessUseDBRsp(void* output, char *msg, int32_t msgSize) {
...
@@ -113,12 +113,19 @@ int32_t queryProcessUseDBRsp(void* output, char *msg, int32_t msgSize) {
return
TSDB_CODE_TSC_VALUE_OUT_OF_RANGE
;
return
TSDB_CODE_TSC_VALUE_OUT_OF_RANGE
;
}
}
pOut
->
dbVgroup
.
vgVersion
=
pRsp
->
vgVersion
;
pOut
->
dbVgroup
=
calloc
(
1
,
sizeof
(
SDBVgroupInfo
));
pOut
->
dbVgroup
.
hashMethod
=
pRsp
->
hashMethod
;
if
(
NULL
==
pOut
->
dbVgroup
)
{
pOut
->
dbVgroup
.
dbId
=
pRsp
->
uid
;
qError
(
"calloc %d failed"
,
(
int32_t
)
sizeof
(
SDBVgroupInfo
));
pOut
->
dbVgroup
.
vgInfo
=
taosHashInit
(
pRsp
->
vgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
if
(
NULL
==
pOut
->
dbVgroup
.
vgInfo
)
{
}
qError
(
"hash init[%d] failed"
,
pRsp
->
vgNum
);
pOut
->
dbVgroup
->
vgVersion
=
pRsp
->
vgVersion
;
pOut
->
dbVgroup
->
hashMethod
=
pRsp
->
hashMethod
;
pOut
->
dbVgroup
->
dbId
=
pRsp
->
uid
;
pOut
->
dbVgroup
->
vgHash
=
taosHashInit
(
pRsp
->
vgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
pOut
->
dbVgroup
->
vgHash
)
{
qError
(
"taosHashInit %d failed"
,
pRsp
->
vgNum
);
tfree
(
pOut
->
dbVgroup
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
...
@@ -131,8 +138,8 @@ int32_t queryProcessUseDBRsp(void* output, char *msg, int32_t msgSize) {
...
@@ -131,8 +138,8 @@ int32_t queryProcessUseDBRsp(void* output, char *msg, int32_t msgSize) {
pRsp
->
vgroupInfo
[
i
].
epset
.
eps
[
n
].
port
=
ntohs
(
pRsp
->
vgroupInfo
[
i
].
epset
.
eps
[
n
].
port
);
pRsp
->
vgroupInfo
[
i
].
epset
.
eps
[
n
].
port
=
ntohs
(
pRsp
->
vgroupInfo
[
i
].
epset
.
eps
[
n
].
port
);
}
}
if
(
0
!=
taosHashPut
(
pOut
->
dbVgroup
.
vgInfo
,
&
pRsp
->
vgroupInfo
[
i
].
vgId
,
sizeof
(
pRsp
->
vgroupInfo
[
i
].
vgId
),
&
pRsp
->
vgroupInfo
[
i
],
sizeof
(
pRsp
->
vgroupInfo
[
i
])))
{
if
(
0
!=
taosHashPut
(
pOut
->
dbVgroup
->
vgHash
,
&
pRsp
->
vgroupInfo
[
i
].
vgId
,
sizeof
(
pRsp
->
vgroupInfo
[
i
].
vgId
),
&
pRsp
->
vgroupInfo
[
i
],
sizeof
(
pRsp
->
vgroupInfo
[
i
])))
{
qError
(
"
hash push
failed"
);
qError
(
"
taosHashPut
failed"
);
goto
_return
;
goto
_return
;
}
}
}
}
...
@@ -142,8 +149,10 @@ int32_t queryProcessUseDBRsp(void* output, char *msg, int32_t msgSize) {
...
@@ -142,8 +149,10 @@ int32_t queryProcessUseDBRsp(void* output, char *msg, int32_t msgSize) {
return
code
;
return
code
;
_return:
_return:
if
(
pOut
)
{
if
(
pOut
)
{
tfree
(
pOut
->
dbVgroup
.
vgInfo
);
taosHashCleanup
(
pOut
->
dbVgroup
->
vgHash
);
tfree
(
pOut
->
dbVgroup
);
}
}
return
code
;
return
code
;
...
@@ -248,16 +257,13 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
...
@@ -248,16 +257,13 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
return
TSDB_CODE_TSC_INVALID_VALUE
;
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
}
strcpy
(
pOut
->
dbFName
,
pMetaMsg
->
dbFName
);
if
(
pMetaMsg
->
tableType
==
TSDB_CHILD_TABLE
)
{
if
(
pMetaMsg
->
tableType
==
TSDB_CHILD_TABLE
)
{
SET_META_TYPE_BOTH_TABLE
(
pOut
->
metaType
);
SET_META_TYPE_BOTH_TABLE
(
pOut
->
metaType
);
if
(
pMetaMsg
->
dbFname
[
0
])
{
strcpy
(
pOut
->
ctbName
,
pMetaMsg
->
tbName
);
snprintf
(
pOut
->
ctbFname
,
sizeof
(
pOut
->
ctbFname
),
"%s.%s"
,
pMetaMsg
->
dbFname
,
pMetaMsg
->
tbFname
);
strcpy
(
pOut
->
tbName
,
pMetaMsg
->
stbName
);
snprintf
(
pOut
->
tbFname
,
sizeof
(
pOut
->
tbFname
),
"%s.%s"
,
pMetaMsg
->
dbFname
,
pMetaMsg
->
stbFname
);
}
else
{
memcpy
(
pOut
->
ctbFname
,
pMetaMsg
->
tbFname
,
sizeof
(
pOut
->
ctbFname
));
memcpy
(
pOut
->
tbFname
,
pMetaMsg
->
stbFname
,
sizeof
(
pOut
->
tbFname
));
}
pOut
->
ctbMeta
.
vgId
=
pMetaMsg
->
vgId
;
pOut
->
ctbMeta
.
vgId
=
pMetaMsg
->
vgId
;
pOut
->
ctbMeta
.
tableType
=
pMetaMsg
->
tableType
;
pOut
->
ctbMeta
.
tableType
=
pMetaMsg
->
tableType
;
...
@@ -268,11 +274,7 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
...
@@ -268,11 +274,7 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
}
else
{
}
else
{
SET_META_TYPE_TABLE
(
pOut
->
metaType
);
SET_META_TYPE_TABLE
(
pOut
->
metaType
);
if
(
pMetaMsg
->
dbFname
[
0
])
{
strcpy
(
pOut
->
tbName
,
pMetaMsg
->
tbName
);
snprintf
(
pOut
->
tbFname
,
sizeof
(
pOut
->
tbFname
),
"%s.%s"
,
pMetaMsg
->
dbFname
,
pMetaMsg
->
tbFname
);
}
else
{
memcpy
(
pOut
->
tbFname
,
pMetaMsg
->
tbFname
,
sizeof
(
pOut
->
tbFname
));
}
code
=
queryCreateTableMetaFromMsg
(
pMetaMsg
,
(
pMetaMsg
->
tableType
==
TSDB_SUPER_TABLE
),
&
pOut
->
tbMeta
);
code
=
queryCreateTableMetaFromMsg
(
pMetaMsg
,
(
pMetaMsg
->
tableType
==
TSDB_SUPER_TABLE
),
&
pOut
->
tbMeta
);
}
}
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
3b5828c0
source/libs/scheduler/inc/schedulerInt.h
浏览文件 @
3b5828c0
...
@@ -132,7 +132,7 @@ typedef struct SSchJob {
...
@@ -132,7 +132,7 @@ typedef struct SSchJob {
SQueryProfileSummary
summary
;
SQueryProfileSummary
summary
;
}
SSchJob
;
}
SSchJob
;
#define SCH_TASK_READY_TO_LUNCH(
task) (atomic_load_32(&(task)->childReady
) >= taosArrayGetSize((task)->children))
#define SCH_TASK_READY_TO_LUNCH(
readyNum, task) ((readyNum
) >= taosArrayGetSize((task)->children))
#define SCH_IS_DATA_SRC_TASK(task) ((task)->plan->type == QUERY_TYPE_SCAN)
#define SCH_IS_DATA_SRC_TASK(task) ((task)->plan->type == QUERY_TYPE_SCAN)
#define SCH_TASK_NEED_WAIT_ALL(task) ((task)->plan->type == QUERY_TYPE_MODIFY)
#define SCH_TASK_NEED_WAIT_ALL(task) ((task)->plan->type == QUERY_TYPE_MODIFY)
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
3b5828c0
...
@@ -773,14 +773,14 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
...
@@ -773,14 +773,14 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
SSchTask
*
par
=
*
(
SSchTask
**
)
taosArrayGet
(
pTask
->
parents
,
i
);
SSchTask
*
par
=
*
(
SSchTask
**
)
taosArrayGet
(
pTask
->
parents
,
i
);
pErrTask
=
par
;
pErrTask
=
par
;
atomic_add_fetch_32
(
&
par
->
childReady
,
1
);
int32_t
readyNum
=
atomic_add_fetch_32
(
&
par
->
childReady
,
1
);
SCH_LOCK
(
SCH_WRITE
,
&
par
->
lock
);
SCH_LOCK
(
SCH_WRITE
,
&
par
->
lock
);
SDownstreamSource
source
=
{.
taskId
=
pTask
->
taskId
,
.
schedId
=
schMgmt
.
sId
,
.
addr
=
pTask
->
succeedAddr
};
SDownstreamSource
source
=
{.
taskId
=
pTask
->
taskId
,
.
schedId
=
schMgmt
.
sId
,
.
addr
=
pTask
->
succeedAddr
};
qSetSubplanExecutionNode
(
par
->
plan
,
pTask
->
plan
->
id
.
templateId
,
&
source
);
qSetSubplanExecutionNode
(
par
->
plan
,
pTask
->
plan
->
id
.
templateId
,
&
source
);
SCH_UNLOCK
(
SCH_WRITE
,
&
par
->
lock
);
SCH_UNLOCK
(
SCH_WRITE
,
&
par
->
lock
);
if
(
SCH_TASK_READY_TO_LUNCH
(
par
))
{
if
(
SCH_TASK_READY_TO_LUNCH
(
readyNum
,
par
))
{
SCH_ERR_RET
(
schLaunchTask
(
pJob
,
par
));
SCH_ERR_RET
(
schLaunchTask
(
pJob
,
par
));
}
}
}
}
...
@@ -1409,7 +1409,7 @@ int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryDag* pDa
...
@@ -1409,7 +1409,7 @@ int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryDag* pDa
}
}
int32_t
schedulerConvertDagToTaskList
(
SQueryDag
*
pDag
,
SArray
**
pTasks
)
{
int32_t
schedulerConvertDagToTaskList
(
SQueryDag
*
pDag
,
SArray
**
pTasks
)
{
if
(
NULL
==
pDag
||
pDag
->
numOfSubplans
<=
0
||
taosArrayGetSize
(
pDag
->
pSubplans
)
<
=
0
)
{
if
(
NULL
==
pDag
||
pDag
->
numOfSubplans
<=
0
||
taosArrayGetSize
(
pDag
->
pSubplans
)
=
=
0
)
{
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
}
...
@@ -1454,7 +1454,6 @@ int32_t schedulerConvertDagToTaskList(SQueryDag* pDag, SArray **pTasks) {
...
@@ -1454,7 +1454,6 @@ int32_t schedulerConvertDagToTaskList(SQueryDag* pDag, SArray **pTasks) {
}
}
SSubQueryMsg
*
pMsg
=
calloc
(
1
,
msgSize
);
SSubQueryMsg
*
pMsg
=
calloc
(
1
,
msgSize
);
memcpy
(
pMsg
->
msg
,
msg
,
msgLen
);
pMsg
->
header
.
vgId
=
tInfo
.
addr
.
nodeId
;
pMsg
->
header
.
vgId
=
tInfo
.
addr
.
nodeId
;
...
@@ -1464,6 +1463,7 @@ int32_t schedulerConvertDagToTaskList(SQueryDag* pDag, SArray **pTasks) {
...
@@ -1464,6 +1463,7 @@ int32_t schedulerConvertDagToTaskList(SQueryDag* pDag, SArray **pTasks) {
pMsg
->
taskType
=
TASK_TYPE_PERSISTENT
;
pMsg
->
taskType
=
TASK_TYPE_PERSISTENT
;
pMsg
->
phyLen
=
msgLen
;
pMsg
->
phyLen
=
msgLen
;
pMsg
->
sqlLen
=
0
;
pMsg
->
sqlLen
=
0
;
memcpy
(
pMsg
->
msg
,
msg
,
msgLen
);
/*memcpy(pMsg->msg, ((SSubQueryMsg*)msg)->msg, msgLen);*/
/*memcpy(pMsg->msg, ((SSubQueryMsg*)msg)->msg, msgLen);*/
tInfo
.
msg
=
pMsg
;
tInfo
.
msg
=
pMsg
;
...
...
source/libs/transport/inc/transComm.h
浏览文件 @
3b5828c0
...
@@ -213,6 +213,12 @@ typedef struct SConnBuffer {
...
@@ -213,6 +213,12 @@ typedef struct SConnBuffer {
typedef
void
(
*
AsyncCB
)(
uv_async_t
*
handle
);
typedef
void
(
*
AsyncCB
)(
uv_async_t
*
handle
);
typedef
struct
{
void
*
pThrd
;
queue
qmsg
;
pthread_mutex_t
mtx
;
// protect qmsg;
}
SAsyncItem
;
typedef
struct
{
typedef
struct
{
int
index
;
int
index
;
int
nAsync
;
int
nAsync
;
...
@@ -221,7 +227,7 @@ typedef struct {
...
@@ -221,7 +227,7 @@ typedef struct {
SAsyncPool
*
transCreateAsyncPool
(
uv_loop_t
*
loop
,
void
*
arg
,
AsyncCB
cb
);
SAsyncPool
*
transCreateAsyncPool
(
uv_loop_t
*
loop
,
void
*
arg
,
AsyncCB
cb
);
void
transDestroyAsyncPool
(
SAsyncPool
*
pool
);
void
transDestroyAsyncPool
(
SAsyncPool
*
pool
);
int
transSendAsync
(
SAsyncPool
*
pool
);
int
transSendAsync
(
SAsyncPool
*
pool
,
queue
*
mq
);
int
transInitBuffer
(
SConnBuffer
*
buf
);
int
transInitBuffer
(
SConnBuffer
*
buf
);
int
transClearBuffer
(
SConnBuffer
*
buf
);
int
transClearBuffer
(
SConnBuffer
*
buf
);
...
...
source/libs/transport/src/transCli.c
浏览文件 @
3b5828c0
...
@@ -432,14 +432,15 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -432,14 +432,15 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
}
}
}
}
static
void
clientAsyncCb
(
uv_async_t
*
handle
)
{
static
void
clientAsyncCb
(
uv_async_t
*
handle
)
{
SCliThrdObj
*
pThrd
=
handle
->
data
;
SAsyncItem
*
item
=
handle
->
data
;
SCliThrdObj
*
pThrd
=
item
->
pThrd
;
SCliMsg
*
pMsg
=
NULL
;
SCliMsg
*
pMsg
=
NULL
;
queue
wq
;
queue
wq
;
// batch process to avoid to lock/unlock frequently
// batch process to avoid to lock/unlock frequently
pthread_mutex_lock
(
&
pThrd
->
msgM
tx
);
pthread_mutex_lock
(
&
item
->
m
tx
);
QUEUE_MOVE
(
&
pThrd
->
msg
,
&
wq
);
QUEUE_MOVE
(
&
item
->
q
msg
,
&
wq
);
pthread_mutex_unlock
(
&
pThrd
->
msgM
tx
);
pthread_mutex_unlock
(
&
item
->
m
tx
);
int
count
=
0
;
int
count
=
0
;
while
(
!
QUEUE_IS_EMPTY
(
&
wq
))
{
while
(
!
QUEUE_IS_EMPTY
(
&
wq
))
{
...
@@ -548,11 +549,11 @@ static void clientSendQuit(SCliThrdObj* thrd) {
...
@@ -548,11 +549,11 @@ static void clientSendQuit(SCliThrdObj* thrd) {
SCliMsg
*
msg
=
calloc
(
1
,
sizeof
(
SCliMsg
));
SCliMsg
*
msg
=
calloc
(
1
,
sizeof
(
SCliMsg
));
msg
->
ctx
=
NULL
;
//
msg
->
ctx
=
NULL
;
//
pthread_mutex_lock
(
&
thrd
->
msgMtx
);
//
pthread_mutex_lock(&thrd->msgMtx);
QUEUE_PUSH
(
&
thrd
->
msg
,
&
msg
->
q
);
//
QUEUE_PUSH(&thrd->msg, &msg->q);
pthread_mutex_unlock
(
&
thrd
->
msgMtx
);
//
pthread_mutex_unlock(&thrd->msgMtx);
transSendAsync
(
thrd
->
asyncPool
);
transSendAsync
(
thrd
->
asyncPool
,
&
msg
->
q
);
// uv_async_send(thrd->cliAsync);
// uv_async_send(thrd->cliAsync);
}
}
void
taosCloseClient
(
void
*
arg
)
{
void
taosCloseClient
(
void
*
arg
)
{
...
@@ -598,14 +599,14 @@ void rpcSendRequest(void* shandle, const SEpSet* pEpSet, SRpcMsg* pMsg, int64_t*
...
@@ -598,14 +599,14 @@ void rpcSendRequest(void* shandle, const SEpSet* pEpSet, SRpcMsg* pMsg, int64_t*
SCliThrdObj
*
thrd
=
((
SClientObj
*
)
pRpc
->
tcphandle
)
->
pThreadObj
[
index
%
pRpc
->
numOfThreads
];
SCliThrdObj
*
thrd
=
((
SClientObj
*
)
pRpc
->
tcphandle
)
->
pThreadObj
[
index
%
pRpc
->
numOfThreads
];
pthread_mutex_lock
(
&
thrd
->
msgMtx
);
//
pthread_mutex_lock(&thrd->msgMtx);
QUEUE_PUSH
(
&
thrd
->
msg
,
&
cliMsg
->
q
);
//
QUEUE_PUSH(&thrd->msg, &cliMsg->q);
pthread_mutex_unlock
(
&
thrd
->
msgMtx
);
//
pthread_mutex_unlock(&thrd->msgMtx);
int
start
=
taosGetTimestampUs
();
//
int start = taosGetTimestampUs();
transSendAsync
(
thrd
->
asyncPool
);
transSendAsync
(
thrd
->
asyncPool
,
&
(
cliMsg
->
q
)
);
// uv_async_send(thrd->cliAsync);
// uv_async_send(thrd->cliAsync);
int
end
=
taosGetTimestampUs
()
-
start
;
//
int end = taosGetTimestampUs() - start;
// tError("client sent to rpc, time cost: %d", (int)end);
// tError("client sent to rpc, time cost: %d", (int)end);
}
}
#endif
#endif
source/libs/transport/src/transComm.c
浏览文件 @
3b5828c0
...
@@ -247,7 +247,7 @@ int transDestroyBuffer(SConnBuffer* buf) {
...
@@ -247,7 +247,7 @@ int transDestroyBuffer(SConnBuffer* buf) {
}
}
SAsyncPool
*
transCreateAsyncPool
(
uv_loop_t
*
loop
,
void
*
arg
,
AsyncCB
cb
)
{
SAsyncPool
*
transCreateAsyncPool
(
uv_loop_t
*
loop
,
void
*
arg
,
AsyncCB
cb
)
{
static
int
sz
=
2
0
;
static
int
sz
=
1
0
;
SAsyncPool
*
pool
=
calloc
(
1
,
sizeof
(
SAsyncPool
));
SAsyncPool
*
pool
=
calloc
(
1
,
sizeof
(
SAsyncPool
));
pool
->
index
=
0
;
pool
->
index
=
0
;
...
@@ -257,24 +257,46 @@ SAsyncPool* transCreateAsyncPool(uv_loop_t* loop, void* arg, AsyncCB cb) {
...
@@ -257,24 +257,46 @@ SAsyncPool* transCreateAsyncPool(uv_loop_t* loop, void* arg, AsyncCB cb) {
for
(
int
i
=
0
;
i
<
pool
->
nAsync
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pool
->
nAsync
;
i
++
)
{
uv_async_t
*
async
=
&
(
pool
->
asyncs
[
i
]);
uv_async_t
*
async
=
&
(
pool
->
asyncs
[
i
]);
uv_async_init
(
loop
,
async
,
cb
);
uv_async_init
(
loop
,
async
,
cb
);
async
->
data
=
arg
;
SAsyncItem
*
item
=
calloc
(
1
,
sizeof
(
SAsyncItem
));
item
->
pThrd
=
arg
;
QUEUE_INIT
(
&
item
->
qmsg
);
pthread_mutex_init
(
&
item
->
mtx
,
NULL
);
async
->
data
=
item
;
}
}
return
pool
;
return
pool
;
}
}
void
transDestroyAsyncPool
(
SAsyncPool
*
pool
)
{
void
transDestroyAsyncPool
(
SAsyncPool
*
pool
)
{
for
(
int
i
=
0
;
i
<
pool
->
nAsync
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pool
->
nAsync
;
i
++
)
{
uv_async_t
*
async
=
&
(
pool
->
asyncs
[
i
]);
uv_async_t
*
async
=
&
(
pool
->
asyncs
[
i
]);
SAsyncItem
*
item
=
async
->
data
;
pthread_mutex_destroy
(
&
item
->
mtx
);
free
(
item
);
}
}
free
(
pool
->
asyncs
);
free
(
pool
->
asyncs
);
free
(
pool
);
free
(
pool
);
}
}
int
transSendAsync
(
SAsyncPool
*
pool
)
{
int
transSendAsync
(
SAsyncPool
*
pool
,
queue
*
q
)
{
int
idx
=
pool
->
index
;
int
idx
=
pool
->
index
;
idx
=
idx
%
pool
->
nAsync
;
idx
=
idx
%
pool
->
nAsync
;
// no need mutex here
// no need mutex here
if
(
pool
->
index
++
>
pool
->
nAsync
)
{
if
(
pool
->
index
++
>
pool
->
nAsync
)
{
pool
->
index
=
0
;
pool
->
index
=
0
;
}
}
return
uv_async_send
(
&
(
pool
->
asyncs
[
idx
]));
uv_async_t
*
async
=
&
(
pool
->
asyncs
[
idx
]);
SAsyncItem
*
item
=
async
->
data
;
int64_t
st
=
taosGetTimestampUs
();
pthread_mutex_lock
(
&
item
->
mtx
);
QUEUE_PUSH
(
&
item
->
qmsg
,
q
);
pthread_mutex_unlock
(
&
item
->
mtx
);
int64_t
el
=
taosGetTimestampUs
()
-
st
;
if
(
el
>
50
)
{
// tInfo("lock and unlock cost: %d", (int)el);
}
return
uv_async_send
(
async
);
}
}
#endif
#endif
source/libs/transport/src/transSrv.c
浏览文件 @
3b5828c0
...
@@ -376,13 +376,15 @@ static void destroySmsg(SSrvMsg* smsg) {
...
@@ -376,13 +376,15 @@ static void destroySmsg(SSrvMsg* smsg) {
free
(
smsg
);
free
(
smsg
);
}
}
void
uvWorkerAsyncCb
(
uv_async_t
*
handle
)
{
void
uvWorkerAsyncCb
(
uv_async_t
*
handle
)
{
SWorkThrdObj
*
pThrd
=
handle
->
data
;
SAsyncItem
*
item
=
handle
->
data
;
SWorkThrdObj
*
pThrd
=
item
->
pThrd
;
SSrvConn
*
conn
=
NULL
;
SSrvConn
*
conn
=
NULL
;
queue
wq
;
queue
wq
;
// batch process to avoid to lock/unlock frequently
// batch process to avoid to lock/unlock frequently
pthread_mutex_lock
(
&
pThrd
->
msgMtx
);
pthread_mutex_lock
(
&
item
->
mtx
);
QUEUE_MOVE
(
&
pThrd
->
msg
,
&
wq
);
QUEUE_MOVE
(
&
item
->
qmsg
,
&
wq
);
pthread_mutex_unlock
(
&
pThrd
->
msgMtx
);
pthread_mutex_unlock
(
&
item
->
mtx
);
// pthread_mutex_unlock(&mtx);
while
(
!
QUEUE_IS_EMPTY
(
&
wq
))
{
while
(
!
QUEUE_IS_EMPTY
(
&
wq
))
{
queue
*
head
=
QUEUE_HEAD
(
&
wq
);
queue
*
head
=
QUEUE_HEAD
(
&
wq
);
...
@@ -539,7 +541,7 @@ static bool addHandleToAcceptloop(void* arg) {
...
@@ -539,7 +541,7 @@ static bool addHandleToAcceptloop(void* arg) {
tError
(
"failed to bind: %s"
,
uv_err_name
(
err
));
tError
(
"failed to bind: %s"
,
uv_err_name
(
err
));
return
false
;
return
false
;
}
}
if
((
err
=
uv_listen
((
uv_stream_t
*
)
&
srv
->
server
,
128
,
uvOnAcceptCb
))
!=
0
)
{
if
((
err
=
uv_listen
((
uv_stream_t
*
)
&
srv
->
server
,
512
,
uvOnAcceptCb
))
!=
0
)
{
tError
(
"failed to listen: %s"
,
uv_err_name
(
err
));
tError
(
"failed to listen: %s"
,
uv_err_name
(
err
));
return
false
;
return
false
;
}
}
...
@@ -671,12 +673,12 @@ void destroyWorkThrd(SWorkThrdObj* pThrd) {
...
@@ -671,12 +673,12 @@ void destroyWorkThrd(SWorkThrdObj* pThrd) {
void
sendQuitToWorkThrd
(
SWorkThrdObj
*
pThrd
)
{
void
sendQuitToWorkThrd
(
SWorkThrdObj
*
pThrd
)
{
SSrvMsg
*
srvMsg
=
calloc
(
1
,
sizeof
(
SSrvMsg
));
SSrvMsg
*
srvMsg
=
calloc
(
1
,
sizeof
(
SSrvMsg
));
pthread_mutex_lock
(
&
pThrd
->
msgMtx
);
//
pthread_mutex_lock(&pThrd->msgMtx);
QUEUE_PUSH
(
&
pThrd
->
msg
,
&
srvMsg
->
q
);
//
QUEUE_PUSH(&pThrd->msg, &srvMsg->q);
pthread_mutex_unlock
(
&
pThrd
->
msgMtx
);
//
pthread_mutex_unlock(&pThrd->msgMtx);
tDebug
(
"send quit msg to work thread"
);
tDebug
(
"send quit msg to work thread"
);
transSendAsync
(
pThrd
->
asyncPool
);
transSendAsync
(
pThrd
->
asyncPool
,
&
srvMsg
->
q
);
// uv_async_send(pThrd->workerAsync);
// uv_async_send(pThrd->workerAsync);
}
}
...
@@ -712,12 +714,12 @@ void rpcSendResponse(const SRpcMsg* pMsg) {
...
@@ -712,12 +714,12 @@ void rpcSendResponse(const SRpcMsg* pMsg) {
srvMsg
->
pConn
=
pConn
;
srvMsg
->
pConn
=
pConn
;
srvMsg
->
msg
=
*
pMsg
;
srvMsg
->
msg
=
*
pMsg
;
pthread_mutex_lock
(
&
pThrd
->
msgMtx
);
//
pthread_mutex_lock(&pThrd->msgMtx);
QUEUE_PUSH
(
&
pThrd
->
msg
,
&
srvMsg
->
q
);
//
QUEUE_PUSH(&pThrd->msg, &srvMsg->q);
pthread_mutex_unlock
(
&
pThrd
->
msgMtx
);
//
pthread_mutex_unlock(&pThrd->msgMtx);
tDebug
(
"conn %p start to send resp"
,
pConn
);
tDebug
(
"conn %p start to send resp"
,
pConn
);
transSendAsync
(
pThrd
->
asyncPool
);
transSendAsync
(
pThrd
->
asyncPool
,
&
srvMsg
->
q
);
// uv_async_send(pThrd->workerAsync);
// uv_async_send(pThrd->workerAsync);
}
}
...
...
source/nodes/src/nodesTraverseFuncs.c
浏览文件 @
3b5828c0
...
@@ -15,68 +15,101 @@
...
@@ -15,68 +15,101 @@
#include "nodes.h"
#include "nodes.h"
typedef
bool
(
*
FQueryNodeWalker
)(
SNode
*
pNode
,
void
*
pContext
);
typedef
enum
ETraversalOrder
{
TRAVERSAL_PREORDER
=
1
,
TRAVERSAL_POSTORDER
}
ETraversalOrder
;
bool
nodesWalkNodeList
(
SNodeList
*
pNodeList
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
static
bool
walkList
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FQueryNodeWalker
walker
,
void
*
pContext
);
SNode
*
node
;
FOREACH
(
node
,
pNodeList
)
{
if
(
!
nodesWalkNode
(
node
,
walker
,
pContext
))
{
return
false
;
}
}
return
true
;
}
bool
nodesWalkNode
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
static
bool
walkNode
(
SNode
*
pNode
,
ETraversalOrder
order
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
if
(
NULL
==
pNode
)
{
if
(
NULL
==
pNode
)
{
return
true
;
return
true
;
}
}
if
(
!
walker
(
pNode
,
pContext
))
{
if
(
TRAVERSAL_PREORDER
==
order
&&
!
walker
(
pNode
,
pContext
))
{
return
false
;
return
false
;
}
}
bool
res
=
true
;
switch
(
nodeType
(
pNode
))
{
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
case
QUERY_NODE_COLUMN
:
case
QUERY_NODE_VALUE
:
case
QUERY_NODE_VALUE
:
case
QUERY_NODE_LIMIT
:
case
QUERY_NODE_LIMIT
:
// these node types with no subnodes
// these node types with no subnodes
return
true
;
break
;
case
QUERY_NODE_OPERATOR
:
{
case
QUERY_NODE_OPERATOR
:
{
SOperatorNode
*
pOpNode
=
(
SOperatorNode
*
)
pNode
;
SOperatorNode
*
pOpNode
=
(
SOperatorNode
*
)
pNode
;
if
(
!
nodesWalkNode
(
pOpNode
->
pLeft
,
walker
,
pContext
))
{
res
=
walkNode
(
pOpNode
->
pLeft
,
order
,
walker
,
pContext
);
return
false
;
if
(
res
)
{
res
=
walkNode
(
pOpNode
->
pRight
,
order
,
walker
,
pContext
);
}
}
return
nodesWalkNode
(
pOpNode
->
pRight
,
walker
,
pContext
)
;
break
;
}
}
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_LOGIC_CONDITION
:
return
nodesWalkNodeList
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
,
walker
,
pContext
);
res
=
walkList
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_IS_NULL_CONDITION
:
case
QUERY_NODE_IS_NULL_CONDITION
:
return
nodesWalkNode
(((
SIsNullCondNode
*
)
pNode
)
->
pExpr
,
walker
,
pContext
);
res
=
walkNode
(((
SIsNullCondNode
*
)
pNode
)
->
pExpr
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_FUNCTION
:
case
QUERY_NODE_FUNCTION
:
return
nodesWalkNodeList
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
,
walker
,
pContext
);
res
=
walkList
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_REAL_TABLE
:
case
QUERY_NODE_REAL_TABLE
:
case
QUERY_NODE_TEMP_TABLE
:
case
QUERY_NODE_TEMP_TABLE
:
return
true
;
// todo
break
;
// todo
case
QUERY_NODE_JOIN_TABLE
:
{
case
QUERY_NODE_JOIN_TABLE
:
{
SJoinTableNode
*
pJoinTableNode
=
(
SJoinTableNode
*
)
pNode
;
SJoinTableNode
*
pJoinTableNode
=
(
SJoinTableNode
*
)
pNode
;
if
(
!
nodesWalkNode
(
pJoinTableNode
->
pLeft
,
walker
,
pContext
))
{
res
=
walkNode
(
pJoinTableNode
->
pLeft
,
order
,
walker
,
pContext
);
return
false
;
if
(
res
)
{
res
=
walkNode
(
pJoinTableNode
->
pRight
,
order
,
walker
,
pContext
);
}
}
if
(
!
nodesWalkNode
(
pJoinTableNode
->
pRight
,
walker
,
pContext
)
)
{
if
(
res
)
{
re
turn
false
;
re
s
=
walkNode
(
pJoinTableNode
->
pOnCond
,
order
,
walker
,
pContext
)
;
}
}
return
nodesWalkNode
(
pJoinTableNode
->
pOnCond
,
walker
,
pContext
)
;
break
;
}
}
case
QUERY_NODE_GROUPING_SET
:
case
QUERY_NODE_GROUPING_SET
:
return
nodesWalkNodeList
(((
SGroupingSetNode
*
)
pNode
)
->
pParameterList
,
walker
,
pContext
);
res
=
walkList
(((
SGroupingSetNode
*
)
pNode
)
->
pParameterList
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_ORDER_BY_EXPR
:
return
nodesWalkNode
(((
SOrderByExprNode
*
)
pNode
)
->
pExpr
,
walker
,
pContext
);
res
=
walkNode
(((
SOrderByExprNode
*
)
pNode
)
->
pExpr
,
order
,
walker
,
pContext
);
break
;
default:
default:
break
;
break
;
}
}
if
(
res
&&
TRAVERSAL_POSTORDER
==
order
)
{
res
=
walker
(
pNode
,
pContext
);
}
return
res
;
}
static
bool
walkList
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
SNode
*
node
;
FOREACH
(
node
,
pNodeList
)
{
if
(
!
walkNode
(
node
,
order
,
walker
,
pContext
))
{
return
false
;
return
false
;
}
}
return
true
;
}
void
nodesWalkNode
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
(
void
)
walkNode
(
pNode
,
TRAVERSAL_PREORDER
,
walker
,
pContext
);
}
void
nodesWalkList
(
SNodeList
*
pNodeList
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
(
void
)
walkList
(
pNodeList
,
TRAVERSAL_PREORDER
,
walker
,
pContext
);
}
void
nodesWalkNodePostOrder
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
(
void
)
walkNode
(
pNode
,
TRAVERSAL_POSTORDER
,
walker
,
pContext
);
}
void
nodesWalkListPostOrder
(
SNodeList
*
pList
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
(
void
)
walkList
(
pList
,
TRAVERSAL_PREORDER
,
walker
,
pContext
);
}
}
bool
nodesWalkStmt
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
bool
nodesWalkStmt
(
SNode
*
pNode
,
FQueryNodeWalker
walker
,
void
*
pContext
)
{
...
...
tests/parallel_test/Jenkinsfile
0 → 100644
浏览文件 @
3b5828c0
import
hudson.model.Result
import
hudson.model.*
;
import
jenkins.model.CauseOfInterruption
node
{
}
def
skipbuild
=
0
def
win_stop
=
0
def
abortPreviousBuilds
()
{
def
currentJobName
=
env
.
JOB_NAME
def
currentBuildNumber
=
env
.
BUILD_NUMBER
.
toInteger
()
def
jobs
=
Jenkins
.
instance
.
getItemByFullName
(
currentJobName
)
def
builds
=
jobs
.
getBuilds
()
for
(
build
in
builds
)
{
if
(!
build
.
isBuilding
())
{
continue
;
}
if
(
currentBuildNumber
==
build
.
getNumber
().
toInteger
())
{
continue
;
}
build
.
doKill
()
//doTerm(),doKill(),doTerm()
}
}
// abort previous build
abortPreviousBuilds
()
def
abort_previous
(){
def
buildNumber
=
env
.
BUILD_NUMBER
as
int
if
(
buildNumber
>
1
)
milestone
(
buildNumber
-
1
)
milestone
(
buildNumber
)
}
def
pre_test
(){
sh
'hostname'
sh
'''
sudo rmtaos || echo "taosd has not installed"
'''
sh
'''
killall -9 taosd ||echo "no taosd running"
killall -9 gdb || echo "no gdb running"
killall -9 python3.8 || echo "no python program running"
cd ${WKC}
'''
script
{
if
(
env
.
CHANGE_TARGET
==
'master'
)
{
sh
'''
cd ${WKC}
git checkout master
'''
}
else
if
(
env
.
CHANGE_TARGET
==
'2.0'
){
sh
'''
cd ${WKC}
git checkout 2.0
'''
}
else
if
(
env
.
CHANGE_TARGET
==
'3.0'
){
sh
'''
cd ${WKC}
git checkout 3.0
'''
}
else
{
sh
'''
cd ${WKC}
git checkout develop
'''
}
}
sh
'''
cd ${WKC}
git pull >/dev/null
git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD
export TZ=Asia/Harbin
date
rm -rf debug
mkdir debug
cd debug
cmake .. > /dev/null
make -j4> /dev/null
'''
return
1
}
pipeline
{
agent
none
options
{
skipDefaultCheckout
()
}
environment
{
WK
=
'/var/lib/jenkins/workspace/TDinternal'
WKC
=
'/var/lib/jenkins/workspace/TDengine'
}
stages
{
stage
(
'pre_build'
){
agent
{
label
'slave3_0'
}
options
{
skipDefaultCheckout
()
}
when
{
changeRequest
()
}
steps
{
script
{
abort_previous
()
abortPreviousBuilds
()
}
timeout
(
time:
45
,
unit:
'MINUTES'
){
pre_test
()
sh
'''
cd ${WKC}/tests
./test-all.sh b1fq
'''
sh
'''
cd ${WKC}/debug
ctest
'''
}
}
}
}
post
{
success
{
emailext
(
subject:
"PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' SUCCESS"
,
body:
"""<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0">
<table width="95%" cellpadding="0" cellspacing="0" style="font-size: 16pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<td><br />
<b><font color="#0B610B"><font size="6">构建信息</font></font></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<div style="font-size:18px">
<li>构建名称>>分支:${env.BRANCH_NAME}</li>
<li>构建结果:<span style="color:green"> Successful </span></li>
<li>构建编号:${BUILD_NUMBER}</li>
<li>触发用户:${env.CHANGE_AUTHOR}</li>
<li>提交信息:${env.CHANGE_TITLE}</li>
<li>构建地址:<a href=${BUILD_URL}>${BUILD_URL}</a></li>
<li>构建日志:<a href=${BUILD_URL}console>${BUILD_URL}console</a></li>
</div>
</ul>
</td>
</tr>
</table></font>
</body>
</html>"""
,
to:
"${env.CHANGE_AUTHOR_EMAIL}"
,
from:
"support@taosdata.com"
)
}
failure
{
emailext
(
subject:
"PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' FAIL"
,
body:
"""<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0">
<table width="95%" cellpadding="0" cellspacing="0" style="font-size: 16pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>
<td><br />
<b><font color="#0B610B"><font size="6">构建信息</font></font></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<div style="font-size:18px">
<li>构建名称>>分支:${env.BRANCH_NAME}</li>
<li>构建结果:<span style="color:red"> Failure </span></li>
<li>构建编号:${BUILD_NUMBER}</li>
<li>触发用户:${env.CHANGE_AUTHOR}</li>
<li>提交信息:${env.CHANGE_TITLE}</li>
<li>构建地址:<a href=${BUILD_URL}>${BUILD_URL}</a></li>
<li>构建日志:<a href=${BUILD_URL}console>${BUILD_URL}console</a></li>
</div>
</ul>
</td>
</tr>
</table></font>
</body>
</html>"""
,
to:
"${env.CHANGE_AUTHOR_EMAIL}"
,
from:
"support@taosdata.com"
)
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录