Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5c5fcc0a
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看板
未验证
提交
5c5fcc0a
编写于
11月 02, 2022
作者:
D
dapan1121
提交者:
GitHub
11月 02, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17768 from taosdata/feat/audit
feat: add audit db for DDL storage
上级
9d4ab263
e28c79b2
变更
35
隐藏空白更改
内联
并排
Showing
35 changed file
with
685 addition
and
182 deletion
+685
-182
packaging/cfg/taos.cfg
packaging/cfg/taos.cfg
+18
-15
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+4
-0
src/common/src/tglobal.c
src/common/src/tglobal.c
+14
-0
src/inc/monitor.h
src/inc/monitor.h
+22
-0
src/inc/taosdef.h
src/inc/taosdef.h
+4
-4
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+5
-5
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+40
-36
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+41
-8
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+13
-13
src/plugins/monitor/src/monMain.c
src/plugins/monitor/src/monMain.c
+205
-11
src/util/inc/tconfig.h
src/util/inc/tconfig.h
+1
-1
src/util/src/tconfig.c
src/util/src/tconfig.c
+19
-19
tests/pytest/alter/alter_keep.py
tests/pytest/alter/alter_keep.py
+2
-2
tests/pytest/client/client.py
tests/pytest/client/client.py
+6
-6
tests/pytest/query/queryError.py
tests/pytest/query/queryError.py
+2
-2
tests/pytest/tag_lite/TestModifyTag.py
tests/pytest/tag_lite/TestModifyTag.py
+3
-3
tests/pytest/tag_lite/alter_tag.py
tests/pytest/tag_lite/alter_tag.py
+3
-3
tests/pytest/tag_lite/bigint.py
tests/pytest/tag_lite/bigint.py
+3
-3
tests/pytest/tag_lite/binary.py
tests/pytest/tag_lite/binary.py
+3
-3
tests/pytest/tag_lite/int.py
tests/pytest/tag_lite/int.py
+3
-3
tests/pytest/tag_lite/json_tag_extra.py
tests/pytest/tag_lite/json_tag_extra.py
+4
-4
tests/pytest/tag_lite/nchar.py
tests/pytest/tag_lite/nchar.py
+1
-1
tests/pytest/tag_lite/smallint.py
tests/pytest/tag_lite/smallint.py
+3
-3
tests/pytest/tag_lite/timestamp.py
tests/pytest/tag_lite/timestamp.py
+6
-6
tests/pytest/tag_lite/tinyint.py
tests/pytest/tag_lite/tinyint.py
+3
-3
tests/pytest/tag_lite/too_many_tag_condtions.py
tests/pytest/tag_lite/too_many_tag_condtions.py
+15
-15
tests/pytest/tag_lite/unsignedBigint.py
tests/pytest/tag_lite/unsignedBigint.py
+3
-3
tests/pytest/tag_lite/unsignedInt.py
tests/pytest/tag_lite/unsignedInt.py
+3
-3
tests/pytest/tag_lite/unsignedSmallint.py
tests/pytest/tag_lite/unsignedSmallint.py
+3
-3
tests/pytest/tag_lite/unsignedTinyint.py
tests/pytest/tag_lite/unsignedTinyint.py
+3
-3
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+1
-0
tests/script/sh/deploy.bat
tests/script/sh/deploy.bat
+1
-0
tests/script/sh/deploy.sh
tests/script/sh/deploy.sh
+1
-0
tests/system-test/0-others/audit.py
tests/system-test/0-others/audit.py
+225
-0
tests/system-test/fulltest-others.sh
tests/system-test/fulltest-others.sh
+2
-1
未找到文件。
packaging/cfg/taos.cfg
浏览文件 @
5c5fcc0a
...
...
@@ -11,7 +11,7 @@
# local fully qualified domain name (FQDN)
# fqdn hostname
# first port number for the connection (12 continuous UDP/TCP port number are used)
# first port number for the connection (12 continuous UDP/TCP port number are used)
# serverPort 6030
# log file's directory
...
...
@@ -23,8 +23,8 @@
# temporary file's directory
# tempDir /tmp/
# the arbitrator's fully qualified domain name (FQDN) for TDengine system, for cluster only
# arbitrator arbitrator_hostname:6042
# the arbitrator's fully qualified domain name (FQDN) for TDengine system, for cluster only
# arbitrator arbitrator_hostname:6042
# number of threads per CPU core
# numOfThreadsPerCore 1.0
...
...
@@ -60,19 +60,19 @@ keepColumnName 1
# max timer control blocks
# maxTmrCtrl 512
# time interval of system monitor, seconds
# time interval of system monitor, seconds
# monitorInterval 30
# number of seconds allowed for a dnode to be offline, for cluster only
# number of seconds allowed for a dnode to be offline, for cluster only
# offlineThreshold 864000
# RPC re-try timer, millisecond
# rpcTimer 300
# RPC maximum time for ack, seconds.
# RPC maximum time for ack, seconds.
# rpcMaxTime 600
# time interval of dnode status reporting to mnode, seconds, for cluster only
# time interval of dnode status reporting to mnode, seconds, for cluster only
# statusInterval 1
# time interval of heart beat from shell to dnode, seconds
...
...
@@ -121,7 +121,7 @@ keepColumnName 1
# maxRows 4096
# the number of acknowledgments required for successful data writing
# quorum 1
# quorum 1
# enable/disable compression
# comp 2
...
...
@@ -132,7 +132,7 @@ keepColumnName 1
# if walLevel is set to 2, the cycle of fsync being executed, if set to 0, fsync is called right away
# fsync 3000
# number of replications, for cluster only
# number of replications, for cluster only
# replica 1
# the compressed rpc message, option:
...
...
@@ -188,9 +188,12 @@ keepColumnName 1
# enbale/disable http service
# http 1
# enable/disable system monitor
# enable/disable system monitor
# monitor 1
# enable/disable system audit
# audit 0
# enable/disable recording the SQL statements via restful interface
# httpEnableRecordSql 0
...
...
@@ -219,7 +222,7 @@ keepColumnName 1
# The following parameters are used for debug purpose only.
# debugFlag 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR
# 131: output warning and error
# 131: output warning and error
# 135: output debug, warning and error
# 143: output trace, debug, warning and error to log
# 199: output debug, warning and error to both screen and file
...
...
@@ -243,13 +246,13 @@ keepColumnName 1
# debug flag for SDB
# sdbDebugFlag 135
# debug flag for RPC
# debug flag for RPC
# rpcDebugFlag 131
# debug flag for TAOS TIMER
# tmrDebugFlag 131
# debug flag for TDengine client
# debug flag for TDengine client
# cDebugFlag 131
# debug flag for JNI
...
...
@@ -302,7 +305,7 @@ keepColumnName 1
# default string type used for storing JSON String, options can be binary/nchar, default is nchar
# defaultJSONStrType nchar
# force TCP transmission
# force TCP transmission
# rpcForceTcp 0
# unit MB. Flush vnode wal file if walSize > walFlushSize and walSize > cache*0.5*blocks
...
...
@@ -318,4 +321,4 @@ keepColumnName 1
# writeBatchTimeout 10
# using thread local write batching. this option is not available when writeBatchSize = 0.
# writeBatchThreadLocal 0
\ No newline at end of file
# writeBatchThreadLocal 0
src/common/inc/tglobal.h
浏览文件 @
5c5fcc0a
...
...
@@ -154,6 +154,10 @@ extern char tsMonitorDbName[];
extern
char
tsInternalPass
[];
extern
int32_t
tsMonitorInterval
;
// audit
extern
int8_t
tsEnableAudit
;
extern
char
tsAuditDbName
[];
// stream
extern
int8_t
tsEnableStream
;
...
...
src/common/src/tglobal.c
浏览文件 @
5c5fcc0a
...
...
@@ -205,6 +205,10 @@ char tsMonitorDbName[TSDB_DB_NAME_LEN] = "log";
char
tsInternalPass
[]
=
"secretkey"
;
int32_t
tsMonitorInterval
=
30
;
// seconds
// audit
int8_t
tsEnableAudit
=
0
;
char
tsAuditDbName
[
TSDB_DB_NAME_LEN
]
=
"audit"
;
// stream
int8_t
tsEnableStream
=
1
;
...
...
@@ -1292,6 +1296,16 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"audit"
;
cfg
.
ptr
=
&
tsEnableAudit
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
1
;
cfg
.
ptrLength
=
1
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"stream"
;
cfg
.
ptr
=
&
tsEnableStream
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT8
;
...
...
src/inc/monitor.h
浏览文件 @
5c5fcc0a
...
...
@@ -27,6 +27,27 @@ extern "C" {
monSaveDnodeLog(level, __VA_ARGS__); \
}
typedef
enum
{
// create
MON_DDL_CMD_CREATE_DATABASE
,
MON_DDL_CMD_CREATE_TABLE
,
MON_DDL_CMD_CREATE_CHILD_TABLE
,
MON_DDL_CMD_CREATE_SUPER_TABLE
,
// drop
MON_DDL_CMD_DROP_DATABASE
,
MON_DDL_CMD_DROP_TABLE
,
MON_DDL_CMD_DROP_CHILD_TABLE
,
MON_DDL_CMD_DROP_SUPER_TABLE
,
// alter
MON_DDL_CMD_ALTER_DATABASE
,
MON_DDL_CMD_ADD_COLUMN
,
MON_DDL_CMD_DROP_COLUMN
,
MON_DDL_CMD_MODIFY_COLUMN
,
MON_DDL_CMD_ADD_TAG
,
MON_DDL_CMD_DROP_TAG
,
MON_DDL_CMD_CHANGE_TAG
,
}
EMonDDLCmdType
;
typedef
struct
{
const
char
*
name
;
int32_t
code
;
...
...
@@ -62,6 +83,7 @@ int32_t monInitSystem();
int32_t
monStartSystem
();
void
monStopSystem
();
void
monCleanupSystem
();
void
monSaveAuditLog
(
int8_t
type
,
const
char
*
user
,
const
char
*
obj
,
bool
result
);
void
monSaveAcctLog
(
SAcctMonitorObj
*
pMonObj
);
void
monSaveLog
(
int32_t
level
,
const
char
*
const
format
,
...);
void
monSaveDnodeLog
(
int32_t
level
,
const
char
*
const
format
,
...);
...
...
src/inc/taosdef.h
浏览文件 @
5c5fcc0a
...
...
@@ -244,12 +244,12 @@ do { \
#define TSDB_VERSION_LEN 12
#define TSDB_LOCALE_LEN 64
#define TSDB_TIMEZONE_LEN 96
#define TSDB_LABEL_LEN 8
#define TSDB_LABEL_LEN 8
#define TSDB_CLUSTER_ID_LEN 40
#define TSDB_FQDN_LEN 128
#define TSDB_EP_LEN (TSDB_FQDN_LEN+6)
#define TSDB_IPv4ADDR_LEN
16
#define TSDB_IPv4ADDR_LEN
16
#define TSDB_FILENAME_LEN 128
#define TSDB_SHOW_SQL_LEN 512
#define TSDB_SHOW_SUBQUERY_LEN 1000
...
...
@@ -313,7 +313,7 @@ do { \
#define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default
#define TSDB_MIN_DAYS_PER_FILE 1
#define TSDB_MAX_DAYS_PER_FILE 3650
#define TSDB_MAX_DAYS_PER_FILE 3650
#define TSDB_DEFAULT_DAYS_PER_FILE 10
#define TSDB_MIN_KEEP 1 // data in db to be reserved.
...
...
@@ -412,7 +412,7 @@ do { \
#define TSDB_ORDER_ASC 1
#define TSDB_ORDER_DESC 2
#define TSDB_DEFAULT_CLUSTER_HASH_SIZE 1
#define TSDB_DEFAULT_MNODES_HASH_SIZE 5
#define TSDB_DEFAULT_DNODES_HASH_SIZE 10
...
...
src/mnode/inc/mnodeDef.h
浏览文件 @
5c5fcc0a
...
...
@@ -57,7 +57,7 @@ typedef struct SDnodeObj {
int8_t
alternativeRole
;
// from dnode status msg, 0-any, 1-mgmt, 2-dnode
int8_t
status
;
// set in balance function
int8_t
isMgmt
;
int8_t
reserve1
[
11
];
int8_t
reserve1
[
11
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
uint32_t
moduleStatus
;
...
...
@@ -90,7 +90,7 @@ typedef struct STableObj {
}
STableObj
;
typedef
struct
SSTableObj
{
STableObj
info
;
STableObj
info
;
int8_t
reserved0
[
9
];
// for fill struct STableObj to 4byte align
int16_t
nextColId
;
int32_t
sversion
;
...
...
@@ -107,10 +107,10 @@ typedef struct SSTableObj {
}
SSTableObj
;
typedef
struct
{
STableObj
info
;
STableObj
info
;
int8_t
reserved0
[
9
];
// for fill struct STableObj to 4byte align
int16_t
nextColId
;
//used by normal table
int32_t
sversion
;
//used by normal table
int32_t
sversion
;
//used by normal table
uint64_t
uid
;
uint64_t
suid
;
int64_t
createdTime
;
...
...
@@ -195,7 +195,7 @@ typedef struct SDbObj {
int32_t
numOfVgroups
;
int32_t
numOfTables
;
int32_t
numOfSuperTables
;
int32_t
vgListSize
;
int32_t
vgListSize
;
int32_t
vgListIndex
;
SVgObj
**
vgList
;
struct
SAcctObj
*
pAcct
;
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
5c5fcc0a
...
...
@@ -160,7 +160,7 @@ static int32_t mnodeDbActionEncode(SSdbRow *pRow) {
static
int32_t
mnodeDbActionDecode
(
SSdbRow
*
pRow
)
{
SDbObj
*
pDb
=
(
SDbObj
*
)
calloc
(
1
,
sizeof
(
SDbObj
));
if
(
pDb
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pDb
,
pRow
->
rowData
,
tsDbUpdateSize
);
pRow
->
pObj
=
pDb
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -205,8 +205,8 @@ int32_t mnodeInitDbs() {
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeGetDbMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeRetrieveDbs
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeCancelGetNextDb
);
mDebug
(
"table:dbs table is created"
);
return
tpInit
();
}
...
...
@@ -224,11 +224,11 @@ SDbObj *mnodeGetDb(char *db) {
}
void
mnodeIncDbRef
(
SDbObj
*
pDb
)
{
sdbIncRef
(
tsDbSdb
,
pDb
);
sdbIncRef
(
tsDbSdb
,
pDb
);
}
void
mnodeDecDbRef
(
SDbObj
*
pDb
)
{
sdbDecRef
(
tsDbSdb
,
pDb
);
void
mnodeDecDbRef
(
SDbObj
*
pDb
)
{
sdbDecRef
(
tsDbSdb
,
pDb
);
}
SDbObj
*
mnodeGetDbByTableName
(
char
*
tableName
)
{
...
...
@@ -409,6 +409,7 @@ static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) {
}
else
{
mError
(
"db:%s, failed to create by %s, reason:%s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
),
tstrerror
(
code
));
}
monSaveAuditLog
(
MON_DDL_CMD_CREATE_DATABASE
,
mnodeGetUserFromMsg
(
pMsg
),
pDb
->
name
,
!
code
);
return
code
;
}
...
...
@@ -419,7 +420,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
SDbObj
*
pDb
=
mnodeGetDb
(
pCreate
->
db
);
if
(
pDb
!=
NULL
)
{
mnodeDecDbRef
(
pDb
);
mnodeDecDbRef
(
pDb
);
if
(
pCreate
->
ignoreExist
)
{
mDebug
(
"db:%s, already exist, ignore exist is set"
,
pCreate
->
db
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -434,8 +435,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
pDb
=
calloc
(
1
,
sizeof
(
SDbObj
));
tstrncpy
(
pDb
->
name
,
pCreate
->
db
,
sizeof
(
pDb
->
name
));
tstrncpy
(
pDb
->
acct
,
pAcct
->
user
,
sizeof
(
pDb
->
acct
));
pDb
->
createdTime
=
taosGetTimestampMs
();
tstrncpy
(
pDb
->
acct
,
pAcct
->
user
,
sizeof
(
pDb
->
acct
));
pDb
->
createdTime
=
taosGetTimestampMs
();
pDb
->
cfg
=
(
SDbCfg
)
{
.
cacheBlockSize
=
pCreate
->
cacheBlockSize
,
.
totalBlocks
=
pCreate
->
totalBlocks
,
...
...
@@ -499,7 +500,7 @@ bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
#if 0
void mnodePrintVgroups(SDbObj *pDb, char *row) {
mInfo("db:%s, vgroup link from head, row:%s", pDb->name, row);
mInfo("db:%s, vgroup link from head, row:%s", pDb->name, row);
SVgObj *pVgroup = pDb->pHead;
while (pVgroup != NULL) {
mInfo("vgId:%d", pVgroup->vgId);
...
...
@@ -621,7 +622,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
pShow
->
bytes
[
cols
]
=
24
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
#ifdef _STORAGE
#ifdef _STORAGE
strcpy
(
pSchema
[
cols
].
name
,
"keep0,keep1,keep2"
);
#else
strcpy
(
pSchema
[
cols
].
name
,
"keep"
);
...
...
@@ -638,13 +639,13 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
strcpy
(
pSchema
[
cols
].
name
,
"cache(MB)"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"blocks"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"minrows"
);
...
...
@@ -743,7 +744,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
name
=
mnodeGetDbStr
(
pDb
->
name
);
if
(
name
!=
NULL
)
{
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
name
,
pShow
->
bytes
[
cols
]);
...
...
@@ -789,10 +790,10 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
#endif
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
tmp
[
128
]
=
{
0
};
#ifdef _STORAGE
if
(
pDb
->
cfg
.
daysToKeep0
>
pDb
->
cfg
.
daysToKeep1
||
pDb
->
cfg
.
daysToKeep0
>
pDb
->
cfg
.
daysToKeep2
)
{
#ifdef _STORAGE
if
(
pDb
->
cfg
.
daysToKeep0
>
pDb
->
cfg
.
daysToKeep1
||
pDb
->
cfg
.
daysToKeep0
>
pDb
->
cfg
.
daysToKeep2
)
{
sprintf
(
tmp
,
"%d,%d,%d"
,
pDb
->
cfg
.
daysToKeep1
,
pDb
->
cfg
.
daysToKeep2
,
pDb
->
cfg
.
daysToKeep0
);
}
else
{
sprintf
(
tmp
,
"%d,%d,%d"
,
pDb
->
cfg
.
daysToKeep0
,
pDb
->
cfg
.
daysToKeep1
,
pDb
->
cfg
.
daysToKeep2
);
...
...
@@ -821,7 +822,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pDb
->
cfg
.
maxRowsPerFileBlock
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int8_t
*
)
pWrite
=
pDb
->
cfg
.
walLevel
;
cols
++
;
...
...
@@ -912,7 +913,7 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb) {
}
static
int32_t
mnodeProcessCreateDbMsg
(
SMnodeMsg
*
pMsg
)
{
SCreateDbMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCreateDbMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
pCreate
->
maxTables
=
htonl
(
pCreate
->
maxTables
);
pCreate
->
cacheBlockSize
=
htonl
(
pCreate
->
cacheBlockSize
);
pCreate
->
totalBlocks
=
htonl
(
pCreate
->
totalBlocks
);
...
...
@@ -925,7 +926,7 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) {
pCreate
->
partitions
=
htons
(
pCreate
->
partitions
);
pCreate
->
minRowsPerFileBlock
=
htonl
(
pCreate
->
minRowsPerFileBlock
);
pCreate
->
maxRowsPerFileBlock
=
htonl
(
pCreate
->
maxRowsPerFileBlock
);
int32_t
code
;
#ifdef GRANT_CHECK_WRITE
if
(
grantCheck
(
TSDB_GRANT_TIME
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -963,7 +964,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
int8_t
cacheLastRow
=
pAlter
->
cacheLastRow
;
int8_t
dbType
=
pAlter
->
dbType
;
int16_t
partitions
=
htons
(
pAlter
->
partitions
);
terrno
=
TSDB_CODE_SUCCESS
;
//UPGRATE FROM LOW VERSION, reorder it
...
...
@@ -1127,6 +1128,8 @@ static int32_t mnodeAlterDbFp(SMnodeMsg *pMsg) {
mDebug
(
"db:%s, all vgroups is altered"
,
pDb
->
name
);
mLInfo
(
"db:%s, is alterd by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
monSaveAuditLog
(
MON_DDL_CMD_ALTER_DATABASE
,
mnodeGetUserFromMsg
(
pMsg
),
pDb
->
name
,
true
);
// in case there is no vnode for this db currently(no table in db,etc.)
if
(
pMsg
->
expected
==
0
)
{
SSdbRow
row
=
{
...
...
@@ -1183,7 +1186,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to alter, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
}
}
}
return
code
;
}
...
...
@@ -1197,7 +1200,7 @@ int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) {
mError
(
"db:%s, failed to alter, invalid db"
,
pAlter
->
db
);
return
TSDB_CODE_MND_INVALID_DB
;
}
if
(
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"db:%s, status:%d, in dropping"
,
pAlter
->
db
,
pMsg
->
pDb
->
status
);
return
TSDB_CODE_MND_DB_IN_DROPPING
;
...
...
@@ -1213,13 +1216,14 @@ static int32_t mnodeDropDbCb(SMnodeMsg *pMsg, int32_t code) {
}
else
{
mLInfo
(
"db:%s, is dropped by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
}
monSaveAuditLog
(
MON_DDL_CMD_DROP_DATABASE
,
mnodeGetUserFromMsg
(
pMsg
),
pDb
->
name
,
!
code
);
return
code
;
}
static
int32_t
mnodeDropDb
(
SMnodeMsg
*
pMsg
)
{
if
(
pMsg
==
NULL
)
return
TSDB_CODE_MND_APP_ERROR
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
mInfo
(
"db:%s, drop db from sdb"
,
pDb
->
name
);
...
...
@@ -1259,7 +1263,7 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg) {
mError("db:%s, can't drop monitor database", pDrop->db);
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
}
#endif
#endif
int32_t
code
=
mnodeSetDbDropping
(
pMsg
->
pDb
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
...
...
@@ -1292,15 +1296,15 @@ static int32_t mnodeSyncDb(SDbObj *pDb, SMnodeMsg *pMsg) {
static
int32_t
mnodeCompact
(
SDbObj
*
pDb
,
SCompactMsg
*
pCompactMsg
)
{
int32_t
count
=
ntohs
(
pCompactMsg
->
numOfVgroup
);
int32_t
*
buf
=
malloc
(
sizeof
(
int32_t
)
*
count
);
int32_t
count
=
ntohs
(
pCompactMsg
->
numOfVgroup
);
int32_t
*
buf
=
malloc
(
sizeof
(
int32_t
)
*
count
);
if
(
buf
==
NULL
)
{
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
buf
[
i
]
=
ntohs
(
pCompactMsg
->
vgid
[
i
]);
}
// copy from mnodeSyncDb, so ugly
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
SVgObj
*
pVgroup
=
NULL
;
...
...
@@ -1312,7 +1316,7 @@ static int32_t mnodeCompact(SDbObj *pDb, SCompactMsg *pCompactMsg) {
if
(
pVgroup
->
pDb
==
pDb
&&
pVgroup
->
vgId
==
buf
[
i
])
{
mnodeSendCompactVgroupMsg
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
valid
=
true
;
valid
=
true
;
break
;
}
mnodeDecVgroupRef
(
pVgroup
);
...
...
@@ -1321,7 +1325,7 @@ static int32_t mnodeCompact(SDbObj *pDb, SCompactMsg *pCompactMsg) {
mLError
(
"db:%s, cannot find valid vgId: %d"
,
pDb
->
name
,
buf
[
i
]);
}
}
free
(
buf
);
free
(
buf
);
mLInfo
(
"db:%s, trigger compact"
,
pDb
->
name
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1352,14 +1356,14 @@ static int32_t mnodeProcessSyncDbMsg(SMnodeMsg *pMsg) {
static
int32_t
mnodeProcessCompactMsg
(
SMnodeMsg
*
pMsg
)
{
SCompactMsg
*
pCompact
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"db:%s, compact is received from thandle:%p"
,
pCompact
->
db
,
pMsg
->
rpcMsg
.
handle
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDb
(
pCompact
->
db
);
if
(
pMsg
->
pDb
==
NULL
)
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
if
(
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"db:%s, status:%d, in dropping, ignore compact request"
,
pCompact
->
db
,
pMsg
->
pDb
->
status
);
return
TSDB_CODE_MND_DB_IN_DROPPING
;
}
}
return
mnodeCompact
(
pMsg
->
pDb
,
pCompact
);
}
...
...
@@ -1382,7 +1386,7 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
.
pTable
=
tsDbSdb
,
.
pObj
=
pDb
};
sdbDeleteRow
(
&
row
);
numOfDbs
++
;
}
...
...
@@ -1410,11 +1414,11 @@ int32_t mnodeCompactDbs() {
};
mInfo
(
"compact dbs %s"
,
pDb
->
name
);
sdbInsertCompactRow
(
&
row
);
}
mInfo
(
"end to compact dbs table..."
);
return
0
;
return
0
;
}
src/mnode/src/mnodeTable.c
浏览文件 @
5c5fcc0a
...
...
@@ -38,6 +38,7 @@
#include "mnodeSdb.h"
#include "mnodeShow.h"
#include "mnodeTable.h"
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeWrite.h"
#include "mnodeRead.h"
...
...
@@ -1047,7 +1048,7 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLInfo
(
"stable:%s, is created in sdb, uid:%"
PRIu64
,
pTable
->
info
.
tableId
,
pTable
->
uid
);
if
(
pMsg
->
pBatchMasterMsg
)
pMsg
->
pBatchMasterMsg
->
successed
++
;
pMsg
->
pBatchMasterMsg
->
successed
++
;
}
else
{
mError
(
"msg:%p, app:%p stable:%s, failed to create in sdb, reason:%s"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
tstrerror
(
code
));
...
...
@@ -1056,11 +1057,12 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
if
(
pMsg
->
pBatchMasterMsg
)
pMsg
->
pBatchMasterMsg
->
received
++
;
}
monSaveAuditLog
(
MON_DDL_CMD_CREATE_SUPER_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
!
code
);
// if super table create by batch msg, check done and send finished to client
if
(
pMsg
->
pBatchMasterMsg
)
{
if
(
pMsg
->
pBatchMasterMsg
->
successed
+
pMsg
->
pBatchMasterMsg
->
received
>=
pMsg
->
pBatchMasterMsg
->
expected
)
dnodeSendRpcMWriteRsp
(
pMsg
->
pBatchMasterMsg
,
code
);
dnodeSendRpcMWriteRsp
(
pMsg
->
pBatchMasterMsg
,
code
);
}
return
code
;
...
...
@@ -1171,11 +1173,12 @@ static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
SSTableObj
*
pTable
=
(
SSTableObj
*
)
pMsg
->
pTable
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"msg:%p, app:%p stable:%s, failed to drop, sdb error"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_SUPER_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
code
;
}
mLInfo
(
"msg:%p, app:%p stable:%s, is dropped from sdb"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_SUPER_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
true
);
SSTableObj
*
pStable
=
(
SSTableObj
*
)
pMsg
->
pTable
;
if
(
pStable
->
vgHash
!=
NULL
/*pStable->numOfTables != 0*/
)
{
...
...
@@ -1250,6 +1253,8 @@ static int32_t mnodeAddSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_ADD_TAG
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1308,6 +1313,8 @@ static int32_t mnodeDropSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_DROP_TAG
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1345,6 +1352,8 @@ static int32_t mnodeModifySuperTableTagNameCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_CHANGE_TAG
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1403,6 +1412,8 @@ static int32_t mnodeAddSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_ADD_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1474,6 +1485,8 @@ static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_DROP_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1522,6 +1535,8 @@ static int32_t mnodeChangeSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_MODIFY_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -2073,6 +2088,9 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
SCreateTableMsg
*
pCreate
=
(
SCreateTableMsg
*
)
((
char
*
)
pMsg
->
rpcMsg
.
pCont
+
sizeof
(
SCMCreateTableMsg
));
assert
(
pTable
);
monSaveAuditLog
((
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
?
MON_DDL_CMD_CREATE_CHILD_TABLE
:
MON_DDL_CMD_CREATE_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
!
code
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
pCreate
->
getMeta
)
{
mDebug
(
"msg:%p, app:%p table:%s, created in dnode and continue to get meta, thandle:%p"
,
pMsg
,
...
...
@@ -2101,6 +2119,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
}
else
{
mError
(
"msg:%p, app:%p table:%s, failed to create table sid:%d, uid:%"
PRIu64
", reason:%s"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
pTable
->
tid
,
pTable
->
uid
,
tstrerror
(
code
));
SSdbRow
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pTable
,
.
pTable
=
tsChildTableSdb
};
sdbDeleteRow
(
&
desc
);
...
...
@@ -2294,6 +2313,8 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
if
(
pDrop
==
NULL
)
{
mError
(
"msg:%p, app:%p ctable:%s, failed to drop ctable, no enough memory"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
((
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
?
MON_DDL_CMD_DROP_CHILD_TABLE
:
MON_DDL_CMD_DROP_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
...
...
@@ -2308,6 +2329,9 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
mInfo
(
"msg:%p, app:%p ctable:%s, send drop ctable msg, vgId:%d sid:%d uid:%"
PRIu64
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pDrop
->
tableFname
,
pTable
->
vgId
,
pTable
->
tid
,
pTable
->
uid
);
monSaveAuditLog
((
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
?
MON_DDL_CMD_DROP_CHILD_TABLE
:
MON_DDL_CMD_DROP_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
true
);
SRpcMsg
rpcMsg
=
{
.
ahandle
=
pMsg
,
.
pCont
=
pDrop
,
...
...
@@ -2327,6 +2351,8 @@ static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SCTableObj
*
pTable
=
(
SCTableObj
*
)
pMsg
->
pTable
;
mError
(
"msg:%p, app:%p ctable:%s, failed to drop, sdb error"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
((
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
?
MON_DDL_CMD_DROP_CHILD_TABLE
:
MON_DDL_CMD_DROP_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
code
;
}
...
...
@@ -2414,6 +2440,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
SDbObj
*
pDb
=
pMsg
->
pDb
;
if
(
ncols
<=
0
)
{
mError
(
"msg:%p, app:%p ctable:%s, add column, ncols:%d <= 0"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
ncols
);
monSaveAuditLog
(
MON_DDL_CMD_ADD_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
TSDB_CODE_MND_APP_ERROR
;
}
...
...
@@ -2421,6 +2448,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
if
(
mnodeFindNormalTableColumnIndex
(
pTable
,
schema
[
i
].
name
)
>
0
)
{
mError
(
"msg:%p, app:%p ctable:%s, add column, column:%s already exist"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
schema
[
i
].
name
);
monSaveAuditLog
(
MON_DDL_CMD_ADD_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
TSDB_CODE_MND_FIELD_ALREAY_EXIST
;
}
}
...
...
@@ -2445,6 +2473,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
}
mInfo
(
"msg:%p, app:%p ctable %s, start to add column"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
(
MON_DDL_CMD_ADD_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
true
);
SSdbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
...
...
@@ -2464,6 +2493,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
if
(
col
<=
0
)
{
mError
(
"msg:%p, app:%p ctable:%s, drop column, column:%s not exist"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
colName
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
TSDB_CODE_MND_FIELD_NOT_EXIST
;
}
...
...
@@ -2478,6 +2508,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
}
mInfo
(
"msg:%p, app:%p ctable %s, start to drop column %s"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
colName
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
true
);
SSdbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
...
...
@@ -2498,6 +2529,7 @@ static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg) {
if
(
col
<
0
)
{
mError
(
"msg:%p, app:%p ctable:%s, change column, name: %s"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
name
);
monSaveAuditLog
(
MON_DDL_CMD_MODIFY_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
TSDB_CODE_MND_FIELD_NOT_EXIST
;
}
...
...
@@ -2508,6 +2540,7 @@ static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg) {
mInfo
(
"msg:%p, app:%p ctable %s, start to modify column %s len to %d"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
name
,
schema
->
bytes
);
monSaveAuditLog
(
MON_DDL_CMD_MODIFY_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
true
);
SSdbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
...
...
@@ -3559,7 +3592,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pTable
->
sql
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pTable
->
sql
,
pShow
->
bytes
[
cols
]);
cols
++
;
numOfRows
++
;
...
...
@@ -3594,13 +3627,13 @@ static int32_t mnodeCompactSuperTables() {
};
//mInfo("compact super %" PRIu64, pTable->uid);
sdbInsertCompactRow
(
&
row
);
}
mInfo
(
"end to compact super table..."
);
return
0
;
return
0
;
}
static
int32_t
mnodeCompactChildTables
()
{
...
...
@@ -3620,13 +3653,13 @@ static int32_t mnodeCompactChildTables() {
};
//mInfo("compact child %" PRIu64 ":%d", pTable->uid, pTable->tid);
sdbInsertCompactRow
(
&
row
);
}
mInfo
(
"end to compact child table..."
);
return
0
;
return
0
;
}
int32_t
mnodeCompactTables
()
{
...
...
src/mnode/src/mnodeUser.c
浏览文件 @
5c5fcc0a
...
...
@@ -108,7 +108,7 @@ static void mnodePrintUserAuth() {
mDebug
(
"failed to auth.txt for write"
);
return
;
}
void
*
pIter
=
NULL
;
SUserObj
*
pUser
=
NULL
;
...
...
@@ -181,7 +181,7 @@ int32_t mnodeInitUsers() {
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_USER
,
mnodeCancelGetNextUser
);
mnodeAddPeerMsgHandle
(
TSDB_MSG_TYPE_DM_AUTH
,
mnodeProcessAuthMsg
);
mDebug
(
"table:%s, hash is created"
,
desc
.
name
);
return
0
;
}
...
...
@@ -195,20 +195,20 @@ SUserObj *mnodeGetUser(char *name) {
return
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
}
void
*
mnodeGetNextUser
(
void
*
pIter
,
SUserObj
**
pUser
)
{
return
sdbFetchRow
(
tsUserSdb
,
pIter
,
(
void
**
)
pUser
);
void
*
mnodeGetNextUser
(
void
*
pIter
,
SUserObj
**
pUser
)
{
return
sdbFetchRow
(
tsUserSdb
,
pIter
,
(
void
**
)
pUser
);
}
void
mnodeCancelGetNextUser
(
void
*
pIter
)
{
sdbFreeIter
(
tsUserSdb
,
pIter
);
}
void
mnodeIncUserRef
(
SUserObj
*
pUser
)
{
sdbIncRef
(
tsUserSdb
,
pUser
);
void
mnodeIncUserRef
(
SUserObj
*
pUser
)
{
sdbIncRef
(
tsUserSdb
,
pUser
);
}
void
mnodeDecUserRef
(
SUserObj
*
pUser
)
{
sdbDecRef
(
tsUserSdb
,
pUser
);
void
mnodeDecUserRef
(
SUserObj
*
pUser
)
{
sdbDecRef
(
tsUserSdb
,
pUser
);
}
static
int32_t
mnodeUpdateUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
...
...
@@ -464,7 +464,7 @@ char *mnodeGetUserFromMsg(void *pMsg) {
static
int32_t
mnodeProcessCreateUserMsg
(
SMnodeMsg
*
pMsg
)
{
SUserObj
*
pOperUser
=
pMsg
->
pUser
;
if
(
pOperUser
->
superAuth
)
{
SCreateUserMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
return
mnodeCreateUser
(
pOperUser
->
pAcct
,
pCreate
->
user
,
pCreate
->
pass
,
pCreate
->
tags
,
pMsg
);
...
...
@@ -477,7 +477,7 @@ static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) {
static
int32_t
mnodeProcessAlterUserMsg
(
SMnodeMsg
*
pMsg
)
{
int32_t
code
;
SUserObj
*
pOperUser
=
pMsg
->
pUser
;
SAlterUserMsg
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
SUserObj
*
pUser
=
mnodeGetUser
(
pAlter
->
user
);
if
(
pUser
==
NULL
)
{
...
...
@@ -686,10 +686,10 @@ int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, cha
static
int32_t
mnodeProcessAuthMsg
(
SMnodeMsg
*
pMsg
)
{
SAuthMsg
*
pAuthMsg
=
pMsg
->
rpcMsg
.
pCont
;
SAuthRsp
*
pAuthRsp
=
rpcMallocCont
(
sizeof
(
SAuthRsp
));
pMsg
->
rpcRsp
.
rsp
=
pAuthRsp
;
pMsg
->
rpcRsp
.
len
=
sizeof
(
SAuthRsp
);
return
mnodeRetriveAuth
(
pAuthMsg
->
user
,
&
pAuthRsp
->
spi
,
&
pAuthRsp
->
encrypt
,
pAuthRsp
->
secret
,
pAuthRsp
->
ckey
);
}
...
...
@@ -711,7 +711,7 @@ int32_t mnodeCompactUsers() {
};
mInfo
(
"compact users %s"
,
pUser
->
user
);
sdbInsertCompactRow
(
&
row
);
}
...
...
src/plugins/monitor/src/monMain.c
浏览文件 @
5c5fcc0a
...
...
@@ -41,6 +41,9 @@
#define DNODE_INFO_LEN 128
#define QUERY_ID_LEN 24
#define CHECK_INTERVAL 1000
#define AUDIT_MAX_RETRIES 10
#define MAX_DDL_TYPE_LEN 32
#define MAX_DDL_OBJ_LEN 512
#define SQL_STR_FMT "\"%s\""
...
...
@@ -161,6 +164,7 @@ typedef struct {
}
SMonStat
;
static
void
*
monHttpStatusHashTable
;
static
void
*
auditConn
;
static
SMonConn
tsMonitor
=
{
0
};
static
SMonStat
tsMonStat
=
{{
0
}};
...
...
@@ -175,16 +179,24 @@ static void monSaveDisksInfo();
static
void
monSaveGrantsInfo
();
static
void
monSaveHttpReqInfo
();
static
void
monGetSysStats
();
static
void
*
monThreadFunc
(
void
*
param
);
static
void
*
monThreadFunc
(
void
*
param
);
static
void
*
monAuditFunc
(
void
*
param
);
static
void
monBuildMonitorSql
(
char
*
sql
,
int32_t
cmd
);
static
void
monInitHttpStatusHashTable
();
static
void
monCleanupHttpStatusHashTable
();
static
void
monInitHttpStatusHashTable
();
static
void
monCleanupHttpStatusHashTable
();
extern
int32_t
(
*
monStartSystemFp
)();
extern
void
(
*
monStopSystemFp
)();
extern
void
(
*
monExecuteSQLFp
)(
char
*
sql
);
extern
char
*
strptime
(
const
char
*
buf
,
const
char
*
fmt
,
struct
tm
*
tm
);
//make the compilation pass
#ifdef _STORAGE
char
*
keepValue
=
"30,30,30"
;
#else
char
*
keepValue
=
"30"
;
#endif
int32_t
monInitSystem
()
{
if
(
tsMonitor
.
ep
[
0
]
==
0
)
{
strcpy
(
tsMonitor
.
ep
,
tsLocalEp
);
...
...
@@ -203,12 +215,20 @@ int32_t monInitSystem() {
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
tsMonitor
.
thread
,
&
thAttr
,
monThreadFunc
,
NULL
))
{
monError
(
"failed to create thread to for monitor module, reason:%s"
,
strerror
(
errno
));
monError
(
"failed to create thread for monitor module, reason:%s"
,
strerror
(
errno
));
return
-
1
;
}
monDebug
(
"monitor thread is launched"
);
pthread_t
auditThread
;
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_DETACHED
);
if
(
pthread_create
(
&
auditThread
,
&
thAttr
,
monAuditFunc
,
NULL
))
{
monError
(
"failed to create audit thread, reason:%s"
,
strerror
(
errno
));
return
-
1
;
}
monDebug
(
"audit thread is launched"
);
pthread_attr_destroy
(
&
thAttr
);
monDebug
(
"monitor thread is launched"
);
monStartSystemFp
=
monStartSystem
;
monStopSystemFp
=
monStopSystem
;
...
...
@@ -250,6 +270,70 @@ SMonHttpStatus *monGetHttpStatusHashTableEntry(int32_t code) {
return
(
SMonHttpStatus
*
)
taosHashGet
(
monHttpStatusHashTable
,
&
code
,
sizeof
(
int32_t
));
}
static
void
*
monAuditFunc
(
void
*
param
)
{
if
(
!
tsEnableAudit
)
{
return
NULL
;
}
monDebug
(
"starting to initialize audit database..."
);
setThreadName
(
"audit"
);
taosMsleep
(
1000
);
int32_t
try
=
0
;
for
(;
try
<
AUDIT_MAX_RETRIES
;
++
try
)
{
auditConn
=
taos_connect
(
NULL
,
"monitor"
,
tsInternalPass
,
""
,
0
);
if
(
auditConn
==
NULL
)
{
monDebug
(
"audit retry connect, tries: %d"
,
try
);
taosMsleep
(
1000
);
}
else
{
monDebug
(
"audit successfuly connect to database"
);
break
;
}
}
if
(
try
==
AUDIT_MAX_RETRIES
)
{
monError
(
"audit failed to connect to database, reason:%s"
,
tstrerror
(
terrno
));
return
NULL
;
}
// create database
char
sql
[
512
]
=
{
0
};
snprintf
(
sql
,
sizeof
(
sql
),
"create database if not exists %s replica 1 days 10 keep %s cache %d "
"blocks %d precision 'us'"
,
tsAuditDbName
,
keepValue
,
TSDB_MIN_CACHE_BLOCK_SIZE
,
TSDB_MIN_TOTAL_BLOCKS
);
void
*
res
=
taos_query
(
auditConn
,
sql
);
int32_t
code
=
taos_errno
(
res
);
taos_free_result
(
res
);
if
(
code
!=
0
)
{
monError
(
"failed to create database: %s, sql:%s, reason:%s"
,
tsAuditDbName
,
sql
,
tstrerror
(
code
));
return
NULL
;
}
// create table
memset
(
sql
,
0
,
sizeof
(
sql
));
snprintf
(
sql
,
sizeof
(
sql
),
"create table if not exists %s.ddl(ts timestamp"
", user_name binary(%d), ip_addr binary(%d), type binary(%d)"
", object binary(%d), result binary(10)"
")"
,
tsAuditDbName
,
TSDB_USER_LEN
,
IP_LEN_STR
,
MAX_DDL_TYPE_LEN
,
MAX_DDL_OBJ_LEN
);
res
=
taos_query
(
auditConn
,
sql
);
code
=
taos_errno
(
res
);
taos_free_result
(
res
);
if
(
code
!=
0
)
{
monError
(
"failed to create table: ddl, exec sql:%s, reason:%s"
,
sql
,
tstrerror
(
code
));
return
NULL
;
}
return
NULL
;
}
static
void
*
monThreadFunc
(
void
*
param
)
{
monDebug
(
"starting to initialize monitor module ..."
);
setThreadName
(
"monitor"
);
...
...
@@ -335,12 +419,6 @@ static void *monThreadFunc(void *param) {
static
void
monBuildMonitorSql
(
char
*
sql
,
int32_t
cmd
)
{
memset
(
sql
,
0
,
SQL_LENGTH
);
#ifdef _STORAGE
char
*
keepValue
=
"30,30,30"
;
#else
char
*
keepValue
=
"30"
;
#endif
if
(
cmd
==
MON_CMD_CREATE_DB
)
{
snprintf
(
sql
,
SQL_LENGTH
,
"create database if not exists %s replica %d days 10 keep %s cache %d "
...
...
@@ -494,6 +572,11 @@ void monCleanupSystem() {
pthread_join
(
tsMonitor
.
thread
,
NULL
);
}
if
(
auditConn
!=
NULL
)
{
taos_close
(
tsMonitor
.
conn
);
auditConn
=
NULL
;
}
if
(
tsMonitor
.
conn
!=
NULL
)
{
taos_close
(
tsMonitor
.
conn
);
tsMonitor
.
conn
=
NULL
;
...
...
@@ -1323,6 +1406,116 @@ static void monExecSqlCb(void *param, TAOS_RES *result, int32_t code) {
taos_free_result
(
result
);
}
static
bool
monConvDDLType2Str
(
int8_t
type
,
char
*
buf
,
int32_t
len
)
{
if
(
buf
==
NULL
)
{
return
false
;
}
switch
(
type
)
{
case
MON_DDL_CMD_CREATE_DATABASE
:
{
strncpy
(
buf
,
"CREATE DATABASE"
,
len
);
break
;
}
case
MON_DDL_CMD_CREATE_TABLE
:
{
strncpy
(
buf
,
"CREATE TABLE"
,
len
);
break
;
}
case
MON_DDL_CMD_CREATE_CHILD_TABLE
:
{
strncpy
(
buf
,
"CREATE CHILD TABLE"
,
len
);
break
;
}
case
MON_DDL_CMD_CREATE_SUPER_TABLE
:
{
strncpy
(
buf
,
"CREATE SUPER TABLE"
,
len
);
break
;
}
case
MON_DDL_CMD_DROP_DATABASE
:
{
strncpy
(
buf
,
"DROP DATABASE"
,
len
);
break
;
}
case
MON_DDL_CMD_DROP_TABLE
:
{
strncpy
(
buf
,
"DROP TABLE"
,
len
);
break
;
}
case
MON_DDL_CMD_DROP_CHILD_TABLE
:
{
strncpy
(
buf
,
"DROP CHILD TABLE"
,
len
);
break
;
}
case
MON_DDL_CMD_DROP_SUPER_TABLE
:
{
strncpy
(
buf
,
"DROP SUPER TABLE"
,
len
);
break
;
}
case
MON_DDL_CMD_DROP_COLUMN
:
{
strncpy
(
buf
,
"DROP COLUMN"
,
len
);
break
;
}
case
MON_DDL_CMD_DROP_TAG
:
{
strncpy
(
buf
,
"DROP TAG"
,
len
);
break
;
}
case
MON_DDL_CMD_ALTER_DATABASE
:
{
strncpy
(
buf
,
"ALTER DATABASE"
,
len
);
break
;
}
case
MON_DDL_CMD_ADD_COLUMN
:
{
strncpy
(
buf
,
"ADD COLUMN"
,
len
);
break
;
}
case
MON_DDL_CMD_ADD_TAG
:
{
strncpy
(
buf
,
"ADD TAG"
,
len
);
break
;
}
case
MON_DDL_CMD_MODIFY_COLUMN
:
{
strncpy
(
buf
,
"MODIFY COLUMN/TAG LENGTH"
,
len
);
break
;
}
case
MON_DDL_CMD_CHANGE_TAG
:
{
strncpy
(
buf
,
"CHANGE TAG NAME"
,
len
);
break
;
}
default:
{
return
false
;
}
}
return
true
;
}
void
monSaveAuditLog
(
int8_t
type
,
const
char
*
user
,
const
char
*
obj
,
bool
result
)
{
if
(
tsEnableAudit
==
0
)
{
//audit not enabled
return
;
}
char
sql
[
1024
]
=
{
0
};
char
typeStr
[
64
]
=
{
0
};
if
(
!
monConvDDLType2Str
(
type
,
typeStr
,
(
int32_t
)
sizeof
(
typeStr
)))
{
monError
(
"unknown DDL type: %d "
,
type
);
return
;
}
snprintf
(
sql
,
1023
,
"insert into %s.ddl values(now, "
SQL_STR_FMT
", "
SQL_STR_FMT
", "
SQL_STR_FMT
", "
SQL_STR_FMT
", "
SQL_STR_FMT
")"
,
tsAuditDbName
,
(
user
!=
NULL
)
?
user
:
"NULL"
,
tsLocalEp
,
typeStr
,
(
obj
!=
NULL
)
?
obj
:
"NULL"
,
result
?
"success"
:
"fail"
);
monDebug
(
"save ddl info, sql:%s"
,
sql
);
void
*
res
=
taos_query
(
auditConn
,
sql
);
int32_t
code
=
taos_errno
(
res
);
taos_free_result
(
res
);
if
(
code
!=
0
)
{
monError
(
"failed to save audit ddl info, reason:%s, sql:%s"
,
tstrerror
(
code
),
sql
);
}
else
{
monDebug
(
"successfully save audit ddl info, sql:%s"
,
sql
);
}
}
void
monSaveAcctLog
(
SAcctMonitorObj
*
pMon
)
{
if
(
tsMonitor
.
state
!=
MON_STATE_INITED
)
return
;
...
...
@@ -1399,6 +1592,7 @@ void monSaveDnodeLog(int32_t level, const char *const format, ...) {
taos_query_a
(
tsMonitor
.
conn
,
sql
,
monExecSqlCb
,
"log"
);
}
void
monExecuteSQL
(
char
*
sql
)
{
if
(
tsMonitor
.
state
!=
MON_STATE_INITED
)
return
;
...
...
src/util/inc/tconfig.h
浏览文件 @
5c5fcc0a
...
...
@@ -20,7 +20,7 @@
extern
"C"
{
#endif
#define TSDB_CFG_MAX_NUM 14
0
#define TSDB_CFG_MAX_NUM 14
1
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
...
...
src/util/src/tconfig.c
浏览文件 @
5c5fcc0a
...
...
@@ -32,20 +32,20 @@ int32_t tsGlobalConfigNum = 0;
}
static
char
*
tsGlobalUnit
[]
=
{
" "
,
"(%)"
,
"(GB)"
,
"(Mb)"
,
"(byte)"
,
"(s)"
,
" "
,
"(%)"
,
"(GB)"
,
"(Mb)"
,
"(byte)"
,
"(s)"
,
"(ms)"
};
char
*
tsCfgStatusStr
[]
=
{
"none"
,
"system default"
,
"config file"
,
"taos_options"
,
"none"
,
"system default"
,
"config file"
,
"taos_options"
,
"program argument list"
};
...
...
@@ -335,7 +335,7 @@ bool taosReadConfigOption(const char *option, char *value, char *value2, char *v
taosReadDataDirCfg
(
value
,
value2
,
value3
);
ret
=
true
;
}
else
{
ret
=
false
;
ret
=
false
;
}
break
;
default:
...
...
@@ -365,8 +365,8 @@ void taosReadGlobalLogCfg() {
wordfree
(
&
full_path
);
return
;
}
if
(
full_path
.
we_wordv
!=
NULL
&&
full_path
.
we_wordv
[
0
]
!=
NULL
)
{
if
(
full_path
.
we_wordv
!=
NULL
&&
full_path
.
we_wordv
[
0
]
!=
NULL
)
{
if
(
strlen
(
full_path
.
we_wordv
[
0
])
>=
TSDB_FILENAME_LEN
)
{
printf
(
"
\n
config file: %s path overflow max len %d, all variables are set to default
\n
"
,
full_path
.
we_wordv
[
0
],
TSDB_FILENAME_LEN
-
1
);
wordfree
(
&
full_path
);
...
...
@@ -380,7 +380,7 @@ void taosReadGlobalLogCfg() {
wordfree
(
&
full_path
);
taosReadLogOption
(
"logDir"
,
tsLogDir
);
sprintf
(
fileName
,
"%s/taos.cfg"
,
configDir
);
fp
=
fopen
(
fileName
,
"r"
);
if
(
fp
==
NULL
)
{
...
...
@@ -391,10 +391,10 @@ void taosReadGlobalLogCfg() {
ssize_t
_bytes
=
0
;
size_t
len
=
1024
;
line
=
calloc
(
1
,
len
);
while
(
!
feof
(
fp
))
{
memset
(
line
,
0
,
len
);
option
=
value
=
NULL
;
olen
=
vlen
=
0
;
...
...
@@ -443,7 +443,7 @@ bool taosReadGlobalCfg() {
ssize_t
_bytes
=
0
;
size_t
len
=
1024
;
line
=
calloc
(
1
,
len
);
while
(
!
feof
(
fp
))
{
memset
(
line
,
0
,
len
);
...
...
@@ -457,7 +457,7 @@ bool taosReadGlobalCfg() {
}
line
[
len
-
1
]
=
0
;
paGetToken
(
line
,
&
option
,
&
olen
);
if
(
olen
==
0
)
continue
;
option
[
olen
]
=
0
;
...
...
@@ -495,7 +495,7 @@ void taosPrintGlobalCfg() {
SGlobalCfg
*
cfg
=
tsGlobalConfig
+
i
;
if
(
tscEmbedded
==
0
&&
!
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CLIENT
))
continue
;
if
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_NOT_PRINT
)
continue
;
int
optionLen
=
(
int
)
strlen
(
cfg
->
option
);
int
blankLen
=
TSDB_CFG_PRINT_LEN
-
optionLen
;
blankLen
=
blankLen
<
0
?
0
:
blankLen
;
...
...
tests/pytest/alter/alter_keep.py
浏览文件 @
5c5fcc0a
...
...
@@ -22,7 +22,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
alterKeepCommunity
(
self
):
tdLog
.
notice
(
'running Keep Test, Community Version'
)
tdLog
.
notice
(
'running parameter test for keep during create'
)
...
...
@@ -174,7 +174,7 @@ class TDTestCase:
tdSql
.
error
(
'insert into tb values (now-15d, 10)'
)
tdSql
.
query
(
'select * from tb'
)
tdSql
.
checkRows
(
2
)
rowNum
=
2
tdLog
.
notice
(
'testing keep will be altered if sudden change from small to big'
)
for
i
in
range
(
30
):
...
...
tests/pytest/client/client.py
浏览文件 @
5c5fcc0a
...
...
@@ -28,8 +28,8 @@ class TDTestCase:
tdSql
.
prepare
()
ret
=
tdSql
.
query
(
'select database()'
)
tdSql
.
checkData
(
0
,
0
,
"db"
)
tdSql
.
checkData
(
0
,
0
,
"db"
)
ret
=
tdSql
.
query
(
'select server_status()'
)
tdSql
.
checkData
(
0
,
0
,
1
)
...
...
@@ -59,10 +59,10 @@ class TDTestCase:
if
create_time
-
time_delta
<
role_time
<
create_time
+
time_delta
:
tdLog
.
info
(
"role_time {} and create_time {} expected within range"
.
format
(
role_time
,
create_time
))
else
:
tdLog
.
exit
(
"role_time {} and create_time {} not expected within range"
.
format
(
role_time
,
create_time
))
tdLog
.
exit
(
"role_time {} and create_time {} not expected within range"
.
format
(
role_time
,
create_time
))
ret
=
tdSql
.
query
(
'show vgroups'
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
execute
(
'create stable st (ts timestamp, f int) tags(t int)'
)
tdSql
.
execute
(
'create table ct1 using st tags(1)'
);
...
...
@@ -74,8 +74,8 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
checkData
(
0
,
1
,
"leader"
)
cmd
=
"taos -h 127.0.0.1 -s 'show databases'"
cmd
=
"taos -h 127.0.0.1 -s 'show databases'"
r
=
os
.
popen
(
cmd
)
text
=
r
.
read
()
r
.
close
...
...
tests/pytest/query/queryError.py
浏览文件 @
5c5fcc0a
...
...
@@ -68,14 +68,14 @@ class TDTestCase:
# TD-6006
tdSql
.
error
(
"select * from dev_001 where 'name' is not null"
)
tdSql
.
error
(
"select * from dev_001 where
\"
name
\"
= 'first'"
)
# TS-1577
tdSql
.
query
(
"show databases"
)
rows
=
tdSql
.
queryRows
for
i
in
range
(
1000
):
tdSql
.
execute
(
"create database test%d"
%
i
)
tdSql
.
query
(
"show databases"
)
tdSql
.
checkRows
(
rows
+
1000
)
...
...
tests/pytest/tag_lite/TestModifyTag.py
浏览文件 @
5c5fcc0a
...
...
@@ -50,8 +50,8 @@ class TDTestCase:
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
run
(
self
):
...
...
@@ -122,4 +122,4 @@ class TDTestCase:
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/tag_lite/alter_tag.py
浏览文件 @
5c5fcc0a
...
...
@@ -43,9 +43,9 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
6
,
None
)
tdSql
.
checkData
(
1
,
6
,
'test'
)
# Test case for: https://jira.taosdata.com:18080/browse/TD-2423
# Test case for: https://jira.taosdata.com:18080/browse/TD-2423
tdSql
.
execute
(
"create table stb(ts timestamp, col1 int, col2 nchar(20)) tags(tg1 int, tg2 binary(20), tg3 nchar(25))"
)
tdSql
.
execute
(
"insert into tb1 using stb(tg1, tg3) tags(1, 'test1') values(now, 1, 'test1')"
)
tdSql
.
execute
(
"insert into tb1 using stb(tg1, tg3) tags(1, 'test1') values(now, 1, 'test1')"
)
tdSql
.
query
(
"select *, tg1, tg2, tg3 from tb1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
3
,
1
)
...
...
@@ -61,7 +61,7 @@ class TDTestCase:
#Test case for TS-1285
tdSql
.
execute
(
"create table stb2(ts timestamp, c1 int) tags(t1 timestamp)"
)
tdSql
.
execute
(
"insert into tb3 using stb2 tags('2022-01-01 18:26:50.224') values(now, 1)"
)
tdSql
.
execute
(
"insert into tb3 using stb2 tags('2022-01-01 18:26:50.224') values(now, 1)"
)
tdSql
.
execute
(
"alter table tb3 set tag t1='2022-03-03 18:26:50.224'"
)
tdSql
.
query
(
"select * from stb2"
)
tdSql
.
checkData
(
0
,
2
,
"2022-03-03 18:26:50.224"
)
...
...
tests/pytest/tag_lite/bigint.py
浏览文件 @
5c5fcc0a
...
...
@@ -577,15 +577,15 @@ class TDTestCase:
tdSql
.
execute
(
"use db"
)
tdSql
.
execute
(
"create table if not exists st (ts timestamp, tagtype int) tags(dev bigint)"
)
tdSql
.
execute
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
63
)
-
1
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_002 using st tags(%d)'
%
(
-
1
*
pow
(
2
,
63
)
+
1
))
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/tag_lite/binary.py
浏览文件 @
5c5fcc0a
...
...
@@ -583,13 +583,13 @@ class TDTestCase:
"create table if not exists st (ts timestamp, tagtype int) tags(dev binary(5))"
)
tdSql
.
error
(
'CREATE TABLE if not exists dev_001 using st tags("dev_001")'
)
tdSql
.
execute
(
'CREATE TABLE if not exists dev_002 using st tags("dev")'
)
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/tag_lite/int.py
浏览文件 @
5c5fcc0a
...
...
@@ -580,15 +580,15 @@ class TDTestCase:
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
pow
(
2
,
31
))
tdSql
.
error
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
-
1
*
pow
(
2
,
31
)))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
31
)
-
1
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_002 using st tags(%d)'
%
(
-
1
*
pow
(
2
,
31
)
+
1
))
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/tag_lite/json_tag_extra.py
浏览文件 @
5c5fcc0a
...
...
@@ -47,16 +47,16 @@ class TDTestCase:
print
(
"==============step1 tag format ======="
)
tdLog
.
info
(
"create database "
)
tdSql
.
execute
(
"create database db_json"
)
tdSql
.
execute
(
"use db_json"
)
# test tag format
tdSql
.
execute
(
"use db_json"
)
# test tag format
tdSql
.
execute
(
"create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json)"
)
tdSql
.
error
(
"create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json(10000000))"
)
tdSql
.
error
(
"create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json,jtag1 json)"
)
tdSql
.
error
(
"create table if not exists jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json,dataBool bool)"
)
tdSql
.
execute
(
"CREATE TABLE if not exists jsons1_1 using jsons1 tags('{
\"
loc
\"
:
\"
fff
\"
,
\"
id
\"
:5}')"
)
# two stables: jsons1 jsons2 ,test tag's value and key
# two stables: jsons1 jsons2 ,test tag's value and key
tdSql
.
execute
(
"insert into jsons1_1(ts,dataInt) using jsons1 tags('{
\"
loc+
\"
:
\"
fff
\"
,
\"
id
\"
:5}') values (now,12)"
)
tdSql
.
error
(
"CREATE TABLE if not exists jsons1_1 using jsons1 tags('{oc:
\"
fff
\"
,
\"
id
\"
:5}')"
)
...
...
tests/pytest/tag_lite/nchar.py
浏览文件 @
5c5fcc0a
...
...
@@ -35,7 +35,7 @@ class TDTestCase:
'CREATE TABLE if not exists dev_002 using st tags("dev")'
)
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
1
)
...
...
tests/pytest/tag_lite/smallint.py
浏览文件 @
5c5fcc0a
...
...
@@ -580,15 +580,15 @@ class TDTestCase:
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
pow
(
2
,
15
))
tdSql
.
error
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
-
1
*
pow
(
2
,
15
)))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
15
)
-
1
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_002 using st tags(%d)'
%
(
-
1
*
pow
(
2
,
15
)
+
1
))
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/tag_lite/timestamp.py
浏览文件 @
5c5fcc0a
...
...
@@ -46,7 +46,7 @@ class TDTestCase:
tdLog
.
info
(
'=============== step2'
)
tdSql
.
query
(
'select * from %s'
%
(
mt
))
tdSql
.
checkRows
(
5
*
rowNum
)
tdSql
.
query
(
'select * from %s where tgTs = %ld and tgcol2 = 0'
%
(
mt
,
ts
))
tdSql
.
checkRows
(
rowNum
)
...
...
@@ -54,7 +54,7 @@ class TDTestCase:
tdSql
.
checkRows
(
rowNum
)
tdLog
.
info
(
'=============== step3'
)
i
=
0
i
=
0
while
(
i
<
5
):
tb
=
"%s%d"
%
(
tbPrefix
,
i
+
100
)
tdLog
.
info
(
'create table %s using %s tags(%d,
\"
%s
\"
, %d)'
%
(
tb
,
mt
,
i
+
100
,
tsStr
,
i
+
100
))
...
...
@@ -80,7 +80,7 @@ class TDTestCase:
tdLog
.
info
(
'=============== step4'
)
i
=
0
tb
=
"%s%d"
%
(
tbPrefix
,
i
+
1000
)
tb
=
"%s%d"
%
(
tbPrefix
,
i
+
1000
)
tdSql
.
execute
(
'insert into %s using %s tags(%d,
\"
%s
\"
, %d) values(now, 10)'
%
(
tb
,
mt
,
i
+
100
,
tsStr
,
i
+
1000
))
tdSql
.
execute
(
'insert into %s using %s tags(%d,
\"
%s
\"
, %d) values(now+2s, 10)'
%
(
tb
,
mt
,
i
+
100
,
tsStr
,
i
+
1000
))
tdSql
.
execute
(
'insert into %s using %s tags(%d,
\"
%s
\"
, %d) values(now+3s, 10)'
%
(
tb
,
mt
,
i
+
100
,
tsStr
,
i
+
1000
))
...
...
@@ -88,11 +88,11 @@ class TDTestCase:
tdSql
.
checkRows
(
3
)
i
=
0
tb
=
"%s%d"
%
(
tbPrefix
,
i
+
10000
)
tb
=
"%s%d"
%
(
tbPrefix
,
i
+
10000
)
tdSql
.
execute
(
'create table %s using %s tags(%d, now, %d)'
%
(
tb
,
mt
,
i
+
10000
,
i
+
10000
))
tdSql
.
checkRows
(
3
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
tests/pytest/tag_lite/tinyint.py
浏览文件 @
5c5fcc0a
...
...
@@ -581,15 +581,15 @@ class TDTestCase:
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
pow
(
2
,
7
))
tdSql
.
error
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
-
1
*
pow
(
2
,
7
)))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
7
)
-
1
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_002 using st tags(%d)'
%
(
-
1
*
pow
(
2
,
7
)
+
1
))
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/tag_lite/too_many_tag_condtions.py
浏览文件 @
5c5fcc0a
...
...
@@ -13,12 +13,12 @@ class TDTestCase:
def
run
(
self
):
tdSql
.
prepare
()
tdLog
.
info
(
'======================== dnode1 start'
)
tbPrefix
=
"ta_cr_tb"
mtPrefix
=
"ta_cr_mt"
tbNum
=
2
rowNum
=
10
tbNum
=
2
rowNum
=
10
totalNum
=
200
tagCondsLimit
=
1024
tdLog
.
info
(
'=============== step1: create tbl and prepare data'
)
...
...
@@ -26,40 +26,40 @@ class TDTestCase:
i
=
2
mt
=
"%s%d"
%
(
mtPrefix
,
i
)
tb
=
"%s%d"
%
(
tbPrefix
,
i
)
sql
=
'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)'
%
(
mt
)
tdLog
.
info
(
sql
)
tdSql
.
execute
(
sql
)
for
i
in
range
(
0
,
tbNum
):
for
i
in
range
(
0
,
tbNum
):
tblName
=
"%s%d"
%
(
tbPrefix
,
i
)
sql
=
'create table %s using %s TAGS(%d)'
%
(
tblName
,
mt
,
i
)
sql
=
'create table %s using %s TAGS(%d)'
%
(
tblName
,
mt
,
i
)
tdSql
.
execute
(
sql
)
for
j
in
range
(
0
,
rowNum
):
sql
=
"insert into %s values(now, %d)"
%
(
tblName
,
j
)
sql
=
"insert into %s values(now, %d)"
%
(
tblName
,
j
)
tdSql
.
execute
(
sql
)
sqlPrefix
=
"select * from %s where "
%
(
mt
)
sqlPrefix
=
"select * from %s where "
%
(
mt
)
for
i
in
range
(
2
,
2048
,
1
):
conds
=
"tgcol=1 and "
*
(
i
-
1
)
conds
=
"%stgcol=1"
%
(
conds
)
sql
=
"%s%s"
%
(
sqlPrefix
,
conds
)
if
i
>=
tagCondsLimit
:
if
i
>=
tagCondsLimit
:
tdSql
.
error
(
sql
)
else
:
else
:
tdSql
.
query
(
sql
)
#tdSql.checkRows(1)
for
i
in
range
(
2
,
2048
,
1
):
conds
=
""
for
j
in
range
(
0
,
i
-
1
):
conds
=
""
for
j
in
range
(
0
,
i
-
1
):
conds
=
conds
+
"tgcol=%d or "
%
(
j
%
tbNum
)
conds
+=
"tgcol=%d"
%
(
i
%
tbNum
)
sql
=
sqlPrefix
+
conds
sql
=
sqlPrefix
+
conds
if
i
>=
tagCondsLimit
:
tdSql
.
error
(
sql
)
else
:
else
:
tdSql
.
query
(
sql
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/tag_lite/unsignedBigint.py
浏览文件 @
5c5fcc0a
...
...
@@ -580,16 +580,16 @@ class TDTestCase:
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
64
)
-
1
))
tdSql
.
error
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
-
1
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
64
)
-
2
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_002 using st tags(%d)'
%
(
0
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_003 using st tags(%s)'
%
(
'NULL'
))
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/tag_lite/unsignedInt.py
浏览文件 @
5c5fcc0a
...
...
@@ -581,16 +581,16 @@ class TDTestCase:
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
32
)
-
1
))
tdSql
.
error
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
-
1
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
32
)
-
2
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_002 using st tags(%d)'
%
(
0
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_003 using st tags(%s)'
%
(
'NULL'
))
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/tag_lite/unsignedSmallint.py
浏览文件 @
5c5fcc0a
...
...
@@ -580,7 +580,7 @@ class TDTestCase:
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
16
)
-
1
))
tdSql
.
error
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
-
1
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
16
)
-
2
))
tdSql
.
execute
(
...
...
@@ -588,9 +588,9 @@ class TDTestCase:
tdSql
.
execute
(
'CREATE TABLE if not exists dev_003 using st tags(%s)'
%
(
'NULL'
))
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/tag_lite/unsignedTinyint.py
浏览文件 @
5c5fcc0a
...
...
@@ -580,16 +580,16 @@ class TDTestCase:
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
8
)
-
1
))
tdSql
.
error
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
-
1
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_001 using st tags(%d)'
%
(
pow
(
2
,
8
)
-
2
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_002 using st tags(%d)'
%
(
0
))
tdSql
.
execute
(
'CREATE TABLE if not exists dev_003 using st tags(%s)'
%
(
'NULL'
))
print
(
"==============step2"
)
print
(
"==============step2"
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/util/dnodes.py
浏览文件 @
5c5fcc0a
...
...
@@ -142,6 +142,7 @@ class TDDnode:
"numOfMnodes"
:
"3"
,
"numOfThreadsPerCore"
:
"2.0"
,
"monitor"
:
"0"
,
"audit"
:
"0"
,
"maxVnodeConnections"
:
"30000"
,
"maxMgmtConnections"
:
"30000"
,
"maxMeterConnections"
:
"30000"
,
...
...
tests/script/sh/deploy.bat
浏览文件 @
5c5fcc0a
...
...
@@ -85,6 +85,7 @@ echo wdebugFlag 135 >> %TAOS_CFG%
echo
cqdebugFlag
135
>>
%TAOS_CFG%
echo
monitor
0
>>
%TAOS_CFG%
echo
monitorInterval
1
>>
%TAOS_CFG%
echo
audit
0
>>
%TAOS_CFG%
echo
http
0
>>
%TAOS_CFG%
echo
slaveQuery
0
>>
%TAOS_CFG%
echo
numOfThreadsPerCore
2
.0
>>
%TAOS_CFG%
...
...
tests/script/sh/deploy.sh
浏览文件 @
5c5fcc0a
...
...
@@ -139,6 +139,7 @@ echo "wdebugFlag 143" >> $TAOS_CFG
echo
"cqdebugFlag 143"
>>
$TAOS_CFG
echo
"monitor 0"
>>
$TAOS_CFG
echo
"monitorInterval 1"
>>
$TAOS_CFG
echo
"audit 0"
>>
$TAOS_CFG
echo
"http 0"
>>
$TAOS_CFG
echo
"slaveQuery 0"
>>
$TAOS_CFG
echo
"numOfThreadsPerCore 2.0"
>>
$TAOS_CFG
...
...
tests/system-test/0-others/audit.py
0 → 100644
浏览文件 @
5c5fcc0a
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
import
time
import
os
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.sql
import
tdSql
class
TDTestCase
:
updatecfgDict
=
{
'audit'
:
1
}
def
caseDescription
(
self
):
'''
TS-1887 Create Audit db for DDL storage
'''
return
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
now
=
time
.
time
()
self
.
ts
=
int
(
round
(
now
*
1000
))
def
run
(
self
):
#tdSql.prepare()
time
.
sleep
(
3
)
print
(
"==============step1 test CREATE DDL"
)
# CREATE DATABASE
tdSql
.
execute
(
"create database db"
)
tdSql
.
execute
(
"use db"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'CREATE DATABASE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# CREATE NORMAL TABLE
tdSql
.
execute
(
"create table tb (ts timestamp, c0 int)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'CREATE TABLE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.tb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# CREATE SUPER TABLE
tdSql
.
execute
(
"create table stb (ts timestamp, c0 int) tags (t0 int)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'CREATE SUPER TABLE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.stb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# CREATE CHILD TABLE
tdSql
.
execute
(
"create table ctb using stb tags (1)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'CREATE CHILD TABLE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.ctb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# CREATE CHILD TABLE(AUTO)
tdSql
.
execute
(
"insert into ctb_auto using stb tags (2) values (now, 2)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'CREATE CHILD TABLE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.ctb_auto'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
print
(
"==============step2 test ALTER DDL"
)
# ALTER ATABASE
tdSql
.
execute
(
"alter database db keep 354"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'ALTER DATABASE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
tdSql
.
execute
(
"alter database db cachelast 1"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'ALTER DATABASE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# ADD COLUMN NORMAL TABLE
tdSql
.
execute
(
"alter table tb add column c1 binary(4)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'ADD COLUMN'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.tb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# MODIFY COLUMN NORMAL TABLE
tdSql
.
execute
(
"alter table tb modify column c1 binary(10)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'MODIFY COLUMN/TAG LENGTH'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.tb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# ADD COLUMN SUPER TABLE
tdSql
.
execute
(
"alter table stb add column c1 binary(4)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'ADD COLUMN'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.stb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# ADD TAG SUPER TABLE
tdSql
.
execute
(
"alter table stb add tag t1 binary(4)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'ADD TAG'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.stb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# MODIFY COLUMN SUPER TABLE
tdSql
.
execute
(
"alter table stb modify column c1 binary(10)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'MODIFY COLUMN/TAG LENGTH'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.stb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# MODIFY TAG SUPER TABLE
tdSql
.
execute
(
"alter table stb modify tag t1 binary(10)"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'MODIFY COLUMN/TAG LENGTH'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.stb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# CHANGE TAG NAME SUPER TABLE
tdSql
.
execute
(
"alter table stb change tag t1 t2"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'CHANGE TAG NAME'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.stb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
print
(
"==============step3 test DROP DDL"
)
# DROP COLUMN NORMAL TABLE
tdSql
.
execute
(
"alter table tb drop column c1"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'DROP COLUMN'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.tb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# DROP COLUMN SUPER TABLE
tdSql
.
execute
(
"alter table stb drop column c1"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'DROP COLUMN'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.stb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# DROP TAG SUPER TABLE
tdSql
.
execute
(
"alter table stb drop tag t2"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'DROP TAG'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.stb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# DROP NORMAL TABLE
tdSql
.
execute
(
"drop table tb"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'DROP TABLE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.tb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# DROP CHILD TABLE
tdSql
.
execute
(
"drop table ctb"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'DROP CHILD TABLE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.ctb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# DROP SUPER TABLE
tdSql
.
execute
(
"drop table stb"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'DROP SUPER TABLE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db.stb'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
# DROP DATABASE
tdSql
.
execute
(
"drop database db"
)
tdSql
.
query
(
"select last(*) from audit.ddl"
);
tdSql
.
checkData
(
0
,
3
,
'DROP DATABASE'
)
tdSql
.
checkData
(
0
,
4
,
'0.db'
)
tdSql
.
checkData
(
0
,
5
,
'success'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/system-test/fulltest-others.sh
浏览文件 @
5c5fcc0a
python3 ./test.py
-f
0-others/create_col_tag.py
\ No newline at end of file
python3 ./test.py
-f
0-others/create_col_tag.py
python3 ./test.py
-f
0-others/audit.py
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录