Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dcbef83d
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dcbef83d
编写于
8月 15, 2023
作者:
W
wangjiaming0909
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: support column comment
上级
0fc4546c
变更
10
展开全部
显示空白变更内容
内联
并排
Showing
10 changed file
with
2464 addition
and
2435 deletion
+2464
-2435
include/common/tmsg.h
include/common/tmsg.h
+2
-0
include/common/ttokendef.h
include/common/ttokendef.h
+118
-118
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+1
-1
include/util/tdef.h
include/util/tdef.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+4
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+2
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+2
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2320
-2315
tests/system-test/0-others/show.py
tests/system-test/0-others/show.py
+13
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
dcbef83d
...
...
@@ -231,6 +231,7 @@ typedef struct SField {
uint8_t
type
;
int8_t
flags
;
int32_t
bytes
;
char
comment
[
TSDB_COL_COMMENT_LEN
];
}
SField
;
typedef
struct
SRetention
{
...
...
@@ -309,6 +310,7 @@ struct SSchema {
col_id_t
colId
;
int32_t
bytes
;
char
name
[
TSDB_COL_NAME_LEN
];
char
comment
[
TSDB_COL_COMMENT_LEN
];
};
struct
SSchema2
{
...
...
include/common/ttokendef.h
浏览文件 @
dcbef83d
...
...
@@ -130,25 +130,25 @@
#define TK_NK_EQ 112
#define TK_USING 113
#define TK_TAGS 114
#define TK_
BOOL
115
#define TK_
TINYINT
116
#define TK_
SMALLINT
117
#define TK_
INT
118
#define TK_INT
EGER
119
#define TK_
BIGINT
120
#define TK_
FLOAT
121
#define TK_
DOUBLE
122
#define TK_
BINARY
123
#define TK_
NCHAR
124
#define TK_
UNSIGNED
125
#define TK_
JSON
126
#define TK_
VARCHAR
127
#define TK_
MEDIUMBLOB
128
#define TK_
BLOB
129
#define TK_
VARBINARY
130
#define TK_
GEOMETRY
131
#define TK_
DECIMAL
132
#define TK_
COMMENT
133
#define TK_
COMMENT
115
#define TK_
BOOL
116
#define TK_
TINYINT
117
#define TK_
SMALLINT
118
#define TK_INT
119
#define TK_
INTEGER
120
#define TK_
BIGINT
121
#define TK_
FLOAT
122
#define TK_
DOUBLE
123
#define TK_
BINARY
124
#define TK_
NCHAR
125
#define TK_
UNSIGNED
126
#define TK_
JSON
127
#define TK_
VARCHAR
128
#define TK_
MEDIUMBLOB
129
#define TK_
BLOB
130
#define TK_
VARBINARY
131
#define TK_
GEOMETRY
132
#define TK_
DECIMAL
133
#define TK_MAX_DELAY 134
#define TK_WATERMARK 135
#define TK_ROLLUP 136
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
dcbef83d
...
...
@@ -155,7 +155,7 @@ typedef struct SColumnDefNode {
ENodeType
type
;
char
colName
[
TSDB_COL_NAME_LEN
];
SDataType
dataType
;
char
comments
[
TSDB_
TB
_COMMENT_LEN
];
char
comments
[
TSDB_
COL
_COMMENT_LEN
];
bool
sma
;
}
SColumnDefNode
;
...
...
include/util/tdef.h
浏览文件 @
dcbef83d
...
...
@@ -230,6 +230,7 @@ typedef enum ELogicConditionType {
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
#define TSDB_TB_COMMENT_LEN 1025
#define TSDB_COL_COMMENT_LEN 1025
#define TSDB_QUERY_ID_LEN 26
#define TSDB_TRANS_OPER_LEN 16
...
...
source/common/src/tmsg.c
浏览文件 @
dcbef83d
...
...
@@ -534,6 +534,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
comment
)
<
0
)
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfTags
;
++
i
)
{
...
...
@@ -542,6 +543,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
comment
)
<
0
)
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFuncs
;
++
i
)
{
...
...
@@ -608,6 +610,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeI8
(
&
decoder
,
&
field
.
flags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
comment
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pColumns
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -620,6 +623,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeI8
(
&
decoder
,
&
field
.
flags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
comment
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pTags
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
dcbef83d
...
...
@@ -834,6 +834,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
pSchema
->
bytes
=
pField
->
bytes
;
pSchema
->
flags
=
pField
->
flags
;
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
memcpy
(
pSchema
->
comment
,
pField
->
comment
,
TSDB_COL_COMMENT_LEN
);
pSchema
->
colId
=
pDst
->
nextColId
;
pDst
->
nextColId
++
;
}
...
...
@@ -847,6 +848,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
SSCHMEA_SET_IDX_ON
(
pSchema
);
}
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
memcpy
(
pSchema
->
comment
,
pField
->
comment
,
TSDB_COL_COMMENT_LEN
);
pSchema
->
colId
=
pDst
->
nextColId
;
pDst
->
nextColId
++
;
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
dcbef83d
...
...
@@ -358,7 +358,7 @@ column_def_list(A) ::= column_def(B).
column_def_list(A) ::= column_def_list(B) NK_COMMA column_def(C). { A = addNodeToList(pCxt, B, C); }
column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt, &B, C, NULL); }
//
column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, &B, C, &D); }
column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, &B, C, &D); }
%type type_name { SDataType }
%destructor type_name { }
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
dcbef83d
...
...
@@ -4688,6 +4688,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) {
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
pNode
;
SField
field
=
{.
type
=
pCol
->
dataType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
dataType
)};
strcpy
(
field
.
name
,
pCol
->
colName
);
strcpy
(
field
.
comment
,
pCol
->
comments
);
if
(
pCol
->
sma
)
{
field
.
flags
|=
COL_SMA_ON
;
}
...
...
@@ -5035,6 +5036,7 @@ static void toSchema(const SColumnDefNode* pCol, col_id_t colId, SSchema* pSchem
pSchema
->
bytes
=
calcTypeBytes
(
pCol
->
dataType
);
pSchema
->
flags
=
flags
;
strcpy
(
pSchema
->
name
,
pCol
->
colName
);
strcpy
(
pSchema
->
comment
,
pCol
->
comments
);
}
typedef
struct
SSampleAstInfo
{
...
...
source/libs/parser/src/sql.c
浏览文件 @
dcbef83d
此差异已折叠。
点击以展开。
tests/system-test/0-others/show.py
浏览文件 @
dcbef83d
...
...
@@ -210,6 +210,18 @@ class TDTestCase:
licences_info
=
tdSql
.
queryResult
tdSql
.
checkEqual
(
grants_info
,
licences_info
)
def
show_create_table_with_col_comment
(
self
):
tdSql
.
execute
(
"create database comment_test_db"
)
tdSql
.
execute
(
"use comment_test_db"
)
tdSql
.
execute
(
"create table normal_table(ts timestamp, c2 int comment 'c2 comment')"
)
tdSql
.
execute
(
"create stable super_table(ts timestamp comment 'ts', c2 int comment 'c2 comment') tags(tg int comment 'tg comment')"
)
tdSql
.
query
(
'show create table normal_table'
)
create_sql
=
"create table `normal_table` (`ts` timestamp, `c2` int)"
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
1
].
lower
(),
create_sql
)
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
)
def
run
(
self
):
self
.
check_gitinfo
()
self
.
show_base
()
...
...
@@ -218,6 +230,7 @@ class TDTestCase:
self
.
show_create_sql
()
self
.
show_create_sysdb_sql
()
self
.
show_create_systb_sql
()
self
.
show_create_table_with_col_comment
()
def
stop
(
self
):
tdSql
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录