Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5a2c3eda
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
5a2c3eda
编写于
6月 02, 2021
作者:
H
haojun Liao
提交者:
GitHub
6月 02, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6343 from taosdata/feature/TD-4399
[TD-4399]modify column length
上级
80096c46
2bcd1f5a
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
1375 addition
and
727 deletion
+1375
-727
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+86
-3
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-0
src/inc/ttokendef.h
src/inc/ttokendef.h
+56
-48
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+14
-3
src/query/inc/sql.y
src/query/inc/sql.y
+34
-0
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+1
-1
src/query/src/sql.c
src/query/src/sql.c
+1062
-670
src/util/src/ttokenizer.c
src/util/src/ttokenizer.c
+2
-1
tests/pytest/query/queryInsertValue.py
tests/pytest/query/queryInsertValue.py
+1
-1
tests/script/general/parser/alter_column.sim
tests/script/general/parser/alter_column.sim
+118
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
5a2c3eda
...
...
@@ -5142,6 +5142,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const
char
*
msg18
=
"primary timestamp column cannot be dropped"
;
const
char
*
msg19
=
"invalid new tag name"
;
const
char
*
msg20
=
"table is not super table"
;
const
char
*
msg21
=
"only binary/nchar column length could be modified"
;
const
char
*
msg22
=
"new column length should be bigger than old one"
;
const
char
*
msg23
=
"only column length coulbe be modified"
;
const
char
*
msg24
=
"invalid binary/nchar column length"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -5172,13 +5176,13 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
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
))
{
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
||
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN
)
{
if
(
!
UTIL_TABLE_IS_SUPER
_TABLE
(
pTableMetaInfo
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
else
if
((
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
&&
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
)))
{
return
invalidOperationMsg
(
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
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
...
...
@@ -5394,6 +5398,85 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tstrncpy
(
name1
,
pItem
->
pVar
.
pz
,
sizeof
(
name1
));
TAOS_FIELD
f
=
tscCreateField
(
TSDB_DATA_TYPE_INT
,
name1
,
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_CHANGE_COLUMN
)
{
if
(
taosArrayGetSize
(
pAlterSQL
->
pAddColumns
)
>=
2
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg16
);
}
TAOS_FIELD
*
pItem
=
taosArrayGet
(
pAlterSQL
->
pAddColumns
,
0
);
if
(
pItem
->
type
!=
TSDB_DATA_TYPE_BINARY
&&
pItem
->
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg21
);
}
SColumnIndex
columnIndex
=
COLUMN_INDEX_INITIALIZER
;
SStrToken
name
=
{.
type
=
TK_STRING
,
.
z
=
pItem
->
name
,
.
n
=
(
uint32_t
)
strlen
(
pItem
->
name
)};
if
(
getColumnIndexByName
(
pCmd
,
&
name
,
pQueryInfo
,
&
columnIndex
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg17
);
}
SSchema
*
pColSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
columnIndex
.
columnIndex
);
if
(
pColSchema
->
type
!=
TSDB_DATA_TYPE_BINARY
&&
pColSchema
->
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg21
);
}
if
(
pItem
->
type
!=
pColSchema
->
type
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg23
);
}
if
((
pItem
->
type
==
TSDB_DATA_TYPE_BINARY
&&
(
pItem
->
bytes
<=
0
||
pItem
->
bytes
>
TSDB_MAX_BINARY_LEN
))
||
(
pItem
->
type
==
TSDB_DATA_TYPE_NCHAR
&&
(
pItem
->
bytes
<=
0
||
pItem
->
bytes
>
TSDB_MAX_NCHAR_LEN
)))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg24
);
}
if
(
pItem
->
bytes
<=
pColSchema
->
bytes
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg22
);
}
TAOS_FIELD
f
=
tscCreateField
(
pColSchema
->
type
,
name
.
z
,
pItem
->
bytes
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN
)
{
if
(
taosArrayGetSize
(
pAlterSQL
->
pAddColumns
)
>=
2
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg16
);
}
TAOS_FIELD
*
pItem
=
taosArrayGet
(
pAlterSQL
->
pAddColumns
,
0
);
if
(
pItem
->
type
!=
TSDB_DATA_TYPE_BINARY
&&
pItem
->
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg21
);
}
SColumnIndex
columnIndex
=
COLUMN_INDEX_INITIALIZER
;
SStrToken
name
=
{.
type
=
TK_STRING
,
.
z
=
pItem
->
name
,
.
n
=
(
uint32_t
)
strlen
(
pItem
->
name
)};
if
(
getColumnIndexByName
(
pCmd
,
&
name
,
pQueryInfo
,
&
columnIndex
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg17
);
}
SSchema
*
pColSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
columnIndex
.
columnIndex
);
if
(
columnIndex
.
columnIndex
<
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg10
);
}
if
(
pColSchema
->
type
!=
TSDB_DATA_TYPE_BINARY
&&
pColSchema
->
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg21
);
}
if
(
pItem
->
type
!=
pColSchema
->
type
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg23
);
}
if
((
pItem
->
type
==
TSDB_DATA_TYPE_BINARY
&&
(
pItem
->
bytes
<=
0
||
pItem
->
bytes
>
TSDB_MAX_BINARY_LEN
))
||
(
pItem
->
type
==
TSDB_DATA_TYPE_NCHAR
&&
(
pItem
->
bytes
<=
0
||
pItem
->
bytes
>
TSDB_MAX_NCHAR_LEN
)))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg24
);
}
if
(
pItem
->
bytes
<=
pColSchema
->
bytes
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg22
);
}
TAOS_FIELD
f
=
tscCreateField
(
pColSchema
->
type
,
name
.
z
,
pItem
->
bytes
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
}
return
TSDB_CODE_SUCCESS
;
...
...
src/inc/taosmsg.h
浏览文件 @
5a2c3eda
...
...
@@ -161,6 +161,7 @@ enum _mgmt_table {
#define TSDB_ALTER_TABLE_ADD_COLUMN 5
#define TSDB_ALTER_TABLE_DROP_COLUMN 6
#define TSDB_ALTER_TABLE_CHANGE_COLUMN 7
#define TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN 8
#define TSDB_FILL_NONE 0
#define TSDB_FILL_NULL 1
...
...
src/inc/ttokendef.h
浏览文件 @
5a2c3eda
...
...
@@ -156,54 +156,62 @@
#define TK_SYNCDB 137
#define TK_ADD 138
#define TK_COLUMN 139
#define TK_TAG 140
#define TK_CHANGE 141
#define TK_SET 142
#define TK_KILL 143
#define TK_CONNECTION 144
#define TK_STREAM 145
#define TK_COLON 146
#define TK_ABORT 147
#define TK_AFTER 148
#define TK_ATTACH 149
#define TK_BEFORE 150
#define TK_BEGIN 151
#define TK_CASCADE 152
#define TK_CLUSTER 153
#define TK_CONFLICT 154
#define TK_COPY 155
#define TK_DEFERRED 156
#define TK_DELIMITERS 157
#define TK_DETACH 158
#define TK_EACH 159
#define TK_END 160
#define TK_EXPLAIN 161
#define TK_FAIL 162
#define TK_FOR 163
#define TK_IGNORE 164
#define TK_IMMEDIATE 165
#define TK_INITIALLY 166
#define TK_INSTEAD 167
#define TK_MATCH 168
#define TK_KEY 169
#define TK_OF 170
#define TK_RAISE 171
#define TK_REPLACE 172
#define TK_RESTRICT 173
#define TK_ROW 174
#define TK_STATEMENT 175
#define TK_TRIGGER 176
#define TK_VIEW 177
#define TK_SEMI 178
#define TK_NONE 179
#define TK_PREV 180
#define TK_LINEAR 181
#define TK_IMPORT 182
#define TK_TBNAME 183
#define TK_JOIN 184
#define TK_INSERT 185
#define TK_INTO 186
#define TK_VALUES 187
#define TK_MODIFY 140
#define TK_TAG 141
#define TK_CHANGE 142
#define TK_SET 143
#define TK_KILL 144
#define TK_CONNECTION 145
#define TK_STREAM 146
#define TK_COLON 147
#define TK_ABORT 148
#define TK_AFTER 149
#define TK_ATTACH 150
#define TK_BEFORE 151
#define TK_BEGIN 152
#define TK_CASCADE 153
#define TK_CLUSTER 154
#define TK_CONFLICT 155
#define TK_COPY 156
#define TK_DEFERRED 157
#define TK_DELIMITERS 158
#define TK_DETACH 159
#define TK_EACH 160
#define TK_END 161
#define TK_EXPLAIN 162
#define TK_FAIL 163
#define TK_FOR 164
#define TK_IGNORE 165
#define TK_IMMEDIATE 166
#define TK_INITIALLY 167
#define TK_INSTEAD 168
#define TK_MATCH 169
#define TK_KEY 170
#define TK_OF 171
#define TK_RAISE 172
#define TK_REPLACE 173
#define TK_RESTRICT 174
#define TK_ROW 175
#define TK_STATEMENT 176
#define TK_TRIGGER 177
#define TK_VIEW 178
#define TK_SEMI 179
#define TK_NONE 180
#define TK_PREV 181
#define TK_LINEAR 182
#define TK_IMPORT 183
#define TK_TBNAME 184
#define TK_JOIN 185
#define TK_INSERT 186
#define TK_INTO 187
#define TK_VALUES 188
#define TK_SPACE 300
#define TK_COMMENT 301
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
5a2c3eda
...
...
@@ -3214,7 +3214,15 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
code
=
mnodeDropSuperTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
);
}
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
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN
)
{
//code = mnodeChangeSuperTableColumn(pMsg, pAlter->schema[0].name, pAlter->schema[1].name);
(
void
)
mnodeChangeSuperTableColumn
;
mError
(
"change table[%s] tag[%s] length to [%d] is not processed"
,
pAlter
->
tableFname
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
0
].
bytes
);
code
=
TSDB_CODE_SUCCESS
;
}
else
{
}
}
else
{
...
...
@@ -3226,7 +3234,10 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
code
=
mnodeDropNormalTableColumn
(
pMsg
,
pAlter
->
schema
[
0
].
name
);
}
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
{
}
}
...
...
@@ -3417,4 +3428,4 @@ int32_t mnodeCompactTables() {
mnodeCompactChildTables
();
return
0
;
}
\ No newline at end of file
}
src/query/inc/sql.y
浏览文件 @
5a2c3eda
...
...
@@ -759,6 +759,12 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER TABLE ids(X) cpxName(F) MODIFY COLUMN columnlist(A). {
X.n += F.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_CHANGE_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;
...
...
@@ -799,6 +805,11 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER TABLE ids(X) cpxName(F) MODIFY TAG columnlist(A). {
X.n += F.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
///////////////////////////////////ALTER STABLE statement//////////////////////////////////
cmd ::= ALTER STABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
...
...
@@ -817,6 +828,12 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER STABLE ids(X) cpxName(F) MODIFY COLUMN columnlist(A). {
X.n += F.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_CHANGE_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;
...
...
@@ -846,6 +863,23 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER STABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
X.n += F.n;
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
A = tVariantListAppend(A, &Z, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
cmd ::= ALTER STABLE ids(X) cpxName(F) MODIFY TAG columnlist(A). {
X.n += F.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
////////////////////////////////////////kill statement///////////////////////////////////////
cmd ::= KILL CONNECTION INTEGER(Y). {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &Y);}
cmd ::= KILL STREAM INTEGER(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &X);}
...
...
src/query/src/qSqlParser.c
浏览文件 @
5a2c3eda
...
...
@@ -893,7 +893,7 @@ SAlterTableInfo *tSetAlterTableInfo(SStrToken *pTableName, SArray *pCols, SArray
pAlterTable
->
type
=
type
;
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
||
type
==
TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN
)
{
pAlterTable
->
pAddColumns
=
pCols
;
assert
(
pVals
==
NULL
);
}
else
{
...
...
src/query/src/sql.c
浏览文件 @
5a2c3eda
此差异已折叠。
点击以展开。
src/util/src/ttokenizer.c
浏览文件 @
5a2c3eda
...
...
@@ -218,7 +218,8 @@ static SKeyword keywordTable[] = {
{
"DISTINCT"
,
TK_DISTINCT
},
{
"PARTITIONS"
,
TK_PARTITIONS
},
{
"TOPIC"
,
TK_TOPIC
},
{
"TOPICS"
,
TK_TOPICS
}
{
"TOPICS"
,
TK_TOPICS
},
{
"MODIFY"
,
TK_MODIFY
}
};
static
const
char
isIdChar
[]
=
{
...
...
tests/pytest/query/queryInsertValue.py
浏览文件 @
5a2c3eda
...
...
@@ -45,7 +45,7 @@ class TDTestCase:
tdSql
.
query
(
"select * from st"
)
tdSql
.
checkRows
(
1
)
tdSql
.
execute
(
"alter table st add column len
gth
int"
)
tdSql
.
execute
(
"alter table st add column len int"
)
tdSql
.
execute
(
"insert into t1 values(now, 1, 2)"
)
tdSql
.
query
(
"select last(*) from st"
)
tdSql
.
checkData
(
0
,
2
,
2
);
...
...
tests/script/general/parser/alter_column.sim
0 → 100644
浏览文件 @
5a2c3eda
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 100
sql connect
$dbPrefix = m_alt_db
$tbPrefix = m_alt_tb
$mtPrefix = m_alt_mt
$tbNum = 10
$rowNum = 5
$totalNum = $tbNum * $rowNum
$ts0 = 1537146000000
$delta = 600000
print ========== alter.sim
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
sql drop database if exists $db
sql create database $db
sql use $db
##### alter table test, simeplest case
sql create table tb (ts timestamp, c1 int, c2 binary(10), c3 nchar(10))
sql insert into tb values (now, 1, "1", "1")
sql alter table tb modify column c2 binary(20);
if $rows != 0 then
return -1
endi
sql alter table tb modify column c3 nchar(20);
if $rows != 0 then
return -1
endi
sql create stable stb (ts timestamp, c1 int, c2 binary(10), c3 nchar(10)) tags(id1 int, id2 binary(10), id3 nchar(10))
sql create table tb1 using stb tags(1, "a", "b")
sql insert into tb1 values (now, 1, "1", "1")
sql alter stable stb modify column c2 binary(20);
if $rows != 0 then
return -1
endi
sql alter table stb modify column c2 binary(30);
if $rows != 0 then
return -1
endi
sql alter stable stb modify column c3 nchar(20);
if $rows != 0 then
return -1
endi
sql alter table stb modify column c3 nchar(30);
if $rows != 0 then
return -1
endi
sql alter table stb modify tag id2 binary(11);
if $rows != 0 then
return -1
endi
sql alter stable stb modify tag id2 binary(11);
if $rows != 0 then
return -1
endi
sql alter table stb modify tag id3 nchar(11);
if $rows != 0 then
return -1
endi
sql alter stable stb modify tag id3 nchar(11);
if $rows != 0 then
return -1
endi
##### ILLEGAL OPERATIONS
# try dropping columns that are defined in metric
sql_error alter table tb modify column c1 binary(10);
sql_error alter table tb modify column c1 double;
sql_error alter table tb modify column c2 int;
sql_error alter table tb modify column c2 binary(10);
sql_error alter table tb modify column c2 binary(9);
sql_error alter table tb modify column c2 binary(-9);
sql_error alter table tb modify column c2 binary(0);
sql_error alter table tb modify column c2 binary(17000);
sql_error alter table tb modify column c2 nchar(30);
sql_error alter table tb modify column c3 double;
sql_error alter table tb modify column c3 nchar(10);
sql_error alter table tb modify column c3 nchar(0);
sql_error alter table tb modify column c3 nchar(-1);
sql_error alter table tb modify column c3 binary(80);
sql_error alter table tb modify column c3 nchar(17000);
sql_error alter table tb modify column c3 nchar(100), c2 binary(30);
sql_error alter table tb modify column c1 nchar(100), c2 binary(30);
sql_error alter stable tb modify column c2 binary(30);
sql_error alter table tb modify tag c2 binary(30);
sql_error alter table stb modify tag id2 binary(10);
sql_error alter table stb modify tag id2 nchar(30);
sql_error alter stable stb modify tag id2 binary(10);
sql_error alter stable stb modify tag id2 nchar(30);
sql_error alter table stb modify tag id3 nchar(10);
sql_error alter table stb modify tag id3 binary(30);
sql_error alter stable stb modify tag id3 nchar(10);
sql_error alter stable stb modify tag id3 binary(30);
sql_error alter stable stb modify tag id1 binary(30);
sql_error alter stable stb modify tag c1 binary(30);
sql_error alter table tb1 modify column c2 binary(30);
sql_error alter table tb1 modify column c3 nchar(30);
sql_error alter table tb1 modify tag id2 binary(30);
sql_error alter table tb1 modify tag id3 nchar(30);
sql_error alter stable tb1 modify tag id2 binary(30);
sql_error alter stable tb1 modify tag id3 nchar(30);
sql_error alter stable tb1 modify column c2 binary(30);
system sh/exec.sh -n dnode1 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录