Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fac7e521
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22019
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fac7e521
编写于
8月 07, 2023
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
s3/evict: fetch atime from stat file
上级
65d8af19
变更
19
显示空白变更内容
内联
并排
Showing
19 changed file
with
300 addition
and
225 deletion
+300
-225
include/os/osFile.h
include/os/osFile.h
+1
-1
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
+2
-2
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
+1
-1
source/dnode/mgmt/node_util/src/dmEps.c
source/dnode/mgmt/node_util/src/dmEps.c
+3
-3
source/dnode/mgmt/node_util/src/dmFile.c
source/dnode/mgmt/node_util/src/dmFile.c
+1
-1
source/dnode/vnode/src/inc/vndCos.h
source/dnode/vnode/src/inc/vndCos.h
+2
-1
source/dnode/vnode/src/tq/tqOffsetSnapshot.c
source/dnode/vnode/src/tq/tqOffsetSnapshot.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+5
-5
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+2
-2
source/dnode/vnode/src/vnd/vnodeCos.c
source/dnode/vnode/src/vnd/vnodeCos.c
+65
-1
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+4
-4
source/libs/index/src/indexFstFile.c
source/libs/index/src/indexFstFile.c
+2
-2
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+109
-98
source/libs/sync/src/syncRaftStore.c
source/libs/sync/src/syncRaftStore.c
+1
-1
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+6
-6
source/os/src/osFile.c
source/os/src/osFile.c
+16
-12
source/util/src/tlog.c
source/util/src/tlog.c
+30
-30
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+48
-52
utils/test/c/tmqDemo.c
utils/test/c/tmqDemo.c
+1
-2
未找到文件。
include/os/osFile.h
浏览文件 @
fac7e521
...
...
@@ -76,7 +76,7 @@ int32_t taosUnLockFile(TdFilePtr pFile);
int32_t
taosUmaskFile
(
int32_t
maskVal
);
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
);
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
,
int32_t
*
atime
);
int32_t
taosDevInoFile
(
TdFilePtr
pFile
,
int64_t
*
stDev
,
int64_t
*
stIno
);
int32_t
taosFStatFile
(
TdFilePtr
pFile
,
int64_t
*
size
,
int32_t
*
mtime
);
bool
taosCheckExistFile
(
const
char
*
pathname
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
浏览文件 @
fac7e521
...
...
@@ -46,7 +46,7 @@ static int32_t mmDecodeOption(SJson *pJson, SMnodeOpt *pOption) {
if
(
code
<
0
)
return
-
1
;
tjsonGetInt32ValueFromDouble
(
replica
,
"role"
,
pOption
->
nodeRoles
[
i
],
code
);
if
(
code
<
0
)
return
-
1
;
if
(
pOption
->
nodeRoles
[
i
]
==
TAOS_SYNC_ROLE_VOTER
)
{
if
(
pOption
->
nodeRoles
[
i
]
==
TAOS_SYNC_ROLE_VOTER
)
{
pOption
->
numOfReplicas
++
;
}
}
...
...
@@ -65,7 +65,7 @@ int32_t mmReadFile(const char *path, SMnodeOpt *pOption) {
char
file
[
PATH_MAX
]
=
{
0
};
snprintf
(
file
,
sizeof
(
file
),
"%s%smnode.json"
,
path
,
TD_DIRSEP
);
if
(
taosStatFile
(
file
,
NULL
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
file
,
NULL
,
NULL
,
NULL
)
<
0
)
{
dInfo
(
"mnode file:%s not exist"
,
file
);
return
0
;
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
浏览文件 @
fac7e521
...
...
@@ -97,7 +97,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
SWrapperCfg
*
pCfgs
=
NULL
;
snprintf
(
file
,
sizeof
(
file
),
"%s%svnodes.json"
,
pMgmt
->
path
,
TD_DIRSEP
);
if
(
taosStatFile
(
file
,
NULL
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
file
,
NULL
,
NULL
,
NULL
)
<
0
)
{
dInfo
(
"vnode file:%s not exist"
,
file
);
return
0
;
}
...
...
source/dnode/mgmt/node_util/src/dmEps.c
浏览文件 @
fac7e521
...
...
@@ -100,7 +100,7 @@ int32_t dmReadEps(SDnodeData *pData) {
goto
_OVER
;
}
if
(
taosStatFile
(
file
,
NULL
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
file
,
NULL
,
NULL
,
NULL
)
<
0
)
{
dInfo
(
"dnode file:%s not exist"
,
file
);
code
=
0
;
goto
_OVER
;
...
...
@@ -350,7 +350,7 @@ void dmRotateMnodeEpSet(SDnodeData *pData) {
}
void
dmGetMnodeEpSetForRedirect
(
SDnodeData
*
pData
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
if
(
!
pData
->
validMnodeEps
)
return
;
if
(
!
pData
->
validMnodeEps
)
return
;
dmGetMnodeEpSet
(
pData
,
pEpSet
);
dTrace
(
"msg is redirected, handle:%p num:%d use:%d"
,
pMsg
->
info
.
handle
,
pEpSet
->
numOfEps
,
pEpSet
->
inUse
);
for
(
int32_t
i
=
0
;
i
<
pEpSet
->
numOfEps
;
++
i
)
{
...
...
@@ -469,7 +469,7 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
char
file
[
PATH_MAX
]
=
{
0
};
snprintf
(
file
,
sizeof
(
file
),
"%s%sdnode%sep.json"
,
tsDataDir
,
TD_DIRSEP
,
TD_DIRSEP
);
if
(
taosStatFile
(
file
,
NULL
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
file
,
NULL
,
NULL
,
NULL
)
<
0
)
{
dDebug
(
"dnode file:%s not exist"
,
file
);
code
=
0
;
goto
_OVER
;
...
...
source/dnode/mgmt/node_util/src/dmFile.c
浏览文件 @
fac7e521
...
...
@@ -38,7 +38,7 @@ int32_t dmReadFile(const char *path, const char *name, bool *pDeployed) {
char
file
[
PATH_MAX
]
=
{
0
};
snprintf
(
file
,
sizeof
(
file
),
"%s%s%s.json"
,
path
,
TD_DIRSEP
,
name
);
if
(
taosStatFile
(
file
,
NULL
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
file
,
NULL
,
NULL
,
NULL
)
<
0
)
{
dInfo
(
"file:%s not exist"
,
file
);
code
=
0
;
goto
_OVER
;
...
...
source/dnode/vnode/src/inc/vndCos.h
浏览文件 @
fac7e521
...
...
@@ -30,8 +30,9 @@ void s3PutObjectFromFile(const char *file, const char *object);
void
s3DeleteObjects
(
const
char
*
object_name
[],
int
nobject
);
bool
s3Exists
(
const
char
*
object_name
);
bool
s3Get
(
const
char
*
object_name
,
const
char
*
path
);
void
s3EvictCache
();
void
s3EvictCache
(
const
char
*
path
,
long
object_size
);
long
s3Size
(
const
char
*
object_name
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/src/tq/tqOffsetSnapshot.c
浏览文件 @
fac7e521
...
...
@@ -60,7 +60,7 @@ int32_t tqOffsetSnapRead(STqOffsetReader* pReader, uint8_t** ppData) {
}
int64_t
sz
=
0
;
if
(
taosStatFile
(
fname
,
&
sz
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
fname
,
&
sz
,
NULL
,
NULL
)
<
0
)
{
taosCloseFile
(
&
pFile
);
taosMemoryFree
(
fname
);
return
-
1
;
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
fac7e521
...
...
@@ -176,7 +176,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
// SDelFile
if
(
pTsdb
->
fs
.
pDelFile
)
{
tsdbDelFileName
(
pTsdb
,
pTsdb
->
fs
.
pDelFile
,
fname
);
if
(
taosStatFile
(
fname
,
&
size
,
NULL
))
{
if
(
taosStatFile
(
fname
,
&
size
,
NULL
,
NULL
))
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -195,7 +195,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
// head =========
tsdbHeadFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
pHeadF
,
fname
);
if
(
taosStatFile
(
fname
,
&
size
,
NULL
))
{
if
(
taosStatFile
(
fname
,
&
size
,
NULL
,
NULL
))
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -206,7 +206,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
// data =========
tsdbDataFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
pDataF
,
fname
);
if
(
taosStatFile
(
fname
,
&
size
,
NULL
))
{
if
(
taosStatFile
(
fname
,
&
size
,
NULL
,
NULL
))
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -221,7 +221,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
// sma =============
tsdbSmaFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
pSmaF
,
fname
);
if
(
taosStatFile
(
fname
,
&
size
,
NULL
))
{
if
(
taosStatFile
(
fname
,
&
size
,
NULL
,
NULL
))
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -237,7 +237,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
// stt ===========
for
(
int32_t
iStt
=
0
;
iStt
<
pSet
->
nSttF
;
iStt
++
)
{
tsdbSttFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
aSttF
[
iStt
],
fname
);
if
(
taosStatFile
(
fname
,
&
size
,
NULL
))
{
if
(
taosStatFile
(
fname
,
&
size
,
NULL
,
NULL
))
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
fac7e521
...
...
@@ -38,7 +38,7 @@ int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **p
const
char
*
object_name
=
taosDirEntryBaseName
((
char
*
)
path
);
long
s3_size
=
s3Size
(
object_name
);
if
(
!
strncmp
(
path
+
strlen
(
path
)
-
5
,
".data"
,
5
)
&&
s3_size
>
0
)
{
s3EvictCache
();
s3EvictCache
(
path
,
s3_size
);
s3Get
(
object_name
,
path
);
pFD
->
pFD
=
taosOpenFile
(
path
,
flag
);
...
...
@@ -66,7 +66,7 @@ int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **p
// not check file size when reading data files.
if
(
flag
!=
TD_FILE_READ
)
{
if
(
taosStatFile
(
path
,
&
pFD
->
szFile
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
path
,
&
pFD
->
szFile
,
NULL
,
NULL
)
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
taosMemoryFree
(
pFD
->
pBuf
);
taosCloseFile
(
&
pFD
->
pFD
);
...
...
source/dnode/vnode/src/vnd/vnodeCos.c
浏览文件 @
fac7e521
...
...
@@ -190,7 +190,71 @@ bool s3Get(const char *object_name, const char *path) {
return
ret
;
}
void
s3EvictCache
()
{}
typedef
struct
{
int64_t
size
;
int32_t
atime
;
char
name
[
TSDB_FILENAME_LEN
];
}
SEvictFile
;
static
int32_t
evictFileCompareAsce
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
SEvictFile
*
lhs
=
(
SEvictFile
*
)
pLeft
;
SEvictFile
*
rhs
=
(
SEvictFile
*
)
pRight
;
return
lhs
->
atime
<
rhs
->
atime
?
-
1
:
1
;
}
void
s3EvictCache
(
const
char
*
path
,
long
object_size
)
{
SDiskSize
disk_size
=
{
0
};
if
(
taosGetDiskSize
((
char
*
)
path
,
&
disk_size
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
vError
(
"failed to get disk:%s size since %s"
,
path
,
terrstr
());
return
;
}
if
(
object_size
>=
disk_size
.
avail
+
1
<<
30
)
{
// evict too old files
// 1, list data files' atime under dir(path)
char
dir_name
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
tstrncpy
(
dir_name
,
path
,
TSDB_FILENAME_LEN
);
taosDirName
(
dir_name
);
tdbDirPtr
pDir
=
taosOpenDir
(
dir_name
);
if
(
pDir
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
vError
(
"failed to open %s since %s"
,
dir_name
,
terrstr
());
}
SArray
*
evict_files
=
taosArrayInit
(
16
,
sizeof
(
SEvictFile
));
tdbDirEntryPtr
pDirEntry
;
while
((
pDirEntry
=
taosReadDir
(
pDir
))
!=
NULL
)
{
char
*
name
=
taosGetDirEntryName
(
pDirEntry
);
if
(
!
strncmp
(
name
+
strlen
(
name
)
-
5
,
".data"
,
5
))
{
SEvictFile
e_file
=
{
0
};
tstrncpy
(
e_file
.
name
,
name
,
TSDB_FILENAME_LEN
);
taosStatFile
(
name
,
&
e_file
.
size
,
NULL
,
&
e_file
.
atime
);
taosArrayPush
(
evict_files
,
&
e_file
);
}
}
taosCloseDir
(
&
pDir
);
// 2, sort by atime
taosArraySort
(
evict_files
,
evictFileCompareAsce
);
// 3, remove files ascendingly until we get enough object_size space
long
evict_size
=
0
;
size_t
ef_size
=
TARRAY_SIZE
(
evict_files
);
for
(
size_t
i
=
0
;
i
<
ef_size
;
++
i
)
{
SEvictFile
*
evict_file
=
taosArrayGet
(
evict_files
,
i
);
taosRemoveFile
(
evict_file
->
name
);
evict_size
+=
evict_file
->
size
;
if
(
evict_size
>=
object_size
)
{
break
;
}
}
taosArrayDestroy
(
evict_files
);
}
}
long
s3Size
(
const
char
*
object_name
)
{
long
size
=
0
;
...
...
source/libs/function/src/udfd.c
浏览文件 @
fac7e521
...
...
@@ -848,7 +848,7 @@ int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) {
char
path
[
PATH_MAX
]
=
{
0
};
udfdGetFuncBodyPath
(
udf
,
path
);
bool
fileExist
=
!
(
taosStatFile
(
path
,
NULL
,
NULL
)
<
0
);
bool
fileExist
=
!
(
taosStatFile
(
path
,
NULL
,
NULL
,
NULL
)
<
0
);
if
(
fileExist
)
{
strncpy
(
udf
->
path
,
path
,
PATH_MAX
);
fnInfo
(
"udfd func body file. reuse existing file %s"
,
path
);
...
...
source/libs/index/src/indexFstFile.c
浏览文件 @
fac7e521
...
...
@@ -162,7 +162,7 @@ static FORCE_INLINE int idxFileCtxGetSize(IFileCtx* ctx) {
return
ctx
->
offset
;
}
else
{
int64_t
file_size
=
0
;
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
,
NULL
);
return
(
int
)
file_size
;
}
}
...
...
@@ -199,7 +199,7 @@ IFileCtx* idxFileCtxCreate(WriterType type, const char* path, bool readOnly, int
code
=
taosFtruncateFile
(
ctx
->
file
.
pFile
,
0
);
UNUSED
(
code
);
code
=
taosStatFile
(
path
,
&
ctx
->
file
.
size
,
NULL
);
code
=
taosStatFile
(
path
,
&
ctx
->
file
.
size
,
NULL
,
NULL
);
UNUSED
(
code
);
ctx
->
file
.
wBufOffset
=
0
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
fac7e521
...
...
@@ -278,7 +278,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
static
int32_t
translateSubquery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
);
static
int32_t
createSimpleSelectStmtFromProjList
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
);
static
int32_t
createSimpleSelectStmtFromProjList
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
);
static
int32_t
createLastTsSelectStmt
(
char
*
pDb
,
char
*
pTable
,
STableMeta
*
pMeta
,
SNode
**
pQuery
);
static
int32_t
setQuery
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
);
static
int32_t
setRefreshMate
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
);
...
...
@@ -772,7 +773,8 @@ static SNodeList* getProjectList(const SNode* pNode) {
static
bool
isTimeLineQuery
(
SNode
*
pStmt
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
return
(
TIME_LINE_MULTI
==
((
SSelectStmt
*
)
pStmt
)
->
timeLineResMode
)
||
(
TIME_LINE_GLOBAL
==
((
SSelectStmt
*
)
pStmt
)
->
timeLineResMode
);
return
(
TIME_LINE_MULTI
==
((
SSelectStmt
*
)
pStmt
)
->
timeLineResMode
)
||
(
TIME_LINE_GLOBAL
==
((
SSelectStmt
*
)
pStmt
)
->
timeLineResMode
);
}
else
if
(
QUERY_NODE_SET_OPERATOR
==
nodeType
(
pStmt
))
{
return
TIME_LINE_GLOBAL
==
((
SSetOperator
*
)
pStmt
)
->
timeLineResMode
;
}
else
{
...
...
@@ -791,7 +793,7 @@ static bool isGlobalTimeLineQuery(SNode* pStmt) {
}
static
bool
isTimeLineAlignedQuery
(
SNode
*
pStmt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
;
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
;
if
(
isGlobalTimeLineQuery
(((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
))
{
return
true
;
}
...
...
@@ -801,7 +803,7 @@ static bool isTimeLineAlignedQuery(SNode* pStmt) {
if
(
QUERY_NODE_SELECT_STMT
!=
nodeType
(((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
))
{
return
false
;
}
SSelectStmt
*
pSub
=
(
SSelectStmt
*
)((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
;
SSelectStmt
*
pSub
=
(
SSelectStmt
*
)((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
;
if
(
nodesListMatch
(
pSelect
->
pPartitionByList
,
pSub
->
pPartitionByList
))
{
return
true
;
}
...
...
@@ -1596,9 +1598,11 @@ static int32_t translateInterpFunc(STranslateContext* pCxt, SFunctionNode* pFunc
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
}
if
(
pSelect
->
hasInterpFunc
&&
(
FUNC_RETURN_ROWS_INDEFINITE
==
pSelect
->
returnRows
||
pSelect
->
returnRows
!=
fmGetFuncReturnRows
(
pFunc
)))
{
if
(
pSelect
->
hasInterpFunc
&&
(
FUNC_RETURN_ROWS_INDEFINITE
==
pSelect
->
returnRows
||
pSelect
->
returnRows
!=
fmGetFuncReturnRows
(
pFunc
)))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
,
"%s ignoring null value options cannot be used when applying to multiple columns"
,
pFunc
->
functionName
);
"%s ignoring null value options cannot be used when applying to multiple columns"
,
pFunc
->
functionName
);
}
if
(
NULL
!=
pSelect
->
pWindow
||
NULL
!=
pSelect
->
pGroupByList
)
{
...
...
@@ -1636,7 +1640,8 @@ static int32_t translateTimelineFunc(STranslateContext* pCxt, SFunctionNode* pFu
}
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCxt
->
pCurrStmt
;
if
(
NULL
!=
pSelect
->
pFromTable
&&
QUERY_NODE_TEMP_TABLE
==
nodeType
(
pSelect
->
pFromTable
)
&&
!
isGlobalTimeLineQuery
(((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
)
&&
!
isTimeLineAlignedQuery
(
pCxt
->
pCurrStmt
))
{
!
isGlobalTimeLineQuery
(((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
)
&&
!
isTimeLineAlignedQuery
(
pCxt
->
pCurrStmt
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
,
"%s function requires valid time series input"
,
pFunc
->
functionName
);
}
...
...
@@ -2296,7 +2301,8 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
}
}
if
(
isScanPseudoColumnFunc
(
*
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
*
pNode
))
{
if
(
pSelect
->
selectFuncNum
>
1
||
pSelect
->
hasOtherVectorFunc
||
!
pSelect
->
hasSelectFunc
||
(
isDistinctOrderBy
(
pCxt
)
&&
pCxt
->
currClause
==
SQL_CLAUSE_ORDER_BY
))
{
if
(
pSelect
->
selectFuncNum
>
1
||
pSelect
->
hasOtherVectorFunc
||
!
pSelect
->
hasSelectFunc
||
(
isDistinctOrderBy
(
pCxt
)
&&
pCxt
->
currClause
==
SQL_CLAUSE_ORDER_BY
))
{
return
generateDealNodeErrMsg
(
pCxt
,
getGroupByErrorCode
(
pCxt
),
((
SExprNode
*
)(
*
pNode
))
->
userAlias
);
}
else
{
return
rewriteColToSelectValFunc
(
pCxt
,
pNode
);
...
...
@@ -2391,14 +2397,14 @@ static int32_t checkHavingGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect)
if
(
NULL
!=
pSelect
->
pHaving
)
{
code
=
checkExprForGroupBy
(
pCxt
,
&
pSelect
->
pHaving
);
}
/*
/*
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pProjectionList) {
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pProjectionList);
}
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pOrderByList) {
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
}
*/
*/
return
code
;
}
...
...
@@ -2657,9 +2663,9 @@ static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSele
static
EDealRes
doTranslateTbName
(
SNode
**
pNode
,
void
*
pContext
)
{
switch
(
nodeType
(
*
pNode
))
{
case
QUERY_NODE_FUNCTION
:
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
*
pNode
;
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
*
pNode
;
if
(
FUNCTION_TYPE_TBNAME
==
pFunc
->
funcType
)
{
SRewriteTbNameContext
*
pCxt
=
(
SRewriteTbNameContext
*
)
pContext
;
SRewriteTbNameContext
*
pCxt
=
(
SRewriteTbNameContext
*
)
pContext
;
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
pVal
)
{
pCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -2699,7 +2705,8 @@ static int32_t replaceTbName(STranslateContext* pCxt, SSelectStmt* pSelect) {
}
SRealTableNode
*
pTable
=
(
SRealTableNode
*
)
pSelect
->
pFromTable
;
if
(
TSDB_CHILD_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_NORMAL_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_SYSTEM_TABLE
!=
pTable
->
pMeta
->
tableType
)
{
if
(
TSDB_CHILD_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_NORMAL_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_SYSTEM_TABLE
!=
pTable
->
pMeta
->
tableType
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -3110,7 +3117,8 @@ static int32_t convertFillValue(STranslateContext* pCxt, SDataType dt, SNodeList
code
=
scalarCalculateConstants
(
pCastFunc
,
&
pCell
->
pNode
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
QUERY_NODE_VALUE
!=
nodeType
(
pCell
->
pNode
))
{
code
=
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
"Fill value can only accept constant"
);
code
=
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
"Fill value can only accept constant"
);
}
else
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
code
=
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
"Filled data type mismatch"
);
}
...
...
@@ -3576,7 +3584,6 @@ static int32_t createDefaultEveryNode(STranslateContext* pCxt, SNode** pOutput)
pEvery
->
isDuration
=
true
;
pEvery
->
literal
=
taosStrdup
(
"1s"
);
*
pOutput
=
(
SNode
*
)
pEvery
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -3675,8 +3682,8 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SSelectStmt* pSelec
if
(
pSelect
->
pPartitionByList
)
{
int8_t
typeType
=
getTableTypeFromTableNode
(
pSelect
->
pFromTable
);
SNode
*
pPar
=
nodesListGetNode
(
pSelect
->
pPartitionByList
,
0
);
if
(
!
((
TSDB_NORMAL_TABLE
==
typeType
||
TSDB_CHILD_TABLE
==
typeType
)
&&
1
==
pSelect
->
pPartitionByList
->
length
&&
(
QUERY_NODE_FUNCTION
==
nodeType
(
pPar
)
&&
FUNCTION_TYPE_TBNAME
==
((
SFunctionNode
*
)
pPar
)
->
funcType
)))
{
if
(
!
((
TSDB_NORMAL_TABLE
==
typeType
||
TSDB_CHILD_TABLE
==
typeType
)
&&
1
==
pSelect
->
pPartitionByList
->
length
&&
(
QUERY_NODE_FUNCTION
==
nodeType
(
pPar
)
&&
FUNCTION_TYPE_TBNAME
==
((
SFunctionNode
*
)
pPar
)
->
funcType
)))
{
pSelect
->
timeLineResMode
=
TIME_LINE_MULTI
;
}
...
...
@@ -3943,9 +3950,9 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
}
snprintf
(
pRightExpr
->
aliasName
,
sizeof
(
pRightExpr
->
aliasName
),
"%s"
,
pLeftExpr
->
aliasName
);
SNode
*
pProj
=
createSetOperProject
(
pSetOperator
->
stmtName
,
pLeft
);
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pLeft
)
&&
QUERY_NODE_COLUMN
==
nodeType
(
pRight
)
&&
((
SColumnNode
*
)
pLeft
)
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
&&
((
SColumnNode
*
)
pRight
)
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pLeft
)
&&
QUERY_NODE_COLUMN
==
nodeType
(
pRight
)
&&
((
SColumnNode
*
)
pLeft
)
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
&&
((
SColumnNode
*
)
pRight
)
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
((
SColumnNode
*
)
pProj
)
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
}
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pSetOperator
->
pProjectionList
,
pProj
))
{
...
...
@@ -5725,7 +5732,6 @@ static int32_t translateRestoreDnode(STranslateContext* pCxt, SRestoreComponentN
return
buildCmdMsg
(
pCxt
,
TDMT_MND_RESTORE_DNODE
,
(
FSerializeFunc
)
tSerializeSRestoreDnodeReq
,
&
restoreReq
);
}
static
int32_t
getSmaIndexDstVgId
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
int32_t
*
pVgId
)
{
SVgroupInfo
vg
=
{
0
};
...
...
@@ -5867,13 +5873,15 @@ int32_t createIntervalFromCreateSmaIndexStmt(SCreateIndexStmt* pStmt, SInterval*
pInterval
->
interval
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
datum
.
i
;
pInterval
->
intervalUnit
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
unit
;
pInterval
->
offset
=
NULL
!=
pStmt
->
pOptions
->
pOffset
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
)
->
datum
.
i
:
0
;
pInterval
->
sliding
=
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
pInterval
->
interval
;
pInterval
->
slidingUnit
=
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pInterval
->
intervalUnit
;
pInterval
->
sliding
=
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
pInterval
->
interval
;
pInterval
->
slidingUnit
=
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pInterval
->
intervalUnit
;
pInterval
->
precision
=
pStmt
->
pOptions
->
tsPrecision
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
translatePostCreateSmaIndex
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
,
void
**
pResRow
)
{
int32_t
translatePostCreateSmaIndex
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
,
void
**
pResRow
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SCreateIndexStmt
*
pStmt
=
(
SCreateIndexStmt
*
)
pQuery
->
pRoot
;
int64_t
lastTs
=
0
;
...
...
@@ -6041,7 +6049,7 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
subDbName
,
pStmt
->
subSTbName
,
&
name
);
tNameGetFullDbName
(
&
name
,
pReq
->
subDbName
);
tNameExtractFullName
(
&
name
,
pReq
->
subStbName
);
if
(
pStmt
->
pQuery
!=
NULL
)
{
if
(
pStmt
->
pQuery
!=
NULL
)
{
code
=
nodesNodeToString
(
pStmt
->
pQuery
,
false
,
&
pReq
->
ast
,
NULL
);
}
}
else
if
(
'\0'
!=
pStmt
->
subDbName
[
0
])
{
...
...
@@ -6100,7 +6108,8 @@ static EDealRes checkColumnTagsInCond(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
static
int32_t
checkCollectTopicTags
(
STranslateContext
*
pCxt
,
SCreateTopicStmt
*
pStmt
,
STableMeta
*
pMeta
,
SNodeList
**
ppProjection
)
{
static
int32_t
checkCollectTopicTags
(
STranslateContext
*
pCxt
,
SCreateTopicStmt
*
pStmt
,
STableMeta
*
pMeta
,
SNodeList
**
ppProjection
)
{
SBuildTopicContext
colCxt
=
{.
colExists
=
false
,
.
colNotFound
=
false
,
.
pMeta
=
pMeta
,
.
pTags
=
NULL
};
nodesWalkExprPostOrder
(
pStmt
->
pWhere
,
checkColumnTagsInCond
,
&
colCxt
);
if
(
colCxt
.
colNotFound
)
{
...
...
@@ -6111,7 +6120,7 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt*
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_SYNTAX_ERROR
,
"Columns are forbidden in where clause"
);
}
if
(
NULL
==
colCxt
.
pTags
)
{
// put one column to select
// for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) {
// for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) {
SSchema
*
column
=
&
pMeta
->
schema
[
0
];
SColumnNode
*
col
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
col
)
{
...
...
@@ -6121,7 +6130,7 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt*
strcpy
(
col
->
node
.
aliasName
,
col
->
colName
);
strcpy
(
col
->
node
.
userAlias
,
col
->
colName
);
addTagList
(
&
colCxt
.
pTags
,
(
SNode
*
)
col
);
// }
// }
}
*
ppProjection
=
colCxt
.
pTags
;
...
...
@@ -6542,7 +6551,8 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
,
"SUBTABLE expression must be of VARCHAR type"
);
}
if
(
NULL
!=
pSelect
->
pSubtable
&&
0
==
LIST_LENGTH
(
pSelect
->
pPartitionByList
)
&&
subtableExprHasColumnOrPseudoColumn
(
pSelect
->
pSubtable
))
{
if
(
NULL
!=
pSelect
->
pSubtable
&&
0
==
LIST_LENGTH
(
pSelect
->
pPartitionByList
)
&&
subtableExprHasColumnOrPseudoColumn
(
pSelect
->
pSubtable
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
,
"SUBTABLE expression must not has column when no partition by clause"
);
}
...
...
@@ -6900,13 +6910,13 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
strcpy
(
col
->
colName
,
pMeta
->
schema
[
0
].
name
);
SNodeList
*
pParamterList
=
nodesMakeList
();
if
(
NULL
==
pParamterList
)
{
nodesDestroyNode
((
SNode
*
)
col
);
nodesDestroyNode
((
SNode
*
)
col
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
nodesListStrictAppend
(
pParamterList
,
(
SNode
*
)
col
);
int32_t
code
=
nodesListStrictAppend
(
pParamterList
,
(
SNode
*
)
col
);
if
(
code
)
{
nodesDestroyNode
((
SNode
*
)
col
);
nodesDestroyNode
((
SNode
*
)
col
);
nodesDestroyList
(
pParamterList
);
return
code
;
}
...
...
@@ -6929,7 +6939,7 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
return
code
;
}
code
=
createSimpleSelectStmtFromProjList
(
pDb
,
pTable
,
pProjectionList
,
(
SSelectStmt
**
)
pQuery
);
code
=
createSimpleSelectStmtFromProjList
(
pDb
,
pTable
,
pProjectionList
,
(
SSelectStmt
**
)
pQuery
);
if
(
code
)
{
nodesDestroyList
(
pProjectionList
);
return
code
;
...
...
@@ -6967,14 +6977,14 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt
if
(
TSDB_CODE_SUCCESS
==
code
&&
pStmt
->
pOptions
->
fillHistory
)
{
SRealTableNode
*
pTable
=
(
SRealTableNode
*
)(((
SSelectStmt
*
)
pStmt
->
pQuery
)
->
pFromTable
);
code
=
createLastTsSelectStmt
(
pTable
->
table
.
dbName
,
pTable
->
table
.
tableName
,
pTable
->
pMeta
,
&
pStmt
->
pPrevQuery
);
/*
/*
if (TSDB_CODE_SUCCESS == code) {
STranslateContext cxt = {0};
int32_t code = initTranslateContext(pCxt->pParseCxt, pCxt->pMetaCache, &cxt);
code = translateQuery(&cxt, pStmt->pPrevQuery);
destroyTranslateContext(&cxt);
}
*/
*/
}
taosMemoryFree
(
pMeta
);
return
code
;
...
...
@@ -7121,7 +7131,6 @@ int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void
return
code
;
}
static
int32_t
translateDropStream
(
STranslateContext
*
pCxt
,
SDropStreamStmt
*
pStmt
)
{
SMDropStreamReq
dropReq
=
{
0
};
SName
name
;
...
...
@@ -7152,7 +7161,7 @@ static int32_t translateResumeStream(STranslateContext* pCxt, SResumeStreamStmt*
static
int32_t
readFromFile
(
char
*
pName
,
int32_t
*
len
,
char
**
buf
)
{
int64_t
filesize
=
0
;
if
(
taosStatFile
(
pName
,
&
filesize
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
pName
,
&
filesize
,
NULL
,
NULL
)
<
0
)
{
return
TAOS_SYSTEM_ERROR
(
errno
);
}
...
...
@@ -7806,7 +7815,8 @@ static SNodeList* createProjectCols(int32_t ncols, const char* const pCols[]) {
return
pProjections
;
}
static
int32_t
createSimpleSelectStmtImpl
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
)
{
static
int32_t
createSimpleSelectStmtImpl
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
nodesMakeNode
(
QUERY_NODE_SELECT_STMT
);
if
(
NULL
==
pSelect
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -7829,7 +7839,6 @@ static int32_t createSimpleSelectStmtImpl(const char* pDb, const char* pTable, S
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
createSimpleSelectStmtFromCols
(
const
char
*
pDb
,
const
char
*
pTable
,
int32_t
numOfProjs
,
const
char
*
const
pProjCol
[],
SSelectStmt
**
pStmt
)
{
SNodeList
*
pProjectionList
=
NULL
;
...
...
@@ -7843,13 +7852,15 @@ static int32_t createSimpleSelectStmtFromCols(const char* pDb, const char* pTabl
return
createSimpleSelectStmtImpl
(
pDb
,
pTable
,
pProjectionList
,
pStmt
);
}
static
int32_t
createSimpleSelectStmtFromProjList
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
)
{
static
int32_t
createSimpleSelectStmtFromProjList
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
)
{
return
createSimpleSelectStmtImpl
(
pDb
,
pTable
,
pProjectionList
,
pStmt
);
}
static
int32_t
createSelectStmtForShow
(
ENodeType
showType
,
SSelectStmt
**
pStmt
)
{
const
SSysTableShowAdapter
*
pShow
=
&
sysTableShowAdapter
[
showType
-
SYSTABLE_SHOW_TYPE_OFFSET
];
return
createSimpleSelectStmtFromCols
(
pShow
->
pDbName
,
pShow
->
pTableName
,
pShow
->
numOfShowCols
,
pShow
->
pShowCols
,
pStmt
);
return
createSimpleSelectStmtFromCols
(
pShow
->
pDbName
,
pShow
->
pTableName
,
pShow
->
numOfShowCols
,
pShow
->
pShowCols
,
pStmt
);
}
static
int32_t
createSelectStmtForShowTableDist
(
SShowTableDistributedStmt
*
pStmt
,
SSelectStmt
**
pOutput
)
{
...
...
@@ -7987,8 +7998,8 @@ static int32_t createShowTableTagsProjections(SNodeList** pProjections, SNodeLis
static
int32_t
rewriteShowStableTags
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
SShowTableTagsStmt
*
pShow
=
(
SShowTableTagsStmt
*
)
pQuery
->
pRoot
;
SSelectStmt
*
pSelect
=
NULL
;
int32_t
code
=
createSimpleSelectStmtFromCols
(((
SValueNode
*
)
pShow
->
pDbName
)
->
literal
,
((
SValueNode
*
)
pShow
->
pT
bName
)
->
literal
,
-
1
,
NULL
,
&
pSelect
);
int32_t
code
=
createSimpleSelectStmtFromCols
(((
SValueNode
*
)
pShow
->
pD
bName
)
->
literal
,
((
SValueNode
*
)
pShow
->
pTbName
)
->
literal
,
-
1
,
NULL
,
&
pSelect
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createShowTableTagsProjections
(
&
pSelect
->
pProjectionList
,
&
pShow
->
pTags
);
}
...
...
source/libs/sync/src/syncRaftStore.c
浏览文件 @
fac7e521
...
...
@@ -42,7 +42,7 @@ int32_t raftStoreReadFile(SSyncNode *pNode) {
const
char
*
file
=
pNode
->
raftStorePath
;
SRaftStore
*
pStore
=
&
pNode
->
raftStore
;
if
(
taosStatFile
(
file
,
NULL
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
file
,
NULL
,
NULL
,
NULL
)
<
0
)
{
sInfo
(
"vgId:%d, raft store file:%s not exist, use default value"
,
pNode
->
vgId
,
file
);
pStore
->
currentTerm
=
0
;
pStore
->
voteFor
.
addr
=
0
;
...
...
source/libs/wal/src/walMeta.c
浏览文件 @
fac7e521
...
...
@@ -53,7 +53,7 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) {
walBuildLogName
(
pWal
,
pFileInfo
->
firstVer
,
fnameStr
);
int64_t
fileSize
=
0
;
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
);
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
,
NULL
);
TdFilePtr
pFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_READ
|
TD_FILE_WRITE
);
if
(
pFile
==
NULL
)
{
...
...
@@ -304,7 +304,7 @@ int walRepairLogFileTs(SWal* pWal, bool* updateMeta) {
walBuildLogName
(
pWal
,
pFileInfo
->
firstVer
,
fnameStr
);
int32_t
mtime
=
0
;
if
(
taosStatFile
(
fnameStr
,
NULL
,
&
mtime
)
<
0
)
{
if
(
taosStatFile
(
fnameStr
,
NULL
,
&
mtime
,
NULL
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"vgId:%d, failed to stat file due to %s, file:%s"
,
pWal
->
cfg
.
vgId
,
strerror
(
errno
),
fnameStr
);
return
-
1
;
...
...
@@ -353,7 +353,7 @@ int walTrimIdxFile(SWal* pWal, int32_t fileIdx) {
walBuildIdxName
(
pWal
,
pFileInfo
->
firstVer
,
fnameStr
);
int64_t
fileSize
=
0
;
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
);
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
,
NULL
);
int64_t
records
=
TMAX
(
0
,
pFileInfo
->
lastVer
-
pFileInfo
->
firstVer
+
1
);
int64_t
lastEndOffset
=
records
*
sizeof
(
SWalIdxEntry
);
...
...
@@ -436,7 +436,7 @@ int walCheckAndRepairMeta(SWal* pWal) {
SWalFileInfo
*
pFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
fileIdx
);
walBuildLogName
(
pWal
,
pFileInfo
->
firstVer
,
fnameStr
);
int32_t
code
=
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
);
int32_t
code
=
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
,
NULL
);
if
(
code
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"failed to stat file since %s. file:%s"
,
terrstr
(),
fnameStr
);
...
...
@@ -522,7 +522,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
walBuildLogName
(
pWal
,
pFileInfo
->
firstVer
,
fLogNameStr
);
int64_t
fileSize
=
0
;
if
(
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
)
<
0
&&
errno
!=
ENOENT
)
{
if
(
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
,
NULL
)
<
0
&&
errno
!=
ENOENT
)
{
wError
(
"vgId:%d, failed to stat file due to %s. file:%s"
,
pWal
->
cfg
.
vgId
,
strerror
(
errno
),
fnameStr
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -935,7 +935,7 @@ int walLoadMeta(SWal* pWal) {
walBuildMetaName
(
pWal
,
metaVer
,
fnameStr
);
// read metafile
int64_t
fileSize
=
0
;
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
);
taosStatFile
(
fnameStr
,
&
fileSize
,
NULL
,
NULL
);
if
(
fileSize
==
0
)
{
(
void
)
taosRemoveFile
(
fnameStr
);
wDebug
(
"vgId:%d, wal find empty meta ver %d"
,
pWal
->
cfg
.
vgId
,
metaVer
);
...
...
source/os/src/osFile.c
浏览文件 @
fac7e521
...
...
@@ -191,7 +191,7 @@ int32_t taosRenameFile(const char *oldName, const char *newName) {
#endif
}
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
)
{
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
,
int32_t
*
atime
)
{
#ifdef WINDOWS
struct
_stati64
fileStat
;
int32_t
code
=
_stati64
(
path
,
&
fileStat
);
...
...
@@ -211,6 +211,10 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
*
mtime
=
fileStat
.
st_mtime
;
}
if
(
atime
!=
NULL
)
{
*
atime
=
fileStat
.
st_mtime
;
}
return
0
;
}
int32_t
taosDevInoFile
(
TdFilePtr
pFile
,
int64_t
*
stDev
,
int64_t
*
stIno
)
{
...
...
source/util/src/tlog.c
浏览文件 @
fac7e521
...
...
@@ -17,8 +17,8 @@
#include "tlog.h"
#include "os.h"
#include "tconfig.h"
#include "tjson.h"
#include "tglobal.h"
#include "tjson.h"
#define LOG_MAX_LINE_SIZE (10024)
#define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 3)
...
...
@@ -403,13 +403,13 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
strcpy
(
name
,
fn
);
strcat
(
name
,
".0"
);
}
bool
log0Exist
=
taosStatFile
(
name
,
NULL
,
&
logstat0_mtime
)
>=
0
;
bool
log0Exist
=
taosStatFile
(
name
,
NULL
,
&
logstat0_mtime
,
NULL
)
>=
0
;
if
(
strlen
(
fn
)
<
LOG_FILE_NAME_LEN
+
50
-
2
)
{
strcpy
(
name
,
fn
);
strcat
(
name
,
".1"
);
}
bool
log1Exist
=
taosStatFile
(
name
,
NULL
,
&
logstat1_mtime
)
>=
0
;
bool
log1Exist
=
taosStatFile
(
name
,
NULL
,
&
logstat1_mtime
,
NULL
)
>=
0
;
// if none of the log files exist, open 0, if both exists, open the old one
if
(
!
log0Exist
&&
!
log1Exist
)
{
...
...
@@ -834,7 +834,7 @@ bool taosAssertDebug(bool condition, const char *file, int32_t line, const char
return
true
;
}
void
taosLogCrashInfo
(
char
*
nodeType
,
char
*
pMsg
,
int64_t
msgLen
,
int
signum
,
void
*
sigInfo
)
{
void
taosLogCrashInfo
(
char
*
nodeType
,
char
*
pMsg
,
int64_t
msgLen
,
int
signum
,
void
*
sigInfo
)
{
const
char
*
flags
=
"UTL FATAL "
;
ELogLevel
level
=
DEBUG_FATAL
;
int32_t
dflag
=
255
;
...
...
@@ -892,17 +892,17 @@ _return:
taosMemoryFree
(
pMsg
);
}
void
taosReadCrashInfo
(
char
*
filepath
,
char
**
pMsg
,
int64_t
*
pMsgLen
,
TdFilePtr
*
pFd
)
{
void
taosReadCrashInfo
(
char
*
filepath
,
char
**
pMsg
,
int64_t
*
pMsgLen
,
TdFilePtr
*
pFd
)
{
const
char
*
flags
=
"UTL FATAL "
;
ELogLevel
level
=
DEBUG_FATAL
;
int32_t
dflag
=
255
;
TdFilePtr
pFile
=
NULL
;
bool
truncateFile
=
false
;
char
*
buf
=
NULL
;
char
*
buf
=
NULL
;
if
(
NULL
==
*
pFd
)
{
int64_t
filesize
=
0
;
if
(
taosStatFile
(
filepath
,
&
filesize
,
NULL
)
<
0
)
{
if
(
taosStatFile
(
filepath
,
&
filesize
,
NULL
,
NULL
)
<
0
)
{
if
(
ENOENT
==
errno
)
{
return
;
}
...
...
@@ -916,7 +916,7 @@ void taosReadCrashInfo(char* filepath, char** pMsg, int64_t* pMsgLen, TdFilePtr*
return
;
}
pFile
=
taosOpenFile
(
filepath
,
TD_FILE_READ
|
TD_FILE_WRITE
);
pFile
=
taosOpenFile
(
filepath
,
TD_FILE_READ
|
TD_FILE_WRITE
);
if
(
pFile
==
NULL
)
{
if
(
ENOENT
==
errno
)
{
return
;
...
...
@@ -952,8 +952,8 @@ void taosReadCrashInfo(char* filepath, char** pMsg, int64_t* pMsgLen, TdFilePtr*
readSize
=
taosReadFile
(
pFile
,
buf
,
msgLen
);
if
(
msgLen
!=
readSize
)
{
truncateFile
=
true
;
taosPrintLog
(
flags
,
level
,
dflag
,
"failed to read file:%s,%p wlen:%"
PRId64
" tlen:%"
PRId64
" since %s"
,
filepath
,
pFile
,
readSize
,
msgLen
,
terrstr
());
taosPrintLog
(
flags
,
level
,
dflag
,
"failed to read file:%s,%p wlen:%"
PRId64
" tlen:%"
PRId64
" since %s"
,
filepath
,
pFile
,
readSize
,
msgLen
,
terrstr
());
goto
_return
;
}
...
...
tools/shell/src/shellEngine.c
浏览文件 @
fac7e521
...
...
@@ -18,9 +18,9 @@
#define _GNU_SOURCE
#define _XOPEN_SOURCE
#define _DEFAULT_SOURCE
#include "shellInt.h"
#include "shellAuto.h"
#include "geosWrapper.h"
#include "shellAuto.h"
#include "shellInt.h"
static
bool
shellIsEmptyCommand
(
const
char
*
cmd
);
static
int32_t
shellRunSingleCommand
(
char
*
command
);
...
...
@@ -143,7 +143,7 @@ int32_t shellRunCommand(char *command, bool recordHistory) {
}
// add help or help;
if
(
strncasecmp
(
command
,
"help;"
,
5
)
==
0
)
{
if
(
strncasecmp
(
command
,
"help;"
,
5
)
==
0
)
{
showHelp
();
return
0
;
}
...
...
@@ -223,14 +223,14 @@ void shellRunSingleCommandImp(char *command) {
}
// pre string
char
*
pre
=
"Query OK"
;
char
*
pre
=
"Query OK"
;
if
(
shellRegexMatch
(
command
,
"^
\\
s*delete
\\
s*from
\\
s*.*"
,
REG_EXTENDED
|
REG_ICASE
))
{
pre
=
"Delete OK"
;
}
else
if
(
shellRegexMatch
(
command
,
"^
\\
s*insert
\\
s*into
\\
s*.*"
,
REG_EXTENDED
|
REG_ICASE
))
{
}
else
if
(
shellRegexMatch
(
command
,
"^
\\
s*insert
\\
s*into
\\
s*.*"
,
REG_EXTENDED
|
REG_ICASE
))
{
pre
=
"Insert OK"
;
}
else
if
(
shellRegexMatch
(
command
,
"^
\\
s*create
\\
s*.*"
,
REG_EXTENDED
|
REG_ICASE
))
{
}
else
if
(
shellRegexMatch
(
command
,
"^
\\
s*create
\\
s*.*"
,
REG_EXTENDED
|
REG_ICASE
))
{
pre
=
"Create OK"
;
}
else
if
(
shellRegexMatch
(
command
,
"^
\\
s*drop
\\
s*.*"
,
REG_EXTENDED
|
REG_ICASE
))
{
}
else
if
(
shellRegexMatch
(
command
,
"^
\\
s*drop
\\
s*.*"
,
REG_EXTENDED
|
REG_ICASE
))
{
pre
=
"Drop OK"
;
}
...
...
@@ -387,8 +387,7 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_JSON
:
{
case
TSDB_DATA_TYPE_JSON
:
{
int32_t
bufIndex
=
0
;
for
(
int32_t
i
=
0
;
i
<
length
;
i
++
)
{
buf
[
bufIndex
]
=
val
[
i
];
...
...
@@ -401,8 +400,7 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
buf
[
bufIndex
]
=
0
;
taosFprintfFile
(
pFile
,
"%s%s%s"
,
quotationStr
,
buf
,
quotationStr
);
}
break
;
}
break
;
case
TSDB_DATA_TYPE_GEOMETRY
:
shellDumpHexValue
(
buf
,
val
,
length
);
taosFprintfFile
(
pFile
,
"%s"
,
buf
);
...
...
@@ -535,12 +533,10 @@ void shellPrintString(const char *str, int32_t width) {
if
(
width
==
0
)
{
printf
(
"%s"
,
str
);
}
else
if
(
len
>
width
)
{
}
else
if
(
len
>
width
)
{
if
(
width
<=
3
)
{
printf
(
"%.*s."
,
width
-
1
,
str
);
}
else
{
}
else
{
printf
(
"%.*s..."
,
width
-
3
,
str
);
}
}
else
{
...
...
@@ -549,7 +545,7 @@ void shellPrintString(const char *str, int32_t width) {
}
void
shellPrintGeometry
(
const
unsigned
char
*
val
,
int32_t
length
,
int32_t
width
)
{
if
(
length
==
0
)
{
//empty value
if
(
length
==
0
)
{
//
empty value
shellPrintString
(
""
,
width
);
return
;
}
...
...
@@ -565,7 +561,7 @@ void shellPrintGeometry(const unsigned char *val, int32_t length, int32_t width)
char
*
outputWKT
=
NULL
;
code
=
doAsText
(
val
,
length
,
&
outputWKT
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
shellPrintString
(
getThreadLocalGeosCtx
()
->
errMsg
,
width
);
//should NOT happen
shellPrintString
(
getThreadLocalGeosCtx
()
->
errMsg
,
width
);
//
should NOT happen
return
;
}
...
...
@@ -612,12 +608,11 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
break
;
case
TSDB_DATA_TYPE_FLOAT
:
if
(
tsEnableScience
)
{
printf
(
"%*.7e"
,
width
,
GET_FLOAT_VAL
(
val
));
printf
(
"%*.7e"
,
width
,
GET_FLOAT_VAL
(
val
));
}
else
{
n
=
snprintf
(
buf
,
TSDB_MAX_BYTES_PER_ROW
,
"%*.7f"
,
width
,
GET_FLOAT_VAL
(
val
));
if
(
n
>
SHELL_FLOAT_WIDTH
)
{
printf
(
"%*.7e"
,
width
,
GET_FLOAT_VAL
(
val
));
printf
(
"%*.7e"
,
width
,
GET_FLOAT_VAL
(
val
));
}
else
{
printf
(
"%s"
,
buf
);
}
...
...
@@ -625,14 +620,14 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
if
(
tsEnableScience
)
{
snprintf
(
buf
,
TSDB_MAX_BYTES_PER_ROW
,
"%*.15e"
,
width
,
GET_DOUBLE_VAL
(
val
));
snprintf
(
buf
,
TSDB_MAX_BYTES_PER_ROW
,
"%*.15e"
,
width
,
GET_DOUBLE_VAL
(
val
));
printf
(
"%s"
,
buf
);
}
else
{
n
=
snprintf
(
buf
,
TSDB_MAX_BYTES_PER_ROW
,
"%*.15f"
,
width
,
GET_DOUBLE_VAL
(
val
));
if
(
n
>
SHELL_DOUBLE_WIDTH
)
{
printf
(
"%*.15e"
,
width
,
GET_DOUBLE_VAL
(
val
));
}
else
{
printf
(
"%*s"
,
width
,
buf
);
printf
(
"%*s"
,
width
,
buf
);
}
}
break
;
...
...
@@ -922,7 +917,7 @@ void shellReadHistory() {
taosMemoryFreeClear
(
line
);
taosCloseFile
(
&
pFile
);
int64_t
file_size
;
if
(
taosStatFile
(
pHistory
->
file
,
&
file_size
,
NULL
)
==
0
&&
file_size
>
SHELL_MAX_COMMAND_SIZE
)
{
if
(
taosStatFile
(
pHistory
->
file
,
&
file_size
,
NULL
,
NULL
)
==
0
&&
file_size
>
SHELL_MAX_COMMAND_SIZE
)
{
TdFilePtr
pFile
=
taosOpenFile
(
pHistory
->
file
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_STREAM
|
TD_FILE_TRUNC
);
if
(
pFile
==
NULL
)
return
;
int32_t
endIndex
=
pHistory
->
hstart
;
...
...
@@ -991,7 +986,7 @@ void shellSourceFile(const char *file) {
tstrncpy
(
fullname
,
file
,
PATH_MAX
);
}
sprintf
(
sourceFileCommand
,
"source %s;"
,
fullname
);
sprintf
(
sourceFileCommand
,
"source %s;"
,
fullname
);
shellRecordCommandToHistory
(
sourceFileCommand
);
TdFilePtr
pFile
=
taosOpenFile
(
fullname
,
TD_FILE_READ
|
TD_FILE_STREAM
);
...
...
@@ -1044,7 +1039,8 @@ void shellGetGrantInfo() {
int32_t
code
=
taos_errno
(
tres
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_OPS_NOT_SUPPORT
&&
code
!=
TSDB_CODE_MND_NO_RIGHTS
&&
code
!=
TSDB_CODE_PAR_PERMISSION_DENIED
)
{
if
(
code
!=
TSDB_CODE_OPS_NOT_SUPPORT
&&
code
!=
TSDB_CODE_MND_NO_RIGHTS
&&
code
!=
TSDB_CODE_PAR_PERMISSION_DENIED
)
{
fprintf
(
stderr
,
"Failed to check Server Edition, Reason:0x%04x:%s
\r\n\r\n
"
,
code
,
taos_errstr
(
tres
));
}
return
;
...
...
@@ -1080,7 +1076,8 @@ void shellGetGrantInfo() {
}
else
if
(
strcmp
(
expiretime
,
"unlimited"
)
==
0
)
{
fprintf
(
stdout
,
"Server is Enterprise %s Edition, %s and will never expire.
\r\n
"
,
serverVersion
,
sinfo
);
}
else
{
fprintf
(
stdout
,
"Server is Enterprise %s Edition, %s and will expire at %s.
\r\n
"
,
serverVersion
,
sinfo
,
expiretime
);
fprintf
(
stdout
,
"Server is Enterprise %s Edition, %s and will expire at %s.
\r\n
"
,
serverVersion
,
sinfo
,
expiretime
);
}
taos_free_result
(
tres
);
...
...
@@ -1123,9 +1120,9 @@ void *shellCancelHandler(void *arg) {
#ifdef WEBSOCKET
}
#endif
#ifdef WINDOWS
#ifdef WINDOWS
printf
(
"
\n
%s"
,
shell
.
info
.
promptHeader
);
#endif
#endif
}
return
NULL
;
...
...
@@ -1165,8 +1162,7 @@ void *shellThreadLoop(void *arg) {
}
int32_t
shellExecute
()
{
printf
(
shell
.
info
.
clientVersion
,
shell
.
info
.
cusName
,
taos_get_client_info
(),
shell
.
info
.
cusName
);
printf
(
shell
.
info
.
clientVersion
,
shell
.
info
.
cusName
,
taos_get_client_info
(),
shell
.
info
.
cusName
);
fflush
(
stdout
);
SShellArgs
*
pArgs
=
&
shell
.
args
;
...
...
utils/test/c/tmqDemo.c
浏览文件 @
fac7e521
...
...
@@ -221,7 +221,7 @@ int64_t getDirectorySize(char* dir) {
totalSize
+=
subDirSize
;
}
else
if
(
0
==
strcmp
(
strchr
(
fileName
,
'.'
),
".log"
))
{
// only calc .log file size, and not include .idx file
int64_t
file_size
=
0
;
taosStatFile
(
subdir
,
&
file_size
,
NULL
);
taosStatFile
(
subdir
,
&
file_size
,
NULL
,
NULL
);
totalSize
+=
file_size
;
}
}
...
...
@@ -702,4 +702,3 @@ int main(int32_t argc, char* argv[]) {
taosCloseFile
(
&
g_fp
);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录