Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
164aed70
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
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看板
提交
164aed70
编写于
7月 11, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into feature/vnode
上级
6b0095e0
00274ef5
变更
29
展开全部
隐藏空白更改
内联
并排
Showing
29 changed file
with
466 addition
and
425 deletion
+466
-425
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+3
-1
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+38
-1
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+9
-5
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+0
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+20
-18
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+39
-41
src/common/src/tglobal.c
src/common/src/tglobal.c
+1
-1
src/common/src/tname.c
src/common/src/tname.c
+1
-1
src/common/src/ttypes.c
src/common/src/ttypes.c
+25
-25
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNode.java
...or/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNode.java
+2
-2
src/inc/query.h
src/inc/query.h
+8
-8
src/inc/taosdef.h
src/inc/taosdef.h
+26
-1
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+0
-3
src/query/inc/qtsbuf.h
src/query/inc/qtsbuf.h
+1
-1
src/query/inc/tsqlfunction.h
src/query/inc/tsqlfunction.h
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+98
-139
src/query/src/qtokenizer.c
src/query/src/qtokenizer.c
+5
-4
src/query/src/qtsbuf.c
src/query/src/qtsbuf.c
+9
-9
src/query/tests/tsBufTest.cpp
src/query/tests/tsBufTest.cpp
+8
-8
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+52
-51
src/util/inc/tarray.h
src/util/inc/tarray.h
+1
-1
src/util/inc/tcache.h
src/util/inc/tcache.h
+12
-9
src/util/src/tcache.c
src/util/src/tcache.c
+59
-41
src/util/src/ttime.c
src/util/src/ttime.c
+12
-8
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+1
-1
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+8
-8
tests/pytest/table/del_stable.py
tests/pytest/table/del_stable.py
+2
-11
tests/script/general/parser/fill_us.sim
tests/script/general/parser/fill_us.sim
+24
-24
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
164aed70
...
...
@@ -160,7 +160,9 @@ void tscFieldInfoUpdateOffsetForInterResult(SQueryInfo* pQueryInfo);
int16_t
tscFieldInfoGetOffset
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
);
void
tscFieldInfoClear
(
SFieldInfo
*
pFieldInfo
);
int32_t
tscNumOfFields
(
SQueryInfo
*
pQueryInfo
);
static
FORCE_INLINE
int32_t
tscNumOfFields
(
SQueryInfo
*
pQueryInfo
)
{
return
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
}
int32_t
tscFieldInfoCompare
(
const
SFieldInfo
*
pFieldInfo1
,
const
SFieldInfo
*
pFieldInfo2
);
void
addExprParams
(
SSqlExpr
*
pExpr
,
char
*
argument
,
int32_t
type
,
int32_t
bytes
,
int16_t
tableIndex
);
...
...
src/client/inc/tsclient.h
浏览文件 @
164aed70
...
...
@@ -412,7 +412,44 @@ char *tscGetErrorMsgPayload(SSqlCmd *pCmd);
int32_t
tscInvalidSQLErrMsg
(
char
*
msg
,
const
char
*
additionalInfo
,
const
char
*
sql
);
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
void
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SFieldInfo
*
pFieldInfo
,
int32_t
column
);
//void tscGetResultColumnChr(SSqlRes *pRes, SFieldInfo* pFieldInfo, int32_t column);
static
FORCE_INLINE
void
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SFieldInfo
*
pFieldInfo
,
int32_t
columnIndex
)
{
SFieldSupInfo
*
pInfo
=
TARRAY_GET_ELEM
(
pFieldInfo
->
pSupportInfo
,
columnIndex
);
assert
(
pInfo
->
pSqlExpr
!=
NULL
);
int32_t
type
=
pInfo
->
pSqlExpr
->
resType
;
int32_t
bytes
=
pInfo
->
pSqlExpr
->
resBytes
;
char
*
pData
=
pRes
->
data
+
pInfo
->
pSqlExpr
->
offset
*
pRes
->
numOfRows
+
bytes
*
pRes
->
row
;
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
realLen
=
varDataLen
(
pData
);
assert
(
realLen
<=
bytes
-
VARSTR_HEADER_SIZE
);
if
(
isNull
(
pData
,
type
))
{
pRes
->
tsrow
[
columnIndex
]
=
NULL
;
}
else
{
pRes
->
tsrow
[
columnIndex
]
=
((
tstr
*
)
pData
)
->
data
;
}
if
(
realLen
<
pInfo
->
pSqlExpr
->
resBytes
-
VARSTR_HEADER_SIZE
)
{
// todo refactor
*
(
pData
+
realLen
+
VARSTR_HEADER_SIZE
)
=
0
;
}
pRes
->
length
[
columnIndex
]
=
realLen
;
}
else
{
assert
(
bytes
==
tDataTypeDesc
[
type
].
nSize
);
if
(
isNull
(
pData
,
type
))
{
pRes
->
tsrow
[
columnIndex
]
=
NULL
;
}
else
{
pRes
->
tsrow
[
columnIndex
]
=
pData
;
}
pRes
->
length
[
columnIndex
]
=
bytes
;
}
}
extern
void
*
tscCacheHandle
;
extern
void
*
tscTmr
;
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
164aed70
...
...
@@ -2952,10 +2952,14 @@ static void tag_project_function(SQLFunctionCtx *pCtx) {
INC_INIT_VAL
(
pCtx
,
pCtx
->
size
);
assert
(
pCtx
->
inputBytes
==
pCtx
->
outputBytes
);
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
tVariantDump
(
&
pCtx
->
tag
,
pCtx
->
aOutputBuf
,
pCtx
->
outputType
,
true
);
tVariantDump
(
&
pCtx
->
tag
,
pCtx
->
aOutputBuf
,
pCtx
->
outputType
,
true
);
char
*
data
=
pCtx
->
aOutputBuf
;
pCtx
->
aOutputBuf
+=
pCtx
->
outputBytes
;
// directly copy from the first one
for
(
int32_t
i
=
1
;
i
<
pCtx
->
size
;
++
i
)
{
memmove
(
pCtx
->
aOutputBuf
,
data
,
pCtx
->
outputBytes
);
pCtx
->
aOutputBuf
+=
pCtx
->
outputBytes
;
}
}
...
...
@@ -3941,7 +3945,7 @@ static void ts_comp_finalize(SQLFunctionCtx *pCtx) {
tsBufFlush
(
pTSbuf
);
strcpy
(
pCtx
->
aOutputBuf
,
pTSbuf
->
path
);
tsBufDest
or
y
(
pTSbuf
);
tsBufDest
ro
y
(
pTSbuf
);
doFinalizer
(
pCtx
);
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
164aed70
...
...
@@ -175,7 +175,6 @@ static int32_t handlePassword(SSqlCmd* pCmd, SSQLToken* pPwd) {
return
TSDB_CODE_SUCCESS
;
}
// todo handle memory leak in error handle function
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
if
(
pInfo
==
NULL
||
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
TSDB_CODE_TSC_APP_ERROR
;
...
...
src/client/src/tscSql.c
浏览文件 @
164aed70
...
...
@@ -403,7 +403,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
taos_fetch_rows_a
(
res
,
waitForRetrieveRsp
,
pSql
->
pTscObj
);
sem_wait
(
&
pSql
->
rspSem
);
}
return
doSetResultRowData
(
pSql
,
true
);
}
...
...
src/client/src/tscSubquery.c
浏览文件 @
164aed70
...
...
@@ -152,8 +152,8 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
tsBufFlush
(
output1
);
tsBufFlush
(
output2
);
tsBufDest
or
y
(
pSupporter1
->
pTSBuf
);
tsBufDest
or
y
(
pSupporter2
->
pTSBuf
);
tsBufDest
ro
y
(
pSupporter1
->
pTSBuf
);
tsBufDest
ro
y
(
pSupporter2
->
pTSBuf
);
tscDebug
(
"%p input1:%"
PRId64
", input2:%"
PRId64
", final:%"
PRId64
" for secondary query after ts blocks "
"intersecting, skey:%"
PRId64
", ekey:%"
PRId64
,
pSql
,
numOfInput1
,
numOfInput2
,
output1
->
numOfTotal
,
...
...
@@ -762,7 +762,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
tsBufMerge
(
pSupporter
->
pTSBuf
,
pBuf
,
pTableMetaInfo
->
vgroupIndex
);
tsBufDest
or
y
(
pBuf
);
tsBufDest
ro
y
(
pBuf
);
}
// continue to retrieve ts-comp data from vnode
...
...
@@ -2106,9 +2106,9 @@ static char *getArithemicInputSrc(void *param, const char *name, int32_t colId)
void
**
doSetResultRowData
(
SSqlObj
*
pSql
,
bool
finalResult
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
assert
(
pRes
->
row
>=
0
&&
pRes
->
row
<=
pRes
->
numOfRows
);
if
(
pCmd
->
command
==
TSDB_SQL_TABLE_JOIN_RETRIEVE
)
{
if
(
pRes
->
completed
)
{
tfree
(
pRes
->
tsrow
);
...
...
@@ -2116,29 +2116,31 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
return
pRes
->
tsrow
;
}
if
(
pRes
->
row
>=
pRes
->
numOfRows
)
{
// all the results has returned to invoker
tfree
(
pRes
->
tsrow
);
return
pRes
->
tsrow
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
size_t
size
=
tscNumOfFields
(
pQueryInfo
);
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
SFieldSupInfo
*
pSup
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fields
Info
,
i
);
SFieldSupInfo
*
pSup
=
TARRAY_GET_ELEM
(
pQueryInfo
->
fieldsInfo
.
pSupport
Info
,
i
);
if
(
pSup
->
pSqlExpr
!=
NULL
)
{
tscGetResultColumnChr
(
pRes
,
&
pQueryInfo
->
fieldsInfo
,
i
);
}
// primary key column cannot be null in interval query, no need to check
if
(
i
==
0
&&
pQueryInfo
->
intervalTime
>
0
)
{
continue
;
}
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
transferNcharData
(
pSql
,
i
,
pField
);
TAOS_FIELD
*
pField
=
TARRAY_GET_ELEM
(
pQueryInfo
->
fieldsInfo
.
pFields
,
i
);
if
(
pRes
->
tsrow
[
i
]
!=
NULL
&&
pField
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
transferNcharData
(
pSql
,
i
,
pField
);
}
// calculate the result from several other columns
if
(
pSup
->
pArithExprInfo
!=
NULL
)
{
if
(
pRes
->
pArithSup
==
NULL
)
{
...
...
@@ -2148,10 +2150,10 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
sas
->
numOfCols
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
sas
->
exprList
=
pQueryInfo
->
exprList
;
sas
->
data
=
calloc
(
sas
->
numOfCols
,
POINTER_BYTES
);
pRes
->
pArithSup
=
sas
;
}
if
(
pRes
->
buffer
[
i
]
==
NULL
)
{
TAOS_FIELD
*
field
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
pRes
->
buffer
[
i
]
=
malloc
(
field
->
bytes
);
...
...
@@ -2161,13 +2163,13 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
k
);
pRes
->
pArithSup
->
data
[
k
]
=
(
pRes
->
data
+
pRes
->
numOfRows
*
pExpr
->
offset
)
+
pRes
->
row
*
pExpr
->
resBytes
;
}
tExprTreeCalcTraverse
(
pRes
->
pArithSup
->
pArithExpr
->
pExpr
,
1
,
pRes
->
buffer
[
i
],
pRes
->
pArithSup
,
TSDB_ORDER_ASC
,
getArithemicInputSrc
);
pRes
->
tsrow
[
i
]
=
pRes
->
buffer
[
i
];
}
}
pRes
->
row
++
;
// index increase one-step
return
pRes
->
tsrow
;
}
...
...
src/client/src/tscUtil.c
浏览文件 @
164aed70
...
...
@@ -794,7 +794,7 @@ SFieldSupInfo* tscFieldInfoAppend(SFieldInfo* pFieldInfo, TAOS_FIELD* pField) {
}
SFieldSupInfo
*
tscFieldInfoGetSupp
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
)
{
return
taosArrayGet
(
pFieldInfo
->
pSupportInfo
,
index
);
return
TARRAY_GET_ELEM
(
pFieldInfo
->
pSupportInfo
,
index
);
}
SFieldSupInfo
*
tscFieldInfoInsert
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
TAOS_FIELD
*
field
)
{
...
...
@@ -858,11 +858,9 @@ void tscFieldInfoCopy(SFieldInfo* dst, const SFieldInfo* src) {
}
TAOS_FIELD
*
tscFieldInfoGetField
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
)
{
return
taosArrayGet
(
pFieldInfo
->
pFields
,
index
);
return
TARRAY_GET_ELEM
(
pFieldInfo
->
pFields
,
index
);
}
int32_t
tscNumOfFields
(
SQueryInfo
*
pQueryInfo
)
{
return
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
}
int16_t
tscFieldInfoGetOffset
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
)
{
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
index
);
assert
(
pInfo
!=
NULL
);
...
...
@@ -1546,7 +1544,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) {
pQueryInfo
->
groupbyExpr
.
columnInfo
=
NULL
;
}
pQueryInfo
->
tsBuf
=
tsBufDest
or
y
(
pQueryInfo
->
tsBuf
);
pQueryInfo
->
tsBuf
=
tsBufDest
ro
y
(
pQueryInfo
->
tsBuf
);
tfree
(
pQueryInfo
->
fillVal
);
}
...
...
@@ -2085,42 +2083,42 @@ void tscTryQueryNextClause(SSqlObj* pSql, void (*queryFp)()) {
}
}
void
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SFieldInfo
*
pFieldInfo
,
int32_t
columnIndex
)
{
SFieldSupInfo
*
pInfo
=
taosArrayGet
(
pFieldInfo
->
pSupportInfo
,
columnIndex
);
assert
(
pInfo
->
pSqlExpr
!=
NULL
);
int32_t
type
=
pInfo
->
pSqlExpr
->
resType
;
int32_t
bytes
=
pInfo
->
pSqlExpr
->
resBytes
;
char
*
pData
=
pRes
->
data
+
pInfo
->
pSqlExpr
->
offset
*
pRes
->
numOfRows
+
bytes
*
pRes
->
row
;
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
realLen
=
varDataLen
(
pData
);
assert
(
realLen
<=
bytes
-
VARSTR_HEADER_SIZE
);
if
(
isNull
(
pData
,
type
))
{
pRes
->
tsrow
[
columnIndex
]
=
NULL
;
}
else
{
pRes
->
tsrow
[
columnIndex
]
=
((
tstr
*
)
pData
)
->
data
;
}
if
(
realLen
<
pInfo
->
pSqlExpr
->
resBytes
-
VARSTR_HEADER_SIZE
)
{
// todo refactor
*
(
pData
+
realLen
+
VARSTR_HEADER_SIZE
)
=
0
;
}
pRes
->
length
[
columnIndex
]
=
realLen
;
}
else
{
assert
(
bytes
==
tDataTypeDesc
[
type
].
nSize
);
if
(
isNull
(
pData
,
type
))
{
pRes
->
tsrow
[
columnIndex
]
=
NULL
;
}
else
{
pRes
->
tsrow
[
columnIndex
]
=
pData
;
}
pRes
->
length
[
columnIndex
]
=
bytes
;
}
}
//
void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pFieldInfo, int32_t columnIndex) {
// SFieldSupInfo* pInfo = TARRAY_GET_ELEM
(pFieldInfo->pSupportInfo, columnIndex);
//
assert(pInfo->pSqlExpr != NULL);
//
//
int32_t type = pInfo->pSqlExpr->resType;
//
int32_t bytes = pInfo->pSqlExpr->resBytes;
//
//
char* pData = pRes->data + pInfo->pSqlExpr->offset * pRes->numOfRows + bytes * pRes->row;
//
//
if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BINARY) {
//
int32_t realLen = varDataLen(pData);
//
assert(realLen <= bytes - VARSTR_HEADER_SIZE);
//
//
if (isNull(pData, type)) {
//
pRes->tsrow[columnIndex] = NULL;
//
} else {
//
pRes->tsrow[columnIndex] = ((tstr*)pData)->data;
//
}
//
//
if (realLen < pInfo->pSqlExpr->resBytes - VARSTR_HEADER_SIZE) { // todo refactor
//
*(pData + realLen + VARSTR_HEADER_SIZE) = 0;
//
}
//
//
pRes->length[columnIndex] = realLen;
//
} else {
//
assert(bytes == tDataTypeDesc[type].nSize);
//
//
if (isNull(pData, type)) {
//
pRes->tsrow[columnIndex] = NULL;
//
} else {
//
pRes->tsrow[columnIndex] = pData;
//
}
//
//
pRes->length[columnIndex] = bytes;
//
}
//
}
void
*
malloc_throw
(
size_t
size
)
{
void
*
p
=
malloc
(
size
);
...
...
src/common/src/tglobal.c
浏览文件 @
164aed70
...
...
@@ -555,7 +555,7 @@ static void doInitGlobalConfig() {
cfg
.
ptr
=
&
tsMinIntervalTime
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
1
0
;
cfg
.
minValue
=
1
;
cfg
.
maxValue
=
1000000
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_MS
;
...
...
src/common/src/tname.c
浏览文件 @
164aed70
...
...
@@ -82,7 +82,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
}
int64_t
start
=
((
startTime
-
intervalTime
)
/
slidingTime
+
1
)
*
slidingTime
;
if
(
!
(
timeUnit
==
'a'
||
timeUnit
==
'm'
||
timeUnit
==
's'
||
timeUnit
==
'h'
))
{
if
(
!
(
timeUnit
==
'
u'
||
timeUnit
==
'
a'
||
timeUnit
==
'm'
||
timeUnit
==
's'
||
timeUnit
==
'h'
))
{
/*
* here we revised the start time of day according to the local time zone,
* but in case of DST, the start time of one day need to be dynamically decided.
...
...
src/common/src/ttypes.c
浏览文件 @
164aed70
...
...
@@ -367,31 +367,31 @@ bool isValidDataType(int32_t type) {
return
type
>=
TSDB_DATA_TYPE_NULL
&&
type
<=
TSDB_DATA_TYPE_NCHAR
;
}
bool
isNull
(
const
char
*
val
,
int32_t
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
return
*
(
uint8_t
*
)
val
==
TSDB_DATA_BOOL_NULL
;
case
TSDB_DATA_TYPE_TINYINT
:
return
*
(
uint8_t
*
)
val
==
TSDB_DATA_TINYINT_NULL
;
case
TSDB_DATA_TYPE_SMALLINT
:
return
*
(
uint16_t
*
)
val
==
TSDB_DATA_SMALLINT_NULL
;
case
TSDB_DATA_TYPE_INT
:
return
*
(
uint32_t
*
)
val
==
TSDB_DATA_INT_NULL
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
*
(
uint64_t
*
)
val
==
TSDB_DATA_BIGINT_NULL
;
case
TSDB_DATA_TYPE_FLOAT
:
return
*
(
uint32_t
*
)
val
==
TSDB_DATA_FLOAT_NULL
;
case
TSDB_DATA_TYPE_DOUBLE
:
return
*
(
uint64_t
*
)
val
==
TSDB_DATA_DOUBLE_NULL
;
case
TSDB_DATA_TYPE_NCHAR
:
return
*
(
uint32_t
*
)
varDataVal
(
val
)
==
TSDB_DATA_NCHAR_NULL
;
case
TSDB_DATA_TYPE_BINARY
:
return
*
(
uint8_t
*
)
varDataVal
(
val
)
==
TSDB_DATA_BINARY_NULL
;
default:
return
false
;
};
}
//
bool isNull(const char *val, int32_t type) {
//
switch (type) {
//
case TSDB_DATA_TYPE_BOOL:
//
return *(uint8_t *)val == TSDB_DATA_BOOL_NULL;
//
case TSDB_DATA_TYPE_TINYINT:
//
return *(uint8_t *)val == TSDB_DATA_TINYINT_NULL;
//
case TSDB_DATA_TYPE_SMALLINT:
//
return *(uint16_t *)val == TSDB_DATA_SMALLINT_NULL;
//
case TSDB_DATA_TYPE_INT:
//
return *(uint32_t *)val == TSDB_DATA_INT_NULL;
//
case TSDB_DATA_TYPE_BIGINT:
//
case TSDB_DATA_TYPE_TIMESTAMP:
//
return *(uint64_t *)val == TSDB_DATA_BIGINT_NULL;
//
case TSDB_DATA_TYPE_FLOAT:
//
return *(uint32_t *)val == TSDB_DATA_FLOAT_NULL;
//
case TSDB_DATA_TYPE_DOUBLE:
//
return *(uint64_t *)val == TSDB_DATA_DOUBLE_NULL;
//
case TSDB_DATA_TYPE_NCHAR:
//
return *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL;
//
case TSDB_DATA_TYPE_BINARY:
//
return *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL;
//
default:
//
return false;
//
};
//
}
void
setVardataNull
(
char
*
val
,
int32_t
type
)
{
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/TDNode.java
浏览文件 @
164aed70
...
...
@@ -52,7 +52,7 @@ public class TDNode {
public
void
start
()
{
String
selfPath
=
System
.
getProperty
(
"user.dir"
);
String
binPath
=
""
;
String
projDir
=
selfPath
+
"/../../../
../
"
;
String
projDir
=
selfPath
+
"/../../../"
;
try
{
ArrayList
<
String
>
taosdPath
=
new
ArrayList
<>();
...
...
@@ -68,7 +68,7 @@ public class TDNode {
return
;
}
else
{
for
(
String
p
:
taosdPath
)
{
if
(!
p
.
contains
(
"packing"
))
{
if
(!
p
.
contains
(
"pack
ag
ing"
))
{
binPath
=
p
;
}
}
...
...
src/inc/query.h
浏览文件 @
164aed70
...
...
@@ -20,7 +20,6 @@ extern "C" {
#endif
typedef
void
*
qinfo_t
;
typedef
void
(
*
_qinfo_free_fn_t
)(
void
*
);
/**
* create the qinfo object according to QueryTableMsg
...
...
@@ -29,13 +28,8 @@ typedef void (*_qinfo_free_fn_t)(void*);
* @param qinfo
* @return
*/
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
int32_t
vgId
,
SQueryTableMsg
*
pQueryTableMsg
,
void
*
param
,
_qinfo_free_fn_t
fn
,
qinfo_t
*
qinfo
);
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
int32_t
vgId
,
SQueryTableMsg
*
pQueryTableMsg
,
void
*
param
,
qinfo_t
*
qinfo
);
/**
* Destroy QInfo object
* @param qinfo qhandle
*/
void
qDestroyQueryInfo
(
qinfo_t
qinfo
);
/**
* the main query execution function, including query on both table and multitables,
...
...
@@ -84,8 +78,14 @@ bool qHasMoreResultsToRetrieve(qinfo_t qinfo);
*/
int32_t
qKillQuery
(
qinfo_t
qinfo
);
/**
* destroy query info structure
* @param qHandle
*/
void
qDestroyQueryInfo
(
qinfo_t
qHandle
);
void
*
qOpenQueryMgmt
(
int32_t
vgId
);
void
q
SetQueryMgmt
Closed
(
void
*
pExecutor
);
void
q
QueryMgmtNotify
Closed
(
void
*
pExecutor
);
void
qCleanupQueryMgmt
(
void
*
pExecutor
);
void
**
qRegisterQInfo
(
void
*
pMgmt
,
uint64_t
qInfo
);
void
**
qAcquireQInfo
(
void
*
pMgmt
,
uint64_t
key
);
...
...
src/inc/taosdef.h
浏览文件 @
164aed70
...
...
@@ -160,7 +160,32 @@ extern tDataTypeDescriptor tDataTypeDesc[11];
#define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*)
bool
isValidDataType
(
int32_t
type
);
bool
isNull
(
const
char
*
val
,
int32_t
type
);
//bool isNull(const char *val, int32_t type);
static
inline
__attribute__
((
always_inline
))
bool
isNull
(
const
char
*
val
,
int32_t
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
return
*
(
uint8_t
*
)
val
==
TSDB_DATA_BOOL_NULL
;
case
TSDB_DATA_TYPE_TINYINT
:
return
*
(
uint8_t
*
)
val
==
TSDB_DATA_TINYINT_NULL
;
case
TSDB_DATA_TYPE_SMALLINT
:
return
*
(
uint16_t
*
)
val
==
TSDB_DATA_SMALLINT_NULL
;
case
TSDB_DATA_TYPE_INT
:
return
*
(
uint32_t
*
)
val
==
TSDB_DATA_INT_NULL
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
*
(
uint64_t
*
)
val
==
TSDB_DATA_BIGINT_NULL
;
case
TSDB_DATA_TYPE_FLOAT
:
return
*
(
uint32_t
*
)
val
==
TSDB_DATA_FLOAT_NULL
;
case
TSDB_DATA_TYPE_DOUBLE
:
return
*
(
uint64_t
*
)
val
==
TSDB_DATA_DOUBLE_NULL
;
case
TSDB_DATA_TYPE_NCHAR
:
return
*
(
uint32_t
*
)
varDataVal
(
val
)
==
TSDB_DATA_NCHAR_NULL
;
case
TSDB_DATA_TYPE_BINARY
:
return
*
(
uint8_t
*
)
varDataVal
(
val
)
==
TSDB_DATA_BINARY_NULL
;
default:
return
false
;
};
}
void
setVardataNull
(
char
*
val
,
int32_t
type
);
void
setNull
(
char
*
val
,
int32_t
type
,
int32_t
bytes
);
...
...
src/query/inc/qExecutor.h
浏览文件 @
164aed70
...
...
@@ -192,7 +192,6 @@ typedef struct SQInfo {
int32_t
offset
;
// offset in group result set of subgroup, todo refactor
SArray
*
arrTableIdInfo
;
T_REF_DECLARE
()
/*
* the query is executed position on which meter of the whole list.
* when the index reaches the last one of the list, it means the query is completed.
...
...
@@ -201,8 +200,6 @@ typedef struct SQInfo {
*/
int32_t
tableIndex
;
int32_t
numOfGroupResultPages
;
_qinfo_free_fn_t
freeFn
;
//todo remove it
void
*
pBuf
;
// allocated buffer for STableQueryInfo, sizeof(STableQueryInfo)*numOfTables;
}
SQInfo
;
...
...
src/query/inc/qtsbuf.h
浏览文件 @
164aed70
...
...
@@ -107,7 +107,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order);
STSBuf
*
tsBufCreateFromFile
(
const
char
*
path
,
bool
autoDelete
);
STSBuf
*
tsBufCreateFromCompBlocks
(
const
char
*
pData
,
int32_t
numOfBlocks
,
int32_t
len
,
int32_t
tsOrder
);
void
*
tsBufDest
or
y
(
STSBuf
*
pTSBuf
);
void
*
tsBufDest
ro
y
(
STSBuf
*
pTSBuf
);
void
tsBufAppend
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
,
int64_t
tag
,
const
char
*
pData
,
int32_t
len
);
int32_t
tsBufMerge
(
STSBuf
*
pDestBuf
,
const
STSBuf
*
pSrcBuf
,
int32_t
vnodeIdx
);
...
...
src/query/inc/tsqlfunction.h
浏览文件 @
164aed70
...
...
@@ -187,7 +187,7 @@ typedef struct SQLFunctionCtx {
}
SQLFunctionCtx
;
typedef
struct
SQLAggFuncElem
{
char
aName
[
TSDB_FUNCTIONS_NAME_MAX_LENGTH
];
char
aName
[
TSDB_FUNCTIONS_NAME_MAX_LENGTH
];
uint8_t
nAggIdx
;
// index of function in aAggs
int8_t
stableFuncId
;
// transfer function for super table query
...
...
src/query/src/qExecutor.c
浏览文件 @
164aed70
此差异已折叠。
点击以展开。
src/query/src/qtokenizer.c
浏览文件 @
164aed70
...
...
@@ -509,10 +509,11 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
for
(
i
=
1
;
isdigit
(
z
[
i
]);
i
++
)
{
}
/* here is the 1a/2s/3m/9y */
if
((
z
[
i
]
==
'a'
||
z
[
i
]
==
's'
||
z
[
i
]
==
'm'
||
z
[
i
]
==
'h'
||
z
[
i
]
==
'd'
||
z
[
i
]
==
'n'
||
z
[
i
]
==
'y'
||
z
[
i
]
==
'w'
||
z
[
i
]
==
'A'
||
z
[
i
]
==
'S'
||
z
[
i
]
==
'M'
||
z
[
i
]
==
'H'
||
z
[
i
]
==
'D'
||
z
[
i
]
==
'N'
||
z
[
i
]
==
'Y'
||
z
[
i
]
==
'W'
)
&&
/* here is the 1u/1a/2s/3m/9y */
if
((
z
[
i
]
==
'u'
||
z
[
i
]
==
'a'
||
z
[
i
]
==
's'
||
z
[
i
]
==
'm'
||
z
[
i
]
==
'h'
||
z
[
i
]
==
'd'
||
z
[
i
]
==
'n'
||
z
[
i
]
==
'y'
||
z
[
i
]
==
'w'
||
z
[
i
]
==
'U'
||
z
[
i
]
==
'A'
||
z
[
i
]
==
'S'
||
z
[
i
]
==
'M'
||
z
[
i
]
==
'H'
||
z
[
i
]
==
'D'
||
z
[
i
]
==
'N'
||
z
[
i
]
==
'Y'
||
z
[
i
]
==
'W'
)
&&
(
isIdChar
[(
uint8_t
)
z
[
i
+
1
]]
==
0
))
{
*
tokenType
=
TK_VARIABLE
;
i
+=
1
;
...
...
src/query/src/qtsbuf.c
浏览文件 @
164aed70
...
...
@@ -79,7 +79,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
pTSBuf
->
numOfAlloc
=
header
.
numOfVnode
;
STSVnodeBlockInfoEx
*
tmp
=
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnodeBlockInfoEx
)
*
pTSBuf
->
numOfAlloc
);
if
(
tmp
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
}
...
...
@@ -92,7 +92,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
pTSBuf
->
tsOrder
=
header
.
tsOrder
;
if
(
pTSBuf
->
tsOrder
!=
TSDB_ORDER_ASC
&&
pTSBuf
->
tsOrder
!=
TSDB_ORDER_DESC
)
{
// tscError("invalid order info in buf:%d", pTSBuf->tsOrder);
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
}
...
...
@@ -100,7 +100,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
STSVnodeBlockInfo
*
buf
=
(
STSVnodeBlockInfo
*
)
calloc
(
1
,
infoSize
);
if
(
buf
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
}
...
...
@@ -120,7 +120,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
struct
stat
fileStat
;
if
(
fstat
(
fileno
(
pTSBuf
->
f
),
&
fileStat
)
!=
0
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
}
...
...
@@ -137,7 +137,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
return
pTSBuf
;
}
void
*
tsBufDest
or
y
(
STSBuf
*
pTSBuf
)
{
void
*
tsBufDest
ro
y
(
STSBuf
*
pTSBuf
)
{
if
(
pTSBuf
==
NULL
)
{
return
NULL
;
}
...
...
@@ -920,13 +920,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
pTSBuf
->
numOfAlloc
=
INITIAL_VNODEINFO_SIZE
;
pTSBuf
->
pData
=
calloc
(
pTSBuf
->
numOfAlloc
,
sizeof
(
STSVnodeBlockInfoEx
));
if
(
pTSBuf
->
pData
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
}
pTSBuf
->
tsData
.
rawBuf
=
malloc
(
MEM_BUF_SIZE
);
if
(
pTSBuf
->
tsData
.
rawBuf
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
}
...
...
@@ -936,13 +936,13 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
pTSBuf
->
assistBuf
=
malloc
(
MEM_BUF_SIZE
);
if
(
pTSBuf
->
assistBuf
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
}
pTSBuf
->
block
.
payload
=
malloc
(
MEM_BUF_SIZE
);
if
(
pTSBuf
->
block
.
payload
==
NULL
)
{
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
return
NULL
;
}
...
...
src/query/tests/tsBufTest.cpp
浏览文件 @
164aed70
...
...
@@ -47,7 +47,7 @@ void simpleTest() {
EXPECT_EQ
(
pTSBuf
->
tsData
.
len
,
0
);
EXPECT_EQ
(
pTSBuf
->
block
.
numOfElem
,
num
);
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
}
// one large list of ts, the ts list need to be split into several small blocks
...
...
@@ -71,7 +71,7 @@ void largeTSTest() {
EXPECT_EQ
(
pTSBuf
->
tsData
.
len
,
0
);
EXPECT_EQ
(
pTSBuf
->
block
.
numOfElem
,
num
);
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
}
void
multiTagsTest
()
{
...
...
@@ -101,7 +101,7 @@ void multiTagsTest() {
EXPECT_EQ
(
pTSBuf
->
tsData
.
len
,
0
);
EXPECT_EQ
(
pTSBuf
->
block
.
numOfElem
,
num
);
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
}
void
multiVnodeTagsTest
()
{
...
...
@@ -139,7 +139,7 @@ void multiVnodeTagsTest() {
EXPECT_EQ
(
pTSBuf
->
tsData
.
len
,
0
);
EXPECT_EQ
(
pTSBuf
->
block
.
numOfElem
,
num
);
tsBufDest
or
y
(
pTSBuf
);
tsBufDest
ro
y
(
pTSBuf
);
}
void
loadDataTest
()
{
...
...
@@ -386,8 +386,8 @@ void mergeDiffVnodeBufferTest() {
tsBufDisplay
(
pTSBuf1
);
tsBufDest
or
y
(
pTSBuf2
);
tsBufDest
or
y
(
pTSBuf1
);
tsBufDest
ro
y
(
pTSBuf2
);
tsBufDest
ro
y
(
pTSBuf1
);
}
void
mergeIdenticalVnodeBufferTest
()
{
...
...
@@ -432,8 +432,8 @@ void mergeIdenticalVnodeBufferTest() {
printf
(
"%d-%"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
,
elem
.
ts
);
}
tsBufDest
or
y
(
pTSBuf1
);
tsBufDest
or
y
(
pTSBuf2
);
tsBufDest
ro
y
(
pTSBuf1
);
tsBufDest
ro
y
(
pTSBuf2
);
}
}
// namespace
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
164aed70
...
...
@@ -110,9 +110,10 @@ typedef struct STsdbQueryHandle {
SFileGroupIter
fileIter
;
SRWHelper
rhelper
;
STableBlockInfo
*
pDataBlockInfo
;
int32_t
allocSize
;
// allocated data block size
SMemTable
*
mem
;
// mem-table
SMemTable
*
imem
;
// imem-table, acquired from snapshot
SArray
*
defaultLoadColumn
;
// default load column
SDataBlockLoadInfo
dataBlockLoadInfo
;
/* record current block load information */
SLoadCompBlockInfo
compBlockLoadInfo
;
/* record current compblock information in SQuery */
}
STsdbQueryHandle
;
...
...
@@ -136,6 +137,34 @@ static void tsdbInitCompBlockLoadInfo(SLoadCompBlockInfo* pCompBlockLoadInfo) {
pCompBlockLoadInfo
->
fileId
=
-
1
;
}
static
SArray
*
getColumnIdList
(
STsdbQueryHandle
*
pQueryHandle
)
{
size_t
numOfCols
=
QH_GET_NUM_OF_COLS
(
pQueryHandle
);
assert
(
numOfCols
<=
TSDB_MAX_COLUMNS
);
SArray
*
pIdList
=
taosArrayInit
(
numOfCols
,
sizeof
(
int16_t
));
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
taosArrayPush
(
pIdList
,
&
pCol
->
info
.
colId
);
}
return
pIdList
;
}
static
SArray
*
getDefaultLoadColumns
(
STsdbQueryHandle
*
pQueryHandle
,
bool
loadTS
)
{
SArray
*
pLocalIdList
=
getColumnIdList
(
pQueryHandle
);
// check if the primary time stamp column needs to load
int16_t
colId
=
*
(
int16_t
*
)
taosArrayGet
(
pLocalIdList
,
0
);
// the primary timestamp column does not be included in the the specified load column list, add it
if
(
loadTS
&&
colId
!=
0
)
{
int16_t
columnId
=
0
;
taosArrayInsert
(
pLocalIdList
,
0
,
&
columnId
);
}
return
pLocalIdList
;
}
TsdbQueryHandleT
*
tsdbQueryTables
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
)
{
STsdbQueryHandle
*
pQueryHandle
=
calloc
(
1
,
sizeof
(
STsdbQueryHandle
));
pQueryHandle
->
order
=
pCond
->
order
;
...
...
@@ -148,7 +177,8 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab
pQueryHandle
->
activeIndex
=
0
;
// current active table index
pQueryHandle
->
qinfo
=
qinfo
;
pQueryHandle
->
outputCapacity
=
((
STsdbRepo
*
)
tsdb
)
->
config
.
maxRowsPerFileBlock
;
pQueryHandle
->
allocSize
=
0
;
tsdbInitReadHelper
(
&
pQueryHandle
->
rhelper
,
(
STsdbRepo
*
)
tsdb
);
tsdbTakeMemSnapshot
(
pQueryHandle
->
pTsdb
,
&
pQueryHandle
->
mem
,
&
pQueryHandle
->
imem
);
...
...
@@ -195,7 +225,9 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab
taosArrayPush
(
pQueryHandle
->
pTableCheckInfo
,
&
info
);
}
}
pQueryHandle
->
defaultLoadColumn
=
getDefaultLoadColumns
(
pQueryHandle
,
true
);
tsdbDebug
(
"%p total numOfTable:%zu in query"
,
pQueryHandle
,
taosArrayGetSize
(
pQueryHandle
->
pTableCheckInfo
));
tsdbInitDataBlockLoadInfo
(
&
pQueryHandle
->
dataBlockLoadInfo
);
...
...
@@ -546,33 +578,7 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
.tid = (_checkInfo)->tableId.tid, \
.uid = (_checkInfo)->tableId.uid})
static
SArray
*
getColumnIdList
(
STsdbQueryHandle
*
pQueryHandle
)
{
size_t
numOfCols
=
QH_GET_NUM_OF_COLS
(
pQueryHandle
);
assert
(
numOfCols
<=
TSDB_MAX_COLUMNS
);
SArray
*
pIdList
=
taosArrayInit
(
numOfCols
,
sizeof
(
int16_t
));
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
taosArrayPush
(
pIdList
,
&
pCol
->
info
.
colId
);
}
return
pIdList
;
}
static
SArray
*
getDefaultLoadColumns
(
STsdbQueryHandle
*
pQueryHandle
,
bool
loadTS
)
{
SArray
*
pLocalIdList
=
getColumnIdList
(
pQueryHandle
);
// check if the primary time stamp column needs to load
int16_t
colId
=
*
(
int16_t
*
)
taosArrayGet
(
pLocalIdList
,
0
);
// the primary timestamp column does not be included in the the specified load column list, add it
if
(
loadTS
&&
colId
!=
0
)
{
int16_t
columnId
=
0
;
taosArrayInsert
(
pLocalIdList
,
0
,
&
columnId
);
}
return
pLocalIdList
;
}
static
bool
doLoadFileDataBlock
(
STsdbQueryHandle
*
pQueryHandle
,
SCompBlock
*
pBlock
,
STableCheckInfo
*
pCheckInfo
)
{
STsdbRepo
*
pRepo
=
pQueryHandle
->
pTsdb
;
...
...
@@ -584,8 +590,6 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
data
->
uid
=
pCheckInfo
->
pTableObj
->
tableId
.
uid
;
bool
blockLoaded
=
false
;
SArray
*
sa
=
getDefaultLoadColumns
(
pQueryHandle
,
true
);
int64_t
st
=
taosGetTimestampUs
();
if
(
pCheckInfo
->
pDataCols
==
NULL
)
{
...
...
@@ -613,7 +617,6 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
assert
(
pCols
->
numOfRows
!=
0
&&
pCols
->
numOfRows
<=
pBlock
->
numOfRows
);
pBlock
->
numOfRows
=
pCols
->
numOfRows
;
taosArrayDestroy
(
sa
);
tfree
(
data
);
int64_t
et
=
taosGetTimestampUs
()
-
st
;
...
...
@@ -656,12 +659,8 @@ static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock*
return
;
}
SArray
*
sa
=
getDefaultLoadColumns
(
pQueryHandle
,
true
);
doLoadFileDataBlock
(
pQueryHandle
,
pBlock
,
pCheckInfo
);
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
,
sa
);
taosArrayDestroy
(
sa
);
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
,
pQueryHandle
->
defaultLoadColumn
);
}
else
{
/*
* no data in cache, only load data from file
...
...
@@ -681,14 +680,12 @@ static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock*
}
static
bool
loadFileDataBlock
(
STsdbQueryHandle
*
pQueryHandle
,
SCompBlock
*
pBlock
,
STableCheckInfo
*
pCheckInfo
)
{
SArray
*
sa
=
getDefaultLoadColumns
(
pQueryHandle
,
true
);
SQueryFilePos
*
cur
=
&
pQueryHandle
->
cur
;
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
// query ended in current block
if
(
pQueryHandle
->
window
.
ekey
<
pBlock
->
keyLast
||
pCheckInfo
->
lastKey
>
pBlock
->
keyFirst
)
{
if
(
!
doLoadFileDataBlock
(
pQueryHandle
,
pBlock
,
pCheckInfo
))
{
taosArrayDestroy
(
sa
);
return
false
;
}
...
...
@@ -702,7 +699,7 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock
cur
->
pos
=
0
;
}
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
,
sa
);
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
,
pQueryHandle
->
defaultLoadColumn
);
}
else
{
// the whole block is loaded in to buffer
handleDataMergeIfNeeded
(
pQueryHandle
,
pBlock
,
pCheckInfo
);
}
...
...
@@ -719,13 +716,12 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock
cur
->
pos
=
pBlock
->
numOfRows
-
1
;
}
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
,
sa
);
doMergeTwoLevelData
(
pQueryHandle
,
pCheckInfo
,
pBlock
,
pQueryHandle
->
defaultLoadColumn
);
}
else
{
handleDataMergeIfNeeded
(
pQueryHandle
,
pBlock
,
pCheckInfo
);
}
}
taosArrayDestroy
(
sa
);
return
pQueryHandle
->
realNumOfRows
>
0
;
}
...
...
@@ -1250,13 +1246,19 @@ static int32_t dataBlockOrderCompar(const void* pLeft, const void* pRight, void*
}
static
int32_t
createDataBlocksInfo
(
STsdbQueryHandle
*
pQueryHandle
,
int32_t
numOfBlocks
,
int32_t
*
numOfAllocBlocks
)
{
char
*
tmp
=
realloc
(
pQueryHandle
->
pDataBlockInfo
,
sizeof
(
STableBlockInfo
)
*
numOfBlocks
);
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_TDB_OUT_OF_MEMORY
;
size_t
size
=
sizeof
(
STableBlockInfo
)
*
numOfBlocks
;
if
(
pQueryHandle
->
allocSize
<
size
)
{
pQueryHandle
->
allocSize
=
size
;
char
*
tmp
=
realloc
(
pQueryHandle
->
pDataBlockInfo
,
pQueryHandle
->
allocSize
);
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_TDB_OUT_OF_MEMORY
;
}
pQueryHandle
->
pDataBlockInfo
=
(
STableBlockInfo
*
)
tmp
;
}
pQueryHandle
->
pDataBlockInfo
=
(
STableBlockInfo
*
)
tmp
;
memset
(
pQueryHandle
->
pDataBlockInfo
,
0
,
sizeof
(
STableBlockInfo
)
*
numOfBlocks
);
memset
(
pQueryHandle
->
pDataBlockInfo
,
0
,
size
);
*
numOfAllocBlocks
=
numOfBlocks
;
int32_t
numOfTables
=
taosArrayGetSize
(
pQueryHandle
->
pTableCheckInfo
);
...
...
@@ -1492,9 +1494,8 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
return
false
;
}
SArray
*
sa
=
getDefaultLoadColumns
(
pQueryHandle
,
true
);
/*SDataBlockInfo* pBlockInfo =*/
tsdbRetrieveDataBlockInfo
(
pHandle
,
&
blockInfo
);
/*SArray *pDataBlock = */
tsdbRetrieveDataBlock
(
pHandle
,
sa
);
/*SArray *pDataBlock = */
tsdbRetrieveDataBlock
(
pHandle
,
pQueryHandle
->
defaultLoadColumn
);
if
(
pQueryHandle
->
cur
.
win
.
ekey
==
pQueryHandle
->
window
.
skey
)
{
// data already retrieve, discard other data rows and return
...
...
@@ -1508,7 +1509,6 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
pQueryHandle
->
window
=
pQueryHandle
->
cur
.
win
;
pQueryHandle
->
cur
.
rows
=
1
;
pQueryHandle
->
type
=
TSDB_QUERY_TYPE_EXTERNAL
;
taosArrayDestroy
(
sa
);
return
true
;
}
else
{
STsdbQueryHandle
*
pSecQueryHandle
=
calloc
(
1
,
sizeof
(
STsdbQueryHandle
));
...
...
@@ -1565,7 +1565,7 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
assert
(
ret
);
/*SDataBlockInfo* pBlockInfo =*/
tsdbRetrieveDataBlockInfo
((
void
*
)
pSecQueryHandle
,
&
blockInfo
);
/*SArray *pDataBlock = */
tsdbRetrieveDataBlock
((
void
*
)
pSecQueryHandle
,
sa
);
/*SArray *pDataBlock = */
tsdbRetrieveDataBlock
((
void
*
)
pSecQueryHandle
,
pSecQueryHandle
->
defaultLoadColumn
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
...
...
@@ -2333,6 +2333,7 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) {
}
taosArrayDestroy
(
pQueryHandle
->
pColumns
);
taosArrayDestroy
(
pQueryHandle
->
defaultLoadColumn
);
tfree
(
pQueryHandle
->
pDataBlockInfo
);
tfree
(
pQueryHandle
->
statis
);
...
...
src/util/inc/tarray.h
浏览文件 @
164aed70
...
...
@@ -23,7 +23,7 @@ extern "C" {
#include "os.h"
#define TARRAY_MIN_SIZE 8
#define TARRAY_GET_ELEM(array, index) ((
array)->pData + (index) * (array)->elemSize
)
#define TARRAY_GET_ELEM(array, index) ((
void*)((array)->pData + (index) * (array)->elemSize)
)
typedef
struct
SArray
{
size_t
size
;
...
...
src/util/inc/tcache.h
浏览文件 @
164aed70
...
...
@@ -33,17 +33,20 @@ typedef struct SCacheStatis {
int64_t
refreshCount
;
}
SCacheStatis
;
struct
STrashElem
;
typedef
struct
SCacheDataNode
{
uint64_t
addedTime
;
// the added time when this element is added or updated into cache
uint64_t
lifespan
;
// expiredTime expiredTime when this element should be remove from cache
uint64_t
signature
;
uint32_t
size
;
// allocated size for current SCacheDataNode
uint64_t
addedTime
;
// the added time when this element is added or updated into cache
uint64_t
lifespan
;
// life duration when this element should be remove from cache
uint64_t
expireTime
;
// expire time
uint64_t
signature
;
struct
STrashElem
*
pTNodeHeader
;
// point to trash node head
uint16_t
keySize
:
15
;
// max key size: 32kb
bool
inTrashCan
:
1
;
// denote if it is in trash or not
uint32_t
size
;
// allocated size for current SCacheDataNode
T_REF_DECLARE
()
uint16_t
keySize
:
15
;
// max key size: 32kb
bool
inTrashCan
:
1
;
// denote if it is in trash or not
int32_t
extendFactor
;
// number of life span extend
char
*
key
;
char
data
[];
char
*
key
;
char
data
[];
}
SCacheDataNode
;
typedef
struct
STrashElem
{
...
...
src/util/src/tcache.c
浏览文件 @
164aed70
...
...
@@ -116,11 +116,13 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
return
;
}
int32_t
size
=
pNode
->
size
;
taosHashRemove
(
pCacheObj
->
pHashTable
,
pNode
->
key
,
pNode
->
keySize
);
pCacheObj
->
totalSize
-=
pNode
->
size
;
uDebug
(
"cache:%s, key:%p, %p is destroyed from cache, totalNum:%d totalSize:%"
PRId64
"bytes size:%dbytes"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
(
int32_t
)
taosHashGetSize
(
pCacheObj
->
pHashTable
),
pCacheObj
->
totalSize
,
size
);
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
(
int32_t
)
taosHashGetSize
(
pCacheObj
->
pHashTable
),
pCacheObj
->
totalSize
,
pNode
->
size
);
if
(
pCacheObj
->
freeFp
)
pCacheObj
->
freeFp
(
pNode
->
data
);
free
(
pNode
);
}
...
...
@@ -285,7 +287,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
uDebug
(
"cache:%s, key:%p, %p added into cache, added:%"
PRIu64
", expire:%"
PRIu64
", totalNum:%d totalSize:%"
PRId64
"bytes size:%"
PRId64
"bytes"
,
pCacheObj
->
name
,
key
,
pNode
->
data
,
pNode
->
addedTime
,
(
pNode
->
lifespan
*
pNode
->
extendFactor
+
pNode
->
addedTime
)
,
pCacheObj
->
name
,
key
,
pNode
->
data
,
pNode
->
addedTime
,
pNode
->
expireTime
,
(
int32_t
)
taosHashGetSize
(
pCacheObj
->
pHashTable
),
pCacheObj
->
totalSize
,
dataSize
);
}
else
{
uError
(
"cache:%s, key:%p, failed to added into cache, out of memory"
,
pCacheObj
->
name
,
key
);
...
...
@@ -312,16 +314,6 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
int32_t
ref
=
0
;
if
(
ptNode
!=
NULL
)
{
ref
=
T_REF_INC
(
*
ptNode
);
// if the remained life span is less then the (*ptNode)->lifeSpan, add up one lifespan
if
(
pCacheObj
->
extendLifespan
)
{
int64_t
now
=
taosGetTimestampMs
();
if
((
now
-
(
*
ptNode
)
->
addedTime
)
<
(
*
ptNode
)
->
lifespan
*
(
*
ptNode
)
->
extendFactor
)
{
(
*
ptNode
)
->
extendFactor
+=
1
;
uDebug
(
"key:%p extend life time to %"
PRId64
,
key
,
(
*
ptNode
)
->
lifespan
*
(
*
ptNode
)
->
extendFactor
+
(
*
ptNode
)
->
addedTime
);
}
}
}
__cache_unlock
(
pCacheObj
);
...
...
@@ -347,8 +339,7 @@ void* taosCacheUpdateExpireTimeByName(SCacheObj *pCacheObj, void *key, size_t ke
SCacheDataNode
**
ptNode
=
(
SCacheDataNode
**
)
taosHashGet
(
pCacheObj
->
pHashTable
,
key
,
keyLen
);
if
(
ptNode
!=
NULL
)
{
T_REF_INC
(
*
ptNode
);
(
*
ptNode
)
->
extendFactor
+=
1
;
// (*ptNode)->lifespan = expireTime;
(
*
ptNode
)
->
expireTime
=
taosGetTimestampMs
()
+
(
*
ptNode
)
->
lifespan
;
}
__cache_unlock
(
pCacheObj
);
...
...
@@ -380,17 +371,6 @@ void *taosCacheAcquireByData(SCacheObj *pCacheObj, void *data) {
int32_t
ref
=
T_REF_INC
(
ptNode
);
uDebug
(
"cache:%s, data: %p acquired by data in cache, refcnt:%d"
,
pCacheObj
->
name
,
ptNode
->
data
,
ref
);
// if the remained life span is less then the (*ptNode)->lifeSpan, add up one lifespan
if
(
pCacheObj
->
extendLifespan
)
{
int64_t
now
=
taosGetTimestampMs
();
if
((
now
-
ptNode
->
addedTime
)
<
ptNode
->
lifespan
*
ptNode
->
extendFactor
)
{
ptNode
->
extendFactor
+=
1
;
uDebug
(
"cache:%s, %p extend life time to %"
PRId64
,
pCacheObj
->
name
,
ptNode
->
data
,
ptNode
->
lifespan
*
ptNode
->
extendFactor
+
ptNode
->
addedTime
);
}
}
// the data if referenced by at least one object, so the reference count must be greater than the value of 2.
assert
(
ref
>=
2
);
return
data
;
...
...
@@ -431,22 +411,58 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
}
*
data
=
NULL
;
int16_t
ref
=
T_REF_DEC
(
pNode
);
uDebug
(
"cache:%s, key:%p, %p is released, refcnt:%d"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
ref
);
if
(
_remove
&&
(
!
pNode
->
inTrashCan
))
{
__cache_wr_lock
(
pCacheObj
);
// note: extend lifespan before dec ref count
if
(
pCacheObj
->
extendLifespan
)
{
atomic_store_64
(
&
pNode
->
expireTime
,
pNode
->
lifespan
+
taosGetTimestampMs
());
uDebug
(
"cache:%s data:%p extend life time to %"
PRId64
" before release"
,
pCacheObj
->
name
,
pNode
->
data
,
pNode
->
expireTime
);
}
bool
inTrashCan
=
pNode
->
inTrashCan
;
uDebug
(
"cache:%s, key:%p, %p is released, refcnt:%d"
,
pCacheObj
->
name
,
pNode
->
key
,
pNode
->
data
,
T_REF_VAL_GET
(
pNode
)
-
1
);
if
(
T_REF_VAL_GET
(
pNode
)
==
0
)
{
// remove directly, if not referenced by other users
taosCacheReleaseNode
(
pCacheObj
,
pNode
);
}
else
{
// pNode may be released immediately by other thread after the reference count of pNode is set to 0,
// So we need to lock it in the first place.
taosCacheMoveToTrash
(
pCacheObj
,
pNode
);
// NOTE: once refcount is decrease, pNode may be free by other thread immediately.
int32_t
ref
=
T_REF_DEC
(
pNode
);
if
(
inTrashCan
)
{
// Remove it if the ref count is 0.
// The ref count does not need to load and check again after lock acquired, since ref count can not be increased when
// the node is in trashcan.
if
(
ref
==
0
)
{
__cache_wr_lock
(
pCacheObj
);
assert
(
pNode
->
pTNodeHeader
->
pData
==
pNode
);
taosRemoveFromTrashCan
(
pCacheObj
,
pNode
->
pTNodeHeader
);
__cache_unlock
(
pCacheObj
);
}
__cache_unlock
(
pCacheObj
);
}
else
{
assert
(
pNode
->
pTNodeHeader
==
NULL
);
if
(
_remove
)
{
// not in trash can, but need to remove it
__cache_wr_lock
(
pCacheObj
);
/*
* If not referenced by other users. Otherwise move this node to trashcan wait for all users
* releasing this resources.
*
* NOTE: previous ref is 0, and current ref is still 0, remove it. If previous is not 0, there is another thread
* that tries to do the same thing.
*/
if
(
ref
==
0
)
{
if
(
T_REF_VAL_GET
(
pNode
)
==
0
)
{
taosCacheReleaseNode
(
pCacheObj
,
pNode
);
}
else
{
taosCacheMoveToTrash
(
pCacheObj
,
pNode
);
}
}
__cache_unlock
(
pCacheObj
);
// } else { // extend its life time
// if (pCacheObj->extendLifespan) {
// atomic_store_64(&pNode->expireTime, pNode->lifespan + taosGetTimestampMs());
// uDebug("cache:%s data:%p extend life time to %"PRId64 " after release", pCacheObj->name, pNode->data, pNode->expireTime);
// }
}
}
}
...
...
@@ -486,7 +502,7 @@ void taosCacheCleanup(SCacheObj *pCacheObj) {
SCacheDataNode
*
taosCreateCacheNode
(
const
char
*
key
,
size_t
keyLen
,
const
char
*
pData
,
size_t
size
,
uint64_t
duration
)
{
size_t
totalSize
=
size
+
sizeof
(
SCacheDataNode
)
+
keyLen
+
1
;
size_t
totalSize
=
size
+
sizeof
(
SCacheDataNode
)
+
keyLen
;
SCacheDataNode
*
pNewNode
=
calloc
(
1
,
totalSize
);
if
(
pNewNode
==
NULL
)
{
...
...
@@ -503,7 +519,7 @@ SCacheDataNode *taosCreateCacheNode(const char *key, size_t keyLen, const char *
pNewNode
->
addedTime
=
(
uint64_t
)
taosGetTimestampMs
();
pNewNode
->
lifespan
=
duration
;
pNewNode
->
ex
tendFactor
=
1
;
pNewNode
->
ex
pireTime
=
pNewNode
->
addedTime
+
pNewNode
->
lifespan
;
pNewNode
->
signature
=
(
uint64_t
)
pNewNode
;
pNewNode
->
size
=
(
uint32_t
)
totalSize
;
...
...
@@ -512,6 +528,7 @@ SCacheDataNode *taosCreateCacheNode(const char *key, size_t keyLen, const char *
void
taosAddToTrash
(
SCacheObj
*
pCacheObj
,
SCacheDataNode
*
pNode
)
{
if
(
pNode
->
inTrashCan
)
{
/* node is already in trash */
assert
(
pNode
->
pTNodeHeader
!=
NULL
&&
pNode
->
pTNodeHeader
->
pData
==
pNode
);
return
;
}
...
...
@@ -527,6 +544,7 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) {
pCacheObj
->
pTrash
=
pElem
;
pNode
->
inTrashCan
=
true
;
pNode
->
pTNodeHeader
=
pElem
;
pCacheObj
->
numOfElemsInTrash
++
;
uDebug
(
"key:%p, %p move to trash, numOfElem in trash:%d"
,
pNode
->
key
,
pNode
->
data
,
pCacheObj
->
numOfElemsInTrash
);
...
...
@@ -629,7 +647,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t
__cache_wr_lock
(
pCacheObj
);
while
(
taosHashIterNext
(
pIter
))
{
SCacheDataNode
*
pNode
=
*
(
SCacheDataNode
**
)
taosHashIterGet
(
pIter
);
if
(
(
pNode
->
addedTime
+
pNode
->
lifespan
*
pNode
->
extendFactor
)
<=
time
&&
T_REF_VAL_GET
(
pNode
)
<=
0
)
{
if
(
pNode
->
expireTime
<
time
&&
T_REF_VAL_GET
(
pNode
)
<=
0
)
{
taosCacheReleaseNode
(
pCacheObj
,
pNode
);
continue
;
}
...
...
src/util/src/ttime.c
浏览文件 @
164aed70
...
...
@@ -317,29 +317,34 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) {
static
int32_t
getTimestampInUsFromStrImpl
(
int64_t
val
,
char
unit
,
int64_t
*
result
)
{
*
result
=
val
;
int64_t
factor
=
1000L
;
switch
(
unit
)
{
case
's'
:
(
*
result
)
*=
MILLISECOND_PER_SECOND
;
(
*
result
)
*=
MILLISECOND_PER_SECOND
*
factor
;
break
;
case
'm'
:
(
*
result
)
*=
MILLISECOND_PER_MINUTE
;
(
*
result
)
*=
MILLISECOND_PER_MINUTE
*
factor
;
break
;
case
'h'
:
(
*
result
)
*=
MILLISECOND_PER_HOUR
;
(
*
result
)
*=
MILLISECOND_PER_HOUR
*
factor
;
break
;
case
'd'
:
(
*
result
)
*=
MILLISECOND_PER_DAY
;
(
*
result
)
*=
MILLISECOND_PER_DAY
*
factor
;
break
;
case
'w'
:
(
*
result
)
*=
MILLISECOND_PER_WEEK
;
(
*
result
)
*=
MILLISECOND_PER_WEEK
*
factor
;
break
;
case
'n'
:
(
*
result
)
*=
MILLISECOND_PER_MONTH
;
(
*
result
)
*=
MILLISECOND_PER_MONTH
*
factor
;
break
;
case
'y'
:
(
*
result
)
*=
MILLISECOND_PER_YEAR
;
(
*
result
)
*=
MILLISECOND_PER_YEAR
*
factor
;
break
;
case
'a'
:
(
*
result
)
*=
factor
;
break
;
case
'u'
:
break
;
default:
{
;
...
...
@@ -348,7 +353,6 @@ static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* resu
}
/* get the value in microsecond */
(
*
result
)
*=
1000L
;
return
0
;
}
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
164aed70
...
...
@@ -508,7 +508,7 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
vTrace
(
"vgId:%d, vnode will cleanup, refCount:%d"
,
pVnode
->
vgId
,
pVnode
->
refCount
);
// release local resources only after cutting off outside connections
q
SetQueryMgmt
Closed
(
pVnode
->
qMgmt
);
q
QueryMgmtNotify
Closed
(
pVnode
->
qMgmt
);
vnodeRelease
(
pVnode
);
}
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
164aed70
...
...
@@ -82,6 +82,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
vWarn
(
"QInfo:%p invalid qhandle, no matched query handle, conn:%p"
,
(
void
*
)
killQueryMsg
->
qhandle
,
pReadMsg
->
rpcMsg
.
handle
);
}
else
{
assert
(
*
qhandle
==
(
void
*
)
killQueryMsg
->
qhandle
);
qKillQuery
(
*
qhandle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
qhandle
,
true
);
}
...
...
@@ -93,7 +94,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
if
(
contLen
!=
0
)
{
qinfo_t
pQInfo
=
NULL
;
code
=
qCreateQueryInfo
(
pVnode
->
tsdb
,
pVnode
->
vgId
,
pQueryTableMsg
,
pVnode
,
NULL
,
&
pQInfo
);
code
=
qCreateQueryInfo
(
pVnode
->
tsdb
,
pVnode
->
vgId
,
pQueryTableMsg
,
pVnode
,
&
pQInfo
);
SQueryTableRsp
*
pRsp
=
(
SQueryTableRsp
*
)
rpcMallocCont
(
sizeof
(
SQueryTableRsp
));
pRsp
->
code
=
code
;
...
...
@@ -108,9 +109,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
handle
=
qRegisterQInfo
(
pVnode
->
qMgmt
,
(
uint64_t
)
pQInfo
);
if
(
handle
==
NULL
)
{
// failed to register qhandle
pRsp
->
code
=
TSDB_CODE_QRY_INVALID_QHANDLE
;
qKillQuery
(
pQInfo
);
qKillQuery
(
pQInfo
);
qDestroyQueryInfo
(
pQInfo
);
// destroy it directly
}
else
{
assert
(
*
handle
==
pQInfo
);
pRsp
->
qhandle
=
htobe64
((
uint64_t
)
pQInfo
);
...
...
@@ -120,10 +119,6 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
if
(
handle
!=
NULL
&&
vnodeNotifyCurrentQhandle
(
pReadMsg
->
rpcMsg
.
handle
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, QInfo:%p, query discarded since link is broken, %p"
,
pVnode
->
vgId
,
*
handle
,
pReadMsg
->
rpcMsg
.
handle
);
pRsp
->
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
// NOTE: there two refcount, needs to kill twice
// query has not been put into qhandle pool, kill it directly.
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
return
pRsp
->
code
;
}
...
...
@@ -134,6 +129,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
dnodePutItemIntoReadQueue
(
pVnode
,
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
false
);
}
vDebug
(
"vgId:%d, QInfo:%p, dnode query msg disposed"
,
vgId
,
pQInfo
);
}
else
{
assert
(
pCont
!=
NULL
);
...
...
@@ -183,6 +179,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
if
(
pRetrieve
->
free
==
1
)
{
vDebug
(
"vgId:%d, QInfo:%p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
*
handle
);
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
pRet
->
rsp
=
(
SRetrieveTableRsp
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableRsp
));
...
...
@@ -209,6 +206,9 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
dnodePutItemIntoReadQueue
(
pVnode
,
*
handle
);
pRet
->
qhandle
=
*
handle
;
freeHandle
=
false
;
}
else
{
qKillQuery
(
*
handle
);
freeHandle
=
true
;
}
}
}
...
...
tests/pytest/table/del_stable.py
浏览文件 @
164aed70
...
...
@@ -37,17 +37,8 @@ class TDTestCase:
except
Exception
as
e
:
tdLog
.
exit
(
e
)
try
:
tdSql
.
execute
(
"select * from db.st"
)
except
Exception
as
e
:
if
e
.
args
[
0
]
!=
'mnode invalid table name'
:
tdLog
.
exit
(
e
)
try
:
tdSql
.
execute
(
"select * from db.tb"
)
except
Exception
as
e
:
if
e
.
args
[
0
]
!=
'mnode invalid table name'
:
tdLog
.
exit
(
e
)
tdSql
.
error
(
"select * from db.st"
)
tdSql
.
error
(
"select * from db.tb"
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/script/general/parser/fill_us.sim
浏览文件 @
164aed70
...
...
@@ -652,25 +652,25 @@ endi
if $data01 != 1 then
return -1
endi
if $data11 !=
null
then
if $data11 !=
NULL
then
return -1
endi
if $data21 != 1 then
return -1
endi
if $data31 !=
null
then
if $data31 !=
NULL
then
return -1
endi
if $data41 != 1 then
return -1
endi
if $data51 !=
null
then
if $data51 !=
NULL
then
return -1
endi
if $data61 != 1 then
return -1
endi
if $data71 !=
null
then
if $data71 !=
NULL
then
return -1
endi
if $data81 != 1 then
...
...
@@ -689,25 +689,25 @@ endi
if $data01 != 0.000000000 then
return -1
endi
if $data11 !=
null
then
if $data11 !=
NULL
then
return -1
endi
if $data21 != 1.000000000 then
return -1
endi
if $data31 !=
null
then
if $data31 !=
NULL
then
return -1
endi
if $data41 != 2.000000000 then
return -1
endi
if $data51 !=
null
then
if $data51 !=
NULL
then
return -1
endi
if $data61 != 3.000000000 then
return -1
endi
if $data71 !=
null
then
if $data71 !=
NULL
then
return -1
endi
if $data81 != 4.000000000 then
...
...
@@ -722,25 +722,25 @@ endi
if $data01 != 0 then
return -1
endi
if $data11 !=
null
then
if $data11 !=
NULL
then
return -1
endi
if $data21 != 1 then
return -1
endi
if $data31 !=
null
then
if $data31 !=
NULL
then
return -1
endi
if $data41 != 2 then
return -1
endi
if $data51 !=
null
then
if $data51 !=
NULL
then
return -1
endi
if $data61 != 3 then
return -1
endi
if $data71 !=
null
then
if $data71 !=
NULL
then
return -1
endi
if $data81 != 4 then
...
...
@@ -755,25 +755,25 @@ endi
if $data01 != 0 then
return -1
endi
if $data11 !=
null
then
if $data11 !=
NULL
then
return -1
endi
if $data21 != 1 then
return -1
endi
if $data31 !=
null
then
if $data31 !=
NULL
then
return -1
endi
if $data41 != 2 then
return -1
endi
if $data51 !=
null
then
if $data51 !=
NULL
then
return -1
endi
if $data61 != 3 then
return -1
endi
if $data71 !=
null
then
if $data71 !=
NULL
then
return -1
endi
if $data81 != 4 then
...
...
@@ -788,25 +788,25 @@ endi
if $data01 != 0 then
return -1
endi
if $data11 !=
null
then
if $data11 !=
NULL
then
return -1
endi
if $data21 != 1 then
return -1
endi
if $data31 !=
null
then
if $data31 !=
NULL
then
return -1
endi
if $data41 != 2 then
return -1
endi
if $data51 !=
null
then
if $data51 !=
NULL
then
return -1
endi
if $data61 != 3 then
return -1
endi
if $data71 !=
null
then
if $data71 !=
NULL
then
return -1
endi
if $data81 != 4 then
...
...
@@ -821,25 +821,25 @@ endi
if $data01 != 0 then
return -1
endi
if $data11 !=
null
then
if $data11 !=
NULL
then
return -1
endi
if $data21 != 1 then
return -1
endi
if $data31 !=
null
then
if $data31 !=
NULL
then
return -1
endi
if $data41 != 2 then
return -1
endi
if $data51 !=
null
then
if $data51 !=
NULL
then
return -1
endi
if $data61 != 3 then
return -1
endi
if $data71 !=
null
then
if $data71 !=
NULL
then
return -1
endi
if $data81 != 4 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录