Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ce2f83fe
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看板
提交
ce2f83fe
编写于
1月 25, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TS-1159]<fix>: fixed a bug for alter operation
上级
90e5a0d6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
13 deletion
+33
-13
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/query/inc/sql.y
src/query/inc/sql.y
+5
-5
src/query/src/sql.c
src/query/src/sql.c
+5
-5
tests/pytest/alter/alterBackQuoteCol.py
tests/pytest/alter/alterBackQuoteCol.py
+22
-2
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
ce2f83fe
...
@@ -7155,7 +7155,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -7155,7 +7155,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidOperationMsg
(
pMsg
,
msg24
);
return
invalidOperationMsg
(
pMsg
,
msg24
);
}
}
name
.
n
=
stringProcess
(
name
.
z
,
name
.
n
);
stringProcess
(
name
.
z
,
name
.
n
);
TAOS_FIELD
f
=
tscCreateField
(
pColSchema
->
type
,
name
.
z
,
pItem
->
bytes
);
TAOS_FIELD
f
=
tscCreateField
(
pColSchema
->
type
,
name
.
z
,
pItem
->
bytes
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
}
}
...
...
src/query/inc/sql.y
浏览文件 @
ce2f83fe
...
@@ -906,7 +906,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
...
@@ -906,7 +906,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
X.n += F.n;
X.n += F.n;
toTSDBType(A.type);
toTSDBType(A.type);
SArray* K = tVariantListAppendToken(NULL, &A, -1,
tru
e);
SArray* K = tVariantListAppendToken(NULL, &A, -1,
fals
e);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
...
@@ -928,7 +928,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
...
@@ -928,7 +928,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
X.n += Z.n;
X.n += Z.n;
toTSDBType(Y.type);
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1,
tru
e);
SArray* A = tVariantListAppendToken(NULL, &Y, -1,
fals
e);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
...
@@ -938,10 +938,10 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
...
@@ -938,10 +938,10 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
X.n += F.n;
X.n += F.n;
toTSDBType(Y.type);
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1,
tru
e);
SArray* A = tVariantListAppendToken(NULL, &Y, -1,
fals
e);
toTSDBType(Z.type);
toTSDBType(Z.type);
A = tVariantListAppendToken(A, &Z, -1,
tru
e);
A = tVariantListAppendToken(A, &Z, -1,
fals
e);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
...
@@ -951,7 +951,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
...
@@ -951,7 +951,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
X.n += F.n;
X.n += F.n;
toTSDBType(Y.type);
toTSDBType(Y.type);
SArray* A = tVariantListAppendToken(NULL, &Y, -1,
tru
e);
SArray* A = tVariantListAppendToken(NULL, &Y, -1,
fals
e);
A = tVariantListAppend(A, &Z, -1);
A = tVariantListAppend(A, &Z, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE);
...
...
src/query/src/sql.c
浏览文件 @
ce2f83fe
...
@@ -3894,7 +3894,7 @@ static YYACTIONTYPE yy_reduce(
...
@@ -3894,7 +3894,7 @@ static YYACTIONTYPE yy_reduce(
yymsp
[
-
4
].
minor
.
yy0
.
n
+=
yymsp
[
-
3
].
minor
.
yy0
.
n
;
yymsp
[
-
4
].
minor
.
yy0
.
n
+=
yymsp
[
-
3
].
minor
.
yy0
.
n
;
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
SArray
*
K
=
tVariantListAppendToken
(
NULL
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
,
tru
e
);
SArray
*
K
=
tVariantListAppendToken
(
NULL
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
,
fals
e
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
NULL
,
K
,
TSDB_ALTER_TABLE_DROP_COLUMN
,
TSDB_SUPER_TABLE
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
NULL
,
K
,
TSDB_ALTER_TABLE_DROP_COLUMN
,
TSDB_SUPER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
...
@@ -3919,7 +3919,7 @@ static YYACTIONTYPE yy_reduce(
...
@@ -3919,7 +3919,7 @@ static YYACTIONTYPE yy_reduce(
yymsp
[
-
4
].
minor
.
yy0
.
n
+=
yymsp
[
-
3
].
minor
.
yy0
.
n
;
yymsp
[
-
4
].
minor
.
yy0
.
n
+=
yymsp
[
-
3
].
minor
.
yy0
.
n
;
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
SArray
*
A
=
tVariantListAppendToken
(
NULL
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
,
tru
e
);
SArray
*
A
=
tVariantListAppendToken
(
NULL
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
,
fals
e
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
NULL
,
A
,
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
,
TSDB_SUPER_TABLE
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
NULL
,
A
,
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
,
TSDB_SUPER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
...
@@ -3930,10 +3930,10 @@ static YYACTIONTYPE yy_reduce(
...
@@ -3930,10 +3930,10 @@ static YYACTIONTYPE yy_reduce(
yymsp
[
-
5
].
minor
.
yy0
.
n
+=
yymsp
[
-
4
].
minor
.
yy0
.
n
;
yymsp
[
-
5
].
minor
.
yy0
.
n
+=
yymsp
[
-
4
].
minor
.
yy0
.
n
;
toTSDBType
(
yymsp
[
-
1
].
minor
.
yy0
.
type
);
toTSDBType
(
yymsp
[
-
1
].
minor
.
yy0
.
type
);
SArray
*
A
=
tVariantListAppendToken
(
NULL
,
&
yymsp
[
-
1
].
minor
.
yy0
,
-
1
,
tru
e
);
SArray
*
A
=
tVariantListAppendToken
(
NULL
,
&
yymsp
[
-
1
].
minor
.
yy0
,
-
1
,
fals
e
);
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
A
=
tVariantListAppendToken
(
A
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
,
tru
e
);
A
=
tVariantListAppendToken
(
A
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
,
fals
e
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
5
].
minor
.
yy0
,
NULL
,
A
,
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
,
TSDB_SUPER_TABLE
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
5
].
minor
.
yy0
,
NULL
,
A
,
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
,
TSDB_SUPER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
...
@@ -3944,7 +3944,7 @@ static YYACTIONTYPE yy_reduce(
...
@@ -3944,7 +3944,7 @@ static YYACTIONTYPE yy_reduce(
yymsp
[
-
6
].
minor
.
yy0
.
n
+=
yymsp
[
-
5
].
minor
.
yy0
.
n
;
yymsp
[
-
6
].
minor
.
yy0
.
n
+=
yymsp
[
-
5
].
minor
.
yy0
.
n
;
toTSDBType
(
yymsp
[
-
2
].
minor
.
yy0
.
type
);
toTSDBType
(
yymsp
[
-
2
].
minor
.
yy0
.
type
);
SArray
*
A
=
tVariantListAppendToken
(
NULL
,
&
yymsp
[
-
2
].
minor
.
yy0
,
-
1
,
tru
e
);
SArray
*
A
=
tVariantListAppendToken
(
NULL
,
&
yymsp
[
-
2
].
minor
.
yy0
,
-
1
,
fals
e
);
A
=
tVariantListAppend
(
A
,
&
yymsp
[
0
].
minor
.
yy162
,
-
1
);
A
=
tVariantListAppend
(
A
,
&
yymsp
[
0
].
minor
.
yy162
,
-
1
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
6
].
minor
.
yy0
,
NULL
,
A
,
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
,
TSDB_SUPER_TABLE
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
6
].
minor
.
yy0
,
NULL
,
A
,
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
,
TSDB_SUPER_TABLE
);
...
...
tests/pytest/alter/alterBackQuoteCol.py
浏览文件 @
ce2f83fe
...
@@ -17,7 +17,8 @@ class TDTestCase:
...
@@ -17,7 +17,8 @@ class TDTestCase:
def
run
(
self
):
def
run
(
self
):
tdLog
.
debug
(
"check databases"
)
tdLog
.
debug
(
"check databases"
)
tdSql
.
prepare
()
tdSql
.
prepare
()
### test normal table
tdSql
.
execute
(
"create database if not exists db"
)
tdSql
.
execute
(
"create database if not exists db"
)
tdSql
.
execute
(
"use db"
)
tdSql
.
execute
(
"use db"
)
tdSql
.
execute
(
"create stable `sch.job.create` (`ts` TIMESTAMP, `tint` int, `node.value` NCHAR(7)) TAGS (`endpoint` NCHAR(7),`task.type` NCHAR(3))"
)
tdSql
.
execute
(
"create stable `sch.job.create` (`ts` TIMESTAMP, `tint` int, `node.value` NCHAR(7)) TAGS (`endpoint` NCHAR(7),`task.type` NCHAR(3))"
)
...
@@ -40,10 +41,29 @@ class TDTestCase:
...
@@ -40,10 +41,29 @@ class TDTestCase:
tdSql
.
query
(
"select `add.type` from `tsch.job.create`"
)
tdSql
.
query
(
"select `add.type` from `tsch.job.create`"
)
tdSql
.
checkData
(
0
,
0
,
"tag2"
)
tdSql
.
checkData
(
0
,
0
,
"tag2"
)
### test stable
tdSql
.
execute
(
"create stable `ssch.job.create` (`ts` TIMESTAMP, `tint` int, `node.value` NCHAR(7)) TAGS (`endpoint` NCHAR(7),`task.type` NCHAR(3))"
)
tdSql
.
execute
(
"alter stable `ssch.job.create` modify tag `task.type` NCHAR(4)"
)
tdSql
.
execute
(
"alter stable `ssch.job.create` change tag `task.type` `chan.type`"
)
tdSql
.
execute
(
"alter stable `ssch.job.create` drop tag `chan.type`"
)
tdSql
.
execute
(
"alter stable `ssch.job.create` add tag `add.type` NCHAR(6)"
)
tdSql
.
query
(
"describe `ssch.job.create`"
)
tdSql
.
checkData
(
4
,
0
,
"add.type"
)
tdSql
.
execute
(
"alter stable `ssch.job.create` modify column `node.value` NCHAR(8)"
)
tdSql
.
execute
(
"alter stable `ssch.job.create` drop column `node.value`"
)
tdSql
.
execute
(
"alter stable `ssch.job.create` add column `add.value` NCHAR(6)"
)
tdSql
.
query
(
"describe `ssch.job.create`"
)
tdSql
.
checkData
(
2
,
0
,
"add.value"
)
tdSql
.
execute
(
"insert into `tssch.job.create` using `ssch.job.create`(`add.type`) TAGS('tag1') values(now, 1, 'here')"
)
tdSql
.
error
(
"alter stable `tssch.job.create` set tag `add.type` = 'tag2'"
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录