Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
85ec4e55
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
85ec4e55
编写于
8月 17, 2023
作者:
L
liuyao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feat/ly_multi
上级
1b8ec28d
4b0d08d5
变更
15
展开全部
隐藏空白更改
内联
并排
Showing
15 changed file
with
2822 addition
and
2661 deletion
+2822
-2661
docs/zh/12-taos-sql/14-stream.md
docs/zh/12-taos-sql/14-stream.md
+9
-0
include/common/tmsg.h
include/common/tmsg.h
+5
-0
include/common/ttokendef.h
include/common/ttokendef.h
+118
-118
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+7
-5
include/util/tdef.h
include/util/tdef.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+6
-2
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+2
-0
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/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-2
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+5
-5
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+5
-7
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+24
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2556
-2518
tests/system-test/0-others/show.py
tests/system-test/0-others/show.py
+62
-0
未找到文件。
docs/zh/12-taos-sql/14-stream.md
浏览文件 @
85ec4e55
...
@@ -249,3 +249,12 @@ T = 最新事件时间 - DELETE_MARK
...
@@ -249,3 +249,12 @@ T = 最新事件时间 - DELETE_MARK
-
[
unique
](
../function/#unique
)
-
[
unique
](
../function/#unique
)
-
[
mode
](
../function/#mode
)
-
[
mode
](
../function/#mode
)
## 暂停、恢复流计算
1.
流计算暂停计算任务
PAUSE STREAM [IF EXISTS] stream_name;
没有指定IF EXISTS,如果该stream不存在,则报错;如果存在,则暂停流计算。指定了IF EXISTS,如果该stream不存在,则返回成功;如果存在,则暂停流计算
2.
流计算恢复计算任务
RESUME STREAM [IF EXISTS] [IGNORE UNTREATED] stream_name;
没有指定IF EXISTS,如果该stream不存在,则报错,如果存在,则恢复流计算;指定了IF EXISTS,如果stream不存在,则返回成功;如果存在,则恢复流计算。如果指定IGNORE UNTREATED,则恢复流计算时,忽略流计算暂停期间写入的数据。
include/common/tmsg.h
浏览文件 @
85ec4e55
...
@@ -231,6 +231,7 @@ typedef struct SField {
...
@@ -231,6 +231,7 @@ typedef struct SField {
uint8_t
type
;
uint8_t
type
;
int8_t
flags
;
int8_t
flags
;
int32_t
bytes
;
int32_t
bytes
;
char
comment
[
TSDB_COL_COMMENT_LEN
];
}
SField
;
}
SField
;
typedef
struct
SRetention
{
typedef
struct
SRetention
{
...
@@ -309,6 +310,7 @@ struct SSchema {
...
@@ -309,6 +310,7 @@ struct SSchema {
col_id_t
colId
;
col_id_t
colId
;
int32_t
bytes
;
int32_t
bytes
;
char
name
[
TSDB_COL_NAME_LEN
];
char
name
[
TSDB_COL_NAME_LEN
];
char
comment
[
TSDB_COL_COMMENT_LEN
];
};
};
struct
SSchema2
{
struct
SSchema2
{
...
@@ -2387,6 +2389,9 @@ typedef struct {
...
@@ -2387,6 +2389,9 @@ typedef struct {
int8_t
type
;
int8_t
type
;
int8_t
flags
;
int8_t
flags
;
int32_t
bytes
;
int32_t
bytes
;
bool
hasColComment
;
char
*
colComment
;
int32_t
colCommentLen
;
// TSDB_ALTER_TABLE_DROP_COLUMN
// TSDB_ALTER_TABLE_DROP_COLUMN
// TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
// TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
int8_t
colModType
;
int8_t
colModType
;
...
...
include/common/ttokendef.h
浏览文件 @
85ec4e55
...
@@ -16,105 +16,105 @@
...
@@ -16,105 +16,105 @@
#ifndef _TD_COMMON_TOKEN_H_
#ifndef _TD_COMMON_TOKEN_H_
#define _TD_COMMON_TOKEN_H_
#define _TD_COMMON_TOKEN_H_
#define TK_OR
1
#define TK_OR 1
#define TK_AND
2
#define TK_AND 2
#define TK_UNION
3
#define TK_UNION 3
#define TK_ALL
4
#define TK_ALL 4
#define TK_MINUS
5
#define TK_MINUS 5
#define TK_EXCEPT
6
#define TK_EXCEPT 6
#define TK_INTERSECT
7
#define TK_INTERSECT 7
#define TK_NK_BITAND
8
#define TK_NK_BITAND 8
#define TK_NK_BITOR
9
#define TK_NK_BITOR 9
#define TK_NK_LSHIFT
10
#define TK_NK_LSHIFT 10
#define TK_NK_RSHIFT
11
#define TK_NK_RSHIFT 11
#define TK_NK_PLUS
12
#define TK_NK_PLUS 12
#define TK_NK_MINUS
13
#define TK_NK_MINUS 13
#define TK_NK_STAR
14
#define TK_NK_STAR 14
#define TK_NK_SLASH
15
#define TK_NK_SLASH 15
#define TK_NK_REM
16
#define TK_NK_REM 16
#define TK_NK_CONCAT
17
#define TK_NK_CONCAT 17
#define TK_CREATE
18
#define TK_CREATE 18
#define TK_ACCOUNT
19
#define TK_ACCOUNT 19
#define TK_NK_ID
20
#define TK_NK_ID 20
#define TK_PASS
21
#define TK_PASS 21
#define TK_NK_STRING
22
#define TK_NK_STRING 22
#define TK_ALTER
23
#define TK_ALTER 23
#define TK_PPS
24
#define TK_PPS 24
#define TK_TSERIES
25
#define TK_TSERIES 25
#define TK_STORAGE
26
#define TK_STORAGE 26
#define TK_STREAMS
27
#define TK_STREAMS 27
#define TK_QTIME
28
#define TK_QTIME 28
#define TK_DBS
29
#define TK_DBS 29
#define TK_USERS
30
#define TK_USERS 30
#define TK_CONNS
31
#define TK_CONNS 31
#define TK_STATE
32
#define TK_STATE 32
#define TK_USER
33
#define TK_USER 33
#define TK_ENABLE
34
#define TK_ENABLE 34
#define TK_NK_INTEGER
35
#define TK_NK_INTEGER 35
#define TK_SYSINFO
36
#define TK_SYSINFO 36
#define TK_DROP
37
#define TK_DROP 37
#define TK_GRANT
38
#define TK_GRANT 38
#define TK_ON
39
#define TK_ON 39
#define TK_TO
40
#define TK_TO 40
#define TK_REVOKE
41
#define TK_REVOKE 41
#define TK_FROM
42
#define TK_FROM 42
#define TK_SUBSCRIBE
43
#define TK_SUBSCRIBE 43
#define TK_NK_COMMA
44
#define TK_NK_COMMA 44
#define TK_READ
45
#define TK_READ 45
#define TK_WRITE
46
#define TK_WRITE 46
#define TK_NK_DOT
47
#define TK_NK_DOT 47
#define TK_WITH
48
#define TK_WITH 48
#define TK_DNODE
49
#define TK_DNODE 49
#define TK_PORT
50
#define TK_PORT 50
#define TK_DNODES
51
#define TK_DNODES 51
#define TK_RESTORE
52
#define TK_RESTORE 52
#define TK_NK_IPTOKEN
53
#define TK_NK_IPTOKEN 53
#define TK_FORCE
54
#define TK_FORCE 54
#define TK_UNSAFE
55
#define TK_UNSAFE 55
#define TK_LOCAL
56
#define TK_LOCAL 56
#define TK_QNODE
57
#define TK_QNODE 57
#define TK_BNODE
58
#define TK_BNODE 58
#define TK_SNODE
59
#define TK_SNODE 59
#define TK_MNODE
60
#define TK_MNODE 60
#define TK_VNODE
61
#define TK_VNODE 61
#define TK_DATABASE
62
#define TK_DATABASE 62
#define TK_USE
63
#define TK_USE 63
#define TK_FLUSH
64
#define TK_FLUSH 64
#define TK_TRIM
65
#define TK_TRIM 65
#define TK_COMPACT
66
#define TK_COMPACT 66
#define TK_IF
67
#define TK_IF 67
#define TK_NOT
68
#define TK_NOT 68
#define TK_EXISTS
69
#define TK_EXISTS 69
#define TK_BUFFER
70
#define TK_BUFFER 70
#define TK_CACHEMODEL
71
#define TK_CACHEMODEL 71
#define TK_CACHESIZE
72
#define TK_CACHESIZE 72
#define TK_COMP
73
#define TK_COMP 73
#define TK_DURATION
74
#define TK_DURATION 74
#define TK_NK_VARIABLE
75
#define TK_NK_VARIABLE 75
#define TK_MAXROWS
76
#define TK_MAXROWS 76
#define TK_MINROWS
77
#define TK_MINROWS 77
#define TK_KEEP
78
#define TK_KEEP 78
#define TK_PAGES
79
#define TK_PAGES 79
#define TK_PAGESIZE
80
#define TK_PAGESIZE 80
#define TK_TSDB_PAGESIZE
81
#define TK_TSDB_PAGESIZE 81
#define TK_PRECISION
82
#define TK_PRECISION 82
#define TK_REPLICA
83
#define TK_REPLICA 83
#define TK_VGROUPS
84
#define TK_VGROUPS 84
#define TK_SINGLE_STABLE
85
#define TK_SINGLE_STABLE 85
#define TK_RETENTIONS
86
#define TK_RETENTIONS 86
#define TK_SCHEMALESS
87
#define TK_SCHEMALESS 87
#define TK_WAL_LEVEL
88
#define TK_WAL_LEVEL 88
#define TK_WAL_FSYNC_PERIOD
89
#define TK_WAL_FSYNC_PERIOD 89
#define TK_WAL_RETENTION_PERIOD
90
#define TK_WAL_RETENTION_PERIOD 90
#define TK_WAL_RETENTION_SIZE
91
#define TK_WAL_RETENTION_SIZE 91
#define TK_WAL_ROLL_PERIOD
92
#define TK_WAL_ROLL_PERIOD 92
#define TK_WAL_SEGMENT_SIZE
93
#define TK_WAL_SEGMENT_SIZE 93
#define TK_STT_TRIGGER
94
#define TK_STT_TRIGGER 94
#define TK_TABLE_PREFIX
95
#define TK_TABLE_PREFIX 95
#define TK_TABLE_SUFFIX
96
#define TK_TABLE_SUFFIX 96
#define TK_NK_COLON
97
#define TK_NK_COLON 97
#define TK_MAX_SPEED
98
#define TK_MAX_SPEED 98
#define TK_START
99
#define TK_START 99
#define TK_TIMESTAMP 100
#define TK_TIMESTAMP 100
#define TK_END 101
#define TK_END 101
#define TK_TABLE 102
#define TK_TABLE 102
...
@@ -130,25 +130,25 @@
...
@@ -130,25 +130,25 @@
#define TK_NK_EQ 112
#define TK_NK_EQ 112
#define TK_USING 113
#define TK_USING 113
#define TK_TAGS 114
#define TK_TAGS 114
#define TK_
BOOL
115
#define TK_
COMMENT
115
#define TK_
TINYINT
116
#define TK_
BOOL
116
#define TK_
SMALLINT
117
#define TK_
TINYINT
117
#define TK_
INT
118
#define TK_
SMALLINT
118
#define TK_INT
EGER
119
#define TK_INT
119
#define TK_
BIGINT
120
#define TK_
INTEGER
120
#define TK_
FLOAT
121
#define TK_
BIGINT
121
#define TK_
DOUBLE
122
#define TK_
FLOAT
122
#define TK_
BINARY
123
#define TK_
DOUBLE
123
#define TK_
NCHAR
124
#define TK_
BINARY
124
#define TK_
UNSIGNED
125
#define TK_
NCHAR
125
#define TK_
JSON
126
#define TK_
UNSIGNED
126
#define TK_
VARCHAR
127
#define TK_
JSON
127
#define TK_
MEDIUMBLOB
128
#define TK_
VARCHAR
128
#define TK_
BLOB
129
#define TK_
MEDIUMBLOB
129
#define TK_
VARBINARY
130
#define TK_
BLOB
130
#define TK_
GEOMETRY
131
#define TK_
VARBINARY
131
#define TK_
DECIMAL
132
#define TK_
GEOMETRY
132
#define TK_
COMMENT
133
#define TK_
DECIMAL
133
#define TK_MAX_DELAY 134
#define TK_MAX_DELAY 134
#define TK_WATERMARK 135
#define TK_WATERMARK 135
#define TK_ROLLUP 136
#define TK_ROLLUP 136
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
85ec4e55
...
@@ -23,10 +23,11 @@ extern "C" {
...
@@ -23,10 +23,11 @@ extern "C" {
#include "query.h"
#include "query.h"
#include "querynodes.h"
#include "querynodes.h"
#define DESCRIBE_RESULT_COLS 4
#define DESCRIBE_RESULT_COLS 5
#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE)
#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_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
#define DESCRIBE_RESULT_NOTE_LEN (8 + 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_COLS 2
#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)
...
@@ -155,7 +156,7 @@ typedef struct SColumnDefNode {
...
@@ -155,7 +156,7 @@ typedef struct SColumnDefNode {
ENodeType
type
;
ENodeType
type
;
char
colName
[
TSDB_COL_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
SDataType
dataType
;
SDataType
dataType
;
char
comments
[
TSDB_
TB
_COMMENT_LEN
];
char
comments
[
TSDB_
COL
_COMMENT_LEN
];
bool
sma
;
bool
sma
;
}
SColumnDefNode
;
}
SColumnDefNode
;
...
@@ -214,6 +215,7 @@ typedef struct SAlterTableStmt {
...
@@ -214,6 +215,7 @@ typedef struct SAlterTableStmt {
char
newColName
[
TSDB_COL_NAME_LEN
];
char
newColName
[
TSDB_COL_NAME_LEN
];
STableOptions
*
pOptions
;
STableOptions
*
pOptions
;
SDataType
dataType
;
SDataType
dataType
;
char
colComment
[
TSDB_COL_COMMENT_LEN
];
SValueNode
*
pVal
;
SValueNode
*
pVal
;
}
SAlterTableStmt
;
}
SAlterTableStmt
;
...
...
include/util/tdef.h
浏览文件 @
85ec4e55
...
@@ -230,6 +230,7 @@ typedef enum ELogicConditionType {
...
@@ -230,6 +230,7 @@ typedef enum ELogicConditionType {
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
#define TSDB_TB_COMMENT_LEN 1025
#define TSDB_TB_COMMENT_LEN 1025
#define TSDB_COL_COMMENT_LEN 1025
#define TSDB_QUERY_ID_LEN 26
#define TSDB_QUERY_ID_LEN 26
#define TSDB_TRANS_OPER_LEN 16
#define TSDB_TRANS_OPER_LEN 16
...
...
source/common/src/tmsg.c
浏览文件 @
85ec4e55
...
@@ -534,6 +534,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -534,6 +534,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
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
)
{
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfTags
;
++
i
)
{
...
@@ -542,6 +543,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -542,6 +543,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
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
)
{
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFuncs
;
++
i
)
{
...
@@ -608,6 +610,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -608,6 +610,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeI8
(
&
decoder
,
&
field
.
flags
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
field
.
flags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
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
)
{
if
(
taosArrayPush
(
pReq
->
pColumns
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -620,6 +623,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -620,6 +623,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeI8
(
&
decoder
,
&
field
.
flags
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
field
.
flags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
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
)
{
if
(
taosArrayPush
(
pReq
->
pTags
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -2301,7 +2305,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
...
@@ -2301,7 +2305,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
}
}
int32_t
totalCols
=
pRsp
->
numOfTags
+
pRsp
->
numOfColumns
;
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
;
if
(
pRsp
->
pSchemas
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
...
@@ -3684,7 +3688,7 @@ static int32_t tDecodeSTableMetaRsp(SDecoder *pDecoder, STableMetaRsp *pRsp) {
...
@@ -3684,7 +3688,7 @@ static int32_t tDecodeSTableMetaRsp(SDecoder *pDecoder, STableMetaRsp *pRsp) {
int32_t
totalCols
=
pRsp
->
numOfTags
+
pRsp
->
numOfColumns
;
int32_t
totalCols
=
pRsp
->
numOfTags
+
pRsp
->
numOfColumns
;
if
(
totalCols
>
0
)
{
if
(
totalCols
>
0
)
{
pRsp
->
pSchemas
=
taosMemory
Malloc
(
sizeof
(
SSchema
)
*
totalCols
);
pRsp
->
pSchemas
=
taosMemory
Calloc
(
totalCols
,
sizeof
(
SSchema
)
);
if
(
pRsp
->
pSchemas
==
NULL
)
return
-
1
;
if
(
pRsp
->
pSchemas
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
85ec4e55
...
@@ -835,6 +835,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -835,6 +835,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
pSchema
->
bytes
=
pField
->
bytes
;
pSchema
->
bytes
=
pField
->
bytes
;
pSchema
->
flags
=
pField
->
flags
;
pSchema
->
flags
=
pField
->
flags
;
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
memcpy
(
pSchema
->
comment
,
pField
->
comment
,
TSDB_COL_COMMENT_LEN
);
pSchema
->
colId
=
pDst
->
nextColId
;
pSchema
->
colId
=
pDst
->
nextColId
;
pDst
->
nextColId
++
;
pDst
->
nextColId
++
;
}
}
...
@@ -848,6 +849,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -848,6 +849,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
SSCHMEA_SET_IDX_ON
(
pSchema
);
SSCHMEA_SET_IDX_ON
(
pSchema
);
}
}
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
memcpy
(
pSchema
->
comment
,
pField
->
comment
,
TSDB_COL_COMMENT_LEN
);
pSchema
->
colId
=
pDst
->
nextColId
;
pSchema
->
colId
=
pDst
->
nextColId
;
pDst
->
nextColId
++
;
pDst
->
nextColId
++
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
85ec4e55
...
@@ -216,7 +216,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
...
@@ -216,7 +216,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
cfgRsp
.
numOfTags
=
schemaTag
.
nCols
;
cfgRsp
.
numOfTags
=
schemaTag
.
nCols
;
cfgRsp
.
numOfColumns
=
schema
.
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
);
memcpy
(
cfgRsp
.
pSchemas
,
schema
.
pSchema
,
sizeof
(
SSchema
)
*
schema
.
nCols
);
if
(
schemaTag
.
nCols
)
{
if
(
schemaTag
.
nCols
)
{
...
...
source/libs/command/src/command.c
浏览文件 @
85ec4e55
...
@@ -78,6 +78,10 @@ static int32_t buildDescResultDataBlock(SSDataBlock** pOutput) {
...
@@ -78,6 +78,10 @@ static int32_t buildDescResultDataBlock(SSDataBlock** pOutput) {
infoData
=
createColumnInfoData
(
TSDB_DATA_TYPE_VARCHAR
,
DESCRIBE_RESULT_NOTE_LEN
,
4
);
infoData
=
createColumnInfoData
(
TSDB_DATA_TYPE_VARCHAR
,
DESCRIBE_RESULT_NOTE_LEN
,
4
);
code
=
blockDataAppendColInfo
(
pBlock
,
&
infoData
);
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
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOutput
=
pBlock
;
*
pOutput
=
pBlock
;
...
@@ -99,7 +103,9 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
...
@@ -99,7 +103,9 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
SColumnInfoData
*
pCol3
=
taosArrayGet
(
pBlock
->
pDataBlock
,
2
);
SColumnInfoData
*
pCol3
=
taosArrayGet
(
pBlock
->
pDataBlock
,
2
);
// Note
// Note
SColumnInfoData
*
pCol4
=
taosArrayGet
(
pBlock
->
pDataBlock
,
3
);
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
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
if
(
invisibleColumn
(
sysInfoUser
,
pMeta
->
tableType
,
pMeta
->
schema
[
i
].
flags
))
{
if
(
invisibleColumn
(
sysInfoUser
,
pMeta
->
tableType
,
pMeta
->
schema
[
i
].
flags
))
{
continue
;
continue
;
...
@@ -112,6 +118,8 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
...
@@ -112,6 +118,8 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
colDataSetVal
(
pCol3
,
pBlock
->
info
.
rows
,
(
const
char
*
)
&
bytes
,
false
);
colDataSetVal
(
pCol3
,
pBlock
->
info
.
rows
,
(
const
char
*
)
&
bytes
,
false
);
STR_TO_VARSTR
(
buf
,
i
>=
pMeta
->
tableInfo
.
numOfColumns
?
"TAG"
:
""
);
STR_TO_VARSTR
(
buf
,
i
>=
pMeta
->
tableInfo
.
numOfColumns
?
"TAG"
:
""
);
colDataSetVal
(
pCol4
,
pBlock
->
info
.
rows
,
buf
,
false
);
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
);
++
(
pBlock
->
info
.
rows
);
}
}
if
(
pBlock
->
info
.
rows
<=
0
)
{
if
(
pBlock
->
info
.
rows
<=
0
)
{
...
@@ -456,14 +464,19 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
...
@@ -456,14 +464,19 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
for
(
int32_t
i
=
0
;
i
<
pCfg
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCfg
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
pCfg
->
pSchemas
+
i
;
SSchema
*
pSchema
=
pCfg
->
pSchemas
+
i
;
char
type
[
32
];
char
type
[
32
];
char
comments
[
TSDB_COL_COMMENT_LEN
+
16
]
=
{
0
};
sprintf
(
type
,
"%s"
,
tDataTypes
[
pSchema
->
type
].
name
);
sprintf
(
type
,
"%s"
,
tDataTypes
[
pSchema
->
type
].
name
);
if
(
TSDB_DATA_TYPE_VARCHAR
==
pSchema
->
type
||
TSDB_DATA_TYPE_GEOMETRY
==
pSchema
->
type
)
{
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
));
sprintf
(
type
+
strlen
(
type
),
"(%d)"
,
(
int32_t
)(
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
));
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
pSchema
->
type
)
{
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
pSchema
->
type
)
{
sprintf
(
type
+
strlen
(
type
),
"(%d)"
,
(
int32_t
)((
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
));
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) {
...
@@ -471,14 +484,18 @@ void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) {
for
(
int32_t
i
=
0
;
i
<
pCfg
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCfg
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
pCfg
->
pSchemas
+
pCfg
->
numOfColumns
+
i
;
SSchema
*
pSchema
=
pCfg
->
pSchemas
+
pCfg
->
numOfColumns
+
i
;
char
type
[
32
];
char
type
[
32
];
char
comments
[
TSDB_COL_COMMENT_LEN
+
16
]
=
{
0
};
sprintf
(
type
,
"%s"
,
tDataTypes
[
pSchema
->
type
].
name
);
sprintf
(
type
,
"%s"
,
tDataTypes
[
pSchema
->
type
].
name
);
if
(
TSDB_DATA_TYPE_VARCHAR
==
pSchema
->
type
||
TSDB_DATA_TYPE_GEOMETRY
==
pSchema
->
type
)
{
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
));
sprintf
(
type
+
strlen
(
type
),
"(%d)"
,
(
int32_t
)(
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
));
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
pSchema
->
type
)
{
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
pSchema
->
type
)
{
sprintf
(
type
+
strlen
(
type
),
"(%d)"
,
(
int32_t
)((
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
));
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/inc/parAst.h
浏览文件 @
85ec4e55
...
@@ -171,8 +171,7 @@ SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNod
...
@@ -171,8 +171,7 @@ SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNod
SNode
*
createDropTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pTables
);
SNode
*
createDropTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pTables
);
SNode
*
createDropSuperTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createDropSuperTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createAlterTableModifyOptions
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
SNode
*
pOptions
);
SNode
*
createAlterTableModifyOptions
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
SNode
*
pOptions
);
SNode
*
createAlterTableAddModifyCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
SToken
*
pColName
,
SNode
*
createAlterTableAddModifyCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
SNode
*
pColDefNode
);
SDataType
dataType
);
SNode
*
createAlterTableDropCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
SToken
*
pColName
);
SNode
*
createAlterTableDropCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
SToken
*
pColName
);
SNode
*
createAlterTableRenameCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
SToken
*
pOldColName
,
SNode
*
createAlterTableRenameCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
SToken
*
pOldColName
,
SToken
*
pNewColName
);
SToken
*
pNewColName
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
85ec4e55
...
@@ -312,17 +312,17 @@ cmd ::= ALTER STABLE alter_table_clause(A).
...
@@ -312,17 +312,17 @@ cmd ::= ALTER STABLE alter_table_clause(A).
alter_table_clause(A) ::= full_table_name(B) alter_table_options(C). { A = createAlterTableModifyOptions(pCxt, B, C); }
alter_table_clause(A) ::= full_table_name(B) alter_table_options(C). { A = createAlterTableModifyOptions(pCxt, B, C); }
alter_table_clause(A) ::=
alter_table_clause(A) ::=
full_table_name(B) ADD COLUMN column_
name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D
); }
full_table_name(B) ADD COLUMN column_
def(C). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, C
); }
alter_table_clause(A) ::= full_table_name(B) DROP COLUMN column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_DROP_COLUMN, &C); }
alter_table_clause(A) ::= full_table_name(B) DROP COLUMN column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_DROP_COLUMN, &C); }
alter_table_clause(A) ::=
alter_table_clause(A) ::=
full_table_name(B) MODIFY COLUMN column_
name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &C, D
); }
full_table_name(B) MODIFY COLUMN column_
def(C). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, C
); }
alter_table_clause(A) ::=
alter_table_clause(A) ::=
full_table_name(B) RENAME COLUMN column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &C, &D); }
full_table_name(B) RENAME COLUMN column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &C, &D); }
alter_table_clause(A) ::=
alter_table_clause(A) ::=
full_table_name(B) ADD TAG column_
name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_TAG, &C, D
); }
full_table_name(B) ADD TAG column_
def(C). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_TAG, C
); }
alter_table_clause(A) ::= full_table_name(B) DROP TAG column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_DROP_TAG, &C); }
alter_table_clause(A) ::= full_table_name(B) DROP TAG column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_DROP_TAG, &C); }
alter_table_clause(A) ::=
alter_table_clause(A) ::=
full_table_name(B) MODIFY TAG column_
name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &C, D
); }
full_table_name(B) MODIFY TAG column_
def(C). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, C
); }
alter_table_clause(A) ::=
alter_table_clause(A) ::=
full_table_name(B) RENAME TAG column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &C, &D); }
full_table_name(B) RENAME TAG column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &C, &D); }
alter_table_clause(A) ::=
alter_table_clause(A) ::=
...
@@ -358,7 +358,7 @@ column_def_list(A) ::= column_def(B).
...
@@ -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_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). { 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 }
%type type_name { SDataType }
%destructor type_name { }
%destructor type_name { }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
85ec4e55
...
@@ -1333,17 +1333,15 @@ SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable,
...
@@ -1333,17 +1333,15 @@ SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable,
return
createAlterTableStmtFinalize
(
pRealTable
,
pStmt
);
return
createAlterTableStmtFinalize
(
pRealTable
,
pStmt
);
}
}
SNode
*
createAlterTableAddModifyCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
SToken
*
pColName
,
SNode
*
createAlterTableAddModifyCol
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
,
int8_t
alterType
,
SNode
*
pColDefNode
)
{
SDataType
dataType
)
{
CHECK_PARSER_STATUS
(
pCxt
);
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkColumnName
(
pCxt
,
pColName
))
{
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
pColDefNode
;
return
NULL
;
}
SAlterTableStmt
*
pStmt
=
(
SAlterTableStmt
*
)
nodesMakeNode
(
QUERY_NODE_ALTER_TABLE_STMT
);
SAlterTableStmt
*
pStmt
=
(
SAlterTableStmt
*
)
nodesMakeNode
(
QUERY_NODE_ALTER_TABLE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
alterType
=
alterType
;
pStmt
->
alterType
=
alterType
;
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
colName
,
pColName
);
strcpy
(
pStmt
->
colName
,
pCol
->
colName
);
pStmt
->
dataType
=
dataType
;
strcpy
(
pStmt
->
colComment
,
pCol
->
comments
);
pStmt
->
dataType
=
pCol
->
dataType
;
return
createAlterTableStmtFinalize
(
pRealTable
,
pStmt
);
return
createAlterTableStmtFinalize
(
pRealTable
,
pStmt
);
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
85ec4e55
...
@@ -4697,6 +4697,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) {
...
@@ -4697,6 +4697,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) {
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
pNode
;
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
pNode
;
SField
field
=
{.
type
=
pCol
->
dataType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
dataType
)};
SField
field
=
{.
type
=
pCol
->
dataType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
dataType
)};
strcpy
(
field
.
name
,
pCol
->
colName
);
strcpy
(
field
.
name
,
pCol
->
colName
);
strcpy
(
field
.
comment
,
pCol
->
comments
);
if
(
pCol
->
sma
)
{
if
(
pCol
->
sma
)
{
field
.
flags
|=
COL_SMA_ON
;
field
.
flags
|=
COL_SMA_ON
;
}
}
...
@@ -5044,6 +5045,7 @@ static void toSchema(const SColumnDefNode* pCol, col_id_t colId, SSchema* pSchem
...
@@ -5044,6 +5045,7 @@ static void toSchema(const SColumnDefNode* pCol, col_id_t colId, SSchema* pSchem
pSchema
->
bytes
=
calcTypeBytes
(
pCol
->
dataType
);
pSchema
->
bytes
=
calcTypeBytes
(
pCol
->
dataType
);
pSchema
->
flags
=
flags
;
pSchema
->
flags
=
flags
;
strcpy
(
pSchema
->
name
,
pCol
->
colName
);
strcpy
(
pSchema
->
name
,
pCol
->
colName
);
strcpy
(
pSchema
->
comment
,
pCol
->
comments
);
}
}
typedef
struct
SSampleAstInfo
{
typedef
struct
SSampleAstInfo
{
...
@@ -7692,6 +7694,10 @@ static int32_t extractDescribeResultSchema(int32_t* numOfCols, SSchema** pSchema
...
@@ -7692,6 +7694,10 @@ static int32_t extractDescribeResultSchema(int32_t* numOfCols, SSchema** pSchema
(
*
pSchema
)[
3
].
bytes
=
DESCRIBE_RESULT_NOTE_LEN
;
(
*
pSchema
)[
3
].
bytes
=
DESCRIBE_RESULT_NOTE_LEN
;
strcpy
((
*
pSchema
)[
3
].
name
,
"note"
);
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
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -8874,6 +8880,15 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
...
@@ -8874,6 +8880,15 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
pReq
->
type
=
pStmt
->
dataType
.
type
;
pReq
->
type
=
pStmt
->
dataType
.
type
;
pReq
->
flags
=
COL_SMA_ON
;
pReq
->
flags
=
COL_SMA_ON
;
pReq
->
bytes
=
calcTypeBytes
(
pStmt
->
dataType
);
pReq
->
bytes
=
calcTypeBytes
(
pStmt
->
dataType
);
if
(
pStmt
->
colComment
[
0
])
{
pReq
->
colComment
=
taosStrdup
(
pStmt
->
colComment
);
if
(
pReq
->
colComment
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pReq
->
colCommentLen
=
strlen
(
pReq
->
colComment
);
}
else
{
pReq
->
colCommentLen
=
-
1
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -8924,6 +8939,15 @@ static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
...
@@ -8924,6 +8939,15 @@ static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pReq
->
colId
=
pSchema
->
colId
;
pReq
->
colId
=
pSchema
->
colId
;
if
(
pStmt
->
colComment
[
0
])
{
pReq
->
colComment
=
taosStrdup
(
pStmt
->
colComment
);
if
(
pReq
->
colComment
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pReq
->
colCommentLen
=
strlen
(
pReq
->
colComment
);
}
else
{
pReq
->
colCommentLen
=
-
1
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
85ec4e55
此差异已折叠。
点击以展开。
tests/system-test/0-others/show.py
浏览文件 @
85ec4e55
...
@@ -210,6 +210,66 @@ class TDTestCase:
...
@@ -210,6 +210,66 @@ class TDTestCase:
licences_info
=
tdSql
.
queryResult
licences_info
=
tdSql
.
queryResult
tdSql
.
checkEqual
(
grants_info
,
licences_info
)
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')"
)
create_sql
=
"create table `normal_table` (`ts` timestamp, `c2` int)"
tdSql
.
query
(
'show create table normal_table'
)
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
)
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
):
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')"
)
create_sql
=
"create table `normal_table` (`ts` timestamp, `c2` int, `c3` int)"
tdSql
.
execute
(
"alter table normal_table add column c3 int comment 'c3 comment'"
,
queryTimes
=
1
)
tdSql
.
query
(
"show create table normal_table"
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
1
].
lower
(),
create_sql
)
create_sql
=
"create table `normal_table` (`ts` timestamp, `c2` int, `c3` int, `c4` varchar(255))"
tdSql
.
execute
(
"alter table normal_table add column c4 varchar(255) comment 'c4 comment'"
,
queryTimes
=
1
)
tdSql
.
query
(
"show create table normal_table"
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
1
].
lower
(),
create_sql
)
create_sql
=
"create table `normal_table` (`ts` timestamp, `c2` int, `c3` int, `c4` varchar(255), `c5` varchar(255))"
tdSql
.
execute
(
"alter table normal_table add column c5 varchar(255)"
,
queryTimes
=
1
)
tdSql
.
query
(
"show create table normal_table"
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
1
].
lower
(),
create_sql
)
create_sql
=
"create stable `super_table` (`ts` timestamp, `c2` int, `c3` int) tags (`tg` int) sma(`ts`,`c2`)"
tdSql
.
execute
(
"alter table super_table add column c3 int comment 'c3 comment'"
,
queryTimes
=
1
)
tdSql
.
query
(
"show create table super_table"
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
1
].
lower
(),
create_sql
)
create_sql
=
"create stable `super_table` (`ts` timestamp, `c2` int, `c3` int, `c4` varchar(255)) tags (`tg` int) sma(`ts`,`c2`)"
tdSql
.
execute
(
"alter table super_table add column c4 varchar(255) comment 'c4 comment'"
,
queryTimes
=
1
)
tdSql
.
query
(
"show create table super_table"
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
1
].
lower
(),
create_sql
)
create_sql
=
"create stable `super_table` (`ts` timestamp, `c2` int, `c3` int, `c4` varchar(256)) tags (`tg` int) sma(`ts`,`c2`)"
tdSql
.
execute
(
"alter table super_table modify column c4 varchar(256) comment 'c4 256 comment'"
,
queryTimes
=
1
)
tdSql
.
query
(
"show create table super_table"
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
1
].
lower
(),
create_sql
)
tdSql
.
execute
(
"drop database comment_test_db"
)
def
run
(
self
):
def
run
(
self
):
self
.
check_gitinfo
()
self
.
check_gitinfo
()
self
.
show_base
()
self
.
show_base
()
...
@@ -218,6 +278,8 @@ class TDTestCase:
...
@@ -218,6 +278,8 @@ class TDTestCase:
self
.
show_create_sql
()
self
.
show_create_sql
()
self
.
show_create_sysdb_sql
()
self
.
show_create_sysdb_sql
()
self
.
show_create_systb_sql
()
self
.
show_create_systb_sql
()
self
.
show_create_table_with_col_comment
()
self
.
alter_table_with_col_comment
()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录