diff --git a/src/dnode/src/dnodeMWrite.c b/src/dnode/src/dnodeMWrite.c index 79744e153e46777c098644ac9902fb76be81fb11..a409d537fa8a56f03ed79d68358ac70b780e74e9 100644 --- a/src/dnode/src/dnodeMWrite.c +++ b/src/dnode/src/dnodeMWrite.c @@ -146,10 +146,10 @@ void dnodeSendRpcMWriteRsp(void *pMsg, int32_t code) { } dTrace("msg:%p, app:%p type:%s master:%p will be responsed", pWrite, pWrite->rpcMsg.ahandle, - taosMsg[pWrite->rpcMsg.msgType], pWrite->pBatchMasterMsg); + taosMsg[pWrite->rpcMsg.msgType], pWrite->pBatchMasterMsg); if (pWrite->pBatchMasterMsg && pWrite != pWrite->pBatchMasterMsg) { dError("msg:%p, app:%p type:%s master:%p sub message should not response!", pWrite, pWrite->rpcMsg.ahandle, - taosMsg[pWrite->rpcMsg.msgType], pWrite->pBatchMasterMsg); + taosMsg[pWrite->rpcMsg.msgType], pWrite->pBatchMasterMsg); return; } diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 9a226b81e8eddc13aa5cb37ca422b68bcb808e03..60d9c38c05a152228f60424fedea45ca88de18ce 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -47,8 +47,11 @@ int32_t dnodeInitShell() { dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DNODE]= dnodeDispatchToMWriteQueue; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DNODE] = dnodeDispatchToMWriteQueue; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DB] = dnodeDispatchToMWriteQueue; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_TP] = dnodeDispatchToMWriteQueue; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DB] = dnodeDispatchToMWriteQueue; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_TP] = dnodeDispatchToMWriteQueue; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_DB] = dnodeDispatchToMWriteQueue; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_TP] = dnodeDispatchToMWriteQueue; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_TABLE]= dnodeDispatchToMWriteQueue; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_TABLE] = dnodeDispatchToMWriteQueue; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_TABLE] = dnodeDispatchToMWriteQueue; diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 7fbf43f253223dd2076d9a29e27277255ae1dfb6..23b4c36d0d8286c1846c040fc4378ba8541875b3 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -912,7 +912,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { int8_t update = pAlter->update; int8_t cacheLastRow = pAlter->cacheLastRow; int8_t dbType = pAlter->dbType; - int16_t partitions = pAlter->partitions; + int16_t partitions = htons(pAlter->partitions); terrno = TSDB_CODE_SUCCESS; @@ -1031,8 +1031,8 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) { } if (dbType >= 0 && dbType != pDb->cfg.dbType) { - mError("db:%s, can't alter dbType option", pDb->name); - terrno = TSDB_CODE_MND_INVALID_DB_OPTION; + mDebug("db:%s, dbType:%d change to %d", pDb->name, pDb->cfg.dbType, dbType); + newCfg.dbType = dbType; } if (partitions >= 0 && partitions != pDb->cfg.partitions) { @@ -1067,6 +1067,8 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) { } static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) { + mDebug("db:%s, type:%d do alter operation", pDb->name, pDb->cfg.dbType); + SDbCfg newCfg = mnodeGetAlterDbOption(pDb, pAlter); if (terrno != TSDB_CODE_SUCCESS) { return terrno; @@ -1099,7 +1101,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) { int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) { SAlterDbMsg *pAlter = pMsg->rpcMsg.pCont; - mDebug("db:%s, alter db msg is received from thandle:%p", pAlter->db, pMsg->rpcMsg.handle); + mDebug("db:%s, alter db msg is received from thandle:%p, dbType:%d", pAlter->db, pMsg->rpcMsg.handle, pAlter->dbType); if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(pAlter->db); if (pMsg->pDb == NULL) { diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index 4ff2a38dffcb2186f73e2254efeaa6419c68d50b..03772f2724c87c74da2f3ab7128705d90c5bb1ad 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -109,6 +109,7 @@ static char *mnodeGetShowType(int32_t showType) { case TSDB_MGMT_TABLE_VNODES: return "show vnodes"; case TSDB_MGMT_TABLE_CLUSTER: return "show clusters"; case TSDB_MGMT_TABLE_STREAMTABLES : return "show streamtables"; + case TSDB_MGMT_TABLE_TP: return "show topics"; default: return "undefined"; } } diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index b6c21ccd009ae39125038ae4772abcb8dd4f6d6d..008a655597f0934a1281ca0e5ccedd84d33bc1f9 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -459,8 +459,8 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi maxVgroupsPerDb = MIN(maxVgroupsPerDb, TSDB_MAX_VNODES_PER_DB); } - if (pDb->cfg.dbType == TSDB_DB_TYPE_TOPIC && pDb->cfg.partitions > 0) { - maxVgroupsPerDb = pDb->cfg.partitions; + if (pDb->cfg.dbType == TSDB_DB_TYPE_TOPIC) { + maxVgroupsPerDb = TSDB_MAX_DB_PARTITON_OPTION; } int32_t code = TSDB_CODE_MND_NO_ENOUGH_DNODES; diff --git a/src/query/src/qParserImpl.c b/src/query/src/qParserImpl.c index c855b38d4a9aa6140dbc62e8251327ee15b785d5..4ac3011ac9a6db8a651f2e383d08dd98314d3f4b 100644 --- a/src/query/src/qParserImpl.c +++ b/src/query/src/qParserImpl.c @@ -944,12 +944,9 @@ void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo) { memset(&pDBInfo->precision, 0, sizeof(SStrToken)); } - void setDefaultCreateTopicOption(SCreateDbInfo *pDBInfo) { setDefaultCreateDbOption(pDBInfo); pDBInfo->dbType = TSDB_DB_TYPE_TOPIC; pDBInfo->partitions = TSDB_DEFAULT_DB_PARTITON_OPTION; } - - diff --git a/tests/script/general/db/topic1.sim b/tests/script/general/db/topic1.sim new file mode 100644 index 0000000000000000000000000000000000000000..0f1ad60f3b6ba38253eb9f70f6ff70d395075db6 --- /dev/null +++ b/tests/script/general/db/topic1.sim @@ -0,0 +1,849 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 100 +system sh/cfg.sh -n dnode1 -c partitions -v 4 +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ====step1 create with default para +sql create topic t1; +sql use t1; + +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +if $data02 != 4 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 < 1 then + return -1 +endi +#numofvgroups +if $data03 < 1 then + return -1 +endi + +sql show t1.vgroups; +if $rows < 1 then + return -1 +endi + +sql show t1.stables; +if $rows != 1 then + return -1 +endi +if $data04 < 1 then + return -1 +endi + +sql show t1.tables; +if $rows < 1 then + return -1 +endi + +sql drop topic t1 +sql show topics; +if $rows != 0 then + return -1 +endi +sql show databases; +if $rows != 0 then + return -1 +endi + +sql_error use t1; +sql_error show t1.vgroups; +sql_error show t1.stables; +sql_error show t1.tables; + +print ====step2 create with giving para +sql create topic t1 partitions 6; + +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +if $data02 != 6 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 6 then + return -1 +endi +#numofvgroups +if $data03 != 6 then + return -1 +endi + +sql show t1.vgroups; +if $rows != 6 then + return -1 +endi + +sql show t1.stables; +if $rows != 1 then + return -1 +endi +if $data00 != ps then + return -1 +endi +if $data04 != 6 then + return -1 +endi + +sql show t1.tables; +if $rows != 6 then + return -1 +endi + +sql describe t1.ps; +if $data00 != off then + return -1 +endi +if $data10 != content then + return -1 +endi +if $data20 != pid then + return -1 +endi + +sql describe t1.p1; +if $data00 != off then + return -1 +endi +if $data10 != content then + return -1 +endi +if $data20 != pid then + return -1 +endi + +sql drop topic t1 +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +sql_error show t1.vgroups; +sql_error show t1.stables; +sql_error show t1.tables; + +sql_error create topic t1 partitions -1; +sql_error create topic t1 partitions 0; +sql_error create topic t1 partitions 10001; + +print =============step3 create with db para +sql create topic db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 +sql show databases +if $data00 != db then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 20,20,20 then + return -1 +endi +if $data08 != 2 then + return -1 +endi +if $data09 != 4 then + return -1 +endi +sql drop topic db; + +sql create topic db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 partitions 7 +sql show databases +if $data00 != db then + return -1 +endi +if $data02 != 7 then + return -1 +endi +if $data03 != 7 then + return -1 +endi +if $data04 != 1 then + return -1 +endi +if $data06 != 10 then + return -1 +endi +if $data07 != 20,20,20 then + return -1 +endi +if $data08 != 2 then + return -1 +endi +if $data09 != 4 then + return -1 +endi + +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != db then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != db then + return -1 +endi +#tables +if $data02 != 7 then + return -1 +endi +#numofvgroups +sql show db.vgroups; +if $rows != 7 then + return -1 +endi +sql show db.stables; +if $rows != 1 then + return -1 +endi +sql show db.tables; +if $rows != 7 then + return -1 +endi + +print ============== step name +sql_error alter database db name d1 +sql_error alter database db name d2 +sql_error alter topic db name d1 +sql_error alter topic db name d2 + +print ============== step ntables +sql_error alter database db ntables -1 +sql_error alter database db ntables 0 +sql_error alter database db ntables 1 +sql_error alter database db ntables 10 +sql_error alter topic db ntables -1 +sql_error alter topic db ntables 0 +sql_error alter topic db ntables 1 +sql_error alter topic db ntables 10 + +print ============== step vgroups +sql_error alter database db vgroups -1 +sql_error alter database db vgroups 0 +sql_error alter database db vgroups 1 +sql_error alter database db vgroups 10 +sql_error alter topic db vgroups -1 +sql_error alter topic db vgroups 0 +sql_error alter topic db vgroups 1 +sql_error alter topic db vgroups 10 + +print ============== step replica +sql_error alter database db replica 2 +sql_error alter database db replica 3 +sql_error alter database db replica 0 +sql_error alter topic db replica 2 +sql_error alter topic db replica 3 +sql_error alter topic db replica 0 + +sql alter database db replica 1 +sql show databases +print replica $data4_db +if $data4_db != 1 then + return -1 +endi + +sql show topics +if $rows != 0 then + return -1 +endi + +print ============== step quorum +sql show databases +print quorum $data5_db +if $data5_db != 1 then + return -1 +endi + +sql_error alter topic db quorum 1 +sql alter database db quorum 1 +sql show databases +print quorum $data5_db +if $data5_db != 1 then + return -1 +endi + +sql_error alter database db quorum 2 +sql_error alter database db quorum 3 +sql_error alter topic db quorum 2 +sql_error alter topic db quorum 3 + +sql_error alter database db quorum 0 +sql_error alter database db quorum 4 +sql_error alter database db quorum 5 +sql_error alter database db quorum -1 +sql_error alter topic db quorum 0 +sql_error alter topic db quorum 4 +sql_error alter topic db quorum 5 +sql_error alter topic db quorum -1 + +print ============== step days +sql_error alter database db days 0 +sql_error alter database db days 1 +sql_error alter database db days 2 +sql_error alter database db days 10 +sql_error alter database db days 50 +sql_error alter database db days 100 +sql_error alter topic db days 0 +sql_error alter topic db days 1 +sql_error alter topic db days 2 +sql_error alter topic db days 10 +sql_error alter topic db days 50 +sql_error alter topic db days 100 + +print ============== step keep +sql show databases +print keep $data7_db +if $data7_db != 20,20,20 then + return -1 +endi + +sql_error topic db keep 20 +sql alter database db keep 20 +sql show databases +print keep $data7_db +if $data7_db != 20,20,20 then + return -1 +endi + +sql_error topic db keep 30 +sql alter database db keep 30 +sql show databases +print keep $data7_db +if $data7_db != 20,20,30 then + return -1 +endi + +sql_error alter database db keep 40 +sql alter database db keep 40 +sql show databases +print keep $data7_db +if $data7_db != 20,20,40 then + return -1 +endi + +sql alter database db keep 40 +sql alter database db keep 30 +sql alter database db keep 20 +sql_error alter database db keep 10 +sql_error alter database db keep 9 +sql_error alter database db keep 1 +sql alter database db keep 0 +sql alter database db keep -1 +sql_error alter database db keep 365001 + +sql_error alter topic db keep 40 +sql_error alter topic db keep 30 +sql_error alter topic db keep 20 +sql_error alter topic db keep 10 +sql_error alter topic db keep 9 +sql_error alter topic db keep 1 +sql_error alter topic db keep 0 +sql_error alter topic db keep -1 +sql_error alter topic db keep 365001 + +print ============== step cache +sql_error alter database db cache 60 +sql_error alter database db cache 50 +sql_error alter database db cache 20 +sql_error alter database db cache 3 +sql_error alter database db cache 129 +sql_error alter database db cache 300 +sql_error alter database db cache 0 +sql_error alter database db cache -1 + +sql_error alter topic db cache 60 +sql_error alter topic db cache 50 +sql_error alter topic db cache 20 +sql_error alter topic db cache 3 +sql_error alter topic db cache 129 +sql_error alter topic db cache 300 +sql_error alter topic db cache 0 +sql_error alter topic db cache -1 + +print ============== step blocks +sql show databases +print blocks $data9_db +if $data9_db != 4 then + return -1 +endi + +sql_error alter topic db blocks 10 +sql alter database db blocks 10 +sql show databases +print blocks $data9_db +if $data9_db != 10 then + return -1 +endi + +sql_error alter topic db blocks 20 +sql alter database db blocks 20 +sql show databases +print blocks $data9_db +if $data9_db != 20 then + return -1 +endi + +sql_error alter topic db blocks 20 +sql alter database db blocks 30 +sql show databases +print blocks $data9_db +if $data9_db != 30 then + return -1 +endi + +sql alter database db blocks 40 +sql alter database db blocks 30 +sql alter database db blocks 20 +sql alter database db blocks 10 +sql_error alter database db blocks 2 +sql_error alter database db blocks 1 +sql alter database db blocks 0 +sql_error alter database db blocks -1 +sql_error alter database db blocks 10001 + +sql_error alter topic db blocks 40 +sql_error alter topic db blocks 30 +sql_error alter topic db blocks 20 +sql_error alter topic db blocks 10 +sql_error alter topic db blocks 2 +sql_error alter topic db blocks 1 +sql_error alter topic db blocks 0 +sql_error alter topic db blocks -1 +sql_error alter topic db blocks 10001 + +print ============== step minrows +sql_error alter database db minrows 1 +sql_error alter database db minrows 100 +sql_error alter database db minrows 1000 + +sql_error alter topic db minrows 1 +sql_error alter topic db minrows 100 +sql_error alter topic db minrows 1000 + +print ============== step maxrows +sql_error alter database db maxrows 1 +sql_error alter database db maxrows 100 +sql_error alter database db maxrows 1000 + +sql_error alter topic db maxrows 1 +sql_error alter topic db maxrows 100 +sql_error alter topic db maxrows 1000 + +print ============== step wallevel +sql show databases +print wallevel $data12_db +if $data12_db != 1 then + return -1 +endi + +sql_error alter topic db wal 1 +sql alter database db wal 1 +sql show databases +print wal $data12_db +if $data12_db != 1 then + return -1 +endi + +sql alter database db wal 1 +sql alter database db wal 2 +sql alter database db wal 1 +sql alter database db wal 2 +sql alter database db wal 0 +sql_error alter database db wal 3 +sql_error alter database db wal 4 +sql_error alter database db wal -1 +sql_error alter database db wal 1000 + +sql_error alter topic db wal 1 +sql_error alter topic db wal 2 +sql_error alter topic db wal 1 +sql_error alter topic db wal 2 +sql_error alter topic db wal 0 +sql_error alter topic db wal 3 +sql_error alter topic db wal 4 +sql_error alter topic db wal -1 +sql_error alter topic db wal 1000 + +print ============== step fsync +sql alter database db fsync 0 +sql alter database db fsync 1 +sql alter database db fsync 3600 +sql alter database db fsync 18000 +sql alter database db fsync 180000 +sql_error alter database db fsync 180001 +sql_error alter database db fsync -1 + +sql_error alter topic db fsync 0 +sql_error alter topic db fsync 1 +sql_error alter topic db fsync 3600 +sql_error alter topic db fsync 18000 +sql_error alter topic db fsync 180000 +sql_error alter topic db fsync 180001 +sql_error alter topic db fsync -1 + +print ============== step comp +sql show databases +print comp $data14_db +if $data14_db != 2 then + return -1 +endi + +sql_error alter topic db comp 1 +sql alter database db comp 1 +sql show databases +print comp $data14_db +if $data14_db != 1 then + return -1 +endi + +sql_error alter topic db comp 2 +sql alter database db comp 2 +sql show databases +print comp $data14_db +if $data14_db != 2 then + return -1 +endi + +sql_error alter topic db comp 0 +sql alter database db comp 0 +sql show databases +print comp $data14_db +if $data14_db != 0 then + return -1 +endi + +sql_error alter database db comp 3 +sql_error alter database db comp 4 +sql_error alter database db comp 5 +sql_error alter database db comp -1 + +sql_error alter topic db comp 3 +sql_error alter topic db comp 4 +sql_error alter topic db comp 5 +sql_error alter topic db comp -1 + +print ============== step precision +sql_error alter database db prec 'us' +sql_error alter topic db prec 'us' + +print ============== step status +sql_error alter database db status 'delete' +sql_error alter topic db status 'delete' + +print ============== step drop +sql drop database db +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +print ============== step db1 +sql create database d1 +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi + +sql alter database d1 fsync 0 +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +sql drop database db +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +print ============== step db2 +sql create topic d1 +sql show topics; +if $rows != 1 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi + +sql alter database d1 fsync 0 +sql show topics; +if $rows != 1 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi + +sql drop database db +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +print ============== step db3 +sql create topic d1 +sql show topics; +if $rows != 1 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi + +sql alter topic d1 partitions 2 +sql show topics; +if $rows != 1 then + return -1 +endi + +sql show databases; +if $rows != 1 then + return -1 +endi + +sql drop database db +sql show topics; +if $rows != 0 then + return -1 +endi + +sql show databases; +if $rows != 0 then + return -1 +endi + +print ============== step partitons +sql create partiton t1 partitons 5 + +sql_error alter database t1 partitons -1 +sql_error alter database t1 partitons 0 +sql_error alter database t1 partitons 1 +sql_error alter database t1 partitons 2 +sql_error alter database t1 partitons 3 +sql_error alter database t1 partitons 100 +sql_error alter database t1 partitons 1000 +sql_error alter database t1 partitons 10000 + +sql_error alter topic t1 partitons -1 +sql_error alter topic t1 partitons 0 +sql_error alter database t1 partitons 10000 + +sql alter topic t1 partitons 1 +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 6 then + return -1 +endi +#numofvgroups +sql show t1.vgroups; +if $rows < 6 then + return -1 +endi +sql show t1.stables; +if $rows != 1 then + return -1 +endi +sql show t1.tables; +if $rows < 6 then + return -1 +endi + +sql alter topic t1 partitons 2 +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 6 then + return -1 +endi +#numofvgroups +sql show t1.vgroups; +if $rows < 6 then + return -1 +endi +sql show t1.stables; +if $rows != 1 then + return -1 +endi +sql show t1.tables; +if $rows < 6 then + return -1 +endi + +sql alter topic t1 partitons 3 +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 6 then + return -1 +endi +#numofvgroups +sql show t1.vgroups; +if $rows < 6 then + return -1 +endi +sql show t1.stables; +if $rows != 1 then + return -1 +endi +sql show t1.tables; +if $rows < 6 then + return -1 +endi + +sql alter topic t1 partitons 20 +sql show topics; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +sql show databases; +if $rows != 1 then + return -1 +endi +if $data00 != t1 then + return -1 +endi +#tables +if $data02 != 6 then + return -1 +endi +#numofvgroups +sql show t1.vgroups; +if $rows < 6 then + return -1 +endi +sql show t1.stables; +if $rows != 1 then + return -1 +endi +sql show t1.tables; +if $rows < 6 then + return -1 +endi + + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/db/topic2.sim b/tests/script/general/db/topic2.sim new file mode 100644 index 0000000000000000000000000000000000000000..21f3ada588222eeee84debe1e31029db59c51a75 --- /dev/null +++ b/tests/script/general/db/topic2.sim @@ -0,0 +1,351 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 + +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql connect + +print ==== step1 +sql create topic t1 partitions 2; +sql show t1.tables +if $rows != 2 then + return -1 +endi +if $data00 != p1 then + return -1 +endi +if $data10 != p2 then + return -1 +endi +sql show t1.vgroups +if $rows != 2 then + return -1 +endi + +sql insert into t1.p1 values(now, '1'); +sql insert into t1.p1 values(now, '2'); +sql insert into t1.p1 values(now, '3'); +sql insert into t1.p1 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p1 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p1 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql insert into t1.p2 values(now, '1'); +sql insert into t1.p2 values(now, '2'); +sql insert into t1.p2 values(now, '3'); +sql insert into t1.p2 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p2 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p2 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql_error insert into t1.p3 values(now, '1'); +sql_error insert into t1.p3 values(now, '2'); +sql_error insert into t1.p3 values(now, '3'); +sql_error insert into t1.p3 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql_error insert into t1.p3 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql_error insert into t1.p3 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql select * from t1.p1 order by off desc +if $rows != 21 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql select * from t1.p2 order by off desc +if $rows != 21 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +print ==== step2 +sql alter topic t1 partitions 4; +sql show t1.tables +if $rows != 4 then + return -1 +endi +if $data00 != p1 then + return -1 +endi +if $data10 != p2 then + return -1 +endi +if $data10 != p3 then + return -1 +endi +if $data10 != p4 then + return -1 +endi +sql show t1.vgroups +if $rows != 4 then + return -1 +endi + +sql insert into t1.p1 values(now, '1'); +sql insert into t1.p1 values(now, '2'); +sql insert into t1.p1 values(now, '3'); +sql insert into t1.p1 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p1 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p1 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql insert into t1.p2 values(now, '1'); +sql insert into t1.p2 values(now, '2'); +sql insert into t1.p2 values(now, '3'); +sql insert into t1.p2 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p2 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p2 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql insert into t1.p3 values(now, '1'); +sql insert into t1.p3 values(now, '2'); +sql insert into t1.p3 values(now, '3'); +sql insert into t1.p3 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p3 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p3 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql insert into t1.p4 values(now, '1'); +sql insert into t1.p4 values(now, '2'); +sql insert into t1.p4 values(now, '3'); +sql insert into t1.p4 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p4 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p4 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql_error insert into t1.p5 values(now, '1'); +sql_error insert into t1.p5 values(now, '2'); +sql_error insert into t1.p5 values(now, '3'); +sql_error insert into t1.p5 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql_error insert into t1.p5 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql_error insert into t1.p5 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql select * from t1.p1 order by off desc +if $rows != 42 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql select * from t1.p2 order by off desc +if $rows != 42 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql select * from t1.p3 order by off desc +if $rows != 21 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql select * from t1.p3 order by off desc +if $rows != 21 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +print ==== step3 +sql alter topic t1 partitions 1; +sql show t1.tables +if $rows != 1 then + return -1 +endi +if $data00 != p1 then + return -1 +endi +sql show t1.vgroups +if $rows != 1 then + return -1 +endi + +sql insert into t1.p1 values(now, '1'); +sql insert into t1.p1 values(now, '2'); +sql insert into t1.p1 values(now, '3'); +sql insert into t1.p1 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p1 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p1 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql_error insert into t1.p2 values(now, '1'); +sql_error insert into t1.p2 values(now, '2'); +sql_error insert into t1.p2 values(now, '3'); +sql_error insert into t1.p2 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql_error insert into t1.p2 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql_error insert into t1.p2 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql_error insert into t1.p3 values(now, '1'); +sql_error insert into t1.p3 values(now, '2'); +sql_error insert into t1.p3 values(now, '3'); +sql_error insert into t1.p3 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql_error insert into t1.p3 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql_error insert into t1.p3 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql_error insert into t1.p4 values(now, '1'); +sql_error insert into t1.p4 values(now, '2'); +sql_error insert into t1.p4 values(now, '3'); +sql_error insert into t1.p4 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql_error insert into t1.p4 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql_error insert into t1.p4 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql_error insert into t1.p5 values(now, '1'); +sql_error insert into t1.p5 values(now, '2'); +sql_error insert into t1.p5 values(now, '3'); +sql_error insert into t1.p5 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql_error insert into t1.p5 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql_error insert into t1.p5 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql select * from t1.p1 order by off desc +if $rows != 63 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql_error select * from t1.p2 order by off desc +sql_error select * from t1.p3 order by off desc +sql_error select * from t1.p4 order by off desc + +print ==== step4 +sql alter topic t1 partitions 3; +sql show t1.tables +if $rows != 3 then + return -1 +endi +if $data00 != p1 then + return -1 +endi +if $data00 != p2 then + return -1 +endi +if $data00 != p3 then + return -1 +endi +sql show t1.vgroups +if $rows != 3 then + return -1 +endi + +sql insert into t1.p1 values(now, '1'); +sql insert into t1.p1 values(now, '2'); +sql insert into t1.p1 values(now, '3'); +sql insert into t1.p1 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p1 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p1 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql insert into t1.p2 values(now, '1'); +sql insert into t1.p2 values(now, '2'); +sql insert into t1.p2 values(now, '3'); +sql insert into t1.p2 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p2 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p2 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql insert into t1.p3 values(now, '1'); +sql insert into t1.p3 values(now, '2'); +sql insert into t1.p3 values(now, '3'); +sql insert into t1.p3 values(now, '4')(now, '5')(now, '6')(now, '7')(now, '8')(now, '9'); +sql insert into t1.p3 values(now, '14')(now, '15')(now, '16')(now, '17')(now, '18')(now, '19'); +sql insert into t1.p3 values(now, '24')(now, '25')(now, '16')(now, '17')(now, '18')(now, '19'); + +sql insert into t1.p4 values(now, '1'); +sql insert into t1.p5 values(now, '1'); +sql insert into t1.p6 values(now, '1'); +sql_error select * from t1.p4 order by off desc +sql_error select * from t1.p5 order by off desc +sql_error select * from t1.p6 order by off desc + +sql select * from t1.p1 order by off desc +if $rows != 84 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql select * from t1.p1 order by off desc +if $rows != 21 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql select * from t1.p1 order by off desc +if $rows != 21 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi + +sql select * from t1.ps order by off desc +if $rows != 126 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT