Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
63bc50a7
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
63bc50a7
编写于
8月 16, 2023
作者:
H
Haojun Liao
提交者:
GitHub
8月 16, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22427 from taosdata/feature/rebuildIndex0
rebuild index at tag0
上级
df13c6fa
7d1e4a98
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
302 addition
and
125 deletion
+302
-125
include/os/osRand.h
include/os/osRand.h
+2
-0
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+40
-38
source/dnode/mnode/impl/src/mndIndex.c
source/dnode/mnode/impl/src/mndIndex.c
+60
-12
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+38
-8
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+7
-7
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+5
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+12
-12
source/os/src/osRand.c
source/os/src/osRand.c
+13
-4
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+3
-0
tests/script/tsim/sma/drop_sma.sim
tests/script/tsim/sma/drop_sma.sim
+47
-18
tests/script/tsim/tagindex/add_index.sim
tests/script/tsim/tagindex/add_index.sim
+45
-3
tests/script/tsim/tagindex/sma_and_tag_index.sim
tests/script/tsim/tagindex/sma_and_tag_index.sim
+13
-9
tests/system-test/0-others/show_tag_index.py
tests/system-test/0-others/show_tag_index.py
+12
-8
tests/system-test/0-others/tag_index_basic.py
tests/system-test/0-others/tag_index_basic.py
+5
-2
未找到文件。
include/os/osRand.h
浏览文件 @
63bc50a7
...
...
@@ -32,6 +32,8 @@ void taosSeedRand(uint32_t seed);
uint32_t
taosRand
(
void
);
uint32_t
taosRandR
(
uint32_t
*
pSeed
);
void
taosRandStr
(
char
*
str
,
int32_t
size
);
void
taosRandStr2
(
char
*
str
,
int32_t
size
);
uint32_t
taosSafeRand
(
void
);
#ifdef __cplusplus
...
...
source/common/src/tdatablock.c
浏览文件 @
63bc50a7
...
...
@@ -26,7 +26,7 @@ int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRo
if
(
pColumnInfoData
->
reassigned
)
{
int32_t
totalSize
=
0
;
for
(
int32_t
row
=
0
;
row
<
numOfRows
;
++
row
)
{
char
*
pColData
=
pColumnInfoData
->
pData
+
pColumnInfoData
->
varmeta
.
offset
[
row
];
char
*
pColData
=
pColumnInfoData
->
pData
+
pColumnInfoData
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pColData
);
...
...
@@ -142,7 +142,8 @@ int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const
return
0
;
}
int32_t
colDataReassignVal
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
dstRowIdx
,
uint32_t
srcRowIdx
,
const
char
*
pData
)
{
int32_t
colDataReassignVal
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
dstRowIdx
,
uint32_t
srcRowIdx
,
const
char
*
pData
)
{
int32_t
type
=
pColumnInfoData
->
info
.
type
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
int32_t
dataLen
=
0
;
...
...
@@ -164,7 +165,6 @@ int32_t colDataReassignVal(SColumnInfoData* pColumnInfoData, uint32_t dstRowIdx,
return
0
;
}
static
int32_t
colDataReserve
(
SColumnInfoData
*
pColumnInfoData
,
size_t
newSize
)
{
if
(
!
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -188,16 +188,17 @@ static int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize)
}
static
int32_t
doCopyNItems
(
struct
SColumnInfoData
*
pColumnInfoData
,
int32_t
currentRow
,
const
char
*
pData
,
int32_t
itemLen
,
int32_t
numOfRows
,
bool
trimValue
)
{
int32_t
itemLen
,
int32_t
numOfRows
,
bool
trimValue
)
{
if
(
pColumnInfoData
->
info
.
bytes
<
itemLen
)
{
uWarn
(
"column/tag actual data len %d is bigger than schema len %d, trim it:%d"
,
itemLen
,
pColumnInfoData
->
info
.
bytes
,
trimValue
);
uWarn
(
"column/tag actual data len %d is bigger than schema len %d, trim it:%d"
,
itemLen
,
pColumnInfoData
->
info
.
bytes
,
trimValue
);
if
(
trimValue
)
{
itemLen
=
pColumnInfoData
->
info
.
bytes
;
}
else
{
return
TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER
;
}
}
size_t
start
=
1
;
// the first item
...
...
@@ -230,8 +231,8 @@ static int32_t doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t cur
return
TSDB_CODE_SUCCESS
;
}
int32_t
colDataSetNItems
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
uint32_t
numOfRows
,
bool
trimValue
)
{
int32_t
colDataSetNItems
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
uint32_t
numOfRows
,
bool
trimValue
)
{
int32_t
len
=
pColumnInfoData
->
info
.
bytes
;
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
len
=
varDataTLen
(
pData
);
...
...
@@ -262,7 +263,7 @@ static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, c
uint8_t
*
p
=
(
uint8_t
*
)
pSource
->
nullbitmap
;
pColumnInfoData
->
nullbitmap
[
BitmapLen
(
numOfRow1
)
-
1
]
&=
(
0
B11111111
<<
shiftBits
);
// clear remind bits
pColumnInfoData
->
nullbitmap
[
BitmapLen
(
numOfRow1
)
-
1
]
|=
(
p
[
0
]
>>
remindBits
);
// copy remind bits
pColumnInfoData
->
nullbitmap
[
BitmapLen
(
numOfRow1
)
-
1
]
|=
(
p
[
0
]
>>
remindBits
);
// copy remind bits
if
(
BitmapLen
(
numOfRow1
)
==
BitmapLen
(
total
))
{
return
;
...
...
@@ -350,7 +351,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
pColumnInfoData
->
pData
=
tmp
;
if
(
BitmapLen
(
numOfRow1
)
<
BitmapLen
(
finalNumOfRows
))
{
char
*
btmp
=
taosMemoryRealloc
(
pColumnInfoData
->
nullbitmap
,
BitmapLen
(
finalNumOfRows
));
char
*
btmp
=
taosMemoryRealloc
(
pColumnInfoData
->
nullbitmap
,
BitmapLen
(
finalNumOfRows
));
if
(
btmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
@@ -622,7 +623,7 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
if
(
pCol
->
reassigned
&&
IS_VAR_DATA_TYPE
(
pCol
->
info
.
type
))
{
for
(
int32_t
row
=
0
;
row
<
numOfRows
;
++
row
)
{
char
*
pColData
=
pCol
->
pData
+
pCol
->
varmeta
.
offset
[
row
];
char
*
pColData
=
pCol
->
pData
+
pCol
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pColData
);
...
...
@@ -698,8 +699,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
return
TSDB_CODE_SUCCESS
;
}
static
bool
colDataIsNNull
(
const
SColumnInfoData
*
pColumnInfoData
,
int32_t
startIndex
,
uint32_t
nRows
)
{
static
bool
colDataIsNNull
(
const
SColumnInfoData
*
pColumnInfoData
,
int32_t
startIndex
,
uint32_t
nRows
)
{
if
(
!
pColumnInfoData
->
hasNull
)
{
return
false
;
}
...
...
@@ -880,7 +880,6 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
}
static
int32_t
blockDataAssign
(
SColumnInfoData
*
pCols
,
const
SSDataBlock
*
pDataBlock
,
const
int32_t
*
index
)
{
size_t
numOfCols
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pDst
=
&
pCols
[
i
];
...
...
@@ -1131,6 +1130,7 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
// memset(tmp, 0, numOfRows * pColumn->info.bytes);
// copy back the existed data
if
(
pColumn
->
pData
!=
NULL
)
{
...
...
@@ -1474,8 +1474,8 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize, int
int
end
=
nRows
;
while
(
start
<=
end
)
{
int
mid
=
start
+
(
end
-
start
)
/
2
;
//
data size + var data type columns offset + fixed data type columns bitmap len
int
midSize
=
rowSize
*
mid
+
numVarCols
*
sizeof
(
int32_t
)
*
mid
+
numFixCols
*
BitmapLen
(
mid
);
//
data size + var data type columns offset + fixed data type columns bitmap len
int
midSize
=
rowSize
*
mid
+
numVarCols
*
sizeof
(
int32_t
)
*
mid
+
numFixCols
*
BitmapLen
(
mid
);
if
(
midSize
>
payloadSize
)
{
result
=
mid
;
end
=
mid
-
1
;
...
...
@@ -1669,7 +1669,7 @@ int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) {
if
(
pColData
->
reassigned
&&
IS_VAR_DATA_TYPE
(
pColData
->
info
.
type
))
{
for
(
int32_t
row
=
0
;
row
<
rows
;
++
row
)
{
char
*
pData
=
pColData
->
pData
+
pColData
->
varmeta
.
offset
[
row
];
char
*
pData
=
pColData
->
pData
+
pColData
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
pColData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pData
);
...
...
@@ -1772,7 +1772,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
// for debug
char
*
dumpBlockData
(
SSDataBlock
*
pDataBlock
,
const
char
*
flag
,
char
**
pDataBuf
)
{
int32_t
size
=
2048
*
1024
;
int32_t
size
=
2048
*
1024
;
*
pDataBuf
=
taosMemoryCalloc
(
size
,
1
);
char
*
dumpBuf
=
*
pDataBuf
;
char
pBuf
[
128
]
=
{
0
};
...
...
@@ -1780,8 +1780,8 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
len
=
0
;
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"===stream===%s|block type %d|child id %d|group id:%"
PRIu64
"|uid:%"
PRId64
"|
rows:%"
PRId64
"|
version:%"
PRIu64
"|cal start:%"
PRIu64
"|cal end:%"
PRIu64
"|tbl:%s
\n
"
,
"===stream===%s|block type %d|child id %d|group id:%"
PRIu64
"|uid:%"
PRId64
"|rows:%"
PRId64
"|version:%"
PRIu64
"|cal start:%"
PRIu64
"|cal end:%"
PRIu64
"|tbl:%s
\n
"
,
flag
,
(
int32_t
)
pDataBlock
->
info
.
type
,
pDataBlock
->
info
.
childId
,
pDataBlock
->
info
.
id
.
groupId
,
pDataBlock
->
info
.
id
.
uid
,
pDataBlock
->
info
.
rows
,
pDataBlock
->
info
.
version
,
pDataBlock
->
info
.
calWin
.
skey
,
pDataBlock
->
info
.
calWin
.
ekey
,
pDataBlock
->
info
.
parTbName
);
...
...
@@ -2156,21 +2156,21 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) {
data
+=
metaSize
;
dataLen
+=
metaSize
;
if
(
pColRes
->
reassigned
&&
IS_VAR_DATA_TYPE
(
pColRes
->
info
.
type
))
{
colSizes
[
col
]
=
0
;
for
(
int32_t
row
=
0
;
row
<
numOfRows
;
++
row
)
{
char
*
pColData
=
pColRes
->
pData
+
pColRes
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
pColRes
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pColData
);
}
else
{
colSize
=
varDataTLen
(
pColData
);
}
colSizes
[
col
]
+=
colSize
;
dataLen
+=
colSize
;
memmove
(
data
,
pColData
,
colSize
);
data
+=
colSize
;
if
(
pColRes
->
reassigned
&&
IS_VAR_DATA_TYPE
(
pColRes
->
info
.
type
))
{
colSizes
[
col
]
=
0
;
for
(
int32_t
row
=
0
;
row
<
numOfRows
;
++
row
)
{
char
*
pColData
=
pColRes
->
pData
+
pColRes
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
pColRes
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pColData
);
}
else
{
colSize
=
varDataTLen
(
pColData
);
}
colSizes
[
col
]
+=
colSize
;
dataLen
+=
colSize
;
memmove
(
data
,
pColData
,
colSize
);
data
+=
colSize
;
}
}
else
{
colSizes
[
col
]
=
colDataGetLength
(
pColRes
,
numOfRows
);
dataLen
+=
colSizes
[
col
];
...
...
@@ -2181,7 +2181,8 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) {
}
colSizes
[
col
]
=
htonl
(
colSizes
[
col
]);
// uError("blockEncode col bytes:%d, type:%d, size:%d, htonl size:%d", pColRes->info.bytes, pColRes->info.type, htonl(colSizes[col]), colSizes[col]);
// uError("blockEncode col bytes:%d, type:%d, size:%d, htonl size:%d", pColRes->info.bytes, pColRes->info.type,
// htonl(colSizes[col]), colSizes[col]);
}
*
actualLen
=
dataLen
;
...
...
@@ -2283,7 +2284,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
}
void
trimDataBlock
(
SSDataBlock
*
pBlock
,
int32_t
totalRows
,
const
bool
*
pBoolList
)
{
// int32_t totalRows = pBlock->info.rows;
// int32_t totalRows = pBlock->info.rows;
int32_t
bmLen
=
BitmapLen
(
totalRows
);
char
*
pBitmap
=
NULL
;
int32_t
maxRows
=
0
;
...
...
@@ -2310,8 +2311,9 @@ void trimDataBlock(SSDataBlock* pBlock, int32_t totalRows, const bool* pBoolList
if
(
colDataIsNull_var
(
pDst
,
j
))
{
colDataSetNull_var
(
pDst
,
numOfRows
);
}
else
{
// fix address sanitizer error. p1 may point to memory that will change during realloc of colDataSetVal, first copy it to p2
char
*
p1
=
colDataGetVarData
(
pDst
,
j
);
// fix address sanitizer error. p1 may point to memory that will change during realloc of colDataSetVal, first
// copy it to p2
char
*
p1
=
colDataGetVarData
(
pDst
,
j
);
int32_t
len
=
0
;
if
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
len
=
getJsonValueLen
(
p1
);
...
...
source/dnode/mnode/impl/src/mndIndex.c
浏览文件 @
63bc50a7
...
...
@@ -79,9 +79,12 @@ int32_t mndInitIdx(SMnode *pMnode) {
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
static
int32_t
mndFindSuperTableTagId
(
const
SStbObj
*
pStb
,
const
char
*
tagName
)
{
static
int32_t
mndFindSuperTableTagId
(
const
SStbObj
*
pStb
,
const
char
*
tagName
,
int8_t
*
hasIdx
)
{
for
(
int32_t
tag
=
0
;
tag
<
pStb
->
numOfTags
;
tag
++
)
{
if
(
strcasecmp
(
pStb
->
pTags
[
tag
].
name
,
tagName
)
==
0
)
{
if
(
IS_IDX_ON
(
&
pStb
->
pTags
[
tag
]))
{
*
hasIdx
=
1
;
}
return
tag
;
}
}
...
...
@@ -597,7 +600,8 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
pNew
->
updateTime
=
taosGetTimestampMs
();
pNew
->
lock
=
0
;
int32_t
tag
=
mndFindSuperTableTagId
(
pOld
,
tagName
);
int8_t
hasIdx
=
0
;
int32_t
tag
=
mndFindSuperTableTagId
(
pOld
,
tagName
,
&
hasIdx
);
if
(
tag
<
0
)
{
terrno
=
TSDB_CODE_MND_TAG_NOT_EXIST
;
return
-
1
;
...
...
@@ -612,14 +616,14 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
SSchema
*
pTag
=
pNew
->
pTags
+
tag
;
if
(
on
==
1
)
{
if
(
IS_IDX_ON
(
pTag
)
)
{
if
(
hasIdx
&&
tag
!=
0
)
{
terrno
=
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
;
return
-
1
;
}
else
{
SSCHMEA_SET_IDX_ON
(
pTag
);
}
}
else
{
if
(
!
IS_IDX_ON
(
pTag
)
)
{
if
(
hasIdx
==
0
)
{
terrno
=
TSDB_CODE_MND_SMA_NOT_EXIST
;
}
else
{
SSCHMEA_SET_IDX_OFF
(
pTag
);
...
...
@@ -667,7 +671,42 @@ _OVER:
mndTransDrop
(
pTrans
);
return
code
;
}
int8_t
mndCheckIndexNameByTagName
(
SMnode
*
pMnode
,
SIdxObj
*
pIdxObj
)
{
// build index on first tag, and no index name;
int8_t
exist
=
0
;
SDbObj
*
pDb
=
NULL
;
if
(
strlen
(
pIdxObj
->
db
)
>
0
)
{
pDb
=
mndAcquireDb
(
pMnode
,
pIdxObj
->
db
);
if
(
pDb
==
NULL
)
return
0
;
}
SSmaAndTagIter
*
pIter
=
NULL
;
SIdxObj
*
pIdx
=
NULL
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_IDX
,
pIter
,
(
void
**
)
&
pIdx
);
if
(
pIter
==
NULL
)
break
;
if
(
NULL
!=
pDb
&&
pIdx
->
dbUid
!=
pDb
->
uid
)
{
sdbRelease
(
pSdb
,
pIdx
);
continue
;
}
if
(
pIdxObj
->
stbUid
!=
pIdx
->
stbUid
)
{
sdbRelease
(
pSdb
,
pIdx
);
continue
;
}
if
(
strncmp
(
pIdxObj
->
colName
,
pIdx
->
colName
,
TSDB_COL_NAME_LEN
)
==
0
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pIdx
);
exist
=
1
;
break
;
}
sdbRelease
(
pSdb
,
pIdx
);
}
mndReleaseDb
(
pMnode
,
pDb
);
return
exist
;
}
static
int32_t
mndAddIndex
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SCreateTagIndexReq
*
req
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
int32_t
code
=
-
1
;
SIdxObj
idxObj
=
{
0
};
...
...
@@ -681,11 +720,20 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *re
idxObj
.
stbUid
=
pStb
->
uid
;
idxObj
.
dbUid
=
pStb
->
dbUid
;
int32_t
tag
=
mndFindSuperTableTagId
(
pStb
,
req
->
colName
);
int8_t
hasIdx
=
0
;
int32_t
tag
=
mndFindSuperTableTagId
(
pStb
,
req
->
colName
,
&
hasIdx
);
if
(
tag
<
0
)
{
terrno
=
TSDB_CODE_MND_TAG_NOT_EXIST
;
return
-
1
;
}
else
if
(
tag
==
0
)
{
}
int8_t
exist
=
0
;
if
(
tag
==
0
&&
hasIdx
==
1
)
{
exist
=
mndCheckIndexNameByTagName
(
pMnode
,
&
idxObj
);
if
(
exist
)
{
terrno
=
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
;
return
-
1
;
}
}
else
if
(
hasIdx
==
1
)
{
terrno
=
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
;
return
-
1
;
}
...
...
@@ -695,11 +743,11 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *re
return
-
1
;
}
SSchema
*
pTag
=
pStb
->
pTags
+
tag
;
if
(
IS_IDX_ON
(
pTag
))
{
terrno
=
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
;
return
-
1
;
}
//
SSchema *pTag = pStb->pTags + tag;
//
if (IS_IDX_ON(pTag)) {
//
terrno = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST;
//
return -1;
//
}
code
=
mndAddIndexImpl
(
pMnode
,
pReq
,
pDb
,
pStb
,
&
idxObj
);
return
code
;
...
...
@@ -806,8 +854,8 @@ int32_t mndDropIdxsByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p
if
(
pIdx
->
stbUid
==
pStb
->
uid
)
{
if
(
mndSetDropIdxCommitLogs
(
pMnode
,
pTrans
,
pIdx
)
!=
0
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pIdx
);
sdbCancelFetch
(
pSdb
,
pIdx
);
return
-
1
;
}
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
63bc50a7
...
...
@@ -18,6 +18,7 @@
#include "mndDb.h"
#include "mndDnode.h"
#include "mndIndex.h"
#include "mndIndexComm.h"
#include "mndInfoSchema.h"
#include "mndMnode.h"
#include "mndPerfSchema.h"
...
...
@@ -822,7 +823,7 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
return
-
1
;
}
if
(
pDst
->
nextColId
<
0
||
pDst
->
nextColId
>=
0x7fff
-
pDst
->
numOfColumns
-
pDst
->
numOfTags
)
{
if
(
pDst
->
nextColId
<
0
||
pDst
->
nextColId
>=
0x7fff
-
pDst
->
numOfColumns
-
pDst
->
numOfTags
)
{
terrno
=
TSDB_CODE_MND_FIELD_VALUE_OVERFLOW
;
return
-
1
;
}
...
...
@@ -857,11 +858,39 @@ static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCrea
SStbObj
stbObj
=
{
0
};
int32_t
code
=
-
1
;
char
fullIdxName
[
TSDB_INDEX_FNAME_LEN
*
2
]
=
{
0
};
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pReq
,
"create-stb"
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
mInfo
(
"trans:%d, used to create stb:%s"
,
pTrans
->
id
,
pCreate
->
name
);
if
(
mndBuildStbFromReq
(
pMnode
,
&
stbObj
,
pCreate
,
pDb
)
!=
0
)
goto
_OVER
;
char
randStr
[
24
]
=
{
0
};
taosRandStr2
(
randStr
,
tListLen
(
randStr
)
-
1
);
SSchema
*
pSchema
=
&
(
stbObj
.
pTags
[
0
]);
sprintf
(
fullIdxName
,
"%s.%s_%s"
,
pDb
->
name
,
pSchema
->
name
,
randStr
);
SSIdx
idx
=
{
0
};
if
(
mndAcquireGlobalIdx
(
pMnode
,
fullIdxName
,
SDB_IDX
,
&
idx
)
==
0
&&
idx
.
pIdx
!=
NULL
)
{
terrno
=
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
;
mndReleaseIdx
(
pMnode
,
idx
.
pIdx
);
goto
_OVER
;
}
SIdxObj
idxObj
=
{
0
};
memcpy
(
idxObj
.
name
,
fullIdxName
,
TSDB_INDEX_FNAME_LEN
);
memcpy
(
idxObj
.
stb
,
stbObj
.
name
,
TSDB_TABLE_FNAME_LEN
);
memcpy
(
idxObj
.
db
,
stbObj
.
db
,
TSDB_DB_FNAME_LEN
);
memcpy
(
idxObj
.
colName
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
idxObj
.
createdTime
=
taosGetTimestampMs
();
idxObj
.
uid
=
mndGenerateUid
(
fullIdxName
,
strlen
(
fullIdxName
));
idxObj
.
stbUid
=
stbObj
.
uid
;
idxObj
.
dbUid
=
stbObj
.
dbUid
;
if
(
mndSetCreateIdxCommitLogs
(
pMnode
,
pTrans
,
&
idxObj
)
<
0
)
goto
_OVER
;
if
(
mndAddStbToTrans
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
<
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
...
...
@@ -956,7 +985,7 @@ static int32_t mndBuildStbFromAlter(SStbObj *pStb, SStbObj *pDst, SMCreateStbReq
return
-
1
;
}
if
(
pDst
->
nextColId
<
0
||
pDst
->
nextColId
>=
0x7fff
-
pDst
->
numOfColumns
-
pDst
->
numOfTags
)
{
if
(
pDst
->
nextColId
<
0
||
pDst
->
nextColId
>=
0x7fff
-
pDst
->
numOfColumns
-
pDst
->
numOfTags
)
{
terrno
=
TSDB_CODE_MND_FIELD_VALUE_OVERFLOW
;
return
-
1
;
}
...
...
@@ -1188,7 +1217,7 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, SArray *p
return
-
1
;
}
if
(
pNew
->
nextColId
<
0
||
pNew
->
nextColId
>=
0x7fff
-
ntags
)
{
if
(
pNew
->
nextColId
<
0
||
pNew
->
nextColId
>=
0x7fff
-
ntags
)
{
terrno
=
TSDB_CODE_MND_FIELD_VALUE_OVERFLOW
;
return
-
1
;
}
...
...
@@ -1478,7 +1507,8 @@ static int32_t mndAlterStbTagBytes(SMnode *pMnode, const SStbObj *pOld, SStbObj
SSchema
*
pTag
=
pNew
->
pTags
+
tag
;
if
(
!
(
pTag
->
type
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
type
==
TSDB_DATA_TYPE_NCHAR
||
pTag
->
type
==
TSDB_DATA_TYPE_GEOMETRY
))
{
if
(
!
(
pTag
->
type
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
type
==
TSDB_DATA_TYPE_NCHAR
||
pTag
->
type
==
TSDB_DATA_TYPE_GEOMETRY
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
...
...
@@ -1506,7 +1536,7 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
return
-
1
;
}
if
(
pNew
->
nextColId
<
0
||
pNew
->
nextColId
>=
0x7fff
-
ncols
)
{
if
(
pNew
->
nextColId
<
0
||
pNew
->
nextColId
>=
0x7fff
-
ncols
)
{
terrno
=
TSDB_CODE_MND_FIELD_VALUE_OVERFLOW
;
return
-
1
;
}
...
...
@@ -1598,7 +1628,8 @@ static int32_t mndAlterStbColumnBytes(SMnode *pMnode, const SStbObj *pOld, SStbO
}
SSchema
*
pCol
=
pNew
->
pColumns
+
col
;
if
(
!
(
pCol
->
type
==
TSDB_DATA_TYPE_BINARY
||
pCol
->
type
==
TSDB_DATA_TYPE_NCHAR
||
pCol
->
type
==
TSDB_DATA_TYPE_GEOMETRY
))
{
if
(
!
(
pCol
->
type
==
TSDB_DATA_TYPE_BINARY
||
pCol
->
type
==
TSDB_DATA_TYPE_NCHAR
||
pCol
->
type
==
TSDB_DATA_TYPE_GEOMETRY
))
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
...
...
@@ -3182,7 +3213,6 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SStbObj
*
pStb
=
NULL
;
int32_t
numOfRows
=
0
;
if
(
!
pShow
->
sysDbRsp
)
{
numOfRows
=
buildSysDbColsInfo
(
pBlock
,
pShow
->
db
,
pShow
->
filterTb
);
...
...
@@ -3206,7 +3236,7 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
if
(
pShow
->
pIter
==
NULL
)
break
;
}
else
{
fetch
=
true
;
void
*
pKey
=
taosHashGetKey
(
pShow
->
pIter
,
NULL
);
void
*
pKey
=
taosHashGetKey
(
pShow
->
pIter
,
NULL
);
pStb
=
sdbAcquire
(
pSdb
,
SDB_STB
,
pKey
);
if
(
!
pStb
)
continue
;
}
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
63bc50a7
...
...
@@ -17,8 +17,8 @@
#include "osMemory.h"
#include "tencode.h"
void
_metaReaderInit
(
SMetaReader
*
pReader
,
void
*
pVnode
,
int32_t
flags
,
SStoreMeta
*
pAPI
)
{
SMeta
*
pMeta
=
((
SVnode
*
)
pVnode
)
->
pMeta
;
void
_metaReaderInit
(
SMetaReader
*
pReader
,
void
*
pVnode
,
int32_t
flags
,
SStoreMeta
*
pAPI
)
{
SMeta
*
pMeta
=
((
SVnode
*
)
pVnode
)
->
pMeta
;
metaReaderDoInit
(
pReader
,
pMeta
,
flags
);
pReader
->
pAPI
=
pAPI
;
}
...
...
@@ -143,7 +143,7 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) {
int
metaGetTableNameByUid
(
void
*
pVnode
,
uint64_t
uid
,
char
*
tbName
)
{
int
code
=
0
;
SMetaReader
mr
=
{
0
};
metaReaderDoInit
(
&
mr
,
((
SVnode
*
)
pVnode
)
->
pMeta
,
0
);
metaReaderDoInit
(
&
mr
,
((
SVnode
*
)
pVnode
)
->
pMeta
,
0
);
code
=
metaReaderGetTableEntryByUid
(
&
mr
,
uid
);
if
(
code
<
0
)
{
metaReaderClear
(
&
mr
);
...
...
@@ -195,7 +195,7 @@ int metaGetTableUidByName(void *pVnode, char *tbName, uint64_t *uid) {
int
metaGetTableTypeByName
(
void
*
pVnode
,
char
*
tbName
,
ETableType
*
tbType
)
{
int
code
=
0
;
SMetaReader
mr
=
{
0
};
metaReaderDoInit
(
&
mr
,
((
SVnode
*
)
pVnode
)
->
pMeta
,
0
);
metaReaderDoInit
(
&
mr
,
((
SVnode
*
)
pVnode
)
->
pMeta
,
0
);
code
=
metaGetTableEntryByName
(
&
mr
,
tbName
);
if
(
code
==
0
)
*
tbType
=
mr
.
me
.
type
;
...
...
@@ -244,7 +244,7 @@ SMTbCursor *metaOpenTbCursor(void *pVnode) {
return
NULL
;
}
SVnode
*
pVnodeObj
=
pVnode
;
SVnode
*
pVnodeObj
=
pVnode
;
// tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
pTbCur
->
pMeta
=
pVnodeObj
->
pMeta
;
pTbCur
->
paused
=
1
;
...
...
@@ -1131,7 +1131,7 @@ int32_t metaFilterTtl(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
pCursor
->
type
=
param
->
type
;
metaRLock
(
pMeta
);
//ret = tdbTbcOpen(pMeta->pTtlIdx, &pCursor->pCur, NULL);
//
ret = tdbTbcOpen(pMeta->pTtlIdx, &pCursor->pCur, NULL);
END:
if
(
pCursor
->
pMeta
)
metaULock
(
pCursor
->
pMeta
);
...
...
@@ -1186,7 +1186,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
ret
=
-
1
;
for
(
int
i
=
0
;
i
<
oStbEntry
.
stbEntry
.
schemaTag
.
nCols
;
i
++
)
{
SSchema
*
schema
=
oStbEntry
.
stbEntry
.
schemaTag
.
pSchema
+
i
;
if
(
schema
->
colId
==
param
->
cid
&&
param
->
type
==
schema
->
type
&&
(
IS_IDX_ON
(
schema
)
||
i
==
0
))
{
if
(
schema
->
colId
==
param
->
cid
&&
param
->
type
==
schema
->
type
&&
(
IS_IDX_ON
(
schema
)))
{
ret
=
0
;
}
}
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
63bc50a7
...
...
@@ -450,12 +450,13 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
goto
_err
;
}
if
(
IS_IDX_ON
(
pNew
)
&&
!
IS_IDX_ON
(
pOld
))
{
if
(
diffIdx
!=
-
1
)
goto
_err
;
//
if (diffIdx != -1) goto _err;
diffIdx
=
i
;
break
;
}
}
if
(
diffIdx
==
-
1
||
diffIdx
==
0
)
{
if
(
diffIdx
==
-
1
)
{
goto
_err
;
}
...
...
@@ -586,7 +587,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
for
(
int
i
=
0
;
i
<
oStbEntry
.
stbEntry
.
schemaTag
.
nCols
;
i
++
)
{
SSchema
*
schema
=
oStbEntry
.
stbEntry
.
schemaTag
.
pSchema
+
i
;
if
(
0
==
strncmp
(
schema
->
name
,
pReq
->
colName
,
sizeof
(
pReq
->
colName
)))
{
if
(
i
!=
0
||
IS_IDX_ON
(
schema
))
{
if
(
IS_IDX_ON
(
schema
))
{
pCol
=
schema
;
}
break
;
...
...
@@ -2094,7 +2095,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
}
else
{
for
(
int
i
=
0
;
i
<
pTagSchema
->
nCols
;
i
++
)
{
pTagColumn
=
&
pTagSchema
->
pSchema
[
i
];
if
(
i
!=
0
&&
!
IS_IDX_ON
(
pTagColumn
))
continue
;
if
(
!
IS_IDX_ON
(
pTagColumn
))
continue
;
STagVal
tagVal
=
{.
cid
=
pTagColumn
->
colId
};
tTagGet
((
const
STag
*
)
pCtbEntry
->
ctbEntry
.
pTags
,
&
tagVal
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
63bc50a7
...
...
@@ -826,18 +826,18 @@ static bool isPrimaryKeyImpl(SNode* pExpr) {
return
true
;
}
}
else
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
pExpr
))
{
SOperatorNode
*
pOper
=
(
SOperatorNode
*
)
pExpr
;
if
(
OP_TYPE_ADD
!=
pOper
->
opType
&&
OP_TYPE_SUB
!=
pOper
->
opType
)
{
return
false
;
}
if
(
!
isPrimaryKeyImpl
(
pOper
->
pLeft
))
{
return
false
;
}
if
(
QUERY_NODE_VALUE
!=
nodeType
(
pOper
->
pRight
))
{
return
false
;
}
return
true
;
SOperatorNode
*
pOper
=
(
SOperatorNode
*
)
pExpr
;
if
(
OP_TYPE_ADD
!=
pOper
->
opType
&&
OP_TYPE_SUB
!=
pOper
->
opType
)
{
return
false
;
}
if
(
!
isPrimaryKeyImpl
(
pOper
->
pLeft
))
{
return
false
;
}
if
(
QUERY_NODE_VALUE
!=
nodeType
(
pOper
->
pRight
))
{
return
false
;
}
return
true
;
}
return
false
;
}
...
...
@@ -864,7 +864,7 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p
pCol
->
tableType
=
pTable
->
pMeta
->
tableType
;
pCol
->
colId
=
pColSchema
->
colId
;
pCol
->
colType
=
(
tagFlag
>=
0
?
COLUMN_TYPE_TAG
:
COLUMN_TYPE_COLUMN
);
pCol
->
hasIndex
=
(
(
0
==
tagFlag
)
||
(
pColSchema
!=
NULL
&&
IS_IDX_ON
(
pColSchema
)
));
pCol
->
hasIndex
=
(
pColSchema
!=
NULL
&&
IS_IDX_ON
(
pColSchema
));
pCol
->
node
.
resType
.
type
=
pColSchema
->
type
;
pCol
->
node
.
resType
.
bytes
=
pColSchema
->
bytes
;
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
pCol
->
node
.
resType
.
type
)
{
...
...
source/os/src/osRand.c
浏览文件 @
63bc50a7
...
...
@@ -27,11 +27,11 @@ void taosSeedRand(uint32_t seed) { return srand(seed); }
uint32_t
taosRand
(
void
)
{
#ifdef WINDOWS
unsigned
int
pSeed
;
rand_s
(
&
pSeed
);
return
pSeed
;
unsigned
int
pSeed
;
rand_s
(
&
pSeed
);
return
pSeed
;
#else
return
rand
();
return
rand
();
#endif
}
...
...
@@ -80,6 +80,15 @@ void taosRandStr(char* str, int32_t size) {
const
char
*
set
=
"abcdefghijklmnopqrstuvwxyz0123456789-_."
;
int32_t
len
=
39
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
str
[
i
]
=
set
[
taosRand
()
%
len
];
}
}
void
taosRandStr2
(
char
*
str
,
int32_t
size
)
{
const
char
*
set
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
int32_t
len
=
36
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
str
[
i
]
=
set
[
taosRand
()
%
len
];
}
...
...
tests/parallel_test/cases.task
浏览文件 @
63bc50a7
...
...
@@ -1204,6 +1204,9 @@
,,y,script,./test.sh -f tsim/tag/drop_tag.sim
,,y,script,./test.sh -f tsim/tag/tbNameIn.sim
,,y,script,./test.sh -f tmp/monitor.sim
,,y,script,./test.sh -f tsim/tagindex/add_index.sim
,,n,script,./test.sh -f tsim/tagindex/sma_and_tag_index.sim
#develop test
,,n,develop-test,python3 ./test.py -f 2-query/table_count_scan.py
...
...
tests/script/tsim/sma/drop_sma.sim
浏览文件 @
63bc50a7
...
...
@@ -52,19 +52,35 @@ sql create sma index sma_index_name1 on stb function(max(c1),max(c2),min(c1)) in
print --> show sma
sql show indexes from stb from d1;
if $rows !=
1
then
if $rows !=
2
then
return -1
endi
if $data[0][0] != sma_index_name1 then
return -1
endi
if $data[0][1] != d1 then
return -1
endi
if $data[0][2] != stb then
return -1
if $data[0][6] == tag_index then
if $data[1][0] != sma_index_name1 then
return -1
endi
if $data[1][1] != d1 then
return -1
endi
if $data[1][2] != stb then
return -1
endi
else
if $data[0][0] != sma_index_name1 then
return -1
endi
if $data[0][1] != d1 then
return -1
endi
if $data[0][2] != stb then
return -1
endi
endi
print --> drop stb
sql drop table stb;
...
...
@@ -78,17 +94,30 @@ sql create sma index sma_index_name1 on stb function(max(c1),max(c2),min(c1)) in
print --> show sma
sql show indexes from stb from d1;
if $rows != 1 then
return -1
endi
if $data[0][0] != sma_index_name1 then
if $rows != 2 then
return -1
endi
if $data[0][1] != d1 then
return -1
endi
if $data[0][2] != stb then
return -1
if $data[0][6] == tag_index then
if $data[1][0] != sma_index_name1 then
return -1
endi
if $data[1][1] != d1 then
return -1
endi
if $data[1][2] != stb then
return -1
endi
else
if $data[0][0] != sma_index_name1 then
return -1
endi
if $data[0][1] != d1 then
return -1
endi
if $data[0][2] != stb then
return -1
endi
endi
print --> drop stb
...
...
tests/script/tsim/tagindex/add_index.sim
浏览文件 @
63bc50a7
...
...
@@ -7,7 +7,7 @@ print ======== step0
$dbPrefix = ta_3_db
$tbPrefix = ta_3_tb
$mtPrefix = ta_3_mt
$tbNum = 50
0
$tbNum = 50
$rowNum = 20
$totalNum = 200
...
...
@@ -48,12 +48,16 @@ while $i < $tbNum
$i = $i + 1
endw
sql_error create index ti1 on $mtPrefix (t1)
sql create index ti2 on $mtPrefix (t2)
sql create index ti5 on $mtPrefix (t5)
print ==== test name conflict
#
sql_error create index ti1 on $mtPrefix(t1)
sql_error create index ti11 on $mtPrefix(t1)
sql_error create index ti3 on $mtPrefix(t2)
sql_error create index ti2 on $mtPrefix(t2)
...
...
@@ -73,6 +77,15 @@ while $i < $tbNum
$i = $i + 1
endw
$i = 0
while $i < $tbNum
sql select * from $mtPrefix where t1= $i ;
if $rows != 1 then
return -1
endi
$i = $i + 1
endw
print ===== test operator great equal
...
...
@@ -250,7 +263,7 @@ endw
print === show index
sql select * from information_schema.ins_indexes
if $rows !=
1
then
if $rows !=
2
then
return -1
endi
...
...
@@ -259,12 +272,41 @@ print === drop index ti2
sql drop index ti2
print === drop not exist index
sql select * from information_schema.ins_indexes
if $rows != 1 then
return -1
endi
sql drop index $data[0][0]
if $rows != 0 then
return -1
endi
sql_error drop index t2
sql_error drop index t3
sql create index ti0 on $mtPrefix (t1)
$i = $interval
while $i < $limit
sql select * from $mtPrefix where t1 <= $i ;
$tmp = $i - $interval
$tmp = $tmp + 1
if $rows != $tmp then
return -1
endi
$i = $i + 1
endw
sql_error create index ti0 on $mtPrefix (t1)
sql_error create index ti2 on $mtPrefix (t1)
sql_error create index t2i on ta_3_tb17 (t2)
...
...
tests/script/tsim/tagindex/sma_and_tag_index.sim
浏览文件 @
63bc50a7
...
...
@@ -69,7 +69,7 @@ sql create sma index smat2i on $mtPrefix function(max(c1)) interval(6m,10s) slid
sql select * from information_schema.ins_indexes
if $rows !=
2
then
if $rows !=
3
then
return -1
endi
...
...
@@ -84,7 +84,7 @@ while $i < 5
endw
sql select * from information_schema.ins_indexes
if $rows !=
6
then
if $rows !=
7
then
return -1
endi
...
...
@@ -114,13 +114,13 @@ sql use $dbPrefix
sql create table if not exists $mtPrefix (ts timestamp, c1 int) tags (t1 int, t2 int, t3 int, t4 int, t5 int)
sql create index tagt2i on $mtPrefix (t2)
sql select * from information_schema.ins_indexes
if $rows !=
1
then
if $rows !=
2
then
return -1
endi
sql alter table $mtPrefix drop tag t2
sql select * from information_schema.ins_indexes
if $rows !=
0
then
if $rows !=
1
then
return -1
endi
...
...
@@ -128,18 +128,22 @@ endi
print ==== rename tag name, and update index colName
sql create index tagt3i on $mtPrefix (t3)
sql select * from information_schema.ins_indexes
if $rows !=
1
then
if $rows !=
2
then
return -1
endi
sql alter table $mtPrefix rename tag t3 txxx
sql select * from information_schema.ins_indexes
if $rows !=
1
then
if $rows !=
2
then
return -1
endi
if $data05 != txxx then
return -1
if $data05 == txxx then
print "manual created index"
elif $data15 == txxx then
print "auto created index at tag0"
else
return -1;
endi
...
...
@@ -153,7 +157,7 @@ sql create table if not exists $mtPrefix (ts timestamp, c1 int) tags (t1 int, t2
sql create index tagt3i on $mtPrefix (t3)
sql select * from information_schema.ins_indexes
if $rows !=
2
then
if $rows !=
4
then
return -1
endi
...
...
tests/system-test/0-others/show_tag_index.py
浏览文件 @
63bc50a7
...
...
@@ -59,14 +59,18 @@ class TDTestCase:
tdSql
.
checkData
(
1
,
2
,
2
)
def
check_indexes
(
self
):
tdSql
.
checkRows
(
1
)
tdSql
.
checkCols
(
7
)
tdSql
.
checkData
(
0
,
0
,
'idx1'
)
tdSql
.
checkData
(
0
,
1
,
'db'
)
tdSql
.
checkData
(
0
,
2
,
'stb'
)
tdSql
.
checkData
(
0
,
3
,
None
)
tdSql
.
checkData
(
0
,
5
,
't1'
)
tdSql
.
checkData
(
0
,
6
,
'tag_index'
)
tdSql
.
checkRows
(
2
)
for
i
in
range
(
2
):
col_name
=
tdSql
.
getData
(
i
,
5
)
if
col_name
==
"t0"
:
continue
tdSql
.
checkCols
(
7
)
tdSql
.
checkData
(
i
,
0
,
'idx1'
)
tdSql
.
checkData
(
i
,
1
,
'db'
)
tdSql
.
checkData
(
i
,
2
,
'stb'
)
tdSql
.
checkData
(
i
,
3
,
None
)
tdSql
.
checkData
(
i
,
5
,
't1'
)
tdSql
.
checkData
(
i
,
6
,
'tag_index'
)
def
run
(
self
):
tdSql
.
execute
(
f
'create database db'
)
...
...
tests/system-test/0-others/tag_index_basic.py
浏览文件 @
63bc50a7
...
...
@@ -118,12 +118,15 @@ class TDTestCase:
def
show_tagidx
(
self
,
stbname
):
sql
=
f
'select index_name,column_name from information_schema.ins_indexes where db_name="db"'
tdSql
.
query
(
sql
)
rows
=
len
(
self
.
tag_dict
.
keys
())
-
1
rows
=
len
(
self
.
tag_dict
.
keys
())
tdSql
.
checkRows
(
rows
)
for
i
in
range
(
rows
):
col_name
=
tdSql
.
getData
(
i
,
1
)
idx_name
=
f
'idx_
{
col_name
}
'
# skip first tag
if
col_name
==
"t1"
:
continue
tdSql
.
checkData
(
i
,
0
,
idx_name
)
tdLog
.
info
(
f
' show
{
rows
}
tag indexs ok.'
)
...
...
@@ -201,7 +204,7 @@ class TDTestCase:
# check idx result is 0
sql
=
f
'select index_name,column_name from information_schema.ins_indexes where db_name="db"'
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
1
)
tdLog
.
info
(
f
' drop
{
cnt
}
tag indexs ok.'
)
# create long name idx
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录