Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c20d5741
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c20d5741
编写于
1月 19, 2021
作者:
H
haojun Liao
提交者:
GitHub
1月 19, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4938 from taosdata/feature/TD-2671
[TD-2671]<fix>:support create/drop/alter stable
上级
20f27624
4c203ccb
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
1767 addition
and
1299 deletion
+1767
-1299
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+18
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/inc/ttokendef.h
src/inc/ttokendef.h
+142
-139
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+4
-2
src/query/inc/sql.y
src/query/inc/sql.y
+65
-9
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+4
-2
src/query/src/sql.c
src/query/src/sql.c
+1533
-1146
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
c20d5741
...
...
@@ -264,6 +264,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case
TSDB_SQL_DROP_DB
:
{
const
char
*
msg2
=
"invalid name"
;
const
char
*
msg3
=
"param name too long"
;
const
char
*
msg4
=
"table is not super table"
;
SStrToken
*
pzName
=
&
pInfo
->
pDCLInfo
->
a
[
0
];
if
((
pInfo
->
type
!=
TSDB_SQL_DROP_DNODE
)
&&
(
tscValidateName
(
pzName
)
!=
TSDB_CODE_SUCCESS
))
{
...
...
@@ -285,6 +286,18 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
if
(
pInfo
->
pDCLInfo
->
tableType
==
TSDB_SUPER_TABLE
)
{
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
if
(
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
}
}
else
if
(
pInfo
->
type
==
TSDB_SQL_DROP_DNODE
)
{
pzName
->
n
=
strdequote
(
pzName
->
z
);
strncpy
(
pTableMetaInfo
->
name
,
pzName
->
z
,
pzName
->
n
);
...
...
@@ -4794,6 +4807,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const
char
*
msg17
=
"invalid column name"
;
const
char
*
msg18
=
"primary timestamp column cannot be dropped"
;
const
char
*
msg19
=
"invalid new tag name"
;
const
char
*
msg20
=
"table is not super table"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -4819,6 +4833,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
pAlterSQL
->
tableType
==
TSDB_SUPER_TABLE
&&
!
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
)))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg20
);
}
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
)
{
if
(
UTIL_TABLE_IS_NORMAL_TABLE
(
pTableMetaInfo
))
{
...
...
src/client/src/tscServer.c
浏览文件 @
c20d5741
...
...
@@ -2193,7 +2193,7 @@ int tscProcessDropTableRsp(SSqlObj *pSql) {
tscDebug
(
"%p remove table meta after drop table:%s, numOfRemain:%d"
,
pSql
,
pTableMetaInfo
->
name
,
(
int32_t
)
taosHashGetSize
(
tscTableMetaInfo
));
assert
(
pTableMetaInfo
->
pTableMeta
==
NULL
)
;
pTableMetaInfo
->
pTableMeta
=
NULL
;
return
0
;
}
...
...
src/inc/ttokendef.h
浏览文件 @
c20d5741
...
...
@@ -82,151 +82,154 @@
#define TK_STABLES 64
#define TK_VGROUPS 65
#define TK_DROP 66
#define TK_
DNODE
67
#define TK_
USER
68
#define TK_
ACCOUNT
69
#define TK_
USE
70
#define TK_
DESCRIBE
71
#define TK_
ALTER
72
#define TK_
PASS
73
#define TK_P
RIVILEGE
74
#define TK_
LOCAL
75
#define TK_
IF
76
#define TK_
EXISTS
77
#define TK_
PPS
78
#define TK_
TSERIES
79
#define TK_
DBS
80
#define TK_
STORAGE
81
#define TK_
QTIME
82
#define TK_
CONNS
83
#define TK_
STATE
84
#define TK_
KEEP
85
#define TK_
CACHE
86
#define TK_
REPLICA
87
#define TK_
QUORUM
88
#define TK_
DAYS
89
#define TK_
MINROWS
90
#define TK_M
AX
ROWS 91
#define TK_
BLOCKS
92
#define TK_
CTIME
93
#define TK_
WAL
94
#define TK_
FSYNC
95
#define TK_
COMP
96
#define TK_
PRECISION
97
#define TK_
UPDATE
98
#define TK_
CACHELAST
99
#define TK_
LP
100
#define TK_
R
P 101
#define TK_
UNSIGNED
102
#define TK_
TAGS
103
#define TK_
USING
104
#define TK_
AS
105
#define TK_
COMMA
106
#define TK_
NULL
107
#define TK_
SELECT
108
#define TK_
UNION
109
#define TK_
ALL
110
#define TK_
FROM
111
#define TK_
VARIABLE
112
#define TK_
INTERVAL
113
#define TK_
FILL
114
#define TK_
SLIDING
115
#define TK_
ORDER
116
#define TK_
BY
117
#define TK_
ASC
118
#define TK_
DESC
119
#define TK_
GROUP
120
#define TK_
HAVING
121
#define TK_
LIMIT
122
#define TK_
OFFSET
123
#define TK_
SLIMI
T 124
#define TK_S
OFFSET
125
#define TK_
WHERE
126
#define TK_
NOW
127
#define TK_
RESET
128
#define TK_
QUERY
129
#define TK_
ADD
130
#define TK_
COLUMN
131
#define TK_
TAG
132
#define TK_
CHANGE
133
#define TK_
SET
134
#define TK_
KILL
135
#define TK_
CONNECTION
136
#define TK_
STREAM
137
#define TK_
COLON
138
#define TK_
ABORT
139
#define TK_A
FTER
140
#define TK_A
TTACH
141
#define TK_
BEFORE
142
#define TK_BE
GIN
143
#define TK_
CASCADE
144
#define TK_C
LUSTER
145
#define TK_C
ONFLICT
146
#define TK_CO
PY
147
#define TK_
DEFERRED
148
#define TK_DE
LIMITERS
149
#define TK_DE
TACH
150
#define TK_
EACH
151
#define TK_E
ND
152
#define TK_E
XPLAIN
153
#define TK_
FAIL
154
#define TK_F
OR
155
#define TK_
IGNORE
156
#define TK_I
MMEDIATE
157
#define TK_I
NITIALLY
158
#define TK_IN
STEAD
159
#define TK_
MATCH
160
#define TK_
KEY
161
#define TK_
OF
162
#define TK_
RAISE
163
#define TK_R
EPLACE
164
#define TK_RE
STRICT
165
#define TK_R
OW
166
#define TK_
STATEMENT
167
#define TK_
TRIGGER
168
#define TK_
VIEW
169
#define TK_
COUNT
170
#define TK_
SUM
171
#define TK_
AVG
172
#define TK_
MIN
173
#define TK_M
AX
174
#define TK_
FIRST
175
#define TK_
LAST
176
#define TK_
TOP
177
#define TK_
BOTTOM
178
#define TK_
STDDEV
179
#define TK_
PERCENTILE
180
#define TK_
APERCENTILE
181
#define TK_
LEASTSQUARES
182
#define TK_
HISTOGRAM
183
#define TK_
DIFF
184
#define TK_
SPREAD
185
#define TK_
TWA
186
#define TK_
INTERP
187
#define TK_
LAST_ROW
188
#define TK_
RATE
189
#define TK_
IRATE
190
#define TK_
SUM_RATE
191
#define TK_SUM_
IRATE
192
#define TK_
AVG_RATE
193
#define TK_AVG_
IRATE
194
#define TK_
TBID
195
#define TK_
SEMI
196
#define TK_
NONE
197
#define TK_
PREV
198
#define TK_
LINEAR
199
#define TK_
IMPORT
200
#define TK_
METRIC
201
#define TK_
TBNAME
202
#define TK_
JOIN
203
#define TK_
METRICS
204
#define TK_
STABLE
205
#define TK_
STABLE
67
#define TK_
DNODE
68
#define TK_
USER
69
#define TK_
ACCOUNT
70
#define TK_
USE
71
#define TK_
DESCRIBE
72
#define TK_
ALTER
73
#define TK_P
ASS
74
#define TK_
PRIVILEGE
75
#define TK_
LOCAL
76
#define TK_
IF
77
#define TK_
EXISTS
78
#define TK_
PPS
79
#define TK_
TSERIES
80
#define TK_
DBS
81
#define TK_
STORAGE
82
#define TK_
QTIME
83
#define TK_
CONNS
84
#define TK_
STATE
85
#define TK_
KEEP
86
#define TK_
CACHE
87
#define TK_
REPLICA
88
#define TK_
QUORUM
89
#define TK_
DAYS
90
#define TK_M
IN
ROWS 91
#define TK_
MAXROWS
92
#define TK_
BLOCKS
93
#define TK_
CTIME
94
#define TK_
WAL
95
#define TK_
FSYNC
96
#define TK_
COMP
97
#define TK_
PRECISION
98
#define TK_
UPDATE
99
#define TK_
CACHELAST
100
#define TK_
L
P 101
#define TK_
RP
102
#define TK_
UNSIGNED
103
#define TK_
TAGS
104
#define TK_
USING
105
#define TK_
AS
106
#define TK_
COMMA
107
#define TK_
NULL
108
#define TK_
SELECT
109
#define TK_
UNION
110
#define TK_
ALL
111
#define TK_
FROM
112
#define TK_
VARIABLE
113
#define TK_
INTERVAL
114
#define TK_
FILL
115
#define TK_
SLIDING
116
#define TK_
ORDER
117
#define TK_
BY
118
#define TK_
ASC
119
#define TK_
DESC
120
#define TK_
GROUP
121
#define TK_
HAVING
122
#define TK_
LIMIT
123
#define TK_
OFFSE
T 124
#define TK_S
LIMIT
125
#define TK_
SOFFSET
126
#define TK_
WHERE
127
#define TK_
NOW
128
#define TK_
RESET
129
#define TK_
QUERY
130
#define TK_
ADD
131
#define TK_
COLUMN
132
#define TK_
TAG
133
#define TK_
CHANGE
134
#define TK_
SET
135
#define TK_
KILL
136
#define TK_
CONNECTION
137
#define TK_
STREAM
138
#define TK_
COLON
139
#define TK_A
BORT
140
#define TK_A
FTER
141
#define TK_
ATTACH
142
#define TK_BE
FORE
143
#define TK_
BEGIN
144
#define TK_C
ASCADE
145
#define TK_C
LUSTER
146
#define TK_CO
NFLICT
147
#define TK_
COPY
148
#define TK_DE
FERRED
149
#define TK_DE
LIMITERS
150
#define TK_
DETACH
151
#define TK_E
ACH
152
#define TK_E
ND
153
#define TK_
EXPLAIN
154
#define TK_F
AIL
155
#define TK_
FOR
156
#define TK_I
GNORE
157
#define TK_I
MMEDIATE
158
#define TK_IN
ITIALLY
159
#define TK_
INSTEAD
160
#define TK_
MATCH
161
#define TK_
KEY
162
#define TK_
OF
163
#define TK_R
AISE
164
#define TK_RE
PLACE
165
#define TK_R
ESTRICT
166
#define TK_
ROW
167
#define TK_
STATEMENT
168
#define TK_
TRIGGER
169
#define TK_
VIEW
170
#define TK_
COUNT
171
#define TK_
SUM
172
#define TK_
AVG
173
#define TK_M
IN
174
#define TK_
MAX
175
#define TK_
FIRST
176
#define TK_
LAST
177
#define TK_
TOP
178
#define TK_
BOTTOM
179
#define TK_
STDDEV
180
#define TK_
PERCENTILE
181
#define TK_
APERCENTILE
182
#define TK_
LEASTSQUARES
183
#define TK_
HISTOGRAM
184
#define TK_
DIFF
185
#define TK_
SPREAD
186
#define TK_
TWA
187
#define TK_
INTERP
188
#define TK_
LAST_ROW
189
#define TK_
RATE
190
#define TK_
IRATE
191
#define TK_SUM_
RATE
192
#define TK_
SUM_IRATE
193
#define TK_AVG_
RATE
194
#define TK_
AVG_IRATE
195
#define TK_
TBID
196
#define TK_
SEMI
197
#define TK_
NONE
198
#define TK_
PREV
199
#define TK_
LINEAR
200
#define TK_
IMPORT
201
#define TK_
METRIC
202
#define TK_
TBNAME
203
#define TK_
JOIN
204
#define TK_
METRICS
205
#define TK_INSERT 206
#define TK_INTO 207
#define TK_VALUES 208
#define TK_SPACE 300
#define TK_COMMENT 301
#define TK_ILLEGAL 302
...
...
src/query/inc/qSqlparser.h
浏览文件 @
c20d5741
...
...
@@ -98,6 +98,7 @@ typedef struct SCreateTableSQL {
typedef
struct
SAlterTableSQL
{
SStrToken
name
;
int16_t
tableType
;
int16_t
type
;
STagData
tagData
;
SArray
*
pAddColumns
;
// SArray<TAOS_FIELD>
...
...
@@ -156,6 +157,7 @@ typedef struct tDCLSQL {
int32_t
nAlloc
;
/* Number of entries allocated below */
SStrToken
*
a
;
/* one entry for element */
bool
existsCheck
;
int16_t
tableType
;
union
{
SCreateDBInfo
dbOpt
;
...
...
@@ -250,7 +252,7 @@ SCreateTableSQL *tSetCreateSqlElems(SArray *pCols, SArray *pTags, SQuerySQL *pSe
void
tSqlExprNodeDestroy
(
tSQLExpr
*
pExpr
);
SAlterTableSQL
*
tAlterTableSqlElems
(
SStrToken
*
pTableName
,
SArray
*
pCols
,
SArray
*
pVals
,
int32_t
type
);
SAlterTableSQL
*
tAlterTableSqlElems
(
SStrToken
*
pTableName
,
SArray
*
pCols
,
SArray
*
pVals
,
int32_t
type
,
int16_t
tableTable
);
SCreatedTableInfo
createNewChildTableInfo
(
SStrToken
*
pTableName
,
SArray
*
pTagVals
,
SStrToken
*
pToken
,
SStrToken
*
igExists
);
void
destroyAllSelectClause
(
SSubclauseInfo
*
pSql
);
...
...
@@ -267,7 +269,7 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken
void
SqlInfoDestroy
(
SSqlInfo
*
pInfo
);
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
);
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
,
int16_t
tableType
);
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
prefix
,
SStrToken
*
pPatterns
);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SStrToken
*
pToken
);
...
...
src/query/inc/sql.y
浏览文件 @
c20d5741
...
...
@@ -131,10 +131,16 @@ cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). {
//drop configure for tables
cmd ::= DROP TABLE ifexists(Y) ids(X) cpxName(Z). {
X.n += Z.n;
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y);
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y
, -1
);
}
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y); }
//drop stable
cmd ::= DROP STABLE ifexists(Y) ids(X) cpxName(Z). {
X.n += Z.n;
setDropDbTableInfo(pInfo, TSDB_SQL_DROP_TABLE, &X, &Y, TSDB_SUPER_TABLE);
}
cmd ::= DROP DATABASE ifexists(Y) ids(X). { setDropDbTableInfo(pInfo, TSDB_SQL_DROP_DB, &X, &Y, -1); }
cmd ::= DROP DNODE ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_DNODE, 1, &X); }
cmd ::= DROP USER ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_USER, 1, &X); }
cmd ::= DROP ACCOUNT ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_DROP_ACCT, 1, &X); }
...
...
@@ -305,6 +311,8 @@ signed(A) ::= MINUS INTEGER(X). { A = -strtol(X.z, NULL, 10);}
////////////////////////////////// The CREATE TABLE statement ///////////////////////////////
cmd ::= CREATE TABLE create_table_args. {}
cmd ::= CREATE TABLE create_stable_args. {}
cmd ::= CREATE STABLE create_stable_args. {}
cmd ::= CREATE TABLE create_table_list(Z). { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = Z;}
%type create_table_list{SCreateTableSQL*}
...
...
@@ -333,7 +341,8 @@ create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP. {
}
// create super table
create_table_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP TAGS LP columnlist(Y) RP. {
%type create_stable_args{SCreateTableSQL*}
create_stable_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP TAGS LP columnlist(Y) RP. {
A = tSetCreateSqlElems(X, Y, NULL, TSQL_CREATE_STABLE);
setSqlInfo(pInfo, A, NULL, TSDB_SQL_CREATE_TABLE);
...
...
@@ -683,7 +692,7 @@ cmd ::= RESET QUERY CACHE. { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
///////////////////////////////////ALTER TABLE statement//////////////////////////////////
cmd ::= ALTER TABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
X.n += F.n;
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
...
...
@@ -693,14 +702,14 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
toTSDBType(A.type);
SArray* K = tVariantListAppendToken(NULL, &A, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
cmd ::= ALTER TABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
X.n += Y.n;
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
...
...
@@ -709,7 +718,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
...
...
@@ -722,7 +731,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
toTSDBType(Z.type);
A = tVariantListAppendToken(A, &Z, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
, -1
);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
...
...
@@ -733,7 +742,54 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
A = tVariantListAppend(A, &Z, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
///////////////////////////////////ALTER STABLE statement//////////////////////////////////
cmd ::= ALTER STABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
X.n += F.n;
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
X.n += F.n;
toTSDBType(A.type);
SArray* K = tVariantListAppendToken(NULL, &A, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
cmd ::= ALTER STABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
X.n += Y.n;
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
X.n += Z.n;
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER STABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
X.n += F.n;
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
toTSDBType(Z.type);
A = tVariantListAppendToken(A, &Z, -1);
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
...
...
src/query/src/qParserImpl.c
浏览文件 @
c20d5741
...
...
@@ -585,11 +585,12 @@ SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVal
return
info
;
}
SAlterTableSQL
*
tAlterTableSqlElems
(
SStrToken
*
pTableName
,
SArray
*
pCols
,
SArray
*
pVals
,
int32_t
type
)
{
SAlterTableSQL
*
tAlterTableSqlElems
(
SStrToken
*
pTableName
,
SArray
*
pCols
,
SArray
*
pVals
,
int32_t
type
,
int16_t
tableType
)
{
SAlterTableSQL
*
pAlterTable
=
calloc
(
1
,
sizeof
(
SAlterTableSQL
));
pAlterTable
->
name
=
*
pTableName
;
pAlterTable
->
type
=
type
;
pAlterTable
->
tableType
=
tableType
;
if
(
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
)
{
pAlterTable
->
pAddColumns
=
pCols
;
...
...
@@ -733,9 +734,10 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
va_end
(
va
);
}
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
)
{
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SStrToken
*
pToken
,
SStrToken
*
existsCheck
,
int16_t
tableType
)
{
pInfo
->
type
=
type
;
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
->
tableType
=
tableType
;
pInfo
->
pDCLInfo
->
existsCheck
=
(
existsCheck
->
n
==
1
);
}
...
...
src/query/src/sql.c
浏览文件 @
c20d5741
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录