feat: encryption algorithm

This commit is contained in:
kailixu 2024-04-01 13:58:13 +08:00
parent 9e4d692d6b
commit 6eaa99bb2d
15 changed files with 3423 additions and 2784 deletions

View File

@ -299,11 +299,11 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
//if(req.encryptAlgorithm == DND_CA_SM4){
if(strlen(tsEncryptKey) == 0){
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
dError("vgId:%d, failed to create vnode since encrypt key is empty", req.vgId);
return -1;
}
// if(strlen(tsEncryptKey) == 0){
// terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
// dError("vgId:%d, failed to create vnode since encrypt key is empty", req.vgId);
// return -1;
// }
//}
vmGenerateVnodeCfg(&req, &vnodeCfg);

View File

@ -477,16 +477,16 @@ static int32_t mndInitWal(SMnode *pMnode) {
};
#if defined(TD_ENTERPRISE)
if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_MNODE_WAL) == DND_CS_MNODE_WAL){
cfg.encryptAlgorithm = (tsiEncryptScope & DND_CS_MNODE_WAL)? tsiEncryptAlgorithm : 0;
if(tsEncryptKey[0] == '\0'){
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
return -1;
}
else{
strncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
}
}
// if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_MNODE_WAL) == DND_CS_MNODE_WAL){
// cfg.encryptAlgorithm = (tsiEncryptScope & DND_CS_MNODE_WAL)? tsiEncryptAlgorithm : 0;
// if(tsEncryptKey[0] == '\0'){
// terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
// return -1;
// }
// else{
// strncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
// }
// }
#endif
pMnode->pWal = walOpen(path, &cfg);

View File

@ -246,15 +246,15 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
tjsonGetNumberValue(pJson, "tsdb.encryptAlgorithm", pCfg->tsdbCfg.encryptAlgorithm, code);
if (code < 0) return -1;
#if defined(TD_ENTERPRISE)
if(pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4){
if(tsEncryptKey[0] == 0){
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
return -1;
}
else{
strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
}
}
// if(pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4){
// if(tsEncryptKey[0] == 0){
// terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
// return -1;
// }
// else{
// strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
// }
// }
#endif
tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId, code);
if (code < 0) return -1;
@ -273,28 +273,28 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
tjsonGetNumberValue(pJson, "wal.encryptAlgorithm", pCfg->walCfg.encryptAlgorithm, code);
if (code < 0) return -1;
#if defined(TD_ENTERPRISE)
if(pCfg->walCfg.encryptAlgorithm == DND_CA_SM4){
if(tsEncryptKey[0] == 0){
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
return -1;
}
else{
strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
}
}
// if(pCfg->walCfg.encryptAlgorithm == DND_CA_SM4){
// if(tsEncryptKey[0] == 0){
// terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
// return -1;
// }
// else{
// strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
// }
// }
#endif
tjsonGetNumberValue(pJson, "tdbEncryptAlgorithm", pCfg->tdbEncryptAlgorithm, code);
if (code < 0) return -1;
#if defined(TD_ENTERPRISE)
if(pCfg->tdbEncryptAlgorithm == DND_CA_SM4){
if(tsEncryptKey[0] == 0){
terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
return -1;
}
else{
strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
}
}
// if(pCfg->tdbEncryptAlgorithm == DND_CA_SM4){
// if(tsEncryptKey[0] == 0){
// terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
// return -1;
// }
// else{
// strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
// }
// }
#endif
tjsonGetNumberValue(pJson, "sstTrigger", pCfg->sttTrigger, code);
if (code < 0) pCfg->sttTrigger = TSDB_DEFAULT_SST_TRIGGER;

View File

@ -296,6 +296,7 @@ alter_db_option(A) ::= WAL_RETENTION_SIZE NK_MINUS(B) NK_INTEGER(C).
A.type = DB_OPTION_WAL_RETENTION_SIZE; A.val = t;
}
alter_db_option(A) ::= KEEP_TIME_OFFSET NK_INTEGER(B). { A.type = DB_OPTION_KEEP_TIME_OFFSET; A.val = B; }
alter_db_option(A) ::= ENCRYPT_ALGORITHM NK_STRING(B). { A.type = DB_OPTION_ENCRYPT_ALGORITHM; A.val = B; }
%type integer_list { SNodeList* }
%destructor integer_list { nodesDestroyList($$); }
@ -753,16 +754,52 @@ insert_query(A) ::= INSERT INTO full_table_name(C) query_or_subquery(B).
/************************************************ tags_literal *************************************************************/
tags_literal(A) ::= NK_INTEGER(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); }
tags_literal(A) ::= NK_INTEGER(B) NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_INTEGER(B) NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_PLUS(B) NK_INTEGER(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_PLUS(B) NK_INTEGER NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_PLUS(B) NK_INTEGER NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_MINUS(B) NK_INTEGER(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_MINUS(B) NK_INTEGER NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_MINUS(B) NK_INTEGER NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_FLOAT(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B, NULL); }
tags_literal(A) ::= NK_PLUS(B) NK_FLOAT(C). {
SToken t = B;
@ -776,29 +813,113 @@ tags_literal(A) ::= NK_MINUS(B) NK_FLOAT(C).
}
tags_literal(A) ::= NK_BIN(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); }
tags_literal(A) ::= NK_BIN(B) NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_BIN(B) NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_PLUS(B) NK_BIN(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_PLUS(B) NK_BIN NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_PLUS(B) NK_BIN NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_MINUS(B) NK_BIN(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_MINUS(B) NK_BIN NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_MINUS(B) NK_BIN NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_HEX(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); }
tags_literal(A) ::= NK_HEX(B) NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_HEX(B) NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_PLUS(B) NK_HEX(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_PLUS(B) NK_HEX NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_PLUS(B) NK_HEX NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_MINUS(B) NK_HEX(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL);
}
tags_literal(A) ::= NK_MINUS(B) NK_HEX NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_MINUS(B) NK_HEX NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_STRING(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B, NULL); }
tags_literal(A) ::= NK_STRING(B) NK_PLUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_STRING(B) NK_MINUS duration_literal(C). {
SToken l = B;
SToken r = getTokenFromRawExprNode(pCxt, C);
l.n = (r.z + r.n) - l.z;
A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, C);
}
tags_literal(A) ::= NK_BOOL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B, NULL); }
tags_literal(A) ::= NULL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &B, NULL); }

View File

@ -1301,6 +1301,7 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) {
pOptions->tablePrefix = -1;
pOptions->tableSuffix = -1;
pOptions->withArbitrator = -1;
pOptions->encryptAlgorithm = -1;
return (SNode*)pOptions;
}
@ -1421,6 +1422,7 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED
break;
case DB_OPTION_ENCRYPT_ALGORITHM:
COPY_STRING_FORM_STR_TOKEN(pDbOptions->encryptAlgorithmStr, (SToken*)pVal);
pDbOptions->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
break;
}
default:

View File

@ -5799,6 +5799,11 @@ static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStm
return code;
}
if (pStmt->pOptions->encryptAlgorithm != -1) {
code = TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE;
return code;
}
SAlterDbReq alterReq = {0};
buildAlterDbReq(pCxt, pStmt, &alterReq);

File diff suppressed because it is too large Load Diff

View File

@ -243,7 +243,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_OPTION_UNCHANGED, "Database options not
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_INDEX_NOT_EXIST, "Index not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SYS_TABLENAME, "Invalid system table name")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_IN_CREATING, "Database in creating status")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE, "encryption is not allowed to be changed after database is created.")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_ENCRYPT_NOT_ALLOW_CHANGE, "Encryption is not allowed to be changed after database is created")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INCONSIST_ENCRYPT_KEY, "Inconsistent encryption key")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ENCRYPT_KEY, "The cluster has not been set properly for database encryption")

View File

@ -936,6 +936,9 @@ sql_error alter table st_bool_i1 set tag tagname="123abc"
sql alter table st_bool_i2 set tag tagname="123"
sql_error alter table st_bool_i3 set tag tagname=abc
sql_error alter table st_bool_i4 set tag tagname="abc"
sql_error alter table st_bool_i4 set tag tagname=now
sql_error alter table st_bool_i4 set tag tagname=now()+1d
sql_error alter table st_bool_i4 set tag tagname=1+1d
sql_error alter table st_bool_i5 set tag tagname=" "
sql_error alter table st_bool_i6 set tag tagname=''

View File

@ -913,6 +913,8 @@ sql_error alter table st_int_e19 set tag tagname=123abc
sql_error alter table st_int_e20 set tag tagname="123abc"
sql_error alter table st_int_e22 set tag tagname=abc
sql_error alter table st_int_e23 set tag tagname="abc"
sql_error alter table st_int_e25 set tag tagname=1+1d
sql_error alter table st_int_e25 set tag tagname="1"+1d
sql_error alter table st_int_e24 set tag tagname=" "
sql_error alter table st_int_e25 set tag tagname=''
sql alter table st_int_e26_1 set tag tagname='123'

View File

@ -132,6 +132,77 @@ sql show tags from st_timestamp_22
if $data05 != -1 then
return -1
endi
sql create table st_timestamp_23 using mt_timestamp tags (1+ 1d )
sql show tags from st_timestamp_23
if $data05 != 86400001 then
return -1
endi
sql create table st_timestamp_24 using mt_timestamp tags (-0 + 1d)
sql show tags from st_timestamp_24
if $data05 != 86400000 then
return -1
endi
sql create table st_timestamp_25 using mt_timestamp tags ("-0" -1s)
sql show tags from st_timestamp_25
if $data05 != -1000 then
return -1
endi
sql create table st_timestamp_26 using mt_timestamp tags (0b01 -1a)
sql show tags from st_timestamp_26
if $data05 != 0 then
return -1
endi
sql create table st_timestamp_27 using mt_timestamp tags (0b01 -1s)
sql show tags from st_timestamp_27
if $data05 != -999 then
return -1
endi
sql create table st_timestamp_28 using mt_timestamp tags ("0x01" +1u)
sql show tags from st_timestamp_28
if $data05 != 1 then
return -1
endi
sql create table st_timestamp_29 using mt_timestamp tags (0x01 +1b)
sql show tags from st_timestamp_29
if $data05 != 1 then
return -1
endi
sql create table st_timestamp_30 using mt_timestamp tags (-0b00 -0a)
sql show tags from st_timestamp_30
if $data05 != 0 then
return -1
endi
sql create table st_timestamp_31 using mt_timestamp tags ("-0x00" +1u)
sql show tags from st_timestamp_31
if $data05 != 0 then
return -1
endi
sql create table st_timestamp_32 using mt_timestamp tags (-0x00 +1b)
sql show tags from st_timestamp_32
if $data05 != 0 then
return -1
endi
sql create table st_timestamp_33 using mt_timestamp tags (now +1b)
sql show tags from st_timestamp_33
if $data05 < 1711883186000 then
return -1
endi
sql create table st_timestamp_34 using mt_timestamp tags ("now()" +1b)
sql show tags from st_timestamp_34
if $data05 < 1711883186000 then
return -1
endi
sql create table st_timestamp_35 using mt_timestamp tags (today() +1d)
sql show tags from st_timestamp_35
if $data05 < 1711883186000 then
return -1
endi
sql create table st_timestamp_36 using mt_timestamp tags ("today()" +1d)
sql show tags from st_timestamp_36
if $data05 < 1711883186000 then
return -1
endi
## case 01: insert values for test column values
sql insert into st_timestamp_0 values(now,NULL)
@ -249,6 +320,76 @@ sql select ts, cast(c as bigint) from st_timestamp_22
if $data01 != -1 then
return -1
endi
sql insert into st_timestamp_23 values(now,1+ 1d )
sql select ts, cast(c as bigint) from st_timestamp_23
if $data01 != 86400001 then
return -1
endi
sql insert into st_timestamp_24 values(now,-0 + 1d)
sql select ts, cast(c as bigint) from st_timestamp_24
if $data01 != 86400000 then
return -1
endi
sql insert into st_timestamp_25 values(now,"-0" -1s)
sql select ts, cast(c as bigint) from st_timestamp_25
if $data01 != -1000 then
return -1
endi
sql insert into st_timestamp_26 values(now,0b01 -1a)
sql select ts, cast(c as bigint) from st_timestamp_26
if $data01 != 0 then
return -1
endi
sql insert into st_timestamp_27 values(now,+0b01 -1s)
sql select ts, cast(c as bigint) from st_timestamp_27
if $data01 != -999 then
return -1
endi
sql insert into st_timestamp_28 values(now,"+0x01" +1u)
sql select ts, cast(c as bigint) from st_timestamp_28
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_29 values(now,0x01 +1b)
sql select ts, cast(c as bigint) from st_timestamp_29
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_30 values(now,-0b00 -0a)
sql show tags from st_timestamp_30
if $data05 != 0 then
return -1
endi
sql insert into st_timestamp_31 values(now,"-0x00" +1u)
sql show tags from st_timestamp_31
if $data05 != 0 then
return -1
endi
sql insert into st_timestamp_32 values (now,-0x00 +1b)
sql show tags from st_timestamp_32
if $data05 != 0 then
return -1
endi
sql insert into st_timestamp_33 values(now,now +1b)
sql select ts, cast(c as bigint) from st_timestamp_33
if $data01 < 1711883186000 then
return -1
endi
sql insert into st_timestamp_34 values(now,"now()" +1b)
sql select ts, cast(c as bigint) from st_timestamp_34
if $data01 < 1711883186000 then
return -1
endi
sql insert into st_timestamp_35 values(now,today() +1d)
sql select ts, cast(c as bigint) from st_timestamp_35
if $data01 < 1711883186000 then
return -1
endi
sql insert into st_timestamp_36 values(now,"today()" +1d)
sql select ts, cast(c as bigint) from st_timestamp_36
if $data01 < 1711883186000 then
return -1
endi
## case 02: dynamic create table for test tag values
sql insert into st_timestamp_100 using mt_timestamp tags(NULL) values(now, NULL)
@ -450,6 +591,136 @@ sql select ts, cast(c as bigint) from st_timestamp_1022
if $data01 != -1 then
return -1
endi
sql insert into st_timestamp_1023 using mt_timestamp tags(+1+1d) values(now,+1+ 1d )
sql show tags from st_timestamp_1023
if $data05 != 86400001 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1023
if $data01 != 86400001 then
return -1
endi
sql insert into st_timestamp_1024 using mt_timestamp tags(-0+1d) values(now,-0 + 1d)
sql show tags from st_timestamp_1024
if $data05 != 86400000 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1024
if $data01 != 86400000 then
return -1
endi
sql insert into st_timestamp_1025 using mt_timestamp tags("-0" -1s) values(now,"-0" -1s)
sql show tags from st_timestamp_1025
if $data05 != -1000 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1025
if $data01 != -1000 then
return -1
endi
sql insert into st_timestamp_1026 using mt_timestamp tags(+0b01-1a) values(now,+0b01 -1a)
sql show tags from st_timestamp_1026
if $data05 != 0 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1026
if $data01 != 0 then
return -1
endi
sql insert into st_timestamp_1027 using mt_timestamp tags(0b01-1s) values(now,0b01 -1s)
sql show tags from st_timestamp_1027
if $data05 != -999 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1027
if $data01 != -999 then
return -1
endi
sql insert into st_timestamp_1028 using mt_timestamp tags("0x01" + 1u) values(now,"0x01" +1u)
sql show tags from st_timestamp_1028
if $data05 != 1 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1028
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_1029 using mt_timestamp tags(+0x01 +1b) values(now,+0x01 +1b)
sql show tags from st_timestamp_1029
if $data05 != 1 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1029
if $data01 != 1 then
return -1
endi
sql insert into st_timestamp_1030 using mt_timestamp tags (-0b00 -0a) values(now,-0b00 -0a)
sql show tags from st_timestamp_1030
if $data05 != 0 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1030
if $data01 != 0 then
return -1
endi
sql insert into st_timestamp_1031 using mt_timestamp tags ("-0x00" +1u) values(now,"-0x00" +1u)
sql show tags from st_timestamp_1031
if $data05 != 0 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1031
if $data01 != 0 then
return -1
endi
sql insert into st_timestamp_1032 using mt_timestamp tags (-0x00 +1b) values(now,-0x00 +1b)
sql show tags from st_timestamp_1032
if $data05 != 0 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1032
if $data01 != 0 then
return -1
endi
sql insert into st_timestamp_1033 using mt_timestamp tags(now+1b) values(now,now +1b)
sql show tags from st_timestamp_1033
if $data05 < 1711883186000 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1033
if $data01 < 1711883186000 then
return -1
endi
sql insert into st_timestamp_1034 using mt_timestamp tags("now" +1b) values(now,"now()" +1b)
sql show tags from st_timestamp_1034
if $data05 < 1711883186000 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1034
if $data01 < 1711883186000 then
return -1
endi
sql insert into st_timestamp_1035 using mt_timestamp tags(today() + 1d) values(now,today() +1d)
sql show tags from st_timestamp_1035
if $data05 < 1711883186000 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1035
if $data01 < 1711883186000 then
return -1
endi
sql insert into st_timestamp_1036 using mt_timestamp tags("today" +1d) values(now,"today()" +1d)
sql show tags from st_timestamp_1036
if $data05 < 1711883186000 then
return -1
endi
sql select ts, cast(c as bigint) from st_timestamp_1036
if $data01 < 1711883186000 then
return -1
endi
### case 03: alter tag values
sql alter table st_timestamp_0 set tag tagname=NULL
@ -567,12 +838,85 @@ sql show tags from st_timestamp_22
if $data05 != -1 then
return -1
endi
sql alter table st_timestamp_23 set tag tagname=1+ 1d
sql show tags from st_timestamp_23
if $data05 != 86400001 then
return -1
endi
sql alter table st_timestamp_24 set tag tagname=-0 + 1d
sql show tags from st_timestamp_24
if $data05 != 86400000 then
return -1
endi
sql alter table st_timestamp_25 set tag tagname="-0" -1s
sql show tags from st_timestamp_25
if $data05 != -1000 then
return -1
endi
sql alter table st_timestamp_26 set tag tagname=+0b01 -1a
sql show tags from st_timestamp_26
if $data05 != 0 then
return -1
endi
sql alter table st_timestamp_27 set tag tagname=0b01 -1s
sql show tags from st_timestamp_27
if $data05 != -999 then
return -1
endi
sql alter table st_timestamp_28 set tag tagname="0x01" +1u
sql show tags from st_timestamp_28
if $data05 != 1 then
return -1
endi
sql alter table st_timestamp_29 set tag tagname=0x01 +1b
sql show tags from st_timestamp_29
if $data05 != 1 then
return -1
endi
sql alter table st_timestamp_30 set tag tagname==-0b00 -0a
sql show tags from st_timestamp_30
if $data05 != 0 then
return -1
endi
sql alter table st_timestamp_31 set tag tagname="-0x00" +1u
sql show tags from st_timestamp_31
if $data05 != 0 then
return -1
endi
sql alter table st_timestamp_32 set tag tagname=-0x00 +1b
sql show tags from st_timestamp_32
if $data05 != 0 then
return -1
endi
sql alter table st_timestamp_33 set tag tagname=now +1b
sql show tags from st_timestamp_33
if $data05 < 1711883186000 then
return -1
endi
sql alter table st_timestamp_34 set tag tagname="now()" +1b
sql show tags from st_timestamp_34
if $data05 < 1711883186000 then
return -1
endi
sql alter table st_timestamp_35 set tag tagname=today( ) +1d
sql show tags from st_timestamp_35
if $data05 < 1711883186000 then
return -1
endi
sql alter table st_timestamp_36 set tag tagname="today()" +1d
sql show tags from st_timestamp_36
if $data05 < 1711883186000 then
return -1
endi
## case 04: illegal input
sql_error create table st_timestamp_e0 using mt_timestamp tags (123abc)
sql_error create table st_timestamp_e0 using mt_timestamp tags ("123abc")
sql_error create table st_timestamp_e0 using mt_timestamp tags (abc)
sql_error create table st_timestamp_e0 using mt_timestamp tags ("abc")
sql_error create table st_timestamp_e0 using mt_timestamp tags (now()+1d+1s)
sql_error create table st_timestamp_e0 using mt_timestamp tags (1+1y)
sql_error create table st_timestamp_e0 using mt_timestamp tags (0x01+1b+1a)
sql_error create table st_timestamp_e0 using mt_timestamp tags (" ")
sql_error create table st_timestamp_e0 using mt_timestamp tags ('')
sql_error create table st_timestamp_104 using mt_timestamp tags ("-123.1")
@ -590,5 +934,7 @@ sql_error create table st_timestamp_115 using mt_timestamp tags (922337203685477
sql create table st_timestamp_116 using mt_timestamp tags (-9223372036854775808)
sql_error create table st_timestamp_117 using mt_timestamp tags (-9223372036854775809)
sql_error insert into st_timestamp_118 using mt_timestamp tags(9223372036854775807) values(9223372036854775807, 9223372036854775807)
sql_error insert into st_timestamp_119 using mt_timestamp tags(1+1s-1s) values(now, now)
sql_error insert into st_timestamp_120 using mt_timestamp tags(1-1s) values(now, now-1s+1d)
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -299,6 +299,8 @@ sql_error create table st_varbinary_1012 using mt_varbinary tags(tRue)
sql_error create table st_varbinary_1013 using mt_varbinary tags(FalsE)
sql_error create table st_varbinary_1014 using mt_varbinary tags(noW)
sql_error create table st_varbinary_1015 using mt_varbinary tags(toDay)
sql_error create table st_varbinary_1016 using mt_varbinary tags(now()+1s)
sql_error create table st_varbinary_1017 using mt_varbinary tags(1+1s)
sql_error insert into st_varbinary_106 using mt_varbinary tags(+0123) values(now, NULL);
sql_error insert into st_varbinary_107 using mt_varbinary tags(-01.23) values(now, NULL);
sql_error insert into st_varbinary_108 using mt_varbinary tags(+0x01) values(now, NULL);
@ -309,6 +311,8 @@ sql_error insert into st_varbinary_1012 using mt_varbinary tags(tRue) values(no
sql_error insert into st_varbinary_1013 using mt_varbinary tags(FalsE) values(now, NULL);
sql_error insert into st_varbinary_1014 using mt_varbinary tags(noW) values(now, NULL);
sql_error insert into st_varbinary_1015 using mt_varbinary tags(toDay) values(now, NULL);
sql_error insert into st_varbinary_1016 using mt_varbinary tags(now()+1s) values(now, NULL);
sql_error insert into st_varbinary_1017 using mt_varbinary tags(1+1s) values(now, NULL);
sql_error insert into st_varbinary_106 using mt_varbinary tags(NULL) values(now(), +0123)
sql_error insert into st_varbinary_107 using mt_varbinary tags(NULL) values(now(), -01.23)
sql_error insert into st_varbinary_108 using mt_varbinary tags(NULL) values(now(), +0x01)
@ -319,5 +323,7 @@ sql_error insert into st_varbinary_1012 using mt_varbinary tags(NULL) values(no
sql_error insert into st_varbinary_1013 using mt_varbinary tags(NULL) values(now(), FalsE)
sql_error insert into st_varbinary_1014 using mt_varbinary tags(NULL) values(now(), noW)
sql_error insert into st_varbinary_1015 using mt_varbinary tags(NULL) values(now(), toDay)
sql_error insert into st_varbinary_1016 using mt_varbinary tags(NULL) values(now(), now()+1s)
sql_error insert into st_varbinary_1017 using mt_varbinary tags(NULL) values(now(), 1+1s)
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -410,6 +410,17 @@ endi
# case 04: illegal input
sql_error create table st_varchar_100 using mt_varchar tags(now+1d)
sql_error create table st_varchar_101 using mt_varchar tags(toDay+1d)
sql_error create table st_varchar_102 using mt_varchar tags(1+1b)
sql_error create table st_varchar_103 using mt_varchar tags(0x01+1d)
sql_error create table st_varchar_104 using mt_varchar tags(0b01+1s)
sql_error insert into st_varchar_1100 using mt_varchar tags('now') values(now(),now+1d)
sql_error insert into st_varchar_1101 using mt_varchar tags('now') values(now(),toDay+1d)
sql_error insert into st_varchar_1102 using mt_varchar tags('now') values(now(),1+1b)
sql_error insert into st_varchar_1103 using mt_varchar tags('now') values(now(),0x01+1d)
sql_error insert into st_varchar_1104 using mt_varchar tags('now') values(now(),0b01+1s)
sql_error alter table st_varchar_15 set tag tagname=now()+1d
system sh/exec.sh -n dnode1 -s stop -x SIGINT

View File

@ -60,7 +60,7 @@ class TDTestCase:
self.ins_list = ['ins_dnodes','ins_mnodes','ins_qnodes','ins_snodes','ins_cluster','ins_databases','ins_functions',\
'ins_indexes','ins_stables','ins_tables','ins_tags','ins_columns','ins_users','ins_grants','ins_vgroups','ins_configs','ins_dnode_variables',\
'ins_topics','ins_subscriptions','ins_streams','ins_stream_tasks','ins_vnodes','ins_user_privileges','ins_views',
'ins_compacts', 'ins_compact_details', 'ins_grants_full','ins_grants_logs', 'ins_machines', 'ins_arbgroups']
'ins_compacts', 'ins_compact_details', 'ins_grants_full','ins_grants_logs', 'ins_machines', 'ins_arbgroups', "ins_encryptions"]
self.perf_list = ['perf_connections','perf_queries','perf_consumers','perf_trans','perf_apps']
def insert_data(self,column_dict,tbname,row_num):
insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str)
@ -220,7 +220,7 @@ class TDTestCase:
tdSql.checkEqual(20470,len(tdSql.queryResult))
tdSql.query("select * from information_schema.ins_columns where db_name ='information_schema'")
tdSql.checkEqual(True, len(tdSql.queryResult) in range(215, 230))
tdSql.checkEqual(True, len(tdSql.queryResult) in range(227, 230))
tdSql.query("select * from information_schema.ins_columns where db_name ='performance_schema'")
tdSql.checkEqual(54, len(tdSql.queryResult))
@ -313,15 +313,39 @@ class TDTestCase:
tdSql.error('alter cluster "activeCode" ""')
tdSql.execute('alter cluster "activeCode" "revoked"')
def ins_encryptions_check(self):
key_status_list = ['unknown', 'unset', 'set', 'loaded']
tdSql.execute('drop database if exists db2')
tdSql.execute('create database if not exists db2 vgroups 1 replica 1')
tdSql.query(f'select * from information_schema.ins_encryptions')
result = tdSql.queryResult
index = 0
for i in range(0, len(result)):
tdSql.checkEqual(True, result[i][1] in key_status_list)
index += 1
tdSql.checkEqual(True, index > 0)
tdSql.query(f'show encryptions')
result = tdSql.queryResult
index = 0
for i in range(0, len(result)):
tdSql.checkEqual(True, result[i][1] in key_status_list)
index += 1
tdSql.checkEqual(True, index > 0)
# ENCRYPT_TODO: create encrypt_key 'xxx'
def run(self):
self.prepare_data()
self.count_check()
self.ins_columns_check()
# self.count_check()
# self.ins_columns_check()
# self.ins_col_check_4096()
self.ins_stable_check()
self.ins_stable_check2()
self.ins_dnodes_check()
self.ins_grants_check()
# self.ins_stable_check()
# self.ins_stable_check2()
# self.ins_dnodes_check()
# self.ins_grants_check()
self.ins_encryptions_check()
def stop(self):

View File

@ -64,6 +64,14 @@ class TDTestCase:
tdSql.error(f'alter database db pages {pages}')
tdSql.execute('drop database db')
def alter_encrypt_alrogithm(self):
tdSql.execute('create database db')
tdSql.checkEqual("Encryption is not allowed to be changed after database is created", tdSql.error('alter database db encrypt_algorithm \'sM4\''))
tdSql.checkEqual("Encryption is not allowed to be changed after database is created", tdSql.error('alter database db encrypt_algorithm \'noNe\''))
tdSql.checkEqual("Encryption is not allowed to be changed after database is created", tdSql.error('alter database db encrypt_algorithm \'\''))
tdSql.checkEqual("Invalid option encrypt_algorithm: none ", tdSql.error('alter database db encrypt_algorithm \'none \''))
tdSql.execute('drop database db')
def alter_same_options(self):
tdSql.execute('drop database if exists db')
tdSql.execute('create database db')
@ -92,6 +100,7 @@ class TDTestCase:
self.alter_buffer()
self.alter_pages()
self.alter_encrypt_alrogithm()
self.alter_same_options()
def stop(self):