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

This commit is contained in:
Xiaoyu Wang 2022-07-16 14:22:30 +08:00
parent 7c585d8ed9
commit 299e117d38
6 changed files with 47 additions and 41 deletions

View File

@ -15,10 +15,10 @@
#include "command.h"
#include "catalog.h"
#include "tdatablock.h"
#include "tglobal.h"
#include "commandInt.h"
#include "scheduler.h"
#include "tdatablock.h"
#include "tglobal.h"
extern SConfig* tsCfg;
@ -222,7 +222,7 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbFName, S
char* retentions = buildRetension(pCfg->pRetensions);
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 "
"STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d",
dbFName, pCfg->buffer, pCfg->cacheLast, pCfg->compression, pCfg->daysPerFile, pCfg->fsyncPeriod,
@ -483,7 +483,7 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableR
static int32_t execAlterCmd(char* cmd, char* value, bool* processed) {
int32_t code = 0;
if (0 == strcasecmp(cmd, COMMAND_RESET_LOG)) {
taosResetLog();
cfgDumpCfg(tsCfg, 0, false);
@ -502,13 +502,13 @@ _return:
if (code) {
terrno = code;
}
return code;
return code;
}
static int32_t execAlterLocal(SAlterLocalStmt* pStmt) {
bool processed = false;
if (execAlterCmd(pStmt->config, pStmt->value, &processed)) {
return terrno;
}
@ -516,7 +516,7 @@ static int32_t execAlterLocal(SAlterLocalStmt* pStmt) {
if (processed) {
goto _return;
}
if (cfgSetItem(tsCfg, pStmt->config, pStmt->value, CFG_STYPE_ALTER_CMD)) {
return terrno;
}

View File

@ -54,7 +54,7 @@ TAOS_KEYWORDS = [
"BOOL", "EQ", "LINEAR", "RESET", "TSERIES",
"BY", "EXISTS", "LOCAL", "RESTRICT", "UMINUS",
"CACHE", "EXPLAIN", "LP", "ROW", "UNION",
"CACHELAST", "FAIL", "LSHIFT", "RP", "UNSIGNED",
"CACHEMODEL", "FAIL", "LSHIFT", "RP", "UNSIGNED",
"CASCADE", "FILE", "LT", "RSHIFT", "UPDATE",
"CHANGE", "FILL", "MATCH", "SCORES", "UPLUS",
"CLUSTER", "FLOAT", "MAXROWS", "SELECT", "USE",

View File

@ -40,13 +40,13 @@ print ============= create database
#database_option: {
# | BUFFER value [3~16384, default: 96]
# | 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]
# | KEEP value [duration, 365000]
# | REPLICA value [1 | 3]
# | 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
print rows: $rows
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
@ -102,7 +102,7 @@ endi
if $data15_db != 0 then # comp
return -1
endi
if $data16_db != 3 then # cachelast
if $data16_db != both then # cachelast
return -1
endi
if $data17_db != ns then # precision
@ -336,37 +336,37 @@ print ============== modify cachelast [0, 1, 2, 3]
sql alter database db cachemodel 'last_value'
sql show databases
print cachelast $data16_db
if $data16_db != 2 then
if $data16_db != last_value then
return -1
endi
sql alter database db cachemodel 'last_row'
sql show databases
print cachelast $data16_db
if $data16_db != 1 then
if $data16_db != last_row then
return -1
endi
sql alter database db cachemodel 'none'
sql show databases
print cachelast $data16_db
if $data16_db != 0 then
if $data16_db != none then
return -1
endi
sql alter database db cachemodel 'last_value'
sql show databases
print cachelast $data16_db
if $data16_db != 2 then
if $data16_db != last_value then
return -1
endi
sql alter database db cachemodel 'both'
sql show databases
print cachelast $data16_db
if $data16_db != 3 then
if $data16_db != both then
return -1
endi
sql_error alter database db cachelast 4
sql_error alter database db cachelast 10
sql_error alter database db cachelast -1
sql_error alter database db cachelast 'other'
print ============== modify precision
sql_error alter database db precision 'ms'

View File

@ -40,7 +40,7 @@ print ============= create database with all options
# | BUFFER value [3~16384, default: 96]
# | PAGES value [64~16384, default: 256]
# | 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]
# | DURATION value [60m ~ min(3650d,keep), default: 10d, unit may be minut/hour/day]
# | FSYNC value [0 ~ 180000 ms, default: 3000]
@ -122,7 +122,7 @@ endi
if $data15_db != 2 then # comp
return -1
endi
if $data16_db != 0 then # cachelast
if $data16_db != none then # cachelast
return -1
endi
if $data17_db != ms then # precision
@ -167,32 +167,32 @@ sql drop database db
#endi
#sql drop database db
print ====> CACHELAST value [0, 1, 2, 3, default: 0]
sql create database db CACHELAST 1
print ====> CACHEMODEL value [0, 1, 2, 3, default: 0]
sql create database db CACHEMODEL 'last_row'
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
if $data16_db != 1 then
if $data16_db != last_row then
return -1
endi
sql drop database db
sql create database db CACHELAST 2
sql create database db CACHEMODEL 'last_value'
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
if $data16_db != 2 then
if $data16_db != last_value then
return -1
endi
sql drop database db
sql create database db CACHELAST 3
sql create database db CACHEMODEL 'both'
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
if $data16_db != 3 then
if $data16_db != both then
return -1
endi
sql drop database db
sql_error create database db CACHELAST 4
sql_error create database db CACHELAST -1
sql_error create database db CACHEMODEL 'other'
sql_error create database db CACHEMODEL '-1'
print ====> COMP [0 | 1 | 2, default: 2]
sql create database db COMP 1

View File

@ -36,22 +36,31 @@ class TDTestCase:
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:
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]
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):
for i in range(4):
tdSql.execute("create database test_db_%d replica 1 cachelast %d " %(i,i))
tdSql.execute("use test_db_%d"%i)
str = self.getCacheModelStr(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 table tb1 using st tags(1) ")
tdSql.execute("create table tb2 using st tags(2) ")
@ -81,10 +90,10 @@ class TDTestCase:
# cache_last_set value
for k , v in cache_lasts.items():
if k.split("_")[-1]==str(v):
tdLog.info(" database %s cache_last value check pass, value is %d "%(k,v) )
if k=="testdb_"+str(v):
tdLog.info(" database %s cache_last value check pass, value is %s "%(k,v) )
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
@ -132,13 +141,10 @@ class TDTestCase:
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
self.illegal_params()
self.prepare_datas()
self.check_cache_last_sets()
self.restart_check_cache_last_sets()
def stop(self):
tdSql.close()

View File

@ -123,7 +123,7 @@ class TDTestCase:
tdSql.query('show databases;')
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.query('show databases;')
# tdSql.checkData(2,5,'strict')