Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
codyshao
TDengine
提交
565e7fde
T
TDengine
项目概览
codyshao
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
565e7fde
编写于
8月 11, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
8月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3018 from taosdata/feature/os
Feature/os
上级
3fbd7388
2bd37287
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
200 addition
and
13 deletion
+200
-13
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+8
-1
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+9
-2
src/kit/shell/src/shellWindows.c
src/kit/shell/src/shellWindows.c
+1
-1
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+1
-1
src/os/src/windows/w64Atomic.c
src/os/src/windows/w64Atomic.c
+4
-0
src/os/src/windows/w64Dir.c
src/os/src/windows/w64Dir.c
+1
-1
src/os/src/windows/w64Lz4.c
src/os/src/windows/w64Lz4.c
+25
-1
src/os/src/windows/w64Sysinfo.c
src/os/src/windows/w64Sysinfo.c
+86
-5
tests/script/unique/big/balance.sim
tests/script/unique/big/balance.sim
+57
-0
tests/script/windows/compute/leastsquare.sim
tests/script/windows/compute/leastsquare.sim
+2
-0
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+6
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
565e7fde
...
...
@@ -1125,7 +1125,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
int32_t
tableIndex
=
columnList
.
ids
[
0
].
tableIndex
;
// todo potential data overflow
char
arithmeticExprStr
[
1024
*
12
]
;
char
*
arithmeticExprStr
=
malloc
(
1024
*
1024
)
;
char
*
p
=
arithmeticExprStr
;
if
(
arithmeticType
==
NORMAL_ARITHMETIC
)
{
...
...
@@ -1134,11 +1134,13 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
// all columns in arithmetic expression must belong to the same table
for
(
int32_t
f
=
1
;
f
<
columnList
.
num
;
++
f
)
{
if
(
columnList
.
ids
[
f
].
tableIndex
!=
tableIndex
)
{
taosTFree
(
arithmeticExprStr
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
}
if
(
arithmeticExprToString
(
pItem
->
pNode
,
&
p
)
!=
TSDB_CODE_SUCCESS
)
{
taosTFree
(
arithmeticExprStr
);
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
@@ -1157,6 +1159,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pNode
,
pItem
->
pNode
,
pQueryInfo
->
exprList
,
pQueryInfo
,
colList
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tExprTreeDestroy
(
&
pNode
,
NULL
);
taosTFree
(
arithmeticExprStr
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
...
...
@@ -1164,6 +1167,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
for
(
int32_t
k
=
0
;
k
<
numOfNode
;
++
k
)
{
SColIndex
*
pIndex
=
taosArrayGet
(
colList
,
k
);
if
(
pIndex
->
flag
==
1
)
{
taosTFree
(
arithmeticExprStr
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
...
...
@@ -1190,6 +1194,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
tExprTreeDestroy
(
&
pNode
,
NULL
);
}
else
{
if
(
arithmeticExprToString
(
pItem
->
pNode
,
&
p
)
!=
TSDB_CODE_SUCCESS
)
{
taosTFree
(
arithmeticExprStr
);
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
@@ -1213,6 +1218,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pArithExprInfo
->
pExpr
,
pItem
->
pNode
,
pQueryInfo
->
exprList
,
pQueryInfo
,
NULL
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tExprTreeDestroy
(
&
pArithExprInfo
->
pExpr
,
NULL
);
taosTFree
(
arithmeticExprStr
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"invalid expression in select clause"
);
}
...
...
@@ -1220,6 +1226,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
}
}
taosTFree
(
arithmeticExprStr
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
565e7fde
...
...
@@ -128,6 +128,9 @@ static int32_t shellRunSingleCommand(TAOS *con, char *command) {
if
(
regex_match
(
command
,
"^[
\t
]*(quit|q|exit)[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
taos_close
(
con
);
write_history
();
#ifdef WINDOWS
exit
(
EXIT_SUCCESS
);
#endif
return
-
1
;
}
...
...
@@ -368,6 +371,10 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
tt
=
(
time_t
)(
val
/
1000
);
}
if
(
tt
<
0
)
{
tt
=
0
;
}
struct
tm
*
ptm
=
localtime
(
&
tt
);
size_t
pos
=
strftime
(
buf
,
32
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
...
...
@@ -736,7 +743,7 @@ void read_history() {
FILE
*
f
=
fopen
(
f_history
,
"r"
);
if
(
f
==
NULL
)
{
fprintf
(
stderr
,
"
Opening
file %s
\n
"
,
f_history
);
fprintf
(
stderr
,
"
Failed to open
file %s
\n
"
,
f_history
);
return
;
}
...
...
@@ -761,7 +768,7 @@ void write_history() {
FILE
*
f
=
fopen
(
f_history
,
"w"
);
if
(
f
==
NULL
)
{
fprintf
(
stderr
,
"
Opening file %s
\n
"
,
f_history
);
fprintf
(
stderr
,
"
Failed to open file %s for write
\n
"
,
f_history
);
return
;
}
...
...
src/kit/shell/src/shellWindows.c
浏览文件 @
565e7fde
...
...
@@ -222,6 +222,6 @@ void *shellLoopQuery(void *arg) {
return
NULL
;
}
void
get_history_path
(
char
*
history
)
{
sprintf
(
history
,
"
%s/%s"
,
".
"
,
HISTORY_FILE
);
}
void
get_history_path
(
char
*
history
)
{
sprintf
(
history
,
"
C:/TDengine/%s
"
,
HISTORY_FILE
);
}
void
exitShell
()
{
exit
(
EXIT_SUCCESS
);
}
src/kit/taosdemo/taosdemo.c
浏览文件 @
565e7fde
...
...
@@ -306,7 +306,7 @@ typedef struct DemoArguments {
printf
(
"%s%s
\n
"
,
indent
,
"-R"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."
);
printf
(
"%s%s
\n
"
,
indent
,
"-D"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Delete data methods
——
0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Delete data methods
0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."
);
}
void
parse_args
(
int
argc
,
char
*
argv
[],
SDemoArguments
*
arguments
)
{
...
...
src/os/src/windows/w64Atomic.c
浏览文件 @
565e7fde
...
...
@@ -43,7 +43,11 @@ long interlocked_add_fetch_32(long volatile* ptr, long val) {
}
__int64
interlocked_add_fetch_64
(
__int64
volatile
*
ptr
,
__int64
val
)
{
#ifdef _WIN64
return
_InterlockedExchangeAdd64
(
ptr
,
val
)
+
val
;
#else
return
_InterlockedExchangeAdd
(
ptr
,
val
)
+
val
;
#endif
}
// and
...
...
src/os/src/windows/w64Dir.c
浏览文件 @
565e7fde
...
...
@@ -23,7 +23,7 @@ void taosRemoveDir(char *rootDir) {
int
taosMkDir
(
const
char
*
path
,
mode_t
mode
)
{
uError
(
"%s not implemented yet"
,
__FUNCTION__
);
return
-
1
;
return
0
;
}
void
taosMvDir
(
char
*
destDir
,
char
*
srcDir
)
{
...
...
src/os/src/windows/w64Lz4.c
浏览文件 @
565e7fde
...
...
@@ -21,9 +21,29 @@
#include "tulog.h"
#include "tutil.h"
unsigned
char
_MyBitScanForward64
(
unsigned
long
*
ret
,
uint64_t
x
)
{
unsigned
long
x0
=
(
unsigned
long
)
x
,
top
,
bottom
;
_BitScanForward
(
&
top
,
(
unsigned
long
)(
x
>>
32
));
_BitScanForward
(
&
bottom
,
x0
);
*
ret
=
x0
?
bottom
:
32
+
top
;
return
x
!=
0
;
}
unsigned
char
_MyBitScanReverse64
(
unsigned
long
*
ret
,
uint64_t
x
)
{
unsigned
long
x1
=
(
unsigned
long
)(
x
>>
32
),
top
,
bottom
;
_BitScanReverse
(
&
top
,
x1
);
_BitScanReverse
(
&
bottom
,
(
unsigned
long
)
x
);
*
ret
=
x1
?
top
+
32
:
bottom
;
return
x
!=
0
;
}
int32_t
BUILDIN_CLZL
(
uint64_t
val
)
{
unsigned
long
r
=
0
;
#ifdef _WIN64
_BitScanReverse64
(
&
r
,
val
);
#else
_MyBitScanReverse64
(
&
r
,
val
);
#endif
return
(
int
)(
r
>>
3
);
}
...
...
@@ -35,7 +55,11 @@ int32_t BUILDIN_CLZ(uint32_t val) {
int32_t
BUILDIN_CTZL
(
uint64_t
val
)
{
unsigned
long
r
=
0
;
#ifdef _WIN64
_BitScanForward64
(
&
r
,
val
);
#else
_MyBitScanForward64
(
&
r
,
val
);
#endif
return
(
int
)(
r
>>
3
);
}
...
...
@@ -43,4 +67,4 @@ int32_t BUILDIN_CTZ(uint32_t val) {
unsigned
long
r
=
0
;
_BitScanForward
(
&
r
,
val
);
return
(
int
)(
r
>>
3
);
}
}
\ No newline at end of file
src/os/src/windows/w64Sysinfo.c
浏览文件 @
565e7fde
...
...
@@ -21,6 +21,15 @@
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
#if (_WIN64)
#include <windows.h>
#include <iphlpapi.h>
#include <psapi.h>
#include <ws2tcpip.h>
#include <stdio.h>
#include <mswsock.h>
#pragma comment(lib, "Mswsock.lib ")
#endif
static
void
taosGetSystemTimezone
()
{
// get and set default timezone
...
...
@@ -69,11 +78,64 @@ void taosGetSystemInfo() {
taosGetSystemLocale
();
}
bool
taosGetDisk
()
{
return
true
;
}
bool
taosGetDisk
()
{
const
double
unit
=
1024
*
1024
*
1024
;
BOOL
fResult
;
unsigned
_int64
i64FreeBytesToCaller
;
unsigned
_int64
i64TotalBytes
;
unsigned
_int64
i64FreeBytes
;
char
dir
[
4
]
=
{
'C'
,
':'
,
'\\'
,
'\0'
};
int
drive_type
;
if
(
tscEmbedded
)
{
drive_type
=
GetDriveTypeA
(
dir
);
if
(
drive_type
==
DRIVE_FIXED
)
{
fResult
=
GetDiskFreeSpaceExA
(
dir
,
(
PULARGE_INTEGER
)
&
i64FreeBytesToCaller
,
(
PULARGE_INTEGER
)
&
i64TotalBytes
,
(
PULARGE_INTEGER
)
&
i64FreeBytes
);
if
(
fResult
)
{
tsTotalDataDirGB
=
tsTotalLogDirGB
=
tsTotalTmpDirGB
=
(
float
)(
i64TotalBytes
/
unit
);
tsAvailDataDirGB
=
tsAvailLogDirGB
=
tsAvailTmpDirectorySpace
=
(
float
)(
i64FreeBytes
/
unit
);
}
}
}
return
true
;
}
bool
taosReadProcIO
(
int64_t
*
readbyte
,
int64_t
*
writebyte
)
{
IO_COUNTERS
io_counter
;
if
(
GetProcessIoCounters
(
GetCurrentProcess
(),
&
io_counter
))
{
if
(
readbyte
)
*
readbyte
=
io_counter
.
ReadTransferCount
;
if
(
writebyte
)
*
writebyte
=
io_counter
.
WriteTransferCount
;
return
true
;
}
return
false
;
}
bool
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
)
{
*
readKB
=
0
;
*
writeKB
=
0
;
static
int64_t
lastReadbyte
=
-
1
;
static
int64_t
lastWritebyte
=
-
1
;
int64_t
curReadbyte
=
0
;
int64_t
curWritebyte
=
0
;
if
(
!
taosReadProcIO
(
&
curReadbyte
,
&
curWritebyte
))
{
return
false
;
}
if
(
lastReadbyte
==
-
1
||
lastWritebyte
==
-
1
)
{
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
return
false
;
}
*
readKB
=
(
float
)((
double
)(
curReadbyte
-
lastReadbyte
)
/
1024
);
*
writeKB
=
(
float
)((
double
)(
curWritebyte
-
lastWritebyte
)
/
1024
);
if
(
*
readKB
<
0
)
*
readKB
=
0
;
if
(
*
writeKB
<
0
)
*
writeKB
=
0
;
lastReadbyte
=
curReadbyte
;
lastWritebyte
=
curWritebyte
;
return
true
;
}
...
...
@@ -89,12 +151,31 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
}
bool
taosGetProcMemory
(
float
*
memoryUsedMB
)
{
*
memoryUsedMB
=
0
;
unsigned
bytes_used
=
0
;
#if defined(_WIN32) && defined(_MSC_VER)
PROCESS_MEMORY_COUNTERS
pmc
;
HANDLE
cur_proc
=
GetCurrentProcess
();
if
(
GetProcessMemoryInfo
(
cur_proc
,
&
pmc
,
sizeof
(
pmc
)))
{
bytes_used
=
(
unsigned
)(
pmc
.
WorkingSetSize
+
pmc
.
PagefileUsage
);
}
#endif
*
memoryUsedMB
=
(
float
)
bytes_used
/
1024
/
1024
;
return
true
;
}
bool
taosGetSysMemory
(
float
*
memoryUsedMB
)
{
*
memoryUsedMB
=
0
;
MEMORYSTATUSEX
memsStat
;
float
nMemFree
;
float
nMemTotal
;
memsStat
.
dwLength
=
sizeof
(
memsStat
);
if
(
!
GlobalMemoryStatusEx
(
&
memsStat
))
{
return
false
;
}
nMemFree
=
memsStat
.
ullAvailPhys
/
(
1024
.
0
f
*
1024
.
0
f
);
nMemTotal
=
memsStat
.
ullTotalPhys
/
(
1024
.
0
f
*
1024
.
0
f
);
*
memoryUsedMB
=
nMemTotal
-
nMemFree
;
return
true
;
}
...
...
tests/script/unique/big/balance.sim
浏览文件 @
565e7fde
...
...
@@ -321,6 +321,63 @@ if $data00 != $totalNum then
goto show5
endi
print ========== step6
sleep 3000
sql alter database db replica 1
$x = 0
show6:
$x = $x + 1
sleep 3000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 freeVnodes $data2_1
print dnode4 freeVnodes $data2_4
if $data2_1 != 2 then
goto show6
endi
if $data2_4 != 2 then
goto show6
endi
sql reset query cache
sleep 1000
sql select count(*) from t10
print select count(*) from t10 $data00 expect $rowNum
if $data00 != $rowNum then
goto show5
endi
sql select count(*) from t1010
print select count(*) from t1010 $data00 expect $rowNum
if $data00 != $rowNum then
goto show5
endi
sql select count(*) from t2010
print select count(*) from t2010 $data00 expect $rowNum
if $data00 != $rowNum then
goto show5
endi
sql select count(*) from t3010
print select count(*) from t3010 $data00 expect $rowNum
if $data00 != $rowNum then
goto show5
endi
sql select count(*) from mt
print select count(*) from mt $data00 expect $rowNum
if $data00 != $totalNum then
goto show5
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
...
...
tests/script/windows/compute/leastsquare.sim
浏览文件 @
565e7fde
...
...
@@ -69,12 +69,14 @@ if $data00 != @{slop:1.000000, intercept:1.000000}@ then
endi
print =============== step5
print select leastsquares(tbcol, 1, 1) as b from $tb interval(1d)
sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1m)
print ===> $data01
if $data01 != @{slop:1.000000, intercept:1.000000}@ then
return -1
endi
print select leastsquares(tbcol, 1, 1) as b from $tb interval(1d)
sql select leastsquares(tbcol, 1, 1) as b from $tb interval(1d)
print ===> $data01
if $data01 != @{slop:1.000000, intercept:1.000000}@ then
...
...
tests/tsim/src/simExe.c
浏览文件 @
565e7fde
...
...
@@ -783,10 +783,15 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
tt
=
*
(
int64_t
*
)
row
[
i
]
/
1000
;
if
(
tt
<
0
)
{
tt
=
0
;
}
tp
=
localtime
(
&
tt
);
strftime
(
timeStr
,
64
,
"%y-%m-%d %H:%M:%S"
,
tp
);
sprintf
(
value
,
"%s.%03d"
,
timeStr
,
(
int
)(
*
((
int64_t
*
)
row
[
i
])
%
1000
));
(
int
)(
*
((
int64_t
*
)
row
[
i
])
%
1000
));
break
;
default:
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录