TD-14409 TD-14436 bugfix
This commit is contained in:
parent
59862e454d
commit
baa238eead
|
@ -524,6 +524,7 @@ typedef struct {
|
|||
int8_t walLevel;
|
||||
int8_t quorum;
|
||||
int8_t cacheLastRow;
|
||||
int8_t replications;
|
||||
} SAlterDbReq;
|
||||
|
||||
int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
|
||||
|
|
|
@ -478,6 +478,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613)
|
||||
#define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614)
|
||||
#define TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615)
|
||||
#define TSDB_CODE_PAR_DB_NOT_SPECIFIED TAOS_DEF_ERROR_CODE(0, 0x2616)
|
||||
#define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
|
||||
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
|
||||
|
||||
#define TSDB_MIN_WAL_LEVEL 0
|
||||
#define TSDB_MIN_WAL_LEVEL 1
|
||||
#define TSDB_MAX_WAL_LEVEL 2
|
||||
#define TSDB_DEFAULT_WAL_LEVEL 1
|
||||
|
||||
|
|
|
@ -1629,6 +1629,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->quorum) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->replications) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
|
@ -1650,6 +1651,7 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->quorum) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tCoderClear(&decoder);
|
||||
|
|
|
@ -159,6 +159,7 @@ alter_db_option(A) ::= KEEP NK_INTEGER(B).
|
|||
alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; }
|
||||
alter_db_option(A) ::= QUORUM NK_INTEGER(B). { A.type = DB_OPTION_QUORUM; A.val = B; }
|
||||
alter_db_option(A) ::= CACHELAST NK_INTEGER(B). { A.type = DB_OPTION_CACHELAST; A.val = B; }
|
||||
alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; }
|
||||
|
||||
/************************************************ create/drop table/stable ********************************************/
|
||||
cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B)
|
||||
|
|
|
@ -180,9 +180,9 @@ static SDatabaseOptions* setDbQuorum(SAstCreateContext* pCxt, SDatabaseOptions*
|
|||
|
||||
static SDatabaseOptions* setDbReplica(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) {
|
||||
int64_t val = strtol(pVal->z, NULL, 10);
|
||||
if (val < TSDB_MIN_DB_REPLICA_OPTION || val > TSDB_MAX_DB_REPLICA_OPTION) {
|
||||
if (!(val == TSDB_MIN_DB_REPLICA_OPTION || val == TSDB_MAX_DB_REPLICA_OPTION)) {
|
||||
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
|
||||
"invalid db option replications: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_DB_REPLICA_OPTION, TSDB_MAX_DB_REPLICA_OPTION);
|
||||
"invalid db option replications: %"PRId64", only 1, 3 allowed", val);
|
||||
pCxt->valid = false;
|
||||
return pOptions;
|
||||
}
|
||||
|
@ -397,7 +397,9 @@ static bool checkUserName(SAstCreateContext* pCxt, SToken* pUserName) {
|
|||
pCxt->valid = false;
|
||||
}
|
||||
}
|
||||
trimEscape(pUserName);
|
||||
if (pCxt->valid) {
|
||||
trimEscape(pUserName);
|
||||
}
|
||||
return pCxt->valid;
|
||||
}
|
||||
|
||||
|
@ -472,45 +474,50 @@ static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t
|
|||
|
||||
static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool query) {
|
||||
if (NULL == pDbName) {
|
||||
pCxt->valid = (query ? NULL != pCxt->pQueryCxt->db : true);
|
||||
if (!pCxt->valid) {
|
||||
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "db not specified");
|
||||
if (query && NULL == pCxt->pQueryCxt->db) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DB_NOT_SPECIFIED);
|
||||
pCxt->valid = false;
|
||||
}
|
||||
} else {
|
||||
pCxt->valid = pDbName->n < TSDB_DB_NAME_LEN ? true : false;
|
||||
if (pDbName->n >= TSDB_DB_NAME_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pDbName->z);
|
||||
pCxt->valid = false;
|
||||
}
|
||||
}
|
||||
if (pCxt->valid) {
|
||||
trimEscape(pDbName);
|
||||
}
|
||||
trimEscape(pDbName);
|
||||
return pCxt->valid;
|
||||
}
|
||||
|
||||
static bool checkTableName(SAstCreateContext* pCxt, SToken* pTableName) {
|
||||
if (NULL == pTableName) {
|
||||
pCxt->valid = true;
|
||||
} else {
|
||||
pCxt->valid = pTableName->n < TSDB_TABLE_NAME_LEN ? true : false;
|
||||
if (NULL != pTableName && pTableName->n >= TSDB_TABLE_NAME_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pTableName->z);
|
||||
pCxt->valid = false;
|
||||
return false;
|
||||
}
|
||||
trimEscape(pTableName);
|
||||
return pCxt->valid;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool checkColumnName(SAstCreateContext* pCxt, SToken* pColumnName) {
|
||||
if (NULL == pColumnName) {
|
||||
pCxt->valid = true;
|
||||
} else {
|
||||
pCxt->valid = pColumnName->n < TSDB_COL_NAME_LEN ? true : false;
|
||||
if (NULL != pColumnName && pColumnName->n >= TSDB_COL_NAME_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pColumnName->z);
|
||||
pCxt->valid = false;
|
||||
return false;
|
||||
}
|
||||
trimEscape(pColumnName);
|
||||
return pCxt->valid;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool checkIndexName(SAstCreateContext* pCxt, SToken* pIndexName) {
|
||||
if (NULL == pIndexName) {
|
||||
if (NULL != pIndexName && pIndexName->n >= TSDB_INDEX_NAME_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pIndexName->z);
|
||||
pCxt->valid = false;
|
||||
} else {
|
||||
pCxt->valid = pIndexName->n < TSDB_INDEX_NAME_LEN ? true : false;
|
||||
return false;
|
||||
}
|
||||
trimEscape(pIndexName);
|
||||
return pCxt->valid;
|
||||
return true;
|
||||
}
|
||||
|
||||
SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) {
|
||||
|
|
|
@ -1048,6 +1048,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
|
|||
pReq->walLevel = pStmt->pOptions->walLevel;
|
||||
pReq->quorum = pStmt->pOptions->quorum;
|
||||
pReq->cacheLastRow = pStmt->pOptions->cachelast;
|
||||
pReq->replications = pStmt->pOptions->replica;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,10 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
|||
return "This statement is no longer supported";
|
||||
case TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL:
|
||||
return "This interval value is too small : %s";
|
||||
case TSDB_CODE_PAR_DB_NOT_SPECIFIED:
|
||||
return "db not specified";
|
||||
case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME:
|
||||
return "Invalid identifier name : %s";
|
||||
case TSDB_CODE_OUT_OF_MEMORY:
|
||||
return "Out of memory";
|
||||
default:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue