diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 056314460dc18fd787a76a63124a55359dcdf5c2..0fd9efcd6f71b725b6b69f0b632d7529937cc9c4 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -5530,6 +5530,13 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCMCreateDbMsg* pCreate) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } + val = htonl(pCreate->fsyncPeriod); + if (val != -1 && (val < TSDB_MIN_FSYNC_PERIOD || val > TSDB_MAX_FSYNC_PERIOD)) { + snprintf(msg, tListLen(msg), "invalid db option fsyncPeriod: %d valid range: [%d, %d]", val, + TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD); + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); + } + if (pCreate->compression != -1 && (pCreate->compression < TSDB_MIN_COMP_LEVEL || pCreate->compression > TSDB_MAX_COMP_LEVEL)) { snprintf(msg, tListLen(msg), "invalid db option compression: %d valid range: [%d, %d]", pCreate->compression, diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index d0c42c4412f8430856fb044b662ac930f8be8bd1..4577a5c31d0b66e348b6c45c60f28227e7bb65be 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -401,6 +401,7 @@ static int32_t dnodeProcessCreateVnodeMsg(SRpcMsg *rpcMsg) { pCreate->cfg.daysToKeep = htonl(pCreate->cfg.daysToKeep); pCreate->cfg.minRowsPerFileBlock = htonl(pCreate->cfg.minRowsPerFileBlock); pCreate->cfg.maxRowsPerFileBlock = htonl(pCreate->cfg.maxRowsPerFileBlock); + pCreate->cfg.fsyncPeriod = htonl(pCreate->cfg.fsyncPeriod); pCreate->cfg.commitTime = htonl(pCreate->cfg.commitTime); for (int32_t j = 0; j < pCreate->cfg.replications; ++j) { diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index c581fc69e23d93e4dfa4ed2dca26373079af8678..0b63e9e71d5cc76cd2b4b1eec3997181e7c5c706 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -222,7 +222,6 @@ #define TK_INTO 204 #define TK_VALUES 205 - #define TK_SPACE 300 #define TK_COMMENT 301 #define TK_ILLEGAL 302 diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 6bb6f450a582d2036db063f3896b76ff4a01511f..e3b1603856237693ee7d857f0129bd107925349e 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -561,6 +561,12 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; + pShow->bytes[cols] = 4; + pSchema[cols].type = TSDB_DATA_TYPE_INT; + strcpy(pSchema[cols].name, "fsync"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + pShow->bytes[cols] = 1; pSchema[cols].type = TSDB_DATA_TYPE_TINYINT; strcpy(pSchema[cols].name, "comp"); @@ -764,6 +770,7 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) { pCreate->daysToKeep1 = htonl(pCreate->daysToKeep1); pCreate->daysToKeep2 = htonl(pCreate->daysToKeep2); pCreate->commitTime = htonl(pCreate->commitTime); + pCreate->fsyncPeriod = htonl(pCreate->fsyncPeriod); pCreate->minRowsPerFileBlock = htonl(pCreate->minRowsPerFileBlock); pCreate->maxRowsPerFileBlock = htonl(pCreate->maxRowsPerFileBlock); diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index a274b5e4500f649098eac27bd3c992e47d945af1..d709b4f838280ade6f43e419a5927216de417be5 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -237,7 +237,7 @@ db_optr(Y) ::= db_optr(Z) maxrows(X). { Y = Z; Y.maxRowsPerBlock = strtod db_optr(Y) ::= db_optr(Z) blocks(X). { Y = Z; Y.numOfBlocks = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) ctime(X). { Y = Z; Y.commitTime = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); } -db_optr(Y) ::= db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtod(X.z, NULL); } +db_optr(Y) ::= db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) prec(X). { Y = Z; Y.precision = X; } db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; } diff --git a/src/query/src/sql.c b/src/query/src/sql.c index a7f3dd875bb1339f4d018f7b3b387b34e4924e2b..ac9952bb97d9c333a5e4209318cf1b26d3fe4b9c 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -30,8 +30,12 @@ #include #include #include +#include "qsqlparser.h" +#include "tcmdtype.h" +#include "tstoken.h" +#include "ttokendef.h" #include "tutil.h" - +#include "tvariant.h" /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols ** in a format understandable to "makeheaders". This section is blank unless @@ -2252,7 +2256,7 @@ static void yy_reduce( yymsp[-1].minor.yy158 = yylhsminor.yy158; break; case 93: /* db_optr ::= db_optr fsync */ -{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.fsyncPeriod = strtod(yymsp[0].minor.yy0.z, NULL); } +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; case 94: /* db_optr ::= db_optr comp */ @@ -2273,7 +2277,7 @@ static void yy_reduce( { setDefaultCreateDbOption(&yymsp[1].minor.yy158);} break; case 104: /* alter_db_optr ::= alter_db_optr fsync */ -{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.fsyncPeriod = strtod(yymsp[0].minor.yy0.z, NULL, 10); } +{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy158 = yylhsminor.yy158; break; case 105: /* typename ::= ids */ diff --git a/src/wal/src/walMain.c b/src/wal/src/walMain.c index 45bacc317fa14d076f404f34b2d0c81dbb38b648..9001d29415ec73373511159349fb64c4c4c8c566 100644 --- a/src/wal/src/walMain.c +++ b/src/wal/src/walMain.c @@ -68,7 +68,10 @@ static void walRelease(SWal *pWal); static void walModuleInitFunc() { walTmrCtrl = taosTmrInit(1000, 100, 300000, "WAL"); - if (walTmrCtrl == NULL) walModuleInit = PTHREAD_ONCE_INIT; + if (walTmrCtrl == NULL) + walModuleInit = PTHREAD_ONCE_INIT; + else + wDebug("WAL module is initialized"); } void *walOpen(const char *path, const SWalCfg *pCfg) { @@ -343,6 +346,7 @@ static void walRelease(SWal *pWal) { if (walTmrCtrl) taosTmrCleanUp(walTmrCtrl); walTmrCtrl = NULL; walModuleInit = PTHREAD_ONCE_INIT; + wDebug("WAL module is cleaned up"); } }