Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
16754b5a
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看板
提交
16754b5a
编写于
8月 17, 2023
作者:
W
wangjiaming0909
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: show create table, desc table with col comments
上级
cb027cc5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
41 addition
and
10 deletion
+41
-10
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+5
-4
source/common/src/tmsg.c
source/common/src/tmsg.c
+2
-2
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+1
-1
source/libs/command/src/command.c
source/libs/command/src/command.c
+20
-3
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+4
-0
tests/system-test/0-others/show.py
tests/system-test/0-others/show.py
+9
-0
未找到文件。
include/libs/nodes/cmdnodes.h
浏览文件 @
16754b5a
...
...
@@ -23,10 +23,11 @@ extern "C" {
#include "query.h"
#include "querynodes.h"
#define DESCRIBE_RESULT_COLS 4
#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_COLS 5
#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_COL_COMMENT_LEN (TSDB_COL_COMMENT_LEN)
#define SHOW_CREATE_DB_RESULT_COLS 2
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
...
...
source/common/src/tmsg.c
浏览文件 @
16754b5a
...
...
@@ -2305,7 +2305,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
}
int32_t
totalCols
=
pRsp
->
numOfTags
+
pRsp
->
numOfColumns
;
pRsp
->
pSchemas
=
taosMemory
Malloc
(
sizeof
(
SSchema
)
*
totalCols
);
pRsp
->
pSchemas
=
taosMemory
Calloc
(
totalCols
,
sizeof
(
SSchema
)
);
if
(
pRsp
->
pSchemas
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
...
...
@@ -3688,7 +3688,7 @@ static int32_t tDecodeSTableMetaRsp(SDecoder *pDecoder, STableMetaRsp *pRsp) {
int32_t
totalCols
=
pRsp
->
numOfTags
+
pRsp
->
numOfColumns
;
if
(
totalCols
>
0
)
{
pRsp
->
pSchemas
=
taosMemory
Malloc
(
sizeof
(
SSchema
)
*
totalCols
);
pRsp
->
pSchemas
=
taosMemory
Calloc
(
totalCols
,
sizeof
(
SSchema
)
);
if
(
pRsp
->
pSchemas
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
16754b5a
...
...
@@ -216,7 +216,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
cfgRsp
.
numOfTags
=
schemaTag
.
nCols
;
cfgRsp
.
numOfColumns
=
schema
.
nCols
;
cfgRsp
.
pSchemas
=
(
SSchema
*
)
taosMemory
Malloc
(
sizeof
(
SSchema
)
*
(
cfgRsp
.
numOfColumns
+
cfgRsp
.
numOfTags
));
cfgRsp
.
pSchemas
=
(
SSchema
*
)
taosMemory
Calloc
(
cfgRsp
.
numOfColumns
+
cfgRsp
.
numOfTags
,
sizeof
(
SSchema
));
memcpy
(
cfgRsp
.
pSchemas
,
schema
.
pSchema
,
sizeof
(
SSchema
)
*
schema
.
nCols
);
if
(
schemaTag
.
nCols
)
{
...
...
source/libs/command/src/command.c
浏览文件 @
16754b5a
...
...
@@ -78,6 +78,10 @@ static int32_t buildDescResultDataBlock(SSDataBlock** pOutput) {
infoData
=
createColumnInfoData
(
TSDB_DATA_TYPE_VARCHAR
,
DESCRIBE_RESULT_NOTE_LEN
,
4
);
code
=
blockDataAppendColInfo
(
pBlock
,
&
infoData
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
infoData
=
createColumnInfoData
(
TSDB_DATA_TYPE_VARCHAR
,
DESCRIBE_RESULT_COL_COMMENT_LEN
,
5
);
code
=
blockDataAppendColInfo
(
pBlock
,
&
infoData
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOutput
=
pBlock
;
...
...
@@ -99,7 +103,9 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
SColumnInfoData
*
pCol3
=
taosArrayGet
(
pBlock
->
pDataBlock
,
2
);
// Note
SColumnInfoData
*
pCol4
=
taosArrayGet
(
pBlock
->
pDataBlock
,
3
);
char
buf
[
DESCRIBE_RESULT_FIELD_LEN
]
=
{
0
};
// Comment
SColumnInfoData
*
pCol5
=
taosArrayGet
(
pBlock
->
pDataBlock
,
4
);
char
buf
[
DESCRIBE_RESULT_COL_COMMENT_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
if
(
invisibleColumn
(
sysInfoUser
,
pMeta
->
tableType
,
pMeta
->
schema
[
i
].
flags
))
{
continue
;
...
...
@@ -112,6 +118,8 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
colDataSetVal
(
pCol3
,
pBlock
->
info
.
rows
,
(
const
char
*
)
&
bytes
,
false
);
STR_TO_VARSTR
(
buf
,
i
>=
pMeta
->
tableInfo
.
numOfColumns
?
"TAG"
:
""
);
colDataSetVal
(
pCol4
,
pBlock
->
info
.
rows
,
buf
,
false
);
STR_TO_VARSTR
(
buf
,
pMeta
->
schema
[
i
].
comment
);
colDataSetVal
(
pCol5
,
pBlock
->
info
.
rows
,
buf
,
false
);
++
(
pBlock
->
info
.
rows
);
}
if
(
pBlock
->
info
.
rows
<=
0
)
{
...
...
@@ -456,14 +464,19 @@ 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
];
char
comments
[
TSDB_COL_COMMENT_LEN
+
16
]
=
{
0
};
sprintf
(
type
,
"%s"
,
tDataTypes
[
pSchema
->
type
].
name
);
if
(
TSDB_DATA_TYPE_VARCHAR
==
pSchema
->
type
||
TSDB_DATA_TYPE_GEOMETRY
==
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
));
}
if
(
pSchema
->
comment
[
0
])
{
sprintf
(
comments
,
" COMMENT '%s'"
,
pSchema
->
comment
);
}
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
"%s`%s` %s"
,
((
i
>
0
)
?
", "
:
""
),
pSchema
->
name
,
type
);
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
"%s`%s` %s%s"
,
((
i
>
0
)
?
", "
:
""
),
pSchema
->
name
,
type
,
comments
);
}
}
...
...
@@ -471,14 +484,18 @@ 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
];
char
comments
[
TSDB_COL_COMMENT_LEN
+
16
]
=
{
0
};
sprintf
(
type
,
"%s"
,
tDataTypes
[
pSchema
->
type
].
name
);
if
(
TSDB_DATA_TYPE_VARCHAR
==
pSchema
->
type
||
TSDB_DATA_TYPE_GEOMETRY
==
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
));
}
if
(
pSchema
->
comment
[
0
])
{
sprintf
(
comments
,
" COMMENT '%s'"
,
pSchema
->
comment
);
}
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
"%s`%s` %s
"
,
((
i
>
0
)
?
", "
:
""
),
pSchema
->
name
,
type
);
*
len
+=
sprintf
(
buf
+
VARSTR_HEADER_SIZE
+
*
len
,
"%s`%s` %s
%s"
,
((
i
>
0
)
?
", "
:
""
),
pSchema
->
name
,
type
,
comments
);
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
16754b5a
...
...
@@ -7683,6 +7683,10 @@ static int32_t extractDescribeResultSchema(int32_t* numOfCols, SSchema** pSchema
(
*
pSchema
)[
3
].
bytes
=
DESCRIBE_RESULT_NOTE_LEN
;
strcpy
((
*
pSchema
)[
3
].
name
,
"note"
);
(
*
pSchema
)[
4
].
type
=
TSDB_DATA_TYPE_BINARY
;
(
*
pSchema
)[
4
].
bytes
=
DESCRIBE_RESULT_COL_COMMENT_LEN
;
strcpy
((
*
pSchema
)[
4
].
name
,
"comment"
);
return
TSDB_CODE_SUCCESS
;
}
...
...
tests/system-test/0-others/show.py
浏览文件 @
16754b5a
...
...
@@ -222,6 +222,15 @@ class TDTestCase:
tdSql
.
query
(
'show create table super_table'
)
create_sql
=
"create stable `super_table` (`ts` timestamp, `c2` int) tags (`tg` int)"
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
1
].
lower
(),
create_sql
)
tdSql
.
query
(
"desc normal_table"
)
tdSql
.
checkCols
(
5
)
tdSql
.
checkData
(
0
,
4
,
""
)
tdSql
.
query
(
"desc super_table"
)
tdSql
.
checkCols
(
5
)
tdSql
.
checkData
(
0
,
4
,
""
)
tdSql
.
execute
(
"drop database comment_test_db"
)
def
alter_table_with_col_comment
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录