Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
ef58f099
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看板
提交
ef58f099
编写于
5月 28, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support alter column length
上级
a8e97be5
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
1110 addition
and
717 deletion
+1110
-717
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+31
-1
src/inc/ttokendef.h
src/inc/ttokendef.h
+52
-48
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+9
-3
src/query/inc/sql.y
src/query/inc/sql.y
+13
-1
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+1
-1
src/query/src/sql.c
src/query/src/sql.c
+1002
-662
src/util/src/ttokenizer.c
src/util/src/ttokenizer.c
+2
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
ef58f099
...
@@ -5074,6 +5074,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -5074,6 +5074,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const
char
*
msg18
=
"primary timestamp column cannot be dropped"
;
const
char
*
msg18
=
"primary timestamp column cannot be dropped"
;
const
char
*
msg19
=
"invalid new tag name"
;
const
char
*
msg19
=
"invalid new tag name"
;
const
char
*
msg20
=
"table is not super table"
;
const
char
*
msg20
=
"table is not super table"
;
const
char
*
msg21
=
"only binary/nchar column length could be altered"
;
const
char
*
msg22
=
"invalid column length"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -5110,7 +5112,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -5110,7 +5112,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
}
}
else
if
((
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
&&
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
)))
{
}
else
if
((
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
&&
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
)))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
else
if
((
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
&&
}
else
if
((
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
&&
UTIL_TABLE_IS_CHILD_TABLE
(
pTableMetaInfo
))
{
UTIL_TABLE_IS_CHILD_TABLE
(
pTableMetaInfo
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
}
...
@@ -5326,6 +5328,34 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -5326,6 +5328,34 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tstrncpy
(
name1
,
pItem
->
pVar
.
pz
,
sizeof
(
name1
));
tstrncpy
(
name1
,
pItem
->
pVar
.
pz
,
sizeof
(
name1
));
TAOS_FIELD
f
=
tscCreateField
(
TSDB_DATA_TYPE_INT
,
name1
,
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
);
TAOS_FIELD
f
=
tscCreateField
(
TSDB_DATA_TYPE_INT
,
name1
,
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
{
if
(
taosArrayGetSize
(
pAlterSQL
->
pAddColumns
)
!=
2
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
NULL
);
}
tVariantListItem
*
pItem
=
taosArrayGet
(
pAlterSQL
->
pAddColumns
,
0
);
SColumnIndex
columnIndex
=
COLUMN_INDEX_INITIALIZER
;
SStrToken
name
=
{.
type
=
TK_STRING
,
.
z
=
pItem
->
pVar
.
pz
,
.
n
=
pItem
->
pVar
.
nLen
};
if
(
getColumnIndexByName
(
pCmd
,
&
name
,
pQueryInfo
,
&
columnIndex
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg17
);
}
SSchema
*
pColSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
columnIndex
.
columnIndex
);
if
(
pColSchema
->
type
!=
TSDB_DATA_TYPE_BINARY
&&
pColSchema
->
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg21
);
}
pItem
=
taosArrayGet
(
pAlterSQL
->
pAddColumns
,
1
);
int64_t
nlen
=
0
;
if
(
tVariantDump
(
&
pItem
->
pVar
,
(
char
*
)
&
nlen
,
TSDB_DATA_TYPE_BIGINT
,
false
)
<
0
||
nlen
<=
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg22
);
}
TAOS_FIELD
f
=
tscCreateField
(
pColSchema
->
type
,
name
.
z
,
nlen
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
src/inc/ttokendef.h
浏览文件 @
ef58f099
...
@@ -155,54 +155,58 @@
...
@@ -155,54 +155,58 @@
#define TK_SYNCDB 136
#define TK_SYNCDB 136
#define TK_ADD 137
#define TK_ADD 137
#define TK_COLUMN 138
#define TK_COLUMN 138
#define TK_TAG 139
#define TK_LENGTH 139
#define TK_CHANGE 140
#define TK_TAG 140
#define TK_SET 141
#define TK_CHANGE 141
#define TK_KILL 142
#define TK_SET 142
#define TK_CONNECTION 143
#define TK_KILL 143
#define TK_STREAM 144
#define TK_CONNECTION 144
#define TK_COLON 145
#define TK_STREAM 145
#define TK_ABORT 146
#define TK_COLON 146
#define TK_AFTER 147
#define TK_ABORT 147
#define TK_ATTACH 148
#define TK_AFTER 148
#define TK_BEFORE 149
#define TK_ATTACH 149
#define TK_BEGIN 150
#define TK_BEFORE 150
#define TK_CASCADE 151
#define TK_BEGIN 151
#define TK_CLUSTER 152
#define TK_CASCADE 152
#define TK_CONFLICT 153
#define TK_CLUSTER 153
#define TK_COPY 154
#define TK_CONFLICT 154
#define TK_DEFERRED 155
#define TK_COPY 155
#define TK_DELIMITERS 156
#define TK_DEFERRED 156
#define TK_DETACH 157
#define TK_DELIMITERS 157
#define TK_EACH 158
#define TK_DETACH 158
#define TK_END 159
#define TK_EACH 159
#define TK_EXPLAIN 160
#define TK_END 160
#define TK_FAIL 161
#define TK_EXPLAIN 161
#define TK_FOR 162
#define TK_FAIL 162
#define TK_IGNORE 163
#define TK_FOR 163
#define TK_IMMEDIATE 164
#define TK_IGNORE 164
#define TK_INITIALLY 165
#define TK_IMMEDIATE 165
#define TK_INSTEAD 166
#define TK_INITIALLY 166
#define TK_MATCH 167
#define TK_INSTEAD 167
#define TK_KEY 168
#define TK_MATCH 168
#define TK_OF 169
#define TK_KEY 169
#define TK_RAISE 170
#define TK_OF 170
#define TK_REPLACE 171
#define TK_RAISE 171
#define TK_RESTRICT 172
#define TK_REPLACE 172
#define TK_ROW 173
#define TK_RESTRICT 173
#define TK_STATEMENT 174
#define TK_ROW 174
#define TK_TRIGGER 175
#define TK_STATEMENT 175
#define TK_VIEW 176
#define TK_TRIGGER 176
#define TK_SEMI 177
#define TK_VIEW 177
#define TK_NONE 178
#define TK_SEMI 178
#define TK_PREV 179
#define TK_NONE 179
#define TK_LINEAR 180
#define TK_PREV 180
#define TK_IMPORT 181
#define TK_LINEAR 181
#define TK_TBNAME 182
#define TK_IMPORT 182
#define TK_JOIN 183
#define TK_TBNAME 183
#define TK_INSERT 184
#define TK_JOIN 184
#define TK_INTO 185
#define TK_INSERT 185
#define TK_VALUES 186
#define TK_INTO 186
#define TK_VALUES 187
#define TK_SPACE 300
#define TK_SPACE 300
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
ef58f099
...
@@ -3100,7 +3100,10 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
...
@@ -3100,7 +3100,10 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
code
=
mnodeDropSuperTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
);
code
=
mnodeDropSuperTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
);
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
{
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
{
code
=
mnodeChangeSuperTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
1
].
name
);
//code = mnodeChangeSuperTableColumn(pMsg, pAlter->schema[0].name, pAlter->schema[1].name);
(
void
)
mnodeChangeSuperTableColumn
;
mError
(
"change table[%s] column[%s] length to [%d] is not processed"
,
pAlter
->
tableFname
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
0
].
bytes
);
code
=
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
}
}
}
else
{
}
else
{
...
@@ -3112,7 +3115,10 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
...
@@ -3112,7 +3115,10 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
code
=
mnodeDropNormalTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
);
code
=
mnodeDropNormalTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
);
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
{
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
{
code
=
mnodeChangeNormalTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
1
].
name
);
//code = mnodeChangeNormalTableColumn(pMsg, pAlter->schema[0].name, pAlter->schema[1].name);
(
void
)
mnodeChangeNormalTableColumn
;
mError
(
"change table[%s] column[%s] length to [%d] is not processed"
,
pAlter
->
tableFname
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
0
].
bytes
);
code
=
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
}
}
}
}
...
@@ -3303,4 +3309,4 @@ int32_t mnodeCompactTables() {
...
@@ -3303,4 +3309,4 @@ int32_t mnodeCompactTables() {
mnodeCompactChildTables
();
mnodeCompactChildTables
();
return
0
;
return
0
;
}
}
\ No newline at end of file
src/query/inc/sql.y
浏览文件 @
ef58f099
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include <stdbool.h>
#include <stdbool.h>
#include "qSqlparser.h"
#include "qSqlparser.h"
#include "tcmdtype.h"
#include "tcmdtype.h"
#include "t
s
token.h"
#include "ttoken.h"
#include "ttokendef.h"
#include "ttokendef.h"
#include "tutil.h"
#include "tutil.h"
#include "tvariant.h"
#include "tvariant.h"
...
@@ -748,6 +748,18 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
...
@@ -748,6 +748,18 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
cmd ::= ALTER TABLE ids(X) cpxName(F) ALTER COLUMN LENGTH ids(A) INTEGER(Z). {
X.n += F.n;
toTSDBType(A.type);
SArray* K = tVariantListAppendToken(NULL, &A, -1);
toTSDBType(Z.type);
K = tVariantListAppendToken(K, &Z, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, K, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
cmd ::= ALTER TABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
cmd ::= ALTER TABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
X.n += Y.n;
X.n += Y.n;
...
...
src/query/src/qSqlParser.c
浏览文件 @
ef58f099
...
@@ -885,7 +885,7 @@ SAlterTableInfo *tSetAlterTableInfo(SStrToken *pTableName, SArray *pCols, SArray
...
@@ -885,7 +885,7 @@ SAlterTableInfo *tSetAlterTableInfo(SStrToken *pTableName, SArray *pCols, SArray
pAlterTable
->
type
=
type
;
pAlterTable
->
type
=
type
;
pAlterTable
->
tableType
=
tableType
;
pAlterTable
->
tableType
=
tableType
;
if
(
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
)
{
if
(
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
||
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
{
pAlterTable
->
pAddColumns
=
pCols
;
pAlterTable
->
pAddColumns
=
pCols
;
assert
(
pVals
==
NULL
);
assert
(
pVals
==
NULL
);
}
else
{
}
else
{
...
...
src/query/src/sql.c
浏览文件 @
ef58f099
此差异已折叠。
点击以展开。
src/util/src/ttokenizer.c
浏览文件 @
ef58f099
...
@@ -217,7 +217,8 @@ static SKeyword keywordTable[] = {
...
@@ -217,7 +217,8 @@ static SKeyword keywordTable[] = {
{
"DISTINCT"
,
TK_DISTINCT
},
{
"DISTINCT"
,
TK_DISTINCT
},
{
"PARTITIONS"
,
TK_PARTITIONS
},
{
"PARTITIONS"
,
TK_PARTITIONS
},
{
"TOPIC"
,
TK_TOPIC
},
{
"TOPIC"
,
TK_TOPIC
},
{
"TOPICS"
,
TK_TOPICS
}
{
"TOPICS"
,
TK_TOPICS
},
{
"LENGTH"
,
TK_LENGTH
}
};
};
static
const
char
isIdChar
[]
=
{
static
const
char
isIdChar
[]
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录