Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
be2935cb
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看板
提交
be2935cb
编写于
6月 20, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: show create table
上级
88aff7ba
变更
29
隐藏空白更改
内联
并排
Showing
29 changed file
with
781 addition
and
35 deletion
+781
-35
include/common/tmsg.h
include/common/tmsg.h
+7
-3
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+2
-0
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+5
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+1
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+128
-2
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+5
-0
source/dnode/mnode/impl/inc/mndInfoSchema.h
source/dnode/mnode/impl/inc/mndInfoSchema.h
+1
-0
source/dnode/mnode/impl/inc/mndPerfSchema.h
source/dnode/mnode/impl/inc/mndPerfSchema.h
+1
-0
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+32
-0
source/dnode/mnode/impl/src/mndPerfSchema.c
source/dnode/mnode/impl/src/mndPerfSchema.c
+31
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+144
-0
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+1
-0
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+18
-5
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+2
-0
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+9
-2
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+2
-1
source/libs/catalog/src/ctgRemote.c
source/libs/catalog/src/ctgRemote.c
+35
-2
source/libs/command/src/command.c
source/libs/command/src/command.c
+221
-4
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-1
source/libs/parser/inc/parUtil.h
source/libs/parser/inc/parUtil.h
+2
-2
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+8
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+19
-4
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+23
-2
source/libs/parser/test/parShowToUse.cpp
source/libs/parser/test/parShowToUse.cpp
+2
-2
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+78
-0
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+0
-3
source/util/src/terror.c
source/util/src/terror.c
+1
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
be2935cb
...
@@ -444,6 +444,7 @@ typedef struct {
...
@@ -444,6 +444,7 @@ typedef struct {
char
*
comment
;
char
*
comment
;
char
*
pAst1
;
char
*
pAst1
;
char
*
pAst2
;
char
*
pAst2
;
SArray
*
pFuncs
;
}
SMCreateStbReq
;
}
SMCreateStbReq
;
int32_t
tSerializeSMCreateStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateStbReq
*
pReq
);
int32_t
tSerializeSMCreateStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateStbReq
*
pReq
);
...
@@ -685,9 +686,12 @@ typedef struct {
...
@@ -685,9 +686,12 @@ typedef struct {
int64_t
watermark1
;
int64_t
watermark1
;
int64_t
watermark2
;
int64_t
watermark2
;
int32_t
ttl
;
int32_t
ttl
;
char
*
pAst1
;
SArray
*
pFuncs
;
char
*
pAst2
;
int32_t
commentLen
;
char
*
pComment
;
SSchema
*
pSchemas
;
SSchema
*
pSchemas
;
int32_t
tagsLen
;
char
*
pTags
;
}
STableCfg
;
}
STableCfg
;
typedef
STableCfg
STableCfgRsp
;
typedef
STableCfg
STableCfgRsp
;
...
@@ -697,7 +701,7 @@ int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq);
...
@@ -697,7 +701,7 @@ int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq);
int32_t
tSerializeSTableCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
STableCfgRsp
*
pRsp
);
int32_t
tSerializeSTableCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
STableCfgRsp
*
pRsp
);
int32_t
tDeserializeSTableCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
STableCfgRsp
*
pRsp
);
int32_t
tDeserializeSTableCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
STableCfgRsp
*
pRsp
);
void
tFreeSTableCfgRsp
(
STableCfgRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
...
...
include/libs/catalog/catalog.h
浏览文件 @
be2935cb
...
@@ -282,6 +282,8 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
...
@@ -282,6 +282,8 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
);
int32_t
catalogGetTableIndex
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pRes
);
int32_t
catalogRefreshGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
);
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
);
int32_t
catalogUpdateTableIndex
(
SCatalog
*
pCtg
,
STableIndexRsp
*
pRsp
);
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
);
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
);
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
be2935cb
...
@@ -32,6 +32,11 @@ extern "C" {
...
@@ -32,6 +32,11 @@ extern "C" {
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_TB_RESULT_COLS 2
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE)
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
#define PRIVILEGE_TYPE_MASK(n) (1 << n)
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0)
...
...
include/libs/qcom/query.h
浏览文件 @
be2935cb
...
@@ -207,6 +207,7 @@ char* jobTaskStatusStr(int32_t status);
...
@@ -207,6 +207,7 @@ char* jobTaskStatusStr(int32_t status);
SSchema
createSchema
(
int8_t
type
,
int32_t
bytes
,
col_id_t
colId
,
const
char
*
name
);
SSchema
createSchema
(
int8_t
type
,
int32_t
bytes
,
col_id_t
colId
,
const
char
*
name
);
void
destroyQueryExecRes
(
SQueryExecRes
*
pRes
);
void
destroyQueryExecRes
(
SQueryExecRes
*
pRes
);
int32_t
dataConverToStr
(
char
*
str
,
int
type
,
void
*
buf
,
int32_t
bufSize
,
int32_t
*
len
);
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
,
void
*
(
*
mallocFp
)(
int32_t
));
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
,
void
*
(
*
mallocFp
)(
int32_t
));
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
...
...
include/util/taoserror.h
浏览文件 @
be2935cb
...
@@ -129,6 +129,7 @@ int32_t* taosGetErrno();
...
@@ -129,6 +129,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TSC_STMT_CLAUSE_ERROR TAOS_DEF_ERROR_CODE(0, 0X0227)
#define TSDB_CODE_TSC_STMT_CLAUSE_ERROR TAOS_DEF_ERROR_CODE(0, 0X0227)
#define TSDB_CODE_TSC_QUERY_KILLED TAOS_DEF_ERROR_CODE(0, 0X0228)
#define TSDB_CODE_TSC_QUERY_KILLED TAOS_DEF_ERROR_CODE(0, 0X0228)
#define TSDB_CODE_TSC_NO_EXEC_NODE TAOS_DEF_ERROR_CODE(0, 0X0229)
#define TSDB_CODE_TSC_NO_EXEC_NODE TAOS_DEF_ERROR_CODE(0, 0X0229)
#define TSDB_CODE_TSC_NOT_STABLE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022a)
// mnode-common
// mnode-common
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300)
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300)
...
...
source/client/inc/clientInt.h
浏览文件 @
be2935cb
...
@@ -46,7 +46,7 @@ extern "C" {
...
@@ -46,7 +46,7 @@ extern "C" {
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
#define HEARTBEAT_INTERVAL 1500 // ms
#define HEARTBEAT_INTERVAL 1500 // ms
#define SYNC_ON_TOP_OF_ASYNC
1
#define SYNC_ON_TOP_OF_ASYNC
0
enum
{
enum
{
RES_TYPE__QUERY
=
1
,
RES_TYPE__QUERY
=
1
,
...
...
source/common/src/tmsg.c
浏览文件 @
be2935cb
...
@@ -532,6 +532,14 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -532,6 +532,14 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
pReq
->
ast2Len
>
0
)
{
if
(
pReq
->
ast2Len
>
0
)
{
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
pAst2
,
pReq
->
ast2Len
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
pAst2
,
pReq
->
ast2Len
)
<
0
)
return
-
1
;
}
}
int32_t
numOfFuncs
=
taosArrayGetSize
(
pReq
->
pFuncs
);
if
(
tEncodeI32
(
&
encoder
,
numOfFuncs
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
const
char
*
pFunc
=
taosArrayGet
(
pReq
->
pFuncs
,
i
);
if
(
tEncodeCStr
(
&
encoder
,
pFunc
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -606,6 +614,21 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -606,6 +614,21 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pAst2
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pAst2
)
<
0
)
return
-
1
;
}
}
int32_t
numOfFuncs
=
0
;
if
(
tDecodeI32
(
&
decoder
,
&
numOfFuncs
)
<
0
)
return
-
1
;
if
(
numOfFuncs
>
0
)
{
pReq
->
pFuncs
=
taosArrayInit
(
numOfFuncs
,
TSDB_FUNC_NAME_LEN
);
if
(
NULL
==
pReq
->
pFuncs
)
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
char
*
pFunc
=
NULL
;
if
(
tDecodeCStrAlloc
(
&
decoder
,
&
pFunc
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pFuncs
,
pFunc
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
@@ -618,8 +641,7 @@ void tFreeSMCreateStbReq(SMCreateStbReq *pReq) {
...
@@ -618,8 +641,7 @@ void tFreeSMCreateStbReq(SMCreateStbReq *pReq) {
taosMemoryFreeClear
(
pReq
->
comment
);
taosMemoryFreeClear
(
pReq
->
comment
);
taosMemoryFreeClear
(
pReq
->
pAst1
);
taosMemoryFreeClear
(
pReq
->
pAst1
);
taosMemoryFreeClear
(
pReq
->
pAst2
);
taosMemoryFreeClear
(
pReq
->
pAst2
);
pReq
->
pColumns
=
NULL
;
taosArrayDestroy
(
pReq
->
pFuncs
);
pReq
->
pTags
=
NULL
;
}
}
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
...
@@ -1804,13 +1826,117 @@ int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq)
...
@@ -1804,13 +1826,117 @@ int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq)
}
}
int32_t
tSerializeSTableCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
STableCfgRsp
*
pRsp
)
{
int32_t
tSerializeSTableCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
STableCfgRsp
*
pRsp
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pRsp
->
tbName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pRsp
->
stbName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pRsp
->
dbFName
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRsp
->
tableType
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
delay1
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
delay2
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
watermark1
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pRsp
->
watermark2
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
ttl
)
<
0
)
return
-
1
;
int32_t
numOfFuncs
=
taosArrayGetSize
(
pRsp
->
pFuncs
);
if
(
tEncodeI32
(
&
encoder
,
numOfFuncs
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
const
char
*
pFunc
=
taosArrayGet
(
pRsp
->
pFuncs
,
i
);
if
(
tEncodeCStr
(
&
encoder
,
pFunc
)
<
0
)
return
-
1
;
}
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
commentLen
)
<
0
)
return
-
1
;
if
(
pRsp
->
commentLen
>
0
)
{
if
(
tEncodeCStr
(
&
encoder
,
pRsp
->
pComment
)
<
0
)
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfColumns
+
pRsp
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
];
if
(
tEncodeSSchema
(
&
encoder
,
pSchema
)
<
0
)
return
-
1
;
}
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
tagsLen
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
&
encoder
,
pRsp
->
pTags
,
pRsp
->
tagsLen
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
}
int32_t
tDeserializeSTableCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
STableCfgRsp
*
pRsp
)
{
int32_t
tDeserializeSTableCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
STableCfgRsp
*
pRsp
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pRsp
->
tbName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pRsp
->
stbName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pRsp
->
dbFName
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
tableType
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pRsp
->
delay1
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pRsp
->
delay2
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pRsp
->
watermark1
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pRsp
->
watermark2
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
ttl
)
<
0
)
return
-
1
;
int32_t
numOfFuncs
=
0
;
if
(
tDecodeI32
(
&
decoder
,
&
numOfFuncs
)
<
0
)
return
-
1
;
if
(
numOfFuncs
>
0
)
{
pRsp
->
pFuncs
=
taosArrayInit
(
numOfFuncs
,
TSDB_FUNC_NAME_LEN
);
if
(
NULL
==
pRsp
->
pFuncs
)
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
char
pFunc
[
TSDB_FUNC_NAME_LEN
];
if
(
tDecodeCStrTo
(
&
decoder
,
pFunc
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pRsp
->
pFuncs
,
pFunc
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
commentLen
)
<
0
)
return
-
1
;
if
(
pRsp
->
commentLen
>
0
)
{
if
(
tDecodeCStrAlloc
(
&
decoder
,
&
pRsp
->
pComment
)
<
0
)
return
-
1
;
}
else
{
pRsp
->
pComment
=
NULL
;
}
int32_t
totalCols
=
pRsp
->
numOfTags
+
pRsp
->
numOfColumns
;
pRsp
->
pSchemas
=
taosMemoryMalloc
(
sizeof
(
SSchema
)
*
totalCols
);
if
(
pRsp
->
pSchemas
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
];
if
(
tDecodeSSchema
(
&
decoder
,
pSchema
)
<
0
)
return
-
1
;
}
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
tagsLen
)
<
0
)
return
-
1
;
if
(
tDecodeBinaryAlloc
(
&
decoder
,
&
pRsp
->
pTags
,
NULL
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
}
void
tFreeSTableCfgRsp
(
STableCfgRsp
*
pRsp
)
{
if
(
NULL
==
pRsp
)
{
return
;
}
taosMemoryFreeClear
(
pRsp
->
pComment
);
taosMemoryFreeClear
(
pRsp
->
pSchemas
);
taosMemoryFreeClear
(
pRsp
->
pTags
);
taosArrayDestroy
(
pRsp
->
pFuncs
);
}
int32_t
tSerializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
)
{
int32_t
tSerializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
SEncoder
encoder
=
{
0
};
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
be2935cb
...
@@ -343,12 +343,17 @@ typedef struct {
...
@@ -343,12 +343,17 @@ typedef struct {
int32_t
nextColId
;
int32_t
nextColId
;
float
xFilesFactor
;
float
xFilesFactor
;
int32_t
delay
;
int32_t
delay
;
int32_t
delay1
;
int32_t
delay2
;
int64_t
watermark1
;
int64_t
watermark2
;
int32_t
ttl
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
commentLen
;
int32_t
commentLen
;
int32_t
ast1Len
;
int32_t
ast1Len
;
int32_t
ast2Len
;
int32_t
ast2Len
;
SArray
*
pFuncs
;
SSchema
*
pColumns
;
SSchema
*
pColumns
;
SSchema
*
pTags
;
SSchema
*
pTags
;
char
*
comment
;
char
*
comment
;
...
...
source/dnode/mnode/impl/inc/mndInfoSchema.h
浏览文件 @
be2935cb
...
@@ -25,6 +25,7 @@ extern "C" {
...
@@ -25,6 +25,7 @@ extern "C" {
int32_t
mndInitInfos
(
SMnode
*
pMnode
);
int32_t
mndInitInfos
(
SMnode
*
pMnode
);
void
mndCleanupInfos
(
SMnode
*
pMnode
);
void
mndCleanupInfos
(
SMnode
*
pMnode
);
int32_t
mndBuildInsTableSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
);
int32_t
mndBuildInsTableSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
);
int32_t
mndBuildInsTableCfg
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableCfgRsp
*
pRsp
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/inc/mndPerfSchema.h
浏览文件 @
be2935cb
...
@@ -23,6 +23,7 @@ extern "C" {
...
@@ -23,6 +23,7 @@ extern "C" {
#endif
#endif
int32_t
mndBuildPerfsTableSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
);
int32_t
mndBuildPerfsTableSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
);
int32_t
mndBuildPerfsTableCfg
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableCfgRsp
*
pRsp
);
int32_t
mndInitPerfs
(
SMnode
*
pMnode
);
int32_t
mndInitPerfs
(
SMnode
*
pMnode
);
void
mndCleanupPerfs
(
SMnode
*
pMnode
);
void
mndCleanupPerfs
(
SMnode
*
pMnode
);
...
...
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
be2935cb
...
@@ -90,6 +90,38 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
...
@@ -90,6 +90,38 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
return
0
;
return
0
;
}
}
int32_t
mndBuildInsTableCfg
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableCfgRsp
*
pRsp
)
{
if
(
NULL
==
pMnode
->
infosMeta
)
{
terrno
=
TSDB_CODE_MND_NOT_READY
;
return
-
1
;
}
STableMetaRsp
*
pMeta
=
taosHashGet
(
pMnode
->
infosMeta
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
pMeta
)
{
mError
(
"invalid information schema table name:%s"
,
tbName
);
terrno
=
TSDB_CODE_MND_INVALID_SYS_TABLENAME
;
return
-
1
;
}
strcpy
(
pRsp
->
tbName
,
pMeta
->
tbName
);
strcpy
(
pRsp
->
stbName
,
pMeta
->
stbName
);
strcpy
(
pRsp
->
dbFName
,
pMeta
->
dbFName
);
pRsp
->
numOfTags
=
pMeta
->
numOfTags
;
pRsp
->
numOfColumns
=
pMeta
->
numOfColumns
;
pRsp
->
tableType
=
pMeta
->
tableType
;
pRsp
->
pSchemas
=
taosMemoryCalloc
(
pMeta
->
numOfColumns
,
sizeof
(
SSchema
));
if
(
pRsp
->
pSchemas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
pRsp
->
pSchemas
=
NULL
;
return
-
1
;
}
memcpy
(
pRsp
->
pSchemas
,
pMeta
->
pSchemas
,
pMeta
->
numOfColumns
*
sizeof
(
SSchema
));
return
0
;
}
int32_t
mndInitInfos
(
SMnode
*
pMnode
)
{
int32_t
mndInitInfos
(
SMnode
*
pMnode
)
{
pMnode
->
infosMeta
=
taosHashInit
(
20
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_VARCHAR
),
false
,
HASH_NO_LOCK
);
pMnode
->
infosMeta
=
taosHashInit
(
20
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_VARCHAR
),
false
,
HASH_NO_LOCK
);
if
(
pMnode
->
infosMeta
==
NULL
)
{
if
(
pMnode
->
infosMeta
==
NULL
)
{
...
...
source/dnode/mnode/impl/src/mndPerfSchema.c
浏览文件 @
be2935cb
...
@@ -92,6 +92,37 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char
...
@@ -92,6 +92,37 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char
return
0
;
return
0
;
}
}
int32_t
mndBuildPerfsTableCfg
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableCfgRsp
*
pRsp
)
{
if
(
NULL
==
pMnode
->
perfsMeta
)
{
terrno
=
TSDB_CODE_MND_NOT_READY
;
return
-
1
;
}
STableMetaRsp
*
pMeta
=
taosHashGet
(
pMnode
->
perfsMeta
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
pMeta
)
{
mError
(
"invalid performance schema table name:%s"
,
tbName
);
terrno
=
TSDB_CODE_MND_INVALID_SYS_TABLENAME
;
return
-
1
;
}
strcpy
(
pRsp
->
tbName
,
pMeta
->
tbName
);
strcpy
(
pRsp
->
stbName
,
pMeta
->
stbName
);
strcpy
(
pRsp
->
dbFName
,
pMeta
->
dbFName
);
pRsp
->
numOfTags
=
pMeta
->
numOfTags
;
pRsp
->
numOfColumns
=
pMeta
->
numOfColumns
;
pRsp
->
tableType
=
pMeta
->
tableType
;
pRsp
->
pSchemas
=
taosMemoryCalloc
(
pMeta
->
numOfColumns
,
sizeof
(
SSchema
));
if
(
pRsp
->
pSchemas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
pRsp
->
pSchemas
=
NULL
;
return
-
1
;
}
memcpy
(
pRsp
->
pSchemas
,
pMeta
->
pSchemas
,
pMeta
->
numOfColumns
*
sizeof
(
SSchema
));
return
0
;
}
int32_t
mndInitPerfs
(
SMnode
*
pMnode
)
{
int32_t
mndInitPerfs
(
SMnode
*
pMnode
)
{
pMnode
->
perfsMeta
=
taosHashInit
(
20
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
pMnode
->
perfsMeta
=
taosHashInit
(
20
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
if
(
pMnode
->
perfsMeta
==
NULL
)
{
if
(
pMnode
->
perfsMeta
==
NULL
)
{
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
be2935cb
...
@@ -43,6 +43,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq);
...
@@ -43,6 +43,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq);
static
int32_t
mndProcessTableMetaReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessTableMetaReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndRetrieveStb
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveStb
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextStb
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextStb
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndProcessTableCfgReq
(
SRpcMsg
*
pReq
);
int32_t
mndInitStb
(
SMnode
*
pMnode
)
{
int32_t
mndInitStb
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{
SSdbTable
table
=
{
...
@@ -249,6 +250,7 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
...
@@ -249,6 +250,7 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
taosMemoryFreeClear
(
pStb
->
comment
);
taosMemoryFreeClear
(
pStb
->
comment
);
taosMemoryFreeClear
(
pStb
->
pAst1
);
taosMemoryFreeClear
(
pStb
->
pAst1
);
taosMemoryFreeClear
(
pStb
->
pAst2
);
taosMemoryFreeClear
(
pStb
->
pAst2
);
taosArrayDestroy
(
pStb
->
pFuncs
);
return
0
;
return
0
;
}
}
...
@@ -677,6 +679,11 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -677,6 +679,11 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
pDst
->
numOfColumns
=
pCreate
->
numOfColumns
;
pDst
->
numOfColumns
=
pCreate
->
numOfColumns
;
pDst
->
numOfTags
=
pCreate
->
numOfTags
;
pDst
->
numOfTags
=
pCreate
->
numOfTags
;
pDst
->
commentLen
=
pCreate
->
commentLen
;
pDst
->
commentLen
=
pCreate
->
commentLen
;
pDst
->
delay1
=
pCreate
->
delay1
;
pDst
->
delay2
=
pCreate
->
delay2
;
pDst
->
pFuncs
=
pCreate
->
pFuncs
;
pCreate
->
pFuncs
=
NULL
;
if
(
pDst
->
commentLen
>
0
)
{
if
(
pDst
->
commentLen
>
0
)
{
pDst
->
comment
=
taosMemoryCalloc
(
pDst
->
commentLen
+
1
,
1
);
pDst
->
comment
=
taosMemoryCalloc
(
pDst
->
commentLen
+
1
,
1
);
if
(
pDst
->
comment
==
NULL
)
{
if
(
pDst
->
comment
==
NULL
)
{
...
@@ -1274,6 +1281,60 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
...
@@ -1274,6 +1281,60 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
return
0
;
return
0
;
}
}
static
int32_t
mndBuildStbCfgImp
(
SDbObj
*
pDb
,
SStbObj
*
pStb
,
const
char
*
tbName
,
STableCfgRsp
*
pRsp
)
{
taosRLockLatch
(
&
pStb
->
lock
);
int32_t
totalCols
=
pStb
->
numOfColumns
+
pStb
->
numOfTags
;
pRsp
->
pSchemas
=
taosMemoryCalloc
(
totalCols
,
sizeof
(
SSchema
));
if
(
pRsp
->
pSchemas
==
NULL
)
{
taosRUnLockLatch
(
&
pStb
->
lock
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
strcpy
(
pRsp
->
dbFName
,
pStb
->
db
);
strcpy
(
pRsp
->
tbName
,
tbName
);
strcpy
(
pRsp
->
stbName
,
tbName
);
pRsp
->
numOfTags
=
pStb
->
numOfTags
;
pRsp
->
numOfColumns
=
pStb
->
numOfColumns
;
pRsp
->
tableType
=
TSDB_SUPER_TABLE
;
pRsp
->
delay1
=
pStb
->
delay1
;
pRsp
->
delay2
=
pStb
->
delay2
;
pRsp
->
watermark1
=
pStb
->
watermark1
;
pRsp
->
watermark2
=
pStb
->
watermark2
;
pRsp
->
ttl
=
pStb
->
ttl
;
pRsp
->
commentLen
=
pStb
->
commentLen
;
if
(
pStb
->
commentLen
>
0
)
{
pRsp
->
pComment
=
strdup
(
pStb
->
comment
);
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
];
SSchema
*
pSrcSchema
=
&
pStb
->
pColumns
[
i
];
memcpy
(
pSchema
->
name
,
pSrcSchema
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
type
=
pSrcSchema
->
type
;
pSchema
->
colId
=
pSrcSchema
->
colId
;
pSchema
->
bytes
=
pSrcSchema
->
bytes
;
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pRsp
->
pSchemas
[
i
+
pStb
->
numOfColumns
];
SSchema
*
pSrcSchema
=
&
pStb
->
pTags
[
i
];
memcpy
(
pSchema
->
name
,
pSrcSchema
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
type
=
pSrcSchema
->
type
;
pSchema
->
colId
=
pSrcSchema
->
colId
;
pSchema
->
bytes
=
pSrcSchema
->
bytes
;
}
if
(
pStb
->
pFuncs
)
{
pRsp
->
pFuncs
=
taosArrayDup
(
pStb
->
pFuncs
);
}
taosRUnLockLatch
(
&
pStb
->
lock
);
return
0
;
}
static
int32_t
mndBuildStbSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
,
static
int32_t
mndBuildStbSchema
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableMetaRsp
*
pRsp
,
int32_t
*
smaVer
)
{
int32_t
*
smaVer
)
{
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
...
@@ -1302,6 +1363,32 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char
...
@@ -1302,6 +1363,32 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char
return
code
;
return
code
;
}
}
static
int32_t
mndBuildStbCfg
(
SMnode
*
pMnode
,
const
char
*
dbFName
,
const
char
*
tbName
,
STableCfgRsp
*
pRsp
)
{
char
tbFName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
snprintf
(
tbFName
,
sizeof
(
tbFName
),
"%s.%s"
,
dbFName
,
tbName
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
dbFName
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
return
-
1
;
}
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFName
);
if
(
pStb
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
terrno
=
TSDB_CODE_PAR_TABLE_NOT_EXIST
;
return
-
1
;
}
int32_t
code
=
mndBuildStbCfgImp
(
pDb
,
pStb
,
tbName
,
pRsp
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
return
code
;
}
static
int32_t
mndBuildSMAlterStbRsp
(
SDbObj
*
pDb
,
const
SMAlterStbReq
*
pAlter
,
SStbObj
*
pObj
,
void
**
pCont
,
static
int32_t
mndBuildSMAlterStbRsp
(
SDbObj
*
pDb
,
const
SMAlterStbReq
*
pAlter
,
SStbObj
*
pObj
,
void
**
pCont
,
int32_t
*
pLen
)
{
int32_t
*
pLen
)
{
int32_t
ret
;
int32_t
ret
;
...
@@ -1661,6 +1748,63 @@ _OVER:
...
@@ -1661,6 +1748,63 @@ _OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessTableCfgReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
STableCfgReq
cfgReq
=
{
0
};
STableCfgRsp
cfgRsp
=
{
0
};
if
(
tDeserializeSTableCfgReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
cfgReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
_OVER
;
}
if
(
0
==
strcmp
(
cfgReq
.
dbFName
,
TSDB_INFORMATION_SCHEMA_DB
))
{
mDebug
(
"information_schema table:%s.%s, start to retrieve cfg"
,
cfgReq
.
dbFName
,
cfgReq
.
tbName
);
if
(
mndBuildInsTableCfg
(
pMnode
,
cfgReq
.
dbFName
,
cfgReq
.
tbName
,
&
cfgRsp
)
!=
0
)
{
goto
_OVER
;
}
}
else
if
(
0
==
strcmp
(
cfgReq
.
dbFName
,
TSDB_PERFORMANCE_SCHEMA_DB
))
{
mDebug
(
"performance_schema table:%s.%s, start to retrieve cfg"
,
cfgReq
.
dbFName
,
cfgReq
.
tbName
);
if
(
mndBuildPerfsTableCfg
(
pMnode
,
cfgReq
.
dbFName
,
cfgReq
.
tbName
,
&
cfgRsp
)
!=
0
)
{
goto
_OVER
;
}
}
else
{
mDebug
(
"stb:%s.%s, start to retrieve cfg"
,
cfgReq
.
dbFName
,
cfgReq
.
tbName
);
if
(
mndBuildStbCfg
(
pMnode
,
cfgReq
.
dbFName
,
cfgReq
.
tbName
,
&
cfgRsp
)
!=
0
)
{
goto
_OVER
;
}
}
int32_t
rspLen
=
tSerializeSTableCfgRsp
(
NULL
,
0
,
&
cfgRsp
);
if
(
rspLen
<
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
_OVER
;
}
void
*
pRsp
=
rpcMallocCont
(
rspLen
);
if
(
pRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_OVER
;
}
tSerializeSTableCfgRsp
(
pRsp
,
rspLen
,
&
cfgRsp
);
pReq
->
info
.
rsp
=
pRsp
;
pReq
->
info
.
rspLen
=
rspLen
;
code
=
0
;
mTrace
(
"%s.%s, cfg is retrieved"
,
cfgReq
.
dbFName
,
cfgReq
.
tbName
);
_OVER:
if
(
code
!=
0
)
{
mError
(
"stb:%s.%s, failed to retrieve cfg since %s"
,
cfgReq
.
dbFName
,
cfgReq
.
tbName
,
terrstr
());
}
tFreeSTableCfgRsp
(
&
cfgRsp
);
return
code
;
}
int32_t
mndValidateStbInfo
(
SMnode
*
pMnode
,
SSTableVersion
*
pStbVersions
,
int32_t
numOfStbs
,
void
**
ppRsp
,
int32_t
mndValidateStbInfo
(
SMnode
*
pMnode
,
SSTableVersion
*
pStbVersions
,
int32_t
numOfStbs
,
void
**
ppRsp
,
int32_t
*
pRspLen
)
{
int32_t
*
pRspLen
)
{
SSTbHbRsp
hbRsp
=
{
0
};
SSTbHbRsp
hbRsp
=
{
0
};
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
be2935cb
...
@@ -71,6 +71,7 @@ void vnodeBufPoolReset(SVBufPool* pPool);
...
@@ -71,6 +71,7 @@ void vnodeBufPoolReset(SVBufPool* pPool);
int32_t
vnodeQueryOpen
(
SVnode
*
pVnode
);
int32_t
vnodeQueryOpen
(
SVnode
*
pVnode
);
void
vnodeQueryClose
(
SVnode
*
pVnode
);
void
vnodeQueryClose
(
SVnode
*
pVnode
);
int32_t
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
int32_t
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
int
vnodeGetTableCfg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
// vnodeCommit.c
// vnodeCommit.c
int32_t
vnodeBegin
(
SVnode
*
pVnode
);
int32_t
vnodeBegin
(
SVnode
*
pVnode
);
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
be2935cb
...
@@ -163,9 +163,8 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -163,9 +163,8 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) {
cfgRsp
.
tableType
=
mer1
.
me
.
type
;
cfgRsp
.
tableType
=
mer1
.
me
.
type
;
if
(
mer1
.
me
.
type
==
TSDB_SUPER_TABLE
)
{
if
(
mer1
.
me
.
type
==
TSDB_SUPER_TABLE
)
{
strcpy
(
cfgRsp
.
stbName
,
mer1
.
me
.
name
);
code
=
TSDB_CODE_VND_HASH_MISMATCH
;
schema
=
mer1
.
me
.
stbEntry
.
schemaRow
;
goto
_exit
;
schemaTag
=
mer1
.
me
.
stbEntry
.
schemaTag
;
}
else
if
(
mer1
.
me
.
type
==
TSDB_CHILD_TABLE
)
{
}
else
if
(
mer1
.
me
.
type
==
TSDB_CHILD_TABLE
)
{
metaReaderInit
(
&
mer2
,
pVnode
->
pMeta
,
0
);
metaReaderInit
(
&
mer2
,
pVnode
->
pMeta
,
0
);
if
(
metaGetTableEntryByUid
(
&
mer2
,
mer1
.
me
.
ctbEntry
.
suid
)
<
0
)
goto
_exit
;
if
(
metaGetTableEntryByUid
(
&
mer2
,
mer1
.
me
.
ctbEntry
.
suid
)
<
0
)
goto
_exit
;
...
@@ -173,8 +172,22 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -173,8 +172,22 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) {
strcpy
(
cfgRsp
.
stbName
,
mer2
.
me
.
name
);
strcpy
(
cfgRsp
.
stbName
,
mer2
.
me
.
name
);
schema
=
mer2
.
me
.
stbEntry
.
schemaRow
;
schema
=
mer2
.
me
.
stbEntry
.
schemaRow
;
schemaTag
=
mer2
.
me
.
stbEntry
.
schemaTag
;
schemaTag
=
mer2
.
me
.
stbEntry
.
schemaTag
;
cfgRsp
.
ttl
=
mer1
.
me
.
ctbEntry
.
ttlDays
;
cfgRsp
.
commentLen
=
mer1
.
me
.
ctbEntry
.
commentLen
;
if
(
mer1
.
me
.
ctbEntry
.
commentLen
>
0
)
{
cfgRsp
.
pComment
=
strdup
(
mer1
.
me
.
ctbEntry
.
comment
);
}
STag
*
pTag
=
(
STag
*
)
mer1
.
me
.
ctbEntry
.
pTags
;
cfgRsp
.
tagsLen
=
pTag
->
len
;
cfgRsp
.
pTags
=
taosMemoryMalloc
(
cfgRsp
.
tagsLen
);
memcpy
(
cfgRsp
.
pTags
,
pTag
,
cfgRsp
.
tagsLen
);
}
else
if
(
mer1
.
me
.
type
==
TSDB_NORMAL_TABLE
)
{
}
else
if
(
mer1
.
me
.
type
==
TSDB_NORMAL_TABLE
)
{
schema
=
mer1
.
me
.
ntbEntry
.
schemaRow
;
schema
=
mer1
.
me
.
ntbEntry
.
schemaRow
;
cfgRsp
.
ttl
=
mer1
.
me
.
ntbEntry
.
ttlDays
;
cfgRsp
.
commentLen
=
mer1
.
me
.
ntbEntry
.
commentLen
;
if
(
mer1
.
me
.
ntbEntry
.
commentLen
>
0
)
{
cfgRsp
.
pComment
=
strdup
(
mer1
.
me
.
ntbEntry
.
comment
);
}
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
@@ -214,7 +227,7 @@ _exit:
...
@@ -214,7 +227,7 @@ _exit:
tmsgSendRsp
(
&
rpcMsg
);
tmsgSendRsp
(
&
rpcMsg
);
t
aosMemoryFree
(
cfgRsp
.
pSchemas
);
t
FreeSTableCfgRsp
(
&
cfgRsp
);
metaReaderClear
(
&
mer2
);
metaReaderClear
(
&
mer2
);
metaReaderClear
(
&
mer1
);
metaReaderClear
(
&
mer1
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -253,4 +266,4 @@ tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STabl
...
@@ -253,4 +266,4 @@ tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STabl
return tsdbQueryCacheLastT(pVnode->pTsdb, pCond, groupList, qId, pMemRef);
return tsdbQueryCacheLastT(pVnode->pTsdb, pCond, groupList, qId, pMemRef);
#endif
#endif
return
0
;
return
0
;
}
}
\ No newline at end of file
source/libs/catalog/inc/catalogInt.h
浏览文件 @
be2935cb
...
@@ -536,6 +536,8 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
...
@@ -536,6 +536,8 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
int32_t
ctgGetTbMetaFromMnodeImpl
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
*
dbFName
,
char
*
tbName
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromMnodeImpl
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
char
*
dbFName
,
char
*
tbName
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromVnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromVnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTableCfgFromVnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableCfg
**
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTableCfgFromMnode
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
out
,
SCtgTask
*
pTask
);
int32_t
ctgInitJob
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgJob
**
job
,
uint64_t
reqId
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int32_t
*
taskNum
);
int32_t
ctgInitJob
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgJob
**
job
,
uint64_t
reqId
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int32_t
*
taskNum
);
int32_t
ctgLaunchJob
(
SCtgJob
*
pJob
);
int32_t
ctgLaunchJob
(
SCtgJob
*
pJob
);
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
be2935cb
...
@@ -1238,14 +1238,21 @@ _return:
...
@@ -1238,14 +1238,21 @@ _return:
CTG_API_LEAVE
(
code
);
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogGetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
int32_t
catalog
Refresh
GetTableCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableCfg
**
pCfg
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pCfg
)
{
if
(
NULL
==
pCtg
||
NULL
==
pConn
||
NULL
==
pTableName
||
NULL
==
pCfg
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
CTG_API_LEAVE
(
ctgGetTbCfg
(
pCtg
,
pConn
,
pTableName
,
pCfg
,
NULL
));
int32_t
code
=
0
;
CTG_ERR_JRET
(
catalogRemoveTableMeta
(
pCtg
,
(
SName
*
)
pTableName
));
CTG_ERR_JRET
(
ctgGetTbCfg
(
pCtg
,
pConn
,
(
SName
*
)
pTableName
,
pCfg
));
_return:
CTG_API_LEAVE
(
code
);
}
}
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
)
{
int32_t
catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
)
{
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
be2935cb
...
@@ -326,6 +326,7 @@ _return:
...
@@ -326,6 +326,7 @@ _return:
int32_t
ctgAcquireTbIndexFromCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
)
{
int32_t
ctgAcquireTbIndexFromCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tbName
,
SCtgDBCache
**
pDb
,
SCtgTbCache
**
pTb
)
{
SCtgDBCache
*
dbCache
=
NULL
;
SCtgDBCache
*
dbCache
=
NULL
;
SCtgTbCache
*
pCache
=
NULL
;
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
ctgAcquireDBCache
(
pCtg
,
dbFName
,
&
dbCache
);
if
(
NULL
==
dbCache
)
{
if
(
NULL
==
dbCache
)
{
ctgDebug
(
"db %s not in cache"
,
dbFName
);
ctgDebug
(
"db %s not in cache"
,
dbFName
);
...
@@ -333,7 +334,7 @@ int32_t ctgAcquireTbIndexFromCache(SCatalog* pCtg, char *dbFName, char* tbName,
...
@@ -333,7 +334,7 @@ int32_t ctgAcquireTbIndexFromCache(SCatalog* pCtg, char *dbFName, char* tbName,
}
}
int32_t
sz
=
0
;
int32_t
sz
=
0
;
SCtgTbCache
*
pCache
=
taosHashAcquire
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
));
pCache
=
taosHashAcquire
(
dbCache
->
tbCache
,
tbName
,
strlen
(
tbName
));
if
(
NULL
==
pCache
)
{
if
(
NULL
==
pCache
)
{
ctgDebug
(
"tb %s not in cache, dbFName:%s"
,
tbName
,
dbFName
);
ctgDebug
(
"tb %s not in cache, dbFName:%s"
,
tbName
,
dbFName
);
goto
_return
;
goto
_return
;
...
...
source/libs/catalog/src/ctgRemote.c
浏览文件 @
be2935cb
...
@@ -172,6 +172,39 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize,
...
@@ -172,6 +172,39 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize,
qDebug
(
"Got table meta from vnode, tbFName:%s"
,
target
);
qDebug
(
"Got table meta from vnode, tbFName:%s"
,
target
);
break
;
break
;
}
}
case
TDMT_VND_TABLE_CFG
:
{
if
(
TSDB_CODE_SUCCESS
!=
rspCode
)
{
qError
(
"error rsp for table cfg from vnode, code:%s, tbFName:%s"
,
tstrerror
(
rspCode
),
target
);
CTG_ERR_RET
(
rspCode
);
}
code
=
queryProcessMsgRsp
[
TMSG_INDEX
(
reqType
)](
out
,
msg
,
msgSize
);
if
(
code
)
{
qError
(
"Process vnode tb cfg rsp failed, code:%s, tbFName:%s"
,
tstrerror
(
code
),
target
);
CTG_ERR_RET
(
code
);
}
qDebug
(
"Got table cfg from vnode, tbFName:%s"
,
target
);
break
;
}
case
TDMT_MND_TABLE_CFG
:
{
if
(
TSDB_CODE_SUCCESS
!=
rspCode
)
{
qError
(
"error rsp for stb cfg from mnode, error:%s, tbFName:%s"
,
tstrerror
(
rspCode
),
target
);
CTG_ERR_RET
(
rspCode
);
}
code
=
queryProcessMsgRsp
[
TMSG_INDEX
(
reqType
)](
out
,
msg
,
msgSize
);
if
(
code
)
{
qError
(
"Process mnode stb cfg rsp failed, error:%s, tbFName:%s"
,
tstrerror
(
code
),
target
);
CTG_ERR_RET
(
code
);
}
qDebug
(
"Got stb cfg from mnode, tbFName:%s"
,
target
);
break
;
}
default:
qError
(
"invalid req type %s"
,
TMSG_INFO
(
reqType
));
return
TSDB_CODE_APP_ERROR
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -655,7 +688,7 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
...
@@ -655,7 +688,7 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
void
*
(
*
mallocFp
)(
int32_t
)
=
pTask
?
taosMemoryMalloc
:
rpcMallocCont
;
void
*
(
*
mallocFp
)(
int32_t
)
=
pTask
?
taosMemoryMalloc
:
rpcMallocCont
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pTableName
,
dbFName
);
tNameGetFullDbName
(
pTableName
,
dbFName
);
SBuildTableInput
bInput
=
{.
vgId
=
vgroupInfo
->
vgId
,
.
dbFName
=
dbFName
,
.
tbName
=
pTableName
->
tname
};
SBuildTableInput
bInput
=
{.
vgId
=
vgroupInfo
->
vgId
,
.
dbFName
=
dbFName
,
.
tbName
=
(
char
*
)
pTableName
->
tname
};
ctgDebug
(
"try to get table cfg from vnode, vgId:%d, tbFName:%s"
,
vgroupInfo
->
vgId
,
tbFName
);
ctgDebug
(
"try to get table cfg from vnode, vgId:%d, tbFName:%s"
,
vgroupInfo
->
vgId
,
tbFName
);
...
@@ -695,7 +728,7 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
...
@@ -695,7 +728,7 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
void
*
(
*
mallocFp
)(
int32_t
)
=
pTask
?
taosMemoryMalloc
:
rpcMallocCont
;
void
*
(
*
mallocFp
)(
int32_t
)
=
pTask
?
taosMemoryMalloc
:
rpcMallocCont
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pTableName
,
dbFName
);
tNameGetFullDbName
(
pTableName
,
dbFName
);
SBuildTableInput
bInput
=
{.
vgId
=
0
,
.
dbFName
=
dbFName
,
.
tbName
=
pTableName
->
tname
};
SBuildTableInput
bInput
=
{.
vgId
=
0
,
.
dbFName
=
dbFName
,
.
tbName
=
(
char
*
)
pTableName
->
tname
};
ctgDebug
(
"try to get table cfg from mnode, tbFName:%s"
,
tbFName
);
ctgDebug
(
"try to get table cfg from mnode, tbFName:%s"
,
tbFName
);
...
...
source/libs/command/src/command.c
浏览文件 @
be2935cb
...
@@ -282,9 +282,226 @@ static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt, SRetrieveT
...
@@ -282,9 +282,226 @@ static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt, SRetrieveT
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
execShowCreateTable
(
SShowCreateTableStmt
*
pStmt
)
{
return
TSDB_CODE_FAILED
;
}
static
SSDataBlock
*
buildCreateTbResultDataBlock
()
{
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
pBlock
->
info
.
numOfCols
=
SHOW_CREATE_TB_RESULT_COLS
;
pBlock
->
info
.
hasVarCol
=
true
;
pBlock
->
pDataBlock
=
taosArrayInit
(
pBlock
->
info
.
numOfCols
,
sizeof
(
SColumnInfoData
));
SColumnInfoData
infoData
=
{
0
};
infoData
.
info
.
type
=
TSDB_DATA_TYPE_VARCHAR
;
infoData
.
info
.
bytes
=
SHOW_CREATE_TB_RESULT_FIELD1_LEN
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
infoData
);
infoData
.
info
.
type
=
TSDB_DATA_TYPE_VARCHAR
;
infoData
.
info
.
bytes
=
SHOW_CREATE_TB_RESULT_FIELD2_LEN
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
infoData
);
return
pBlock
;
}
void
appendColumnFields
(
char
*
buf
,
int32_t
*
len
,
STableCfg
*
pCfg
)
{
for
(
int32_t
i
=
0
;
i
<
pCfg
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
pCfg
->
pSchemas
+
i
;
char
type
[
32
];
sprintf
(
type
,
"%s"
,
tDataTypes
[
pSchema
->
type
].
name
);
if
(
TSDB_DATA_TYPE_VARCHAR
==
pSchema
->
type
)
{
sprintf
(
type
+
strlen
(
type
),
"(%d)"
,
(
int32_t
)(
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
));
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
pSchema
->
type
)
{
sprintf
(
type
+
strlen
(
type
),
"(%d)"
,
(
int32_t
)((
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
));
}
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
"%s`%s` %s"
,
((
i
>
0
)
?
", "
:
""
),
pSchema
->
name
,
type
);
}
}
void
appendTagFields
(
char
*
buf
,
int32_t
*
len
,
STableCfg
*
pCfg
)
{
for
(
int32_t
i
=
0
;
i
<
pCfg
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
pCfg
->
pSchemas
+
pCfg
->
numOfColumns
+
i
;
char
type
[
32
];
sprintf
(
type
,
"%s"
,
tDataTypes
[
pSchema
->
type
].
name
);
if
(
TSDB_DATA_TYPE_VARCHAR
==
pSchema
->
type
)
{
sprintf
(
type
+
strlen
(
type
),
"(%d)"
,
(
int32_t
)(
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
));
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
pSchema
->
type
)
{
sprintf
(
type
+
strlen
(
type
),
"(%d)"
,
(
int32_t
)((
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
));
}
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
"%s`%s` %s"
,
((
i
>
0
)
?
", "
:
""
),
pSchema
->
name
,
type
);
}
}
int32_t
appendTagValues
(
char
*
buf
,
int32_t
*
len
,
STableCfg
*
pCfg
)
{
SArray
*
pTagVals
=
NULL
;
STag
*
pTag
=
(
STag
*
)
pCfg
->
pTags
;
if
(
pCfg
->
pTags
&&
pTag
->
flags
&
TD_TAG_JSON
)
{
char
*
pJson
=
parseTagDatatoJson
(
pTag
);
if
(
pJson
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
"%s"
,
pJson
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
code
=
tTagToValArray
((
const
STag
*
)
pCfg
->
pTags
,
&
pTagVals
);
if
(
code
)
{
return
code
;
}
int16_t
nCols
=
taosArrayGetSize
(
pTagVals
);
int32_t
num
=
0
;
for
(
int
i
=
0
;
i
<
nCols
;
i
++
)
{
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
char
type
=
pTagVal
->
type
;
int32_t
tlen
=
0
;
dataConverToStr
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
type
,
pTagVal
->
pData
,
pTagVal
->
nData
,
&
tlen
);
*
len
+=
tlen
;
/*
if (type == TSDB_DATA_TYPE_BINARY) {
if (pTagVal->nData > 0) {
if (num) {
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", ");
}
memcpy(buf + VARSTR_HEADER_SIZE + *len, pTagVal->pData, pTagVal->nData);
*len += pTagVal->nData;
}
} else if (type == TSDB_DATA_TYPE_NCHAR) {
if (pTagVal->nData > 0) {
if (num) {
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", ");
}
int32_t tlen = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, buf + VARSTR_HEADER_SIZE + *len);
}
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
double val = *(double *)(&pTagVal->i64);
int len = 0;
term = indexTermCreate(suid, ADD_VALUE, type, key, nKey, (const char *)&val, len);
} else if (type == TSDB_DATA_TYPE_BOOL) {
int val = *(int *)(&pTagVal->i64);
int len = 0;
term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_INT, key, nKey, (const char *)&val, len);
}
*/
}
}
void
appendTableOptions
(
char
*
buf
,
int32_t
*
len
,
STableCfg
*
pCfg
)
{
if
(
pCfg
->
commentLen
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" COMMENT '%s'"
,
pCfg
->
pComment
);
}
else
if
(
0
==
pCfg
->
commentLen
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" COMMENT ''"
);
}
if
(
pCfg
->
watermark1
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" WATERMARK %"
PRId64
"a"
,
pCfg
->
watermark1
);
if
(
pCfg
->
watermark2
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
", %"
PRId64
"a"
,
pCfg
->
watermark2
);
}
}
if
(
pCfg
->
delay1
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" MAX_DELAY %"
PRId64
"a"
,
pCfg
->
delay1
);
if
(
pCfg
->
delay2
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
", %"
PRId64
"a"
,
pCfg
->
delay2
);
}
}
int32_t
funcNum
=
taosArrayGetSize
(
pCfg
->
pFuncs
);
if
(
funcNum
>
0
)
{
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
" ROLLUP("
);
for
(
int32_t
i
=
0
;
i
<
funcNum
;
++
i
)
{
char
*
pFunc
=
taosArrayGet
(
pCfg
->
pFuncs
,
i
);
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
"%s%s"
,
((
i
>
0
)
?
", "
:
""
),
pFunc
);
}
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
")"
);
}
}
static
int32_t
setCreateTBResultIntoDataBlock
(
SSDataBlock
*
pBlock
,
char
*
tbName
,
STableCfg
*
pCfg
)
{
int32_t
code
=
0
;
blockDataEnsureCapacity
(
pBlock
,
1
);
pBlock
->
info
.
rows
=
1
;
SColumnInfoData
*
pCol1
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
char
buf1
[
SHOW_CREATE_TB_RESULT_FIELD1_LEN
]
=
{
0
};
STR_TO_VARSTR
(
buf1
,
tbName
);
colDataAppend
(
pCol1
,
0
,
buf1
,
false
);
SColumnInfoData
*
pCol2
=
taosArrayGet
(
pBlock
->
pDataBlock
,
1
);
char
buf2
[
SHOW_CREATE_TB_RESULT_FIELD2_LEN
]
=
{
0
};
int32_t
len
=
0
;
if
(
TSDB_SUPER_TABLE
==
pCfg
->
tableType
)
{
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
,
"CREATE STABLE `%s` ("
,
tbName
);
appendColumnFields
(
buf2
,
&
len
,
pCfg
);
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
") TAGS ("
);
appendTagFields
(
buf2
,
&
len
,
pCfg
);
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
")"
);
}
else
if
(
TSDB_CHILD_TABLE
==
pCfg
->
tableType
)
{
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
,
"CREATE TABLE `%s` USING `%s` TAGS ("
,
tbName
,
pCfg
->
stbName
);
code
=
appendTagValues
(
buf2
,
&
len
,
pCfg
);
if
(
code
)
{
return
code
;
}
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
")"
);
}
else
{
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
,
"CREATE TABLE `%s` ("
,
tbName
);
appendColumnFields
(
buf2
,
&
len
,
pCfg
);
len
+=
sprintf
(
buf2
+
VARSTR_HEADER_SIZE
+
len
,
")"
);
}
(
varDataLen
(
buf2
))
=
len
;
colDataAppend
(
pCol2
,
0
,
buf2
,
false
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
execShowCreateTable
(
SShowCreateTableStmt
*
pStmt
,
SRetrieveTableRsp
**
pRsp
)
{
SSDataBlock
*
pBlock
=
buildCreateTbResultDataBlock
();
int32_t
code
=
setCreateTBResultIntoDataBlock
(
pBlock
,
pStmt
->
tableName
,
pStmt
->
pCfg
);
if
(
code
)
{
return
code
;
}
size_t
rspSize
=
sizeof
(
SRetrieveTableRsp
)
+
blockGetEncodeSize
(
pBlock
);
*
pRsp
=
taosMemoryCalloc
(
1
,
rspSize
);
if
(
NULL
==
*
pRsp
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
(
*
pRsp
)
->
useconds
=
0
;
(
*
pRsp
)
->
completed
=
1
;
(
*
pRsp
)
->
precision
=
0
;
(
*
pRsp
)
->
compressed
=
0
;
(
*
pRsp
)
->
compLen
=
0
;
(
*
pRsp
)
->
numOfRows
=
htonl
(
1
);
(
*
pRsp
)
->
numOfCols
=
htonl
(
SHOW_CREATE_TB_RESULT_COLS
);
static
int32_t
execShowCreateSTable
(
SShowCreateTableStmt
*
pStmt
)
{
return
TSDB_CODE_FAILED
;
}
int32_t
len
=
0
;
blockCompressEncode
(
pBlock
,
(
*
pRsp
)
->
data
,
&
len
,
SHOW_CREATE_TB_RESULT_COLS
,
false
);
ASSERT
(
len
==
rspSize
-
sizeof
(
SRetrieveTableRsp
));
blockDataDestroy
(
pBlock
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
execShowCreateSTable
(
SShowCreateTableStmt
*
pStmt
,
SRetrieveTableRsp
**
pRsp
)
{
STableCfg
*
pCfg
=
(
STableCfg
*
)
pStmt
->
pCfg
;
if
(
TSDB_SUPER_TABLE
!=
pCfg
->
tableType
)
{
terrno
=
TSDB_CODE_TSC_NOT_STABLE_ERROR
;
return
terrno
;
}
return
execShowCreateTable
(
pStmt
,
pRsp
);
}
static
int32_t
execAlterLocal
(
SAlterLocalStmt
*
pStmt
)
{
return
TSDB_CODE_FAILED
;
}
static
int32_t
execAlterLocal
(
SAlterLocalStmt
*
pStmt
)
{
return
TSDB_CODE_FAILED
;
}
...
@@ -297,9 +514,9 @@ int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) {
...
@@ -297,9 +514,9 @@ int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) {
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
return
execShowCreateDatabase
((
SShowCreateDatabaseStmt
*
)
pStmt
,
pRsp
);
return
execShowCreateDatabase
((
SShowCreateDatabaseStmt
*
)
pStmt
,
pRsp
);
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
return
execShowCreateTable
((
SShowCreateTableStmt
*
)
pStmt
);
return
execShowCreateTable
((
SShowCreateTableStmt
*
)
pStmt
,
pRsp
);
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
return
execShowCreateSTable
((
SShowCreateTableStmt
*
)
pStmt
);
return
execShowCreateSTable
((
SShowCreateTableStmt
*
)
pStmt
,
pRsp
);
case
QUERY_NODE_ALTER_LOCAL_STMT
:
case
QUERY_NODE_ALTER_LOCAL_STMT
:
return
execAlterLocal
((
SAlterLocalStmt
*
)
pStmt
);
return
execAlterLocal
((
SAlterLocalStmt
*
)
pStmt
);
default:
default:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
be2935cb
...
@@ -649,7 +649,7 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -649,7 +649,7 @@ void nodesDestroyNode(SNode* pNode) {
break
;
break
;
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_STABLE_STMT
:
taosMemoryFreeClear
(((
SShowCreateTableStmt
*
)
pNode
)
->
p
Meta
);
taosMemoryFreeClear
(((
SShowCreateTableStmt
*
)
pNode
)
->
p
Cfg
);
break
;
break
;
case
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
:
// no pointer field
case
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
:
// no pointer field
case
QUERY_NODE_KILL_CONNECTION_STMT
:
// no pointer field
case
QUERY_NODE_KILL_CONNECTION_STMT
:
// no pointer field
...
...
source/libs/parser/inc/parUtil.h
浏览文件 @
be2935cb
...
@@ -47,7 +47,7 @@ typedef struct SParseMetaCache {
...
@@ -47,7 +47,7 @@ typedef struct SParseMetaCache {
SHashObj
*
pUserAuth
;
// key is SUserAuthInfo serialized string, element is bool indicating whether or not to pass
SHashObj
*
pUserAuth
;
// key is SUserAuthInfo serialized string, element is bool indicating whether or not to pass
SHashObj
*
pUdf
;
// key is funcName, element is SFuncInfo*
SHashObj
*
pUdf
;
// key is funcName, element is SFuncInfo*
SHashObj
*
pTableIndex
;
// key is tbFName, element is SArray<STableIndexInfo>*
SHashObj
*
pTableIndex
;
// key is tbFName, element is SArray<STableIndexInfo>*
SHashObj
*
pTableCfg
;
// key is tbFName, element is STableMeta
*
SHashObj
*
pTableCfg
;
// key is tbFName, element is STableCfg
*
}
SParseMetaCache
;
}
SParseMetaCache
;
int32_t
generateSyntaxErrMsg
(
SMsgBuf
*
pBuf
,
int32_t
errCode
,
...);
int32_t
generateSyntaxErrMsg
(
SMsgBuf
*
pBuf
,
int32_t
errCode
,
...);
...
@@ -89,7 +89,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
...
@@ -89,7 +89,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
bool
*
pPass
);
bool
*
pPass
);
int32_t
getUdfInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pFunc
,
SFuncInfo
*
pInfo
);
int32_t
getUdfInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pFunc
,
SFuncInfo
*
pInfo
);
int32_t
getTableIndexFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
SArray
**
pIndexes
);
int32_t
getTableIndexFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
SArray
**
pIndexes
);
int32_t
getTableCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pFunc
,
STableCfg
**
pInfo
);
int32_t
getTableCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
STableCfg
**
pOutput
);
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
);
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
be2935cb
...
@@ -402,7 +402,14 @@ static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SS
...
@@ -402,7 +402,14 @@ static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SS
}
}
static
int32_t
collectMetaKeyFromShowCreateTable
(
SCollectMetaKeyCxt
*
pCxt
,
SShowCreateTableStmt
*
pStmt
)
{
static
int32_t
collectMetaKeyFromShowCreateTable
(
SCollectMetaKeyCxt
*
pCxt
,
SShowCreateTableStmt
*
pStmt
)
{
return
reserveTableCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pStmt
->
dbName
);
strcpy
(
name
.
tname
,
pStmt
->
tableName
);
int32_t
code
=
catalogRemoveTableMeta
(
pCxt
->
pParseCxt
->
pCatalog
,
&
name
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
return
code
;
}
}
static
int32_t
collectMetaKeyFromShowApps
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
static
int32_t
collectMetaKeyFromShowApps
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
be2935cb
...
@@ -147,11 +147,11 @@ static int32_t getTableCfg(STranslateContext* pCxt, const SName* pName, STableCf
...
@@ -147,11 +147,11 @@ static int32_t getTableCfg(STranslateContext* pCxt, const SName* pName, STableCf
.
requestId
=
pParCxt
->
requestId
,
.
requestId
=
pParCxt
->
requestId
,
.
requestObjRefId
=
pParCxt
->
requestRid
,
.
requestObjRefId
=
pParCxt
->
requestRid
,
.
mgmtEps
=
pParCxt
->
mgmtEpSet
};
.
mgmtEps
=
pParCxt
->
mgmtEpSet
};
code
=
catalogGetTableCfg
(
pParCxt
->
pCatalog
,
&
conn
,
pName
,
pCfg
);
code
=
catalog
Refresh
GetTableCfg
(
pParCxt
->
pCatalog
,
&
conn
,
pName
,
pCfg
);
}
}
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
parserError
(
"catalog
GetTableMeta
error, code:%s, dbName:%s, tbName:%s"
,
tstrerror
(
code
),
pName
->
dbname
,
parserError
(
"catalog
RefreshGetTableCfg
error, code:%s, dbName:%s, tbName:%s"
,
tstrerror
(
code
),
pName
->
dbname
,
pName
->
tname
);
pName
->
tname
);
}
}
return
code
;
return
code
;
...
@@ -3474,13 +3474,24 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt,
...
@@ -3474,13 +3474,24 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt,
return
code
;
return
code
;
}
}
static
int32_t
buildRollupFuncs
(
SNodeList
*
pFuncs
,
SArray
**
pArray
)
{
if
(
NULL
==
pFuncs
)
{
return
TSDB_CODE_SUCCESS
;
}
*
pArray
=
taosArrayInit
(
LIST_LENGTH
(
pFuncs
),
TSDB_FUNC_NAME_LEN
);
SNode
*
pNode
;
FOREACH
(
pNode
,
pFuncs
)
{
taosArrayPush
(
*
pArray
,
((
SFunctionNode
*
)
pNode
)
->
functionName
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
buildCreateStbReq
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
,
SMCreateStbReq
*
pReq
)
{
static
int32_t
buildCreateStbReq
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
,
SMCreateStbReq
*
pReq
)
{
pReq
->
igExists
=
pStmt
->
ignoreExists
;
pReq
->
igExists
=
pStmt
->
ignoreExists
;
pReq
->
delay1
=
pStmt
->
pOptions
->
maxDelay1
;
pReq
->
delay1
=
pStmt
->
pOptions
->
maxDelay1
;
pReq
->
delay2
=
pStmt
->
pOptions
->
maxDelay2
;
pReq
->
delay2
=
pStmt
->
pOptions
->
maxDelay2
;
pReq
->
watermark1
=
pStmt
->
pOptions
->
watermark1
;
pReq
->
watermark1
=
pStmt
->
pOptions
->
watermark1
;
pReq
->
watermark2
=
pStmt
->
pOptions
->
watermark2
;
pReq
->
watermark2
=
pStmt
->
pOptions
->
watermark2
;
// pReq->ttl = pStmt->pOptions->ttl;
columnDefNodeToField
(
pStmt
->
pCols
,
&
pReq
->
pColumns
);
columnDefNodeToField
(
pStmt
->
pCols
,
&
pReq
->
pColumns
);
columnDefNodeToField
(
pStmt
->
pTags
,
&
pReq
->
pTags
);
columnDefNodeToField
(
pStmt
->
pTags
,
&
pReq
->
pTags
);
pReq
->
numOfColumns
=
LIST_LENGTH
(
pStmt
->
pCols
);
pReq
->
numOfColumns
=
LIST_LENGTH
(
pStmt
->
pCols
);
...
@@ -3494,6 +3505,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
...
@@ -3494,6 +3505,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
}
else
{
}
else
{
pReq
->
commentLen
=
-
1
;
pReq
->
commentLen
=
-
1
;
}
}
buildRollupFuncs
(
pStmt
->
pOptions
->
pRollupFuncs
,
&
pReq
->
pFuncs
);
SName
tableName
;
SName
tableName
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pReq
->
name
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pReq
->
name
);
...
@@ -4263,7 +4275,10 @@ static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateD
...
@@ -4263,7 +4275,10 @@ static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateD
}
}
static
int32_t
translateShowCreateTable
(
STranslateContext
*
pCxt
,
SShowCreateTableStmt
*
pStmt
)
{
static
int32_t
translateShowCreateTable
(
STranslateContext
*
pCxt
,
SShowCreateTableStmt
*
pStmt
)
{
return
getTableCfg
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
(
STableCfg
*
)
&
pStmt
->
pCfg
);
SName
name
;
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
name
);
return
getTableCfg
(
pCxt
,
&
name
,
(
STableCfg
**
)
&
pStmt
->
pCfg
);
}
}
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
be2935cb
...
@@ -885,11 +885,32 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
...
@@ -885,11 +885,32 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
return
code
;
return
code
;
}
}
int32_t
getTableCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pFunc
,
STableCfg
**
pOutput
)
{
STableCfg
*
tableCfgDup
(
STableCfg
*
pCfg
)
{
STableCfg
*
pNew
=
taosMemoryMalloc
(
sizeof
(
*
pNew
));
memcpy
(
pNew
,
pCfg
,
sizeof
(
*
pNew
));
if
(
pNew
->
pComment
)
{
pNew
->
pComment
=
strdup
(
pNew
->
pComment
);
}
if
(
pNew
->
pFuncs
)
{
pNew
->
pFuncs
=
taosArrayDup
(
pNew
->
pFuncs
);
}
int32_t
schemaSize
=
(
pCfg
->
numOfColumns
+
pCfg
->
numOfTags
)
*
sizeof
(
SSchema
);
SSchema
*
pSchema
=
taosMemoryMalloc
(
schemaSize
);
memcpy
(
pSchema
,
pCfg
->
pSchemas
,
schemaSize
);
pNew
->
pSchemas
=
pSchema
;
return
pNew
;
}
int32_t
getTableCfgFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
STableCfg
**
pOutput
)
{
char
fullName
[
TSDB_TABLE_FNAME_LEN
];
char
fullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
pName
,
fullName
);
tNameExtractFullName
(
pName
,
fullName
);
STableCfg
*
pCfg
=
NULL
;
STableCfg
*
pCfg
=
NULL
;
int32_t
code
=
getMetaDataFromHash
(
fullName
,
strlen
(
fullName
),
pMetaCache
->
pTable
Index
,
(
void
**
)
&
pCfg
);
int32_t
code
=
getMetaDataFromHash
(
fullName
,
strlen
(
fullName
),
pMetaCache
->
pTable
Cfg
,
(
void
**
)
&
pCfg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOutput
=
tableCfgDup
(
pCfg
);
*
pOutput
=
tableCfgDup
(
pCfg
);
if
(
NULL
==
*
pOutput
)
{
if
(
NULL
==
*
pOutput
)
{
...
...
source/libs/parser/test/parShowToUse.cpp
浏览文件 @
be2935cb
...
@@ -45,7 +45,7 @@ TEST_F(ParserShowToUseTest, showCreateSTable) {
...
@@ -45,7 +45,7 @@ TEST_F(ParserShowToUseTest, showCreateSTable) {
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_SHOW_CREATE_STABLE_STMT
);
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_SHOW_CREATE_STABLE_STMT
);
ASSERT_EQ
(
pQuery
->
execMode
,
QUERY_EXEC_MODE_LOCAL
);
ASSERT_EQ
(
pQuery
->
execMode
,
QUERY_EXEC_MODE_LOCAL
);
ASSERT_TRUE
(
pQuery
->
haveResultSet
);
ASSERT_TRUE
(
pQuery
->
haveResultSet
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
p
Meta
,
nullptr
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
p
Cfg
,
nullptr
);
});
});
run
(
"SHOW CREATE STABLE st1"
);
run
(
"SHOW CREATE STABLE st1"
);
...
@@ -58,7 +58,7 @@ TEST_F(ParserShowToUseTest, showCreateTable) {
...
@@ -58,7 +58,7 @@ TEST_F(ParserShowToUseTest, showCreateTable) {
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_SHOW_CREATE_TABLE_STMT
);
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_SHOW_CREATE_TABLE_STMT
);
ASSERT_EQ
(
pQuery
->
execMode
,
QUERY_EXEC_MODE_LOCAL
);
ASSERT_EQ
(
pQuery
->
execMode
,
QUERY_EXEC_MODE_LOCAL
);
ASSERT_TRUE
(
pQuery
->
haveResultSet
);
ASSERT_TRUE
(
pQuery
->
haveResultSet
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
p
Meta
,
nullptr
);
ASSERT_NE
(((
SShowCreateTableStmt
*
)
pQuery
->
pRoot
)
->
p
Cfg
,
nullptr
);
});
});
run
(
"SHOW CREATE TABLE t1"
);
run
(
"SHOW CREATE TABLE t1"
);
...
...
source/libs/qcom/src/queryUtil.c
浏览文件 @
be2935cb
...
@@ -220,3 +220,81 @@ void destroyQueryExecRes(SQueryExecRes* pRes) {
...
@@ -220,3 +220,81 @@ void destroyQueryExecRes(SQueryExecRes* pRes) {
qError
(
"invalid exec result for request type %d"
,
pRes
->
msgType
);
qError
(
"invalid exec result for request type %d"
,
pRes
->
msgType
);
}
}
}
}
int32_t
dataConverToStr
(
char
*
str
,
int
type
,
void
*
buf
,
int32_t
bufSize
,
int32_t
*
len
)
{
int32_t
n
=
0
;
switch
(
type
)
{
case
TSDB_DATA_TYPE_NULL
:
n
=
sprintf
(
str
,
"null"
);
break
;
case
TSDB_DATA_TYPE_BOOL
:
n
=
sprintf
(
str
,
(
*
(
int8_t
*
)
buf
)
?
"true"
:
"false"
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
n
=
sprintf
(
str
,
"%d"
,
*
(
int8_t
*
)
buf
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
n
=
sprintf
(
str
,
"%d"
,
*
(
int16_t
*
)
buf
);
break
;
case
TSDB_DATA_TYPE_INT
:
n
=
sprintf
(
str
,
"%d"
,
*
(
int32_t
*
)
buf
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
n
=
sprintf
(
str
,
"%"
PRId64
,
*
(
int64_t
*
)
buf
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
n
=
sprintf
(
str
,
"%e"
,
GET_FLOAT_VAL
(
buf
));
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
n
=
sprintf
(
str
,
"%e"
,
GET_DOUBLE_VAL
(
buf
));
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
if
(
bufSize
<
0
)
{
// tscError("invalid buf size");
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
*
str
=
'"'
;
memcpy
(
str
+
1
,
buf
,
bufSize
);
*
(
str
+
bufSize
+
1
)
=
'"'
;
n
=
bufSize
+
2
;
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
n
=
sprintf
(
str
,
"%d"
,
*
(
uint8_t
*
)
buf
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
n
=
sprintf
(
str
,
"%d"
,
*
(
uint16_t
*
)
buf
);
break
;
case
TSDB_DATA_TYPE_UINT
:
n
=
sprintf
(
str
,
"%u"
,
*
(
uint32_t
*
)
buf
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
n
=
sprintf
(
str
,
"%"
PRIu64
,
*
(
uint64_t
*
)
buf
);
break
;
default:
// tscError("unsupported type:%d", type);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
*
len
=
n
;
return
TSDB_CODE_SUCCESS
;
}
source/libs/qcom/src/querymsg.c
浏览文件 @
be2935cb
...
@@ -514,7 +514,6 @@ int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
...
@@ -514,7 +514,6 @@ int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
queryProcessGetTbCfgRsp
(
void
*
output
,
char
*
msg
,
int32_t
msgSize
)
{
int32_t
queryProcessGetTbCfgRsp
(
void
*
output
,
char
*
msg
,
int32_t
msgSize
)
{
if
(
NULL
==
output
||
NULL
==
msg
||
msgSize
<=
0
)
{
if
(
NULL
==
output
||
NULL
==
msg
||
msgSize
<=
0
)
{
return
TSDB_CODE_TSC_INVALID_INPUT
;
return
TSDB_CODE_TSC_INVALID_INPUT
;
...
@@ -531,8 +530,6 @@ int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) {
...
@@ -531,8 +530,6 @@ int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
initQueryModuleMsgHandle
()
{
void
initQueryModuleMsgHandle
()
{
queryBuildMsg
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)]
=
queryBuildTableMetaReqMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_VND_TABLE_META
)]
=
queryBuildTableMetaReqMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_TABLE_META
)]
=
queryBuildTableMetaReqMsg
;
queryBuildMsg
[
TMSG_INDEX
(
TDMT_MND_TABLE_META
)]
=
queryBuildTableMetaReqMsg
;
...
...
source/util/src/terror.c
浏览文件 @
be2935cb
...
@@ -134,6 +134,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_TBNAME_ERROR, "Stmt table name not s
...
@@ -134,6 +134,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_TBNAME_ERROR, "Stmt table name not s
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_STMT_CLAUSE_ERROR
,
"not supported stmt clause"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_STMT_CLAUSE_ERROR
,
"not supported stmt clause"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_QUERY_KILLED
,
"Query killed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_QUERY_KILLED
,
"Query killed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_NO_EXEC_NODE
,
"No available execution node"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_NO_EXEC_NODE
,
"No available execution node"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_NOT_STABLE_ERROR
,
"Table is not a super table"
)
// mnode-common
// mnode-common
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_APP_ERROR
,
"Mnode internal error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_APP_ERROR
,
"Mnode internal error"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录