Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dd3467f8
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
dd3467f8
编写于
9月 27, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
9月 27, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3693 from taosdata/feature/http
Feature/http
上级
2568e384
251fdf2c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
251 addition
and
16 deletion
+251
-16
src/dnode/src/dnodeModule.c
src/dnode/src/dnodeModule.c
+2
-2
src/mnode/src/mnodeInt.c
src/mnode/src/mnodeInt.c
+5
-0
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+2
-2
src/os/src/detail/osDir.c
src/os/src/detail/osDir.c
+2
-1
src/plugins/http/src/httpParser.c
src/plugins/http/src/httpParser.c
+15
-10
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+2
-1
tests/test/c/CMakeLists.txt
tests/test/c/CMakeLists.txt
+3
-0
tests/test/c/invalidTableId.c
tests/test/c/invalidTableId.c
+220
-0
未找到文件。
src/dnode/src/dnodeModule.c
浏览文件 @
dd3467f8
...
...
@@ -147,13 +147,13 @@ void dnodeProcessModuleStatus(uint32_t moduleStatus) {
}
bool
dnodeCheckMnodeStarting
()
{
if
(
tsModuleStatus
&
TSDB_MOD_MNODE
)
return
false
;
if
(
tsModuleStatus
&
(
1
<<
TSDB_MOD_MNODE
)
)
return
false
;
SDMMnodeInfos
*
mnodes
=
dnodeGetMnodeInfos
();
for
(
int32_t
i
=
0
;
i
<
mnodes
->
nodeNum
;
++
i
)
{
SDMMnodeInfo
*
node
=
&
mnodes
->
nodeInfos
[
i
];
if
(
node
->
nodeId
==
dnodeGetDnodeId
())
{
uint32_t
moduleStatus
=
tsModuleStatus
|
(
1
<<
TSDB_MOD_MNODE
);
;
uint32_t
moduleStatus
=
tsModuleStatus
|
(
1
<<
TSDB_MOD_MNODE
);
dInfo
(
"start mnode module, module status:%d, new status:%d"
,
tsModuleStatus
,
moduleStatus
);
dnodeProcessModuleStatus
(
moduleStatus
);
return
true
;
...
...
src/mnode/src/mnodeInt.c
浏览文件 @
dd3467f8
...
...
@@ -39,6 +39,11 @@ void mnodeCreateMsg(SMnodeMsg *pMsg, SRpcMsg *rpcMsg) {
}
int32_t
mnodeInitMsg
(
SMnodeMsg
*
pMsg
)
{
if
(
pMsg
->
pUser
!=
NULL
)
{
mDebug
(
"app:%p:%p, user info already inited"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
);
return
TSDB_CODE_SUCCESS
;
}
pMsg
->
pUser
=
mnodeGetUserFromConn
(
pMsg
->
rpcMsg
.
handle
);
if
(
pMsg
->
pUser
==
NULL
)
{
return
TSDB_CODE_MND_INVALID_USER
;
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
dd3467f8
...
...
@@ -2093,11 +2093,11 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
tableType
=
pTable
->
info
.
type
;
tstrncpy
(
pMeta
->
tableId
,
pTable
->
info
.
tableId
,
TSDB_TABLE_FNAME_LEN
);
if
(
pTable
->
superTable
)
{
if
(
pTable
->
superTable
!=
NULL
)
{
tstrncpy
(
pMeta
->
sTableId
,
pTable
->
superTable
->
info
.
tableId
,
TSDB_TABLE_FNAME_LEN
);
}
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
&&
pTable
->
superTable
!=
NULL
)
{
pMeta
->
sversion
=
htons
(
pTable
->
superTable
->
sversion
);
pMeta
->
tversion
=
htons
(
pTable
->
superTable
->
tversion
);
pMeta
->
numOfTags
=
(
int8_t
)
pTable
->
superTable
->
numOfTags
;
...
...
src/os/src/detail/osDir.c
浏览文件 @
dd3467f8
...
...
@@ -126,12 +126,13 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) {
dstFp
=
gzdopen
(
fd
,
"wb6f"
);
if
(
dstFp
==
NULL
)
{
ret
=
-
3
;
close
(
fd
);
goto
cmp_end
;
}
while
(
!
feof
(
srcFp
))
{
len
=
(
int32_t
)
fread
(
data
,
1
,
COMPRESS_STEP_SIZE
,
srcFp
);
gzwrite
(
dstFp
,
data
,
len
);
(
void
)
gzwrite
(
dstFp
,
data
,
len
);
}
cmp_end:
...
...
src/plugins/http/src/httpParser.c
浏览文件 @
dd3467f8
...
...
@@ -153,10 +153,10 @@ static int32_t httpOnRequestLine(HttpParser *pParser, char *method, char *target
for
(
int32_t
i
=
0
;
i
<
HTTP_MAX_URL
;
i
++
)
{
char
*
pSeek
=
strchr
(
pStart
,
'/'
);
if
(
pSeek
==
NULL
)
{
httpAppendString
(
pParser
->
path
+
i
,
pStart
,
strlen
(
pStart
));
(
void
)
httpAppendString
(
pParser
->
path
+
i
,
pStart
,
strlen
(
pStart
));
break
;
}
else
{
httpAppendString
(
pParser
->
path
+
i
,
pStart
,
(
int32_t
)(
pSeek
-
pStart
));
(
void
)
httpAppendString
(
pParser
->
path
+
i
,
pStart
,
(
int32_t
)(
pSeek
-
pStart
));
}
pStart
=
pSeek
+
1
;
}
...
...
@@ -485,11 +485,11 @@ void httpClearParser(HttpParser *parser) {
}
void
httpDestroyParser
(
HttpParser
*
parser
)
{
if
(
!
parser
)
return
;
HttpContext
*
pContext
=
parser
->
pContext
;
httpTrace
(
"context:%p, fd:%d, destroy parser"
,
pContext
,
pContext
->
fd
);
if
(
!
parser
)
return
;
free
(
parser
->
method
);
parser
->
method
=
NULL
;
free
(
parser
->
target
);
parser
->
target
=
NULL
;
free
(
parser
->
version
);
parser
->
version
=
NULL
;
...
...
@@ -684,23 +684,28 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state,
break
;
}
if
(
c
!=
'0'
&&
c
!=
'1
'
)
{
if
(
c
!=
'0'
&&
c
!=
'1'
&&
c
!=
'2
'
)
{
httpError
(
"context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x"
,
pContext
,
pContext
->
fd
,
state
,
c
,
c
);
ok
=
-
1
;
httpOnError
(
parser
,
400
,
TSDB_CODE_HTTP_PARSE_VERSION_FAILED
);
break
;
}
if
(
httpAppendString
(
&
parser
->
str
,
&
c
,
1
))
{
httpError
(
"context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom"
,
pContext
,
pContext
->
fd
,
state
,
c
,
c
);
ok
=
-
1
;
httpOnError
(
parser
,
507
,
TSDB_CODE_HTTP_PARSE_VERSION_FAILED
);
break
;
}
if
(
c
==
'0'
)
parser
->
httpVersion
=
HTTP_VERSION_10
;
else
if
(
c
==
'1'
)
parser
->
httpVersion
=
HTTP_VERSION_11
;
else
if
(
c
==
'2'
)
parser
->
httpVersion
=
HTTP_VERSION_12
;
else
parser
->
httpVersion
=
HTTP_INVALID_VERSION
;
if
(
c
==
'0'
)
parser
->
httpVersion
=
HTTP_VERSION_10
;
else
if
(
c
==
'1'
)
parser
->
httpVersion
=
HTTP_VERSION_11
;
else
if
(
c
==
'2'
)
parser
->
httpVersion
=
HTTP_VERSION_12
;
else
{
}
parser
->
version
=
strdup
(
parser
->
str
.
str
);
if
(
!
parser
->
version
)
{
...
...
src/sync/src/syncMain.c
浏览文件 @
dd3467f8
...
...
@@ -167,6 +167,8 @@ void *syncStart(const SSyncInfo *pInfo) {
}
}
syncAddNodeRef
(
pNode
);
if
(
pNode
->
selfIndex
<
0
)
{
sInfo
(
"vgId:%d, this node is not configured"
,
pNode
->
vgId
);
terrno
=
TSDB_CODE_SYN_INVALID_CONFIG
;
...
...
@@ -194,7 +196,6 @@ void *syncStart(const SSyncInfo *pInfo) {
}
syncAddArbitrator
(
pNode
);
syncAddNodeRef
(
pNode
);
taosHashPut
(
vgIdHash
,
(
const
char
*
)
&
pNode
->
vgId
,
sizeof
(
int32_t
),
(
char
*
)(
&
pNode
),
sizeof
(
SSyncNode
*
));
if
(
pNode
->
notifyRole
)
{
...
...
tests/test/c/CMakeLists.txt
浏览文件 @
dd3467f8
...
...
@@ -42,5 +42,8 @@ IF (TD_LINUX)
#add_executable(cacheTest cacheTest.c)
#target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4)
#add_executable(invalidTableId invalidTableId.c)
#target_link_libraries(invalidTableId taos_static tutil common pthread)
ENDIF
()
tests/test/c/invalidTableId.c
0 → 100644
浏览文件 @
dd3467f8
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "taos.h"
#include "tulog.h"
#include "tutil.h"
#include "tglobal.h"
#include "hash.h"
#define MAX_RANDOM_POINTS 20000
#define GREEN "\033[1;32m"
#define NC "\033[0m"
#define MAX_DB_NUM 100
void
*
con
;
char
dbNames
[
MAX_DB_NUM
][
48
];
int32_t
dbNum
=
0
;
void
parseArgument
(
int
argc
,
char
*
argv
[]);
void
connDb
();
void
getDbNames
();
void
printDbNames
();
void
queryTables
(
char
*
dbName
);
void
checkTables
(
char
*
dbName
);
int
main
(
int
argc
,
char
*
argv
[])
{
parseArgument
(
argc
,
argv
);
taos_init
();
connDb
();
getDbNames
();
printDbNames
();
for
(
int
dbIndex
=
0
;
dbIndex
<
dbNum
;
++
dbIndex
)
{
queryTables
((
char
*
)(
dbNames
[
dbIndex
]));
checkTables
((
char
*
)(
dbNames
[
dbIndex
]));
}
pPrint
(
"all %d database is checked"
,
dbNum
);
}
void
connDb
()
{
con
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
con
==
NULL
)
{
pError
(
"failed to connect to DB, reason:%s"
,
taos_errstr
(
con
));
exit
(
0
);
}
}
void
getDbNames
()
{
if
(
dbNum
!=
0
)
return
;
char
*
qstr
=
"show databases"
;
TAOS_RES
*
result
=
taos_query
(
con
,
qstr
);
int32_t
code
=
taos_errno
(
result
);
if
(
result
==
NULL
||
code
!=
0
)
{
pError
(
"failed to exec sql:%s, code:0x%x reason:%s"
,
qstr
,
code
&
0XFFFF
,
tstrerror
(
code
));
exit
(
0
);
}
TAOS_ROW
row
;
int
num_fields
=
taos_num_fields
(
result
);
if
(
num_fields
<=
0
)
return
;
while
((
row
=
taos_fetch_row
(
result
)))
{
char
*
dbName
=
(
char
*
)
dbNames
[
dbNum
];
int32_t
*
length
=
taos_fetch_lengths
(
result
);
int
len
=
length
[
0
];
memcpy
(
dbName
,
(
char
*
)
row
[
0
],
len
);
dbName
[
len
]
=
0
;
dbNum
++
;
}
taos_free_result
(
result
);
}
void
printDbNames
()
{
for
(
int
dbIndex
=
0
;
dbIndex
<
dbNum
;
++
dbIndex
)
{
pPrint
(
"db:%d %s"
,
dbIndex
,
dbNames
[
dbIndex
]);
}
}
void
queryTables
(
char
*
dbName
)
{
char
qstr
[
1024
];
char
fileName
[
1024
];
char
ts
[
35
]
=
{
0
};
int32_t
precision
=
1000
;
sprintf
(
qstr
,
"show %s.tables"
,
dbName
);
sprintf
(
fileName
,
"%s_tables.txt"
,
dbName
);
TAOS_RES
*
result
=
taos_query
(
con
,
qstr
);
int32_t
code
=
taos_errno
(
result
);
if
(
result
==
NULL
||
code
!=
0
)
{
pError
(
"failed to exec sql:%s, code:0x%x reason:%s"
,
qstr
,
code
&
0XFFFF
,
tstrerror
(
code
));
exit
(
0
);
}
FILE
*
fp
=
fopen
(
fileName
,
"w"
);
if
(
!
fp
)
return
;
TAOS_ROW
row
;
int32_t
rows
=
0
;
while
((
row
=
taos_fetch_row
(
result
)))
{
char
tableName
[
256
]
=
{
0
};
int32_t
*
length
=
taos_fetch_lengths
(
result
);
int
len
=
length
[
0
];
memcpy
(
tableName
,
(
char
*
)
row
[
0
],
len
);
tableName
[
len
]
=
0
;
int64_t
t
=
*
((
int64_t
*
)
row
[
1
]);
time_t
tt
=
t
/
1000
;
struct
tm
*
ptm
=
localtime
(
&
tt
);
int32_t
tl
=
(
int32_t
)
strftime
(
ts
,
35
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
snprintf
(
ts
+
tl
,
5
,
".%03ld"
,
t
%
precision
);
// fprintf(fp, "%s %s\n", tableName, ts);
fprintf
(
fp
,
"%s.%s
\n
"
,
dbName
,
tableName
);
rows
++
;
}
taos_free_result
(
result
);
fclose
(
fp
);
pPrint
(
"db:%s has %d tables, write to %s"
,
dbName
,
rows
,
fileName
);
}
void
checkTables
(
char
*
dbName
)
{
char
qstr
[
1024
];
char
fileName1
[
1024
];
char
fileName2
[
1024
];
sprintf
(
qstr
,
"show %s.tables"
,
dbName
);
sprintf
(
fileName1
,
"%s_tables.txt"
,
dbName
);
sprintf
(
fileName2
,
"%s_count.txt"
,
dbName
);
FILE
*
fp1
=
fopen
(
fileName1
,
"r"
);
if
(
!
fp1
)
return
;
FILE
*
fp2
=
fopen
(
fileName2
,
"w"
);
if
(
!
fp2
)
return
;
int32_t
successRows
=
0
;
int32_t
failedRows
=
0
;
char
tbName
[
256
];
while
(
!
feof
(
fp1
))
{
int
size
=
fscanf
(
fp1
,
"%s"
,
tbName
);
if
(
size
<=
0
)
{
break
;
}
sprintf
(
qstr
,
"select count(*) from %s"
,
tbName
);
TAOS_RES
*
result
=
taos_query
(
con
,
qstr
);
int32_t
code
=
taos_errno
(
result
);
if
(
result
==
NULL
||
code
!=
0
)
{
pError
(
"failed to exec sql:%s, code:0x%x reason:%s"
,
qstr
,
code
&
0XFFFF
,
tstrerror
(
code
));
fprintf
(
fp2
,
"%s failed to exec sql:%s, code:0x%x reason:%s"
,
tbName
,
qstr
,
code
&
0XFFFF
,
tstrerror
(
code
));
taos_free_result
(
result
);
failedRows
++
;
continue
;
}
TAOS_ROW
row
;
int64_t
count
=
0
;
while
((
row
=
taos_fetch_row
(
result
)))
{
count
=
*
((
int64_t
*
)
row
[
0
]);
}
fprintf
(
fp2
,
"%s %"
PRId64
"
\n
"
,
tbName
,
count
);
successRows
++
;
if
(
successRows
%
1000
==
0
)
{
pPrint
(
"query %d tables"
,
successRows
);
}
taos_free_result
(
result
);
}
fclose
(
fp1
);
fclose
(
fp2
);
pPrint
(
"db:%s query tables, success:%d failed:%d write to %s"
,
dbName
,
successRows
,
failedRows
,
fileName2
);
}
void
printHelp
()
{
char
indent
[
10
]
=
" "
;
printf
(
"Used to checkTables
\n
"
);
printf
(
"%s%s
\n
"
,
indent
,
"-c"
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
indent
,
"Configuration directory, default is "
,
configDir
);
printf
(
"%s%s
\n
"
,
indent
,
"-d"
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
indent
,
"The name of the database to be checked, default is "
,
"all"
);
exit
(
EXIT_SUCCESS
);
}
void
parseArgument
(
int
argc
,
char
*
argv
[])
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
||
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
printHelp
();
exit
(
0
);
}
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
)
{
strcpy
(
dbNames
[
0
],
argv
[
++
i
]);
dbNum
++
;
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
strcpy
(
configDir
,
argv
[
++
i
]);
}
else
{
}
}
pPrint
(
"%s configDir:%s %s"
,
GREEN
,
configDir
,
NC
);
pPrint
(
"%s start to checkTables %s"
,
GREEN
,
NC
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录