提交 299e117d 编写于 作者: X Xiaoyu Wang

fix: database options 'strict' and 'cachelast' syntax adjustments

上级 7c585d8e
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
#include "command.h" #include "command.h"
#include "catalog.h" #include "catalog.h"
#include "tdatablock.h"
#include "tglobal.h"
#include "commandInt.h" #include "commandInt.h"
#include "scheduler.h" #include "scheduler.h"
#include "tdatablock.h"
#include "tglobal.h"
extern SConfig* tsCfg; extern SConfig* tsCfg;
...@@ -222,7 +222,7 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, S ...@@ -222,7 +222,7 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, S
char* retentions = buildRetension(pCfg->pRetensions); char* retentions = buildRetension(pCfg->pRetensions);
len += sprintf(buf2 + VARSTR_HEADER_SIZE, len += sprintf(buf2 + VARSTR_HEADER_SIZE,
"CREATE DATABASE `%s` BUFFER %d CACHELAST %d COMP %d DURATION %dm " "CREATE DATABASE `%s` BUFFER %d CACHEMODEL %d COMP %d DURATION %dm "
"FSYNC %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d " "FSYNC %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d "
"STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d", "STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d",
dbFName, pCfg->buffer, pCfg->cacheLast, pCfg->compression, pCfg->daysPerFile, pCfg->fsyncPeriod, dbFName, pCfg->buffer, pCfg->cacheLast, pCfg->compression, pCfg->daysPerFile, pCfg->fsyncPeriod,
...@@ -483,7 +483,7 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableR ...@@ -483,7 +483,7 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableR
static int32_t execAlterCmd(char* cmd, char* value, bool* processed) { static int32_t execAlterCmd(char* cmd, char* value, bool* processed) {
int32_t code = 0; int32_t code = 0;
if (0 == strcasecmp(cmd, COMMAND_RESET_LOG)) { if (0 == strcasecmp(cmd, COMMAND_RESET_LOG)) {
taosResetLog(); taosResetLog();
cfgDumpCfg(tsCfg, 0, false); cfgDumpCfg(tsCfg, 0, false);
...@@ -502,13 +502,13 @@ _return: ...@@ -502,13 +502,13 @@ _return:
if (code) { if (code) {
terrno = code; terrno = code;
} }
return code; return code;
} }
static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { static int32_t execAlterLocal(SAlterLocalStmt* pStmt) {
bool processed = false; bool processed = false;
if (execAlterCmd(pStmt->config, pStmt->value, &processed)) { if (execAlterCmd(pStmt->config, pStmt->value, &processed)) {
return terrno; return terrno;
} }
...@@ -516,7 +516,7 @@ static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { ...@@ -516,7 +516,7 @@ static int32_t execAlterLocal(SAlterLocalStmt* pStmt) {
if (processed) { if (processed) {
goto _return; goto _return;
} }
if (cfgSetItem(tsCfg, pStmt->config, pStmt->value, CFG_STYPE_ALTER_CMD)) { if (cfgSetItem(tsCfg, pStmt->config, pStmt->value, CFG_STYPE_ALTER_CMD)) {
return terrno; return terrno;
} }
......
...@@ -54,7 +54,7 @@ TAOS_KEYWORDS = [ ...@@ -54,7 +54,7 @@ TAOS_KEYWORDS = [
"BOOL", "EQ", "LINEAR", "RESET", "TSERIES", "BOOL", "EQ", "LINEAR", "RESET", "TSERIES",
"BY", "EXISTS", "LOCAL", "RESTRICT", "UMINUS", "BY", "EXISTS", "LOCAL", "RESTRICT", "UMINUS",
"CACHE", "EXPLAIN", "LP", "ROW", "UNION", "CACHE", "EXPLAIN", "LP", "ROW", "UNION",
"CACHELAST", "FAIL", "LSHIFT", "RP", "UNSIGNED", "CACHEMODEL", "FAIL", "LSHIFT", "RP", "UNSIGNED",
"CASCADE", "FILE", "LT", "RSHIFT", "UPDATE", "CASCADE", "FILE", "LT", "RSHIFT", "UPDATE",
"CHANGE", "FILL", "MATCH", "SCORES", "UPLUS", "CHANGE", "FILL", "MATCH", "SCORES", "UPLUS",
"CLUSTER", "FLOAT", "MAXROWS", "SELECT", "USE", "CLUSTER", "FLOAT", "MAXROWS", "SELECT", "USE",
......
...@@ -40,13 +40,13 @@ print ============= create database ...@@ -40,13 +40,13 @@ print ============= create database
#database_option: { #database_option: {
# | BUFFER value [3~16384, default: 96] # | BUFFER value [3~16384, default: 96]
# | PAGES value [64~16384, default: 256] # | PAGES value [64~16384, default: 256]
# | CACHELAST value [0, 1, 2, 3] # | CACHEMODEL value ['node', 'last_row', 'last_value', 'both']
# | FSYNC value [0 ~ 180000 ms] # | FSYNC value [0 ~ 180000 ms]
# | KEEP value [duration, 365000] # | KEEP value [duration, 365000]
# | REPLICA value [1 | 3] # | REPLICA value [1 | 3]
# | WAL value [1 | 2] # | WAL value [1 | 2]
sql create database db CACHELAST 3 COMP 0 DURATION 240 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1000 PRECISION 'ns' REPLICA 3 WAL 2 VGROUPS 6 SINGLE_STABLE 1 sql create database db CACHEMODEL 'both' COMP 0 DURATION 240 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1000 PRECISION 'ns' REPLICA 3 WAL 2 VGROUPS 6 SINGLE_STABLE 1
sql show databases sql show databases
print rows: $rows print rows: $rows
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
...@@ -102,7 +102,7 @@ endi ...@@ -102,7 +102,7 @@ endi
if $data15_db != 0 then # comp if $data15_db != 0 then # comp
return -1 return -1
endi endi
if $data16_db != 3 then # cachelast if $data16_db != both then # cachelast
return -1 return -1
endi endi
if $data17_db != ns then # precision if $data17_db != ns then # precision
...@@ -336,37 +336,37 @@ print ============== modify cachelast [0, 1, 2, 3] ...@@ -336,37 +336,37 @@ print ============== modify cachelast [0, 1, 2, 3]
sql alter database db cachemodel 'last_value' sql alter database db cachemodel 'last_value'
sql show databases sql show databases
print cachelast $data16_db print cachelast $data16_db
if $data16_db != 2 then if $data16_db != last_value then
return -1 return -1
endi endi
sql alter database db cachemodel 'last_row' sql alter database db cachemodel 'last_row'
sql show databases sql show databases
print cachelast $data16_db print cachelast $data16_db
if $data16_db != 1 then if $data16_db != last_row then
return -1 return -1
endi endi
sql alter database db cachemodel 'none' sql alter database db cachemodel 'none'
sql show databases sql show databases
print cachelast $data16_db print cachelast $data16_db
if $data16_db != 0 then if $data16_db != none then
return -1 return -1
endi endi
sql alter database db cachemodel 'last_value' sql alter database db cachemodel 'last_value'
sql show databases sql show databases
print cachelast $data16_db print cachelast $data16_db
if $data16_db != 2 then if $data16_db != last_value then
return -1 return -1
endi endi
sql alter database db cachemodel 'both' sql alter database db cachemodel 'both'
sql show databases sql show databases
print cachelast $data16_db print cachelast $data16_db
if $data16_db != 3 then if $data16_db != both then
return -1 return -1
endi endi
sql_error alter database db cachelast 4 sql_error alter database db cachelast 4
sql_error alter database db cachelast 10 sql_error alter database db cachelast 10
sql_error alter database db cachelast -1 sql_error alter database db cachelast 'other'
print ============== modify precision print ============== modify precision
sql_error alter database db precision 'ms' sql_error alter database db precision 'ms'
......
...@@ -40,7 +40,7 @@ print ============= create database with all options ...@@ -40,7 +40,7 @@ print ============= create database with all options
# | BUFFER value [3~16384, default: 96] # | BUFFER value [3~16384, default: 96]
# | PAGES value [64~16384, default: 256] # | PAGES value [64~16384, default: 256]
# | PAGESIZE value [1~16384, default: 4] # | PAGESIZE value [1~16384, default: 4]
# | CACHELAST value [0, 1, 2, 3, default: 0] # | CACHEMODEL value ['node', 'last_row', 'last_value', 'both', default: 'node']
# | COMP [0 | 1 | 2, default: 2] # | COMP [0 | 1 | 2, default: 2]
# | DURATION value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day] # | DURATION value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day]
# | FSYNC value [0 ~ 180000 ms, default: 3000] # | FSYNC value [0 ~ 180000 ms, default: 3000]
...@@ -122,7 +122,7 @@ endi ...@@ -122,7 +122,7 @@ endi
if $data15_db != 2 then # comp if $data15_db != 2 then # comp
return -1 return -1
endi endi
if $data16_db != 0 then # cachelast if $data16_db != none then # cachelast
return -1 return -1
endi endi
if $data17_db != ms then # precision if $data17_db != ms then # precision
...@@ -167,32 +167,32 @@ sql drop database db ...@@ -167,32 +167,32 @@ sql drop database db
#endi #endi
#sql drop database db #sql drop database db
print ====> CACHELAST value [0, 1, 2, 3, default: 0] print ====> CACHEMODEL value [0, 1, 2, 3, default: 0]
sql create database db CACHELAST 1 sql create database db CACHEMODEL 'last_row'
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data16_db != 1 then if $data16_db != last_row then
return -1 return -1
endi endi
sql drop database db sql drop database db
sql create database db CACHELAST 2 sql create database db CACHEMODEL 'last_value'
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data16_db != 2 then if $data16_db != last_value then
return -1 return -1
endi endi
sql drop database db sql drop database db
sql create database db CACHELAST 3 sql create database db CACHEMODEL 'both'
sql show databases sql show databases
print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db print $data0_db $data1_db $data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $data16_db != 3 then if $data16_db != both then
return -1 return -1
endi endi
sql drop database db sql drop database db
sql_error create database db CACHELAST 4 sql_error create database db CACHEMODEL 'other'
sql_error create database db CACHELAST -1 sql_error create database db CACHEMODEL '-1'
print ====> COMP [0 | 1 | 2, default: 2] print ====> COMP [0 | 1 | 2, default: 2]
sql create database db COMP 1 sql create database db COMP 1
......
...@@ -36,22 +36,31 @@ class TDTestCase: ...@@ -36,22 +36,31 @@ class TDTestCase:
def illegal_params(self): def illegal_params(self):
illegal_params = ["1","0","NULL","None","False","True" ,"keep","now" ,"*" , "," ,"_" , "abc" ,"keep"] illegal_params = ["1","0","NULL","False","True" ,"keep","now" ,"*" , "," ,"_" , "abc" ,"keep"]
for value in illegal_params: for value in illegal_params:
tdSql.error("create database testdb replica 1 cachelast '%s' " %value) tdSql.error("create database testdb replica 1 cachemodel '%s' " %value)
unexpected_numbers = [-1 , 0.0 , 3.0 , 4, 10 , 100] unexpected_numbers = [-1 , 0.0 , 3.0 , 4, 10 , 100]
for number in unexpected_numbers: for number in unexpected_numbers:
tdSql.error("create database testdb replica 1 cachelast %s " %number) tdSql.error("create database testdb replica 1 cachemodel %s " %number)
def getCacheModelStr(self, value):
numbers = {
0 : "none",
1 : "last_row",
2 : "last_value",
3 : "both"
}
return numbers.get(value, 'other')
def prepare_datas(self): def prepare_datas(self):
for i in range(4): for i in range(4):
tdSql.execute("create database test_db_%d replica 1 cachelast %d " %(i,i)) str = self.getCacheModelStr(i)
tdSql.execute("use test_db_%d"%i) tdSql.execute("create database testdb_%s replica 1 cachemodel '%s' " %(str, str))
tdSql.execute("use testdb_%s"%str)
tdSql.execute("create stable st(ts timestamp , c1 int ,c2 float ) tags(ind int) ") tdSql.execute("create stable st(ts timestamp , c1 int ,c2 float ) tags(ind int) ")
tdSql.execute("create table tb1 using st tags(1) ") tdSql.execute("create table tb1 using st tags(1) ")
tdSql.execute("create table tb2 using st tags(2) ") tdSql.execute("create table tb2 using st tags(2) ")
...@@ -81,10 +90,10 @@ class TDTestCase: ...@@ -81,10 +90,10 @@ class TDTestCase:
# cache_last_set value # cache_last_set value
for k , v in cache_lasts.items(): for k , v in cache_lasts.items():
if k.split("_")[-1]==str(v): if k=="testdb_"+str(v):
tdLog.info(" database %s cache_last value check pass, value is %d "%(k,v) ) tdLog.info(" database %s cache_last value check pass, value is %s "%(k,v) )
else: else:
tdLog.exit(" database %s cache_last value check fail, value is %d "%(k,v) ) tdLog.exit(" database %s cache_last value check fail, value is %s "%(k,v) )
# # check storage layer implementation # # check storage layer implementation
...@@ -132,13 +141,10 @@ class TDTestCase: ...@@ -132,13 +141,10 @@ class TDTestCase:
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
self.illegal_params() self.illegal_params()
self.prepare_datas() self.prepare_datas()
self.check_cache_last_sets() self.check_cache_last_sets()
self.restart_check_cache_last_sets() self.restart_check_cache_last_sets()
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -123,7 +123,7 @@ class TDTestCase: ...@@ -123,7 +123,7 @@ class TDTestCase:
tdSql.query('show databases;') tdSql.query('show databases;')
tdSql.checkData(2,5,'off') tdSql.checkData(2,5,'off')
tdSql.error('alter database db strict 'off'') tdSql.error("alter database db strict 'off'")
# tdSql.execute('alter database db strict 'on'') # tdSql.execute('alter database db strict 'on'')
# tdSql.query('show databases;') # tdSql.query('show databases;')
# tdSql.checkData(2,5,'strict') # tdSql.checkData(2,5,'strict')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册