Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
17c8f8b1
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
17c8f8b1
编写于
2月 09, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test for update stb
上级
604ff6c4
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
422 addition
and
234 deletion
+422
-234
include/common/tmsg.h
include/common/tmsg.h
+4
-5
include/util/taoserror.h
include/util/taoserror.h
+2
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+35
-34
source/dnode/mgmt/impl/test/vnode/vnode.cpp
source/dnode/mgmt/impl/test/vnode/vnode.cpp
+3
-3
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+21
-19
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+346
-160
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+4
-4
source/libs/parser/src/astGenerator.c
source/libs/parser/src/astGenerator.c
+1
-1
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+4
-4
source/util/src/terror.c
source/util/src/terror.c
+2
-2
未找到文件。
include/common/tmsg.h
浏览文件 @
17c8f8b1
...
@@ -111,8 +111,8 @@ typedef enum _mgmt_table {
...
@@ -111,8 +111,8 @@ typedef enum _mgmt_table {
TSDB_MGMT_TABLE_MAX
,
TSDB_MGMT_TABLE_MAX
,
}
EShowType
;
}
EShowType
;
#define TSDB_ALTER_TABLE_ADD_TAG
_COLUMN
1
#define TSDB_ALTER_TABLE_ADD_TAG 1
#define TSDB_ALTER_TABLE_DROP_TAG
_COLUMN
2
#define TSDB_ALTER_TABLE_DROP_TAG 2
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3
#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4
...
@@ -1198,8 +1198,8 @@ typedef struct {
...
@@ -1198,8 +1198,8 @@ typedef struct {
int32_t
tSerializeSVCreateTbBatchReq
(
void
**
buf
,
SVCreateTbBatchReq
*
pReq
);
int32_t
tSerializeSVCreateTbBatchReq
(
void
**
buf
,
SVCreateTbBatchReq
*
pReq
);
void
*
tDeserializeSVCreateTbBatchReq
(
void
*
buf
,
SVCreateTbBatchReq
*
pReq
);
void
*
tDeserializeSVCreateTbBatchReq
(
void
*
buf
,
SVCreateTbBatchReq
*
pReq
);
int32_t
tSerializeSVCreateTbBatchR
eqp
(
void
**
buf
,
SVCreateTbBatchReq
*
pRsp
);
int32_t
tSerializeSVCreateTbBatchR
sp
(
void
**
buf
,
SVCreateTbBatchRsp
*
pRsp
);
void
*
tDeserializeSVCreateTbBatchR
eq
(
void
*
buf
,
SVCreateTbBatchReq
*
pRsp
);
void
*
tDeserializeSVCreateTbBatchR
sp
(
void
*
buf
,
SVCreateTbBatchRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
uint64_t
ver
;
uint64_t
ver
;
...
@@ -1209,7 +1209,6 @@ typedef struct {
...
@@ -1209,7 +1209,6 @@ typedef struct {
}
SVDropTbReq
;
}
SVDropTbReq
;
typedef
struct
{
typedef
struct
{
uint64_t
ver
;
}
SVDropTbRsp
;
}
SVDropTbRsp
;
int32_t
tSerializeSVDropTbReq
(
void
**
buf
,
SVDropTbReq
*
pReq
);
int32_t
tSerializeSVDropTbReq
(
void
**
buf
,
SVDropTbReq
*
pReq
);
...
...
include/util/taoserror.h
浏览文件 @
17c8f8b1
...
@@ -223,10 +223,10 @@ int32_t* taosGetErrno();
...
@@ -223,10 +223,10 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x03A4)
#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x03A4)
#define TSDB_CODE_MND_STB_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03A5)
#define TSDB_CODE_MND_STB_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03A5)
#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x03A6)
#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x03A6)
#define TSDB_CODE_MND_TAG_ALREA
Y_EXIST
TAOS_DEF_ERROR_CODE(0, 0x03A7)
#define TSDB_CODE_MND_TAG_ALREA
DY_EXIST
TAOS_DEF_ERROR_CODE(0, 0x03A7)
#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A8)
#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A8)
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03A9)
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03A9)
#define TSDB_CODE_MND_COLUMN_ALREA
Y_EXIST
TAOS_DEF_ERROR_CODE(0, 0x03AA)
#define TSDB_CODE_MND_COLUMN_ALREA
DY_EXIST
TAOS_DEF_ERROR_CODE(0, 0x03AA)
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB)
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB)
#define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03AC)
#define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03AC)
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03AD)
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03AD)
...
...
source/common/src/tmsg.c
浏览文件 @
17c8f8b1
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#undef TD_MSG_SEG_CODE_
#undef TD_MSG_SEG_CODE_
#include "tmsgdef.h"
#include "tmsgdef.h"
int
tInitSubmitMsgIter
(
SSubmitMsg
*
pMsg
,
SSubmitMsgIter
*
pIter
)
{
int
32_t
tInitSubmitMsgIter
(
SSubmitMsg
*
pMsg
,
SSubmitMsgIter
*
pIter
)
{
if
(
pMsg
==
NULL
)
{
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP
;
terrno
=
TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP
;
return
-
1
;
return
-
1
;
...
@@ -44,7 +44,7 @@ int tInitSubmitMsgIter(SSubmitMsg *pMsg, SSubmitMsgIter *pIter) {
...
@@ -44,7 +44,7 @@ int tInitSubmitMsgIter(SSubmitMsg *pMsg, SSubmitMsgIter *pIter) {
return
0
;
return
0
;
}
}
int
tGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
)
{
int
32_t
tGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
)
{
if
(
pIter
->
len
==
0
)
{
if
(
pIter
->
len
==
0
)
{
pIter
->
len
+=
sizeof
(
SSubmitMsg
);
pIter
->
len
+=
sizeof
(
SSubmitMsg
);
}
else
{
}
else
{
...
@@ -63,7 +63,7 @@ int tGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
...
@@ -63,7 +63,7 @@ int tGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
return
0
;
return
0
;
}
}
int
tInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
)
{
int
32_t
tInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
)
{
if
(
pBlock
->
dataLen
<=
0
)
return
-
1
;
if
(
pBlock
->
dataLen
<=
0
)
return
-
1
;
pIter
->
totalLen
=
pBlock
->
dataLen
;
pIter
->
totalLen
=
pBlock
->
dataLen
;
pIter
->
len
=
0
;
pIter
->
len
=
0
;
...
@@ -85,14 +85,14 @@ SMemRow tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
...
@@ -85,14 +85,14 @@ SMemRow tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
}
}
}
}
int
tSerializeSClientHbReq
(
void
**
buf
,
const
SClientHbReq
*
pReq
)
{
int
32_t
tSerializeSClientHbReq
(
void
**
buf
,
const
SClientHbReq
*
pReq
)
{
int
tlen
=
0
;
int
32_t
tlen
=
0
;
tlen
+=
taosEncodeSClientHbKey
(
buf
,
&
pReq
->
connKey
);
tlen
+=
taosEncodeSClientHbKey
(
buf
,
&
pReq
->
connKey
);
int32_t
kvNum
=
taosHashGetSize
(
pReq
->
info
);
int32_t
kvNum
=
taosHashGetSize
(
pReq
->
info
);
tlen
+=
taosEncodeFixedI32
(
buf
,
kvNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
kvNum
);
SKv
*
kv
;
SKv
*
kv
;
void
*
pIter
=
taosHashIterate
(
pReq
->
info
,
NULL
);
void
*
pIter
=
taosHashIterate
(
pReq
->
info
,
NULL
);
while
(
pIter
!=
NULL
)
{
while
(
pIter
!=
NULL
)
{
kv
=
pIter
;
kv
=
pIter
;
tlen
+=
taosEncodeSKv
(
buf
,
kv
);
tlen
+=
taosEncodeSKv
(
buf
,
kv
);
...
@@ -111,7 +111,7 @@ void *tDeserializeSClientHbReq(void *buf, SClientHbReq *pReq) {
...
@@ -111,7 +111,7 @@ void *tDeserializeSClientHbReq(void *buf, SClientHbReq *pReq) {
if
(
pReq
->
info
==
NULL
)
{
if
(
pReq
->
info
==
NULL
)
{
pReq
->
info
=
taosHashInit
(
kvNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
pReq
->
info
=
taosHashInit
(
kvNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
}
}
for
(
in
t
i
=
0
;
i
<
kvNum
;
i
++
)
{
for
(
int32_
t
i
=
0
;
i
<
kvNum
;
i
++
)
{
SKv
kv
;
SKv
kv
;
buf
=
taosDecodeSKv
(
buf
,
&
kv
);
buf
=
taosDecodeSKv
(
buf
,
&
kv
);
taosHashPut
(
pReq
->
info
,
&
kv
.
key
,
sizeof
(
kv
.
key
),
&
kv
,
sizeof
(
kv
));
taosHashPut
(
pReq
->
info
,
&
kv
.
key
,
sizeof
(
kv
.
key
),
&
kv
,
sizeof
(
kv
));
...
@@ -120,25 +120,26 @@ void *tDeserializeSClientHbReq(void *buf, SClientHbReq *pReq) {
...
@@ -120,25 +120,26 @@ void *tDeserializeSClientHbReq(void *buf, SClientHbReq *pReq) {
return
buf
;
return
buf
;
}
}
int
tSerializeSClientHbRsp
(
void
**
buf
,
const
SClientHbRsp
*
pRsp
)
{
int
32_t
tSerializeSClientHbRsp
(
void
**
buf
,
const
SClientHbRsp
*
pRsp
)
{
int
tlen
=
0
;
int
32_t
tlen
=
0
;
int32_t
kvNum
=
taosArrayGetSize
(
pRsp
->
info
);
int32_t
kvNum
=
taosArrayGetSize
(
pRsp
->
info
);
tlen
+=
taosEncodeSClientHbKey
(
buf
,
&
pRsp
->
connKey
);
tlen
+=
taosEncodeSClientHbKey
(
buf
,
&
pRsp
->
connKey
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
status
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
status
);
tlen
+=
taosEncodeFixedI32
(
buf
,
kvNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
kvNum
);
for
(
int
i
=
0
;
i
<
kvNum
;
i
++
)
{
for
(
int
32_t
i
=
0
;
i
<
kvNum
;
i
++
)
{
SKv
*
kv
=
(
SKv
*
)
taosArrayGet
(
pRsp
->
info
,
i
);
SKv
*
kv
=
(
SKv
*
)
taosArrayGet
(
pRsp
->
info
,
i
);
tlen
+=
taosEncodeSKv
(
buf
,
kv
);
tlen
+=
taosEncodeSKv
(
buf
,
kv
);
}
}
return
tlen
;
return
tlen
;
}
}
void
*
tDeserializeSClientHbRsp
(
void
*
buf
,
SClientHbRsp
*
pRsp
)
{
void
*
tDeserializeSClientHbRsp
(
void
*
buf
,
SClientHbRsp
*
pRsp
)
{
int32_t
kvNum
=
0
;
int32_t
kvNum
=
0
;
buf
=
taosDecodeSClientHbKey
(
buf
,
&
pRsp
->
connKey
);
buf
=
taosDecodeSClientHbKey
(
buf
,
&
pRsp
->
connKey
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
status
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
status
);
buf
=
taosDecodeFixedI32
(
buf
,
&
kvNum
);
buf
=
taosDecodeFixedI32
(
buf
,
&
kvNum
);
pRsp
->
info
=
taosArrayInit
(
kvNum
,
sizeof
(
SKv
));
pRsp
->
info
=
taosArrayInit
(
kvNum
,
sizeof
(
SKv
));
for
(
int
i
=
0
;
i
<
kvNum
;
i
++
)
{
for
(
int
32_t
i
=
0
;
i
<
kvNum
;
i
++
)
{
SKv
kv
=
{
0
};
SKv
kv
=
{
0
};
buf
=
taosDecodeSKv
(
buf
,
&
kv
);
buf
=
taosDecodeSKv
(
buf
,
&
kv
);
taosArrayPush
(
pRsp
->
info
,
&
kv
);
taosArrayPush
(
pRsp
->
info
,
&
kv
);
...
@@ -147,19 +148,19 @@ void* tDeserializeSClientHbRsp(void* buf, SClientHbRsp* pRsp) {
...
@@ -147,19 +148,19 @@ void* tDeserializeSClientHbRsp(void* buf, SClientHbRsp* pRsp) {
return
buf
;
return
buf
;
}
}
int
tSerializeSClientHbBatchReq
(
void
**
buf
,
const
SClientHbBatchReq
*
pBatchReq
)
{
int
32_t
tSerializeSClientHbBatchReq
(
void
**
buf
,
const
SClientHbBatchReq
*
pBatchReq
)
{
int
tlen
=
0
;
int
32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pBatchReq
->
reqId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pBatchReq
->
reqId
);
int32_t
reqNum
=
taosArrayGetSize
(
pBatchReq
->
reqs
);
int32_t
reqNum
=
taosArrayGetSize
(
pBatchReq
->
reqs
);
tlen
+=
taosEncodeFixedI32
(
buf
,
reqNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
reqNum
);
for
(
int
i
=
0
;
i
<
reqNum
;
i
++
)
{
for
(
int
32_t
i
=
0
;
i
<
reqNum
;
i
++
)
{
SClientHbReq
*
pReq
=
taosArrayGet
(
pBatchReq
->
reqs
,
i
);
SClientHbReq
*
pReq
=
taosArrayGet
(
pBatchReq
->
reqs
,
i
);
tlen
+=
tSerializeSClientHbReq
(
buf
,
pReq
);
tlen
+=
tSerializeSClientHbReq
(
buf
,
pReq
);
}
}
return
tlen
;
return
tlen
;
}
}
void
*
tDeserializeSClientHbBatchReq
(
void
*
buf
,
SClientHbBatchReq
*
pBatchReq
)
{
void
*
tDeserializeSClientHbBatchReq
(
void
*
buf
,
SClientHbBatchReq
*
pBatchReq
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pBatchReq
->
reqId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pBatchReq
->
reqId
);
if
(
pBatchReq
->
reqs
==
NULL
)
{
if
(
pBatchReq
->
reqs
==
NULL
)
{
pBatchReq
->
reqs
=
taosArrayInit
(
0
,
sizeof
(
SClientHbReq
));
pBatchReq
->
reqs
=
taosArrayInit
(
0
,
sizeof
(
SClientHbReq
));
...
@@ -167,7 +168,7 @@ void* tDeserializeSClientHbBatchReq(void* buf, SClientHbBatchReq* pBatchReq) {
...
@@ -167,7 +168,7 @@ void* tDeserializeSClientHbBatchReq(void* buf, SClientHbBatchReq* pBatchReq) {
int32_t
reqNum
;
int32_t
reqNum
;
buf
=
taosDecodeFixedI32
(
buf
,
&
reqNum
);
buf
=
taosDecodeFixedI32
(
buf
,
&
reqNum
);
for
(
int
i
=
0
;
i
<
reqNum
;
i
++
)
{
for
(
int
32_t
i
=
0
;
i
<
reqNum
;
i
++
)
{
SClientHbReq
req
=
{
0
};
SClientHbReq
req
=
{
0
};
buf
=
tDeserializeSClientHbReq
(
buf
,
&
req
);
buf
=
tDeserializeSClientHbReq
(
buf
,
&
req
);
taosArrayPush
(
pBatchReq
->
reqs
,
&
req
);
taosArrayPush
(
pBatchReq
->
reqs
,
&
req
);
...
@@ -175,22 +176,22 @@ void* tDeserializeSClientHbBatchReq(void* buf, SClientHbBatchReq* pBatchReq) {
...
@@ -175,22 +176,22 @@ void* tDeserializeSClientHbBatchReq(void* buf, SClientHbBatchReq* pBatchReq) {
return
buf
;
return
buf
;
}
}
int
tSerializeSClientHbBatchRsp
(
void
**
buf
,
const
SClientHbBatchRsp
*
pBatchRsp
)
{
int
32_t
tSerializeSClientHbBatchRsp
(
void
**
buf
,
const
SClientHbBatchRsp
*
pBatchRsp
)
{
int
tlen
=
0
;
int
32_t
tlen
=
0
;
int32_t
sz
=
taosArrayGetSize
(
pBatchRsp
->
rsps
);
int32_t
sz
=
taosArrayGetSize
(
pBatchRsp
->
rsps
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int
32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SClientHbRsp
*
pRsp
=
taosArrayGet
(
pBatchRsp
->
rsps
,
i
);
SClientHbRsp
*
pRsp
=
taosArrayGet
(
pBatchRsp
->
rsps
,
i
);
tlen
+=
tSerializeSClientHbRsp
(
buf
,
pRsp
);
tlen
+=
tSerializeSClientHbRsp
(
buf
,
pRsp
);
}
}
return
tlen
;
return
tlen
;
}
}
void
*
tDeserializeSClientHbBatchRsp
(
void
*
buf
,
SClientHbBatchRsp
*
pBatchRsp
)
{
void
*
tDeserializeSClientHbBatchRsp
(
void
*
buf
,
SClientHbBatchRsp
*
pBatchRsp
)
{
int32_t
sz
;
int32_t
sz
;
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pBatchRsp
->
rsps
=
taosArrayInit
(
sz
,
sizeof
(
SClientHbRsp
));
pBatchRsp
->
rsps
=
taosArrayInit
(
sz
,
sizeof
(
SClientHbRsp
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int
32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SClientHbRsp
rsp
=
{
0
};
SClientHbRsp
rsp
=
{
0
};
buf
=
tDeserializeSClientHbRsp
(
buf
,
&
rsp
);
buf
=
tDeserializeSClientHbRsp
(
buf
,
&
rsp
);
taosArrayPush
(
pBatchRsp
->
rsps
,
&
rsp
);
taosArrayPush
(
pBatchRsp
->
rsps
,
&
rsp
);
...
@@ -198,8 +199,8 @@ void* tDeserializeSClientHbBatchRsp(void* buf, SClientHbBatchRsp* pBatchRsp) {
...
@@ -198,8 +199,8 @@ void* tDeserializeSClientHbBatchRsp(void* buf, SClientHbBatchRsp* pBatchRsp) {
return
buf
;
return
buf
;
}
}
int
tSerializeSVCreateTbReq
(
void
**
buf
,
SVCreateTbReq
*
pReq
)
{
int
32_t
tSerializeSVCreateTbReq
(
void
**
buf
,
SVCreateTbReq
*
pReq
)
{
int
tlen
=
0
;
int
32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
...
@@ -293,8 +294,8 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -293,8 +294,8 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
return
buf
;
return
buf
;
}
}
int
tSerializeSVCreateTbBatchReq
(
void
**
buf
,
SVCreateTbBatchReq
*
pReq
)
{
int
32_t
tSerializeSVCreateTbBatchReq
(
void
**
buf
,
SVCreateTbBatchReq
*
pReq
)
{
int
tlen
=
0
;
int
32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeFixedU32
(
buf
,
taosArrayGetSize
(
pReq
->
pArray
));
tlen
+=
taosEncodeFixedU32
(
buf
,
taosArrayGetSize
(
pReq
->
pArray
));
...
@@ -322,7 +323,7 @@ void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
...
@@ -322,7 +323,7 @@ void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
}
}
int32_t
tSerializeSVDropTbReq
(
void
**
buf
,
SVDropTbReq
*
pReq
)
{
int32_t
tSerializeSVDropTbReq
(
void
**
buf
,
SVDropTbReq
*
pReq
)
{
int
tlen
=
0
;
int
32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeFixedU8
(
buf
,
pReq
->
type
);
tlen
+=
taosEncodeFixedU8
(
buf
,
pReq
->
type
);
...
...
source/dnode/mgmt/impl/test/vnode/vnode.cpp
浏览文件 @
17c8f8b1
...
@@ -108,7 +108,7 @@ TEST_F(DndTestVnode, 01_Create_Vnode) {
...
@@ -108,7 +108,7 @@ TEST_F(DndTestVnode, 01_Create_Vnode) {
}
}
}
}
TEST_F
(
DndTestVnode
,
02
_A
LTER
_Vnode
)
{
TEST_F
(
DndTestVnode
,
02
_A
lter
_Vnode
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SAlterVnodeReq
);
int32_t
contLen
=
sizeof
(
SAlterVnodeReq
);
...
@@ -219,7 +219,7 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
...
@@ -219,7 +219,7 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
}
}
}
}
TEST_F
(
DndTestVnode
,
04
_A
LTER
_Stb
)
{
TEST_F
(
DndTestVnode
,
04
_A
lter
_Stb
)
{
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
ver
=
0
;
...
@@ -310,7 +310,7 @@ TEST_F(DndTestVnode, 05_DROP_Stb) {
...
@@ -310,7 +310,7 @@ TEST_F(DndTestVnode, 05_DROP_Stb) {
}
}
}
}
TEST_F
(
DndTestVnode
,
06
_D
ROP
_Vnode
)
{
TEST_F
(
DndTestVnode
,
06
_D
rop
_Vnode
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SDropVnodeReq
);
int32_t
contLen
=
sizeof
(
SDropVnodeReq
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
17c8f8b1
...
@@ -652,12 +652,12 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const SSc
...
@@ -652,12 +652,12 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const SSc
for
(
int32_t
i
=
0
;
i
<
ntags
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
ntags
;
i
++
)
{
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
terrno
=
TSDB_CODE_MND_
TAG_ALREA
Y_EXIST
;
terrno
=
TSDB_CODE_MND_
COLUMN_ALREAD
Y_EXIST
;
return
-
1
;
return
-
1
;
}
}
if
(
mndFindSuperTableTagIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
if
(
mndFindSuperTableTagIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
terrno
=
TSDB_CODE_MND_
COLUMN_ALREA
Y_EXIST
;
terrno
=
TSDB_CODE_MND_
TAG_ALREAD
Y_EXIST
;
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -692,6 +692,7 @@ static int32_t mndDropSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const ch
...
@@ -692,6 +692,7 @@ static int32_t mndDropSuperTableTag(const SStbObj *pOld, SStbObj *pNew, const ch
}
}
memmove
(
pNew
->
pTags
+
tag
,
pNew
->
pTags
+
tag
+
1
,
sizeof
(
SSchema
)
*
(
pNew
->
numOfTags
-
tag
-
1
));
memmove
(
pNew
->
pTags
+
tag
,
pNew
->
pTags
+
tag
+
1
,
sizeof
(
SSchema
)
*
(
pNew
->
numOfTags
-
tag
-
1
));
pNew
->
numOfTags
--
;
pNew
->
version
++
;
pNew
->
version
++
;
mDebug
(
"stb:%s, start to drop tag %s"
,
pNew
->
name
,
tagName
);
mDebug
(
"stb:%s, start to drop tag %s"
,
pNew
->
name
,
tagName
);
...
@@ -706,13 +707,12 @@ static int32_t mndAlterStbTagName(const SStbObj *pOld, SStbObj *pNew, const char
...
@@ -706,13 +707,12 @@ static int32_t mndAlterStbTagName(const SStbObj *pOld, SStbObj *pNew, const char
}
}
if
(
mndFindSuperTableTagIndex
(
pOld
,
newTagName
)
>=
0
)
{
if
(
mndFindSuperTableTagIndex
(
pOld
,
newTagName
)
>=
0
)
{
terrno
=
TSDB_CODE_MND_TAG_ALREAY_EXIST
;
terrno
=
TSDB_CODE_MND_TAG_ALREA
D
Y_EXIST
;
return
-
1
;
return
-
1
;
}
}
int32_t
len
=
(
int32_t
)
strlen
(
newTagName
);
if
(
mndFindSuperTableColumnIndex
(
pOld
,
newTagName
)
>=
0
)
{
if
(
len
>=
TSDB_COL_NAME_LEN
)
{
terrno
=
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
return
-
1
;
}
}
...
@@ -765,12 +765,12 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
...
@@ -765,12 +765,12 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
if
(
mndFindSuperTableColumnIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
terrno
=
TSDB_CODE_MND_TAG_ALREAY_EXIST
;
terrno
=
TSDB_CODE_MND_TAG_ALREA
D
Y_EXIST
;
return
-
1
;
return
-
1
;
}
}
if
(
mndFindSuperTableTagIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
if
(
mndFindSuperTableTagIndex
(
pOld
,
pSchemas
[
i
].
name
)
>
0
)
{
terrno
=
TSDB_CODE_MND_COLUMN_ALREAY_EXIST
;
terrno
=
TSDB_CODE_MND_COLUMN_ALREA
D
Y_EXIST
;
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -805,6 +805,7 @@ static int32_t mndDropSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
...
@@ -805,6 +805,7 @@ static int32_t mndDropSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, const
}
}
memmove
(
pNew
->
pColumns
+
col
,
pNew
->
pColumns
+
col
+
1
,
sizeof
(
SSchema
)
*
(
pNew
->
numOfColumns
-
col
-
1
));
memmove
(
pNew
->
pColumns
+
col
,
pNew
->
pColumns
+
col
+
1
,
sizeof
(
SSchema
)
*
(
pNew
->
numOfColumns
-
col
-
1
));
pNew
->
numOfColumns
--
;
pNew
->
version
++
;
pNew
->
version
++
;
mDebug
(
"stb:%s, start to drop col %s"
,
pNew
->
name
,
colName
);
mDebug
(
"stb:%s, start to drop col %s"
,
pNew
->
name
,
colName
);
...
@@ -914,12 +915,13 @@ static int32_t mndAlterStb(SMnode *pMnode, SMnodeMsg *pReq, const SMAltertbReq *
...
@@ -914,12 +915,13 @@ static int32_t mndAlterStb(SMnode *pMnode, SMnodeMsg *pReq, const SMAltertbReq *
taosRUnLockLatch
(
&
pOld
->
lock
);
taosRUnLockLatch
(
&
pOld
->
lock
);
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
NULL
;
switch
(
pAlter
->
alterType
)
{
switch
(
pAlter
->
alterType
)
{
case
TSDB_ALTER_TABLE_ADD_TAG
_COLUMN
:
case
TSDB_ALTER_TABLE_ADD_TAG
:
code
=
mndAddSuperTableTag
(
pOld
,
&
stbObj
,
pAlter
->
pSchemas
,
1
);
code
=
mndAddSuperTableTag
(
pOld
,
&
stbObj
,
pAlter
->
pSchemas
,
1
);
break
;
break
;
case
TSDB_ALTER_TABLE_DROP_TAG
_COLUMN
:
case
TSDB_ALTER_TABLE_DROP_TAG
:
code
=
mndDropSuperTableTag
(
pOld
,
&
stbObj
,
pAlter
->
pSchemas
[
0
].
name
);
code
=
mndDropSuperTableTag
(
pOld
,
&
stbObj
,
pAlter
->
pSchemas
[
0
].
name
);
break
;
break
;
case
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
:
case
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
:
...
@@ -945,7 +947,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SMnodeMsg *pReq, const SMAltertbReq *
...
@@ -945,7 +947,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SMnodeMsg *pReq, const SMAltertbReq *
if
(
code
!=
0
)
goto
ALTER_STB_OVER
;
if
(
code
!=
0
)
goto
ALTER_STB_OVER
;
code
=
-
1
;
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pReq
->
rpcMsg
);
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
ALTER_STB_OVER
;
if
(
pTrans
==
NULL
)
goto
ALTER_STB_OVER
;
mDebug
(
"trans:%d, used to alter stb:%s"
,
pTrans
->
id
,
pAlter
->
name
);
mDebug
(
"trans:%d, used to alter stb:%s"
,
pTrans
->
id
,
pAlter
->
name
);
...
@@ -975,17 +977,17 @@ static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) {
...
@@ -975,17 +977,17 @@ static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) {
return
-
1
;
return
-
1
;
}
}
S
StbObj
*
pStb
=
mndAcquire
Stb
(
pMnode
,
pAlter
->
name
);
S
DbObj
*
pDb
=
mndAcquireDbBy
Stb
(
pMnode
,
pAlter
->
name
);
if
(
p
St
b
==
NULL
)
{
if
(
p
D
b
==
NULL
)
{
terrno
=
TSDB_CODE_MND_
STB_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_
INVALID_DB
;
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
S
DbObj
*
pDb
=
mndAcquireDbBy
Stb
(
pMnode
,
pAlter
->
name
);
S
StbObj
*
pStb
=
mndAcquire
Stb
(
pMnode
,
pAlter
->
name
);
if
(
p
D
b
==
NULL
)
{
if
(
p
St
b
==
NULL
)
{
mndRelease
Stb
(
pMnode
,
pSt
b
);
mndRelease
Db
(
pMnode
,
pD
b
);
terrno
=
TSDB_CODE_MND_
DB_NOT_SELECTED
;
terrno
=
TSDB_CODE_MND_
STB_NOT_EXIST
;
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -994,7 +996,7 @@ static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) {
...
@@ -994,7 +996,7 @@ static int32_t mndProcessMAlterStbReq(SMnodeMsg *pReq) {
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseStb
(
pMnode
,
pStb
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
t
strerror
(
code
));
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
t
errstr
(
));
return
code
;
return
code
;
}
}
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
17c8f8b1
...
@@ -24,7 +24,12 @@ class MndTestStb : public ::testing::Test {
...
@@ -24,7 +24,12 @@ class MndTestStb : public ::testing::Test {
SCreateDbReq
*
BuildCreateDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
SCreateDbReq
*
BuildCreateDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
SMCreateStbReq
*
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
SMCreateStbReq
*
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbDropTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbUpdateTagNameReq
(
const
char
*
stbname
,
const
char
*
tagname
,
const
char
*
newtagname
,
int32_t
*
pContLen
);
SMAltertbReq
*
BuildAlterStbDUpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
int32_t
*
pContLen
);
};
};
Testbase
MndTestStb
::
test
;
Testbase
MndTestStb
::
test
;
...
@@ -58,7 +63,7 @@ SCreateDbReq* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen
...
@@ -58,7 +63,7 @@ SCreateDbReq* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen
return
pReq
;
return
pReq
;
}
}
SMCreateStbReq
*
MndTestStb
::
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
SMCreateStbReq
*
MndTestStb
::
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
int32_t
cols
=
2
;
int32_t
cols
=
2
;
int32_t
tags
=
3
;
int32_t
tags
=
3
;
int32_t
contLen
=
(
tags
+
cols
)
*
sizeof
(
SSchema
)
+
sizeof
(
SMCreateStbReq
);
int32_t
contLen
=
(
tags
+
cols
)
*
sizeof
(
SSchema
)
+
sizeof
(
SMCreateStbReq
);
...
@@ -107,173 +112,228 @@ SMCreateStbReq* MndTestStb::BuildCreateStbReq(const char *stbname, int32_t* pCon
...
@@ -107,173 +112,228 @@ SMCreateStbReq* MndTestStb::BuildCreateStbReq(const char *stbname, int32_t* pCon
return
pReq
;
return
pReq
;
}
}
//
TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
TEST_F
(
MndTestStb
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
// const char *
dbname = "1.d1";
const
char
*
dbname
=
"1.d1"
;
// const char *
stbname = "1.d1.stb";
const
char
*
stbname
=
"1.d1.stb"
;
//
{
{
//
int32_t contLen = 0;
int32_t
contLen
=
0
;
//
SCreateDbReq* pReq = BuildCreateDbReq(dbname, &contLen);
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
//
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
//
ASSERT_NE(pRsp, nullptr);
ASSERT_NE
(
pRsp
,
nullptr
);
//
ASSERT_EQ(pRsp->code, 0);
ASSERT_EQ
(
pRsp
->
code
,
0
);
//
}
}
//
{
{
//
int32_t contLen = 0;
int32_t
contLen
=
0
;
//
SMCreateStbReq* pReq = BuildCreateStbReq(stbname, &contLen);
SMCreateStbReq
*
pReq
=
BuildCreateStbReq
(
stbname
,
&
contLen
);
//
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
//
ASSERT_NE(pRsp, nullptr);
ASSERT_NE
(
pRsp
,
nullptr
);
//
ASSERT_EQ(pRsp->code, 0);
ASSERT_EQ
(
pRsp
->
code
,
0
);
//
}
}
//
{
{
//
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
//
CHECK_META("show stables", 4);
CHECK_META
(
"show stables"
,
4
);
//
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name");
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
//
CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
//
CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "columns");
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_INT
,
4
,
"columns"
);
//
CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "tags");
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_INT
,
4
,
"tags"
);
//
test.SendShowRetrieveReq();
test
.
SendShowRetrieveReq
();
//
EXPECT_EQ(test.GetShowRows(), 1);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
//
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
//
CheckTimestamp();
CheckTimestamp
();
//
CheckInt32(2);
CheckInt32
(
2
);
//
CheckInt32(3);
CheckInt32
(
3
);
//
}
}
//
// ----- meta ------
// ----- meta ------
//
{
{
// int32_t
contLen = sizeof(STableInfoReq);
int32_t
contLen
=
sizeof
(
STableInfoReq
);
//
STableInfoReq* pReq = (STableInfoReq*)rpcMallocCont(contLen);
STableInfoReq
*
pReq
=
(
STableInfoReq
*
)
rpcMallocCont
(
contLen
);
//
strcpy(pReq->dbFName, dbname);
strcpy
(
pReq
->
dbFName
,
dbname
);
//
strcpy(pReq->tbName, "stb");
strcpy
(
pReq
->
tbName
,
"stb"
);
//
SRpcMsg* pMsg = test.SendReq(TDMT_MND_STB_META, pReq, contLen);
SRpcMsg
*
pMsg
=
test
.
SendReq
(
TDMT_MND_STB_META
,
pReq
,
contLen
);
//
ASSERT_NE(pMsg, nullptr);
ASSERT_NE
(
pMsg
,
nullptr
);
//
ASSERT_EQ(pMsg->code, 0);
ASSERT_EQ
(
pMsg
->
code
,
0
);
//
STableMetaRsp* pRsp = (STableMetaRsp*)pMsg->pCont;
STableMetaRsp
*
pRsp
=
(
STableMetaRsp
*
)
pMsg
->
pCont
;
//
pRsp->numOfTags = htonl(pRsp->numOfTags);
pRsp
->
numOfTags
=
htonl
(
pRsp
->
numOfTags
);
//
pRsp->numOfColumns = htonl(pRsp->numOfColumns);
pRsp
->
numOfColumns
=
htonl
(
pRsp
->
numOfColumns
);
//
pRsp->sversion = htonl(pRsp->sversion);
pRsp
->
sversion
=
htonl
(
pRsp
->
sversion
);
//
pRsp->tversion = htonl(pRsp->tversion);
pRsp
->
tversion
=
htonl
(
pRsp
->
tversion
);
//
pRsp->suid = be64toh(pRsp->suid);
pRsp
->
suid
=
be64toh
(
pRsp
->
suid
);
//
pRsp->tuid = be64toh(pRsp->tuid);
pRsp
->
tuid
=
be64toh
(
pRsp
->
tuid
);
//
pRsp->vgId = be64toh(pRsp->vgId);
pRsp
->
vgId
=
be64toh
(
pRsp
->
vgId
);
//
for (int32_t i = 0; i < pRsp->numOfTags + pRsp->numOfColumns; ++i) {
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfTags
+
pRsp
->
numOfColumns
;
++
i
)
{
//
SSchema* pSchema = &pRsp->pSchema[i];
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
i
];
//
pSchema->colId = htonl(pSchema->colId);
pSchema
->
colId
=
htonl
(
pSchema
->
colId
);
//
pSchema->bytes = htonl(pSchema->bytes);
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
//
}
}
//
EXPECT_STREQ(pRsp->dbFName, dbname);
EXPECT_STREQ
(
pRsp
->
dbFName
,
dbname
);
//
EXPECT_STREQ(pRsp->tbName, "stb");
EXPECT_STREQ
(
pRsp
->
tbName
,
"stb"
);
//
EXPECT_STREQ(pRsp->stbName, "stb");
EXPECT_STREQ
(
pRsp
->
stbName
,
"stb"
);
//
EXPECT_EQ(pRsp->numOfColumns, 2);
EXPECT_EQ
(
pRsp
->
numOfColumns
,
2
);
//
EXPECT_EQ(pRsp->numOfTags, 3);
EXPECT_EQ
(
pRsp
->
numOfTags
,
3
);
//
EXPECT_EQ(pRsp->precision, TSDB_TIME_PRECISION_MILLI);
EXPECT_EQ
(
pRsp
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
//
EXPECT_EQ(pRsp->tableType, TSDB_SUPER_TABLE);
EXPECT_EQ
(
pRsp
->
tableType
,
TSDB_SUPER_TABLE
);
//
EXPECT_EQ(pRsp->update, 0);
EXPECT_EQ
(
pRsp
->
update
,
0
);
//
EXPECT_EQ(pRsp->sversion, 1);
EXPECT_EQ
(
pRsp
->
sversion
,
1
);
//
EXPECT_EQ(pRsp->tversion, 0);
EXPECT_EQ
(
pRsp
->
tversion
,
0
);
//
EXPECT_GT(pRsp->suid, 0);
EXPECT_GT
(
pRsp
->
suid
,
0
);
//
EXPECT_GT(pRsp->tuid, 0);
EXPECT_GT
(
pRsp
->
tuid
,
0
);
//
EXPECT_EQ(pRsp->vgId, 0);
EXPECT_EQ
(
pRsp
->
vgId
,
0
);
//
{
{
//
SSchema* pSchema = &pRsp->pSchema[0];
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
0
];
//
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TIMESTAMP
);
//
EXPECT_EQ(pSchema->colId, 1);
EXPECT_EQ
(
pSchema
->
colId
,
1
);
//
EXPECT_EQ(pSchema->bytes, 8);
EXPECT_EQ
(
pSchema
->
bytes
,
8
);
//
EXPECT_STREQ(pSchema->name, "ts");
EXPECT_STREQ
(
pSchema
->
name
,
"ts"
);
//
}
}
//
{
{
//
SSchema* pSchema = &pRsp->pSchema[1];
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
1
];
//
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_INT
);
//
EXPECT_EQ(pSchema->colId, 2);
EXPECT_EQ
(
pSchema
->
colId
,
2
);
//
EXPECT_EQ(pSchema->bytes, 4);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
//
EXPECT_STREQ(pSchema->name, "col1");
EXPECT_STREQ
(
pSchema
->
name
,
"col1"
);
//
}
}
//
{
{
//
SSchema* pSchema = &pRsp->pSchema[2];
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
2
];
//
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TINYINT);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TINYINT
);
//
EXPECT_EQ(pSchema->colId, 3);
EXPECT_EQ
(
pSchema
->
colId
,
3
);
//
EXPECT_EQ(pSchema->bytes, 2);
EXPECT_EQ
(
pSchema
->
bytes
,
2
);
//
EXPECT_STREQ(pSchema->name, "tag1");
EXPECT_STREQ
(
pSchema
->
name
,
"tag1"
);
//
}
}
//
{
{
//
SSchema* pSchema = &pRsp->pSchema[3];
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
3
];
//
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BIGINT);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BIGINT
);
//
EXPECT_EQ(pSchema->colId, 4);
EXPECT_EQ
(
pSchema
->
colId
,
4
);
//
EXPECT_EQ(pSchema->bytes, 8);
EXPECT_EQ
(
pSchema
->
bytes
,
8
);
//
EXPECT_STREQ(pSchema->name, "tag2");
EXPECT_STREQ
(
pSchema
->
name
,
"tag2"
);
//
}
}
//
{
{
//
SSchema* pSchema = &pRsp->pSchema[4];
SSchema
*
pSchema
=
&
pRsp
->
pSchema
[
4
];
//
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
//
EXPECT_EQ(pSchema->colId, 5);
EXPECT_EQ
(
pSchema
->
colId
,
5
);
//
EXPECT_EQ(pSchema->bytes, 16);
EXPECT_EQ
(
pSchema
->
bytes
,
16
);
//
EXPECT_STREQ(pSchema->name, "tag3");
EXPECT_STREQ
(
pSchema
->
name
,
"tag3"
);
//
}
}
//
}
}
//
// restart
// restart
//
test.Restart();
test
.
Restart
();
//
{
{
//
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
//
CHECK_META("show stables", 4);
CHECK_META
(
"show stables"
,
4
);
//
test.SendShowRetrieveReq();
test
.
SendShowRetrieveReq
();
//
EXPECT_EQ(test.GetShowRows(), 1);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
//
CheckBinary("stb", TSDB_TABLE_NAME_LEN);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
//
CheckTimestamp();
CheckTimestamp
();
//
CheckInt32(2);
CheckInt32
(
2
);
//
CheckInt32(3);
CheckInt32
(
3
);
//
}
}
//
{
{
//
int32_t contLen = sizeof(SMDropStbReq);
int32_t
contLen
=
sizeof
(
SMDropStbReq
);
//
SMDropStbReq* pReq = (SMDropStbReq*)rpcMallocCont(contLen);
SMDropStbReq
*
pReq
=
(
SMDropStbReq
*
)
rpcMallocCont
(
contLen
);
//
strcpy(pReq->name, stbname);
strcpy
(
pReq
->
name
,
stbname
);
//
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
//
ASSERT_NE(pRsp, nullptr);
ASSERT_NE
(
pRsp
,
nullptr
);
//
ASSERT_EQ(pRsp->code, 0);
ASSERT_EQ
(
pRsp
->
code
,
0
);
//
}
}
//
test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
//
CHECK_META("show stables", 4);
CHECK_META
(
"show stables"
,
4
);
//
test.SendShowRetrieveReq();
test
.
SendShowRetrieveReq
();
//
EXPECT_EQ(test.GetShowRows(), 0);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
//
}
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
SMAltertbReq
*
MndTestStb
::
BuildAlterStbAddTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_ADD_TAG
_COLUMN
;
pReq
->
alterType
=
TSDB_ALTER_TABLE_ADD_TAG
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
4
);
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_INT
;
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
"tag4"
);
strcpy
(
pSchema
->
name
,
tagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbDropTagReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_DROP_TAG
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
SMAltertbReq
*
MndTestStb
::
BuildAlterStbUpdateTagNameReq
(
const
char
*
stbname
,
const
char
*
tagname
,
const
char
*
newtagname
,
int32_t
*
pContLen
)
{
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
2
*
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
pSchema
=
&
pReq
->
pSchemas
[
1
];
pSchema
->
bytes
=
htonl
(
12
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
newtagname
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
return
pReq
;
return
pReq
;
}
}
TEST_F
(
MndTestStb
,
01
_Alter_Stb
)
{
SMAltertbReq
*
MndTestStb
::
BuildAlterStbDUpdateTagBytesReq
(
const
char
*
stbname
,
const
char
*
tagname
,
int32_t
bytes
,
const
char
*
dbname
=
"1.d2"
;
int32_t
*
pContLen
)
{
const
char
*
stbname
=
"1.d2.stb"
;
int32_t
contLen
=
sizeof
(
SMAltertbReq
)
+
sizeof
(
SSchema
);
SMAltertbReq
*
pReq
=
(
SMAltertbReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
stbname
);
pReq
->
numOfSchemas
=
htonl
(
1
);
pReq
->
alterType
=
TSDB_ALTER_TABLE_DROP_TAG
;
SSchema
*
pSchema
=
&
pReq
->
pSchemas
[
0
];
pSchema
->
bytes
=
htonl
(
bytes
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
tagname
);
*
pContLen
=
contLen
;
return
pReq
;
}
TEST_F
(
MndTestStb
,
02
_Alter_Stb_AddTag
)
{
const
char
*
dbname
=
"1.d2"
;
const
char
*
stbname
=
"1.d2.stb"
;
{
{
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
...
@@ -291,9 +351,34 @@ TEST_F(MndTestStb, 01_Alter_Stb) {
...
@@ -291,9 +351,34 @@ TEST_F(MndTestStb, 01_Alter_Stb) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
{
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
&
contLen
);
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
"1.d3.stb"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_DB
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
"1.d2.stb3"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_NOT_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
"tag3"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbAddTagReq
(
stbname
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
...
@@ -307,3 +392,104 @@ TEST_F(MndTestStb, 01_Alter_Stb) {
...
@@ -307,3 +392,104 @@ TEST_F(MndTestStb, 01_Alter_Stb) {
CheckInt32
(
4
);
CheckInt32
(
4
);
}
}
}
}
TEST_F
(
MndTestStb
,
03
_Alter_Stb_DropTag
)
{
const
char
*
dbname
=
"1.d3"
;
const
char
*
stbname
=
"1.d3.stb"
;
int32_t
contLen
=
0
;
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMCreateStbReq
*
pReq
=
BuildCreateStbReq
(
stbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropTagReq
(
stbname
,
"tag5"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbDropTagReq
(
stbname
,
"tag3"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
CheckTimestamp
();
CheckInt32
(
2
);
CheckInt32
(
2
);
}
}
TEST_F
(
MndTestStb
,
04
_Alter_Stb_AddTagName
)
{
const
char
*
dbname
=
"1.d4"
;
const
char
*
stbname
=
"1.d4.stb"
;
int32_t
contLen
=
0
;
{
SCreateDbReq
*
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMCreateStbReq
*
pReq
=
BuildCreateStbReq
(
stbname
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag5"
,
"tag6"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"col1"
,
"tag6"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_NOT_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"col1"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_ALREADY_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"tag2"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"tag2"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_TAG_ALREADY_EXIST
);
}
{
SMAltertbReq
*
pReq
=
BuildAlterStbUpdateTagNameReq
(
stbname
,
"tag3"
,
"tag4"
,
&
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
CheckTimestamp
();
CheckInt32
(
2
);
CheckInt32
(
3
);
}
}
\ No newline at end of file
source/libs/parser/inc/sql.y
浏览文件 @
17c8f8b1
...
@@ -820,7 +820,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) MODIFY COLUMN columnlist(A). {
...
@@ -820,7 +820,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) MODIFY COLUMN columnlist(A). {
//////////////////////////////////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;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG
_COLUMN
, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
...
@@ -829,7 +829,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
...
@@ -829,7 +829,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
toTSDBType(Y.type);
toTSDBType(Y.type);
SArray* A = tListItemAppendToken(NULL, &Y, -1);
SArray* A = tListItemAppendToken(NULL, &Y, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG
_COLUMN
, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
...
@@ -889,7 +889,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) MODIFY COLUMN columnlist(A). {
...
@@ -889,7 +889,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) MODIFY COLUMN columnlist(A). {
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
cmd ::= ALTER STABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
cmd ::= ALTER STABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
X.n += Y.n;
X.n += Y.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG
_COLUMN
, TSDB_SUPER_TABLE);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
...
@@ -898,7 +898,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
...
@@ -898,7 +898,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
toTSDBType(Y.type);
toTSDBType(Y.type);
SArray* A = tListItemAppendToken(NULL, &Y, -1);
SArray* A = tListItemAppendToken(NULL, &Y, -1);
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, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
}
...
...
source/libs/parser/src/astGenerator.c
浏览文件 @
17c8f8b1
...
@@ -610,7 +610,7 @@ SAlterTableInfo *tSetAlterTableInfo(SToken *pTableName, SArray *pCols, SArray *p
...
@@ -610,7 +610,7 @@ SAlterTableInfo *tSetAlterTableInfo(SToken *pTableName, SArray *pCols, SArray *p
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
||
type
==
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
||
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
)
{
if
(
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
||
type
==
TSDB_ALTER_TABLE_ADD_TAG
||
type
==
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
||
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
)
{
pAlterTable
->
pAddColumns
=
pCols
;
pAlterTable
->
pAddColumns
=
pCols
;
assert
(
pVals
==
NULL
);
assert
(
pVals
==
NULL
);
}
else
{
}
else
{
...
...
source/libs/parser/src/sql.c
浏览文件 @
17c8f8b1
...
@@ -3206,7 +3206,7 @@ static void yy_reduce(
...
@@ -3206,7 +3206,7 @@ static void yy_reduce(
case
286
:
/* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
case
286
:
/* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{
{
yymsp
[
-
4
].
minor
.
yy0
.
n
+=
yymsp
[
-
3
].
minor
.
yy0
.
n
;
yymsp
[
-
4
].
minor
.
yy0
.
n
+=
yymsp
[
-
3
].
minor
.
yy0
.
n
;
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
yymsp
[
0
].
minor
.
yy165
,
NULL
,
TSDB_ALTER_TABLE_ADD_TAG
_COLUMN
,
-
1
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
yymsp
[
0
].
minor
.
yy165
,
NULL
,
TSDB_ALTER_TABLE_ADD_TAG
,
-
1
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
}
}
break
;
break
;
...
@@ -3217,7 +3217,7 @@ static void yy_reduce(
...
@@ -3217,7 +3217,7 @@ static void yy_reduce(
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
SArray
*
A
=
tListItemAppendToken
(
NULL
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
);
SArray
*
A
=
tListItemAppendToken
(
NULL
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
NULL
,
A
,
TSDB_ALTER_TABLE_DROP_TAG
_COLUMN
,
-
1
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
NULL
,
A
,
TSDB_ALTER_TABLE_DROP_TAG
,
-
1
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
}
}
break
;
break
;
...
@@ -3282,7 +3282,7 @@ static void yy_reduce(
...
@@ -3282,7 +3282,7 @@ static void yy_reduce(
case
294
:
/* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
case
294
:
/* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
{
{
yymsp
[
-
4
].
minor
.
yy0
.
n
+=
yymsp
[
-
3
].
minor
.
yy0
.
n
;
yymsp
[
-
4
].
minor
.
yy0
.
n
+=
yymsp
[
-
3
].
minor
.
yy0
.
n
;
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
yymsp
[
0
].
minor
.
yy165
,
NULL
,
TSDB_ALTER_TABLE_ADD_TAG
_COLUMN
,
TSDB_SUPER_TABLE
);
SAlterTableInfo
*
pAlterTable
=
tSetAlterTableInfo
(
&
yymsp
[
-
4
].
minor
.
yy0
,
yymsp
[
0
].
minor
.
yy165
,
NULL
,
TSDB_ALTER_TABLE_ADD_TAG
,
TSDB_SUPER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
}
}
break
;
break
;
...
@@ -3293,7 +3293,7 @@ static void yy_reduce(
...
@@ -3293,7 +3293,7 @@ static void yy_reduce(
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
toTSDBType
(
yymsp
[
0
].
minor
.
yy0
.
type
);
SArray
*
A
=
tListItemAppendToken
(
NULL
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
);
SArray
*
A
=
tListItemAppendToken
(
NULL
,
&
yymsp
[
0
].
minor
.
yy0
,
-
1
);
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
,
TSDB_SUPER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
setSqlInfo
(
pInfo
,
pAlterTable
,
NULL
,
TSDB_SQL_ALTER_TABLE
);
}
}
break
;
break
;
...
...
source/util/src/terror.c
浏览文件 @
17c8f8b1
...
@@ -233,10 +233,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STB, "Invalid stable name")
...
@@ -233,10 +233,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STB, "Invalid stable name")
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STB_OPTION
,
"Invalid stable options"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STB_OPTION
,
"Invalid stable options"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STB_OPTION_UNCHNAGED
,
"Stable options not changed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STB_OPTION_UNCHNAGED
,
"Stable options not changed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_MANY_TAGS
,
"Too many tags"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_MANY_TAGS
,
"Too many tags"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TAG_ALREA
Y_EXIST
,
"Tag already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TAG_ALREA
DY_EXIST
,
"Tag already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TAG_NOT_EXIST
,
"Tag does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TAG_NOT_EXIST
,
"Tag does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_MANY_COLUMNS
,
"Too many columns"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_MANY_COLUMNS
,
"Too many columns"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_COLUMN_ALREA
Y_EXIST
,
"Column already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_COLUMN_ALREA
DY_EXIST
,
"Column already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_COLUMN_NOT_EXIST
,
"Column does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_COLUMN_NOT_EXIST
,
"Column does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_ROW_BYTES
,
"Invalid row bytes"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_ROW_BYTES
,
"Invalid row bytes"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录