Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
1a87c8f4
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1a87c8f4
编写于
8月 09, 2021
作者:
H
Hongze Cheng
提交者:
GitHub
8月 09, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7188 from taosdata/hotfix/TD-5812
hotfix/TD-5812
上级
e136773c
b6280cee
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
126 addition
and
31 deletion
+126
-31
src/tsdb/inc/tsdbMeta.h
src/tsdb/inc/tsdbMeta.h
+3
-5
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+54
-25
tests/pytest/alter/alterColMultiTimes.py
tests/pytest/alter/alterColMultiTimes.py
+67
-0
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+1
-0
tests/pytest/insert/schemalessInsert.py
tests/pytest/insert/schemalessInsert.py
+1
-1
未找到文件。
src/tsdb/inc/tsdbMeta.h
浏览文件 @
1a87c8f4
...
...
@@ -24,8 +24,7 @@ typedef struct STable {
tstr
*
name
;
// NOTE: there a flexible string here
uint64_t
suid
;
struct
STable
*
pSuper
;
// super table pointer
uint8_t
numOfSchemas
;
STSchema
*
schema
[
TSDB_MAX_TABLE_SCHEMAS
];
SArray
*
schema
;
STSchema
*
tagSchema
;
SKVRow
tagVal
;
SSkipList
*
pIndex
;
// For TSDB_SUPER_TABLE, it is the skiplist index
...
...
@@ -107,10 +106,9 @@ static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock,
if
(
lock
)
TSDB_RLOCK_TABLE
(
pDTable
);
if
(
_version
<
0
)
{
// get the latest version of schema
pTSchema
=
pDTable
->
schema
[
pDTable
->
numOfSchemas
-
1
]
;
pTSchema
=
*
(
STSchema
**
)
taosArrayGetLast
(
pDTable
->
schema
)
;
}
else
{
// get the schema with version
void
*
ptr
=
taosbsearch
(
&
_version
,
pDTable
->
schema
,
pDTable
->
numOfSchemas
,
sizeof
(
STSchema
*
),
tsdbCompareSchemaVersion
,
TD_EQ
);
void
*
ptr
=
taosArraySearch
(
pDTable
->
schema
,
&
_version
,
tsdbCompareSchemaVersion
,
TD_EQ
);
if
(
ptr
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
goto
_exit
;
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
1a87c8f4
...
...
@@ -44,6 +44,8 @@ static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable);
static
int
tsdbRmTableFromMeta
(
STsdbRepo
*
pRepo
,
STable
*
pTable
);
static
int
tsdbAdjustMetaTables
(
STsdbRepo
*
pRepo
,
int
tid
);
static
int
tsdbCheckTableTagVal
(
SKVRow
*
pKVRow
,
STSchema
*
pSchema
);
static
int
tsdbAddSchema
(
STable
*
pTable
,
STSchema
*
pSchema
);
static
void
tsdbFreeTableSchema
(
STable
*
pTable
);
// ------------------ OUTER FUNCTIONS ------------------
int
tsdbCreateTable
(
STsdbRepo
*
repo
,
STableCfg
*
pCfg
)
{
...
...
@@ -723,17 +725,10 @@ void tsdbUpdateTableSchema(STsdbRepo *pRepo, STable *pTable, STSchema *pSchema,
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STable
*
pCTable
=
(
TABLE_TYPE
(
pTable
)
==
TSDB_CHILD_TABLE
)
?
pTable
->
pSuper
:
pTable
;
ASSERT
(
schemaVersion
(
pSchema
)
>
schemaVersion
(
pCTable
->
schema
[
pCTable
->
numOfSchemas
-
1
]
));
ASSERT
(
schemaVersion
(
pSchema
)
>
schemaVersion
(
*
(
STSchema
**
)
taosArrayGetLast
(
pCTable
->
schema
)
));
TSDB_WLOCK_TABLE
(
pCTable
);
if
(
pCTable
->
numOfSchemas
<
TSDB_MAX_TABLE_SCHEMAS
)
{
pCTable
->
schema
[
pCTable
->
numOfSchemas
++
]
=
pSchema
;
}
else
{
ASSERT
(
pCTable
->
numOfSchemas
==
TSDB_MAX_TABLE_SCHEMAS
);
tdFreeSchema
(
pCTable
->
schema
[
0
]);
memmove
(
pCTable
->
schema
,
pCTable
->
schema
+
1
,
sizeof
(
STSchema
*
)
*
(
TSDB_MAX_TABLE_SCHEMAS
-
1
));
pCTable
->
schema
[
pCTable
->
numOfSchemas
-
1
]
=
pSchema
;
}
tsdbAddSchema
(
pCTable
,
pSchema
);
if
(
schemaNCols
(
pSchema
)
>
pMeta
->
maxCols
)
pMeta
->
maxCols
=
schemaNCols
(
pSchema
);
if
(
schemaTLen
(
pSchema
)
>
pMeta
->
maxRowBytes
)
pMeta
->
maxRowBytes
=
schemaTLen
(
pSchema
);
...
...
@@ -829,9 +824,7 @@ static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper, STable *pST
TABLE_TID
(
pTable
)
=
-
1
;
TABLE_SUID
(
pTable
)
=
-
1
;
pTable
->
pSuper
=
NULL
;
pTable
->
numOfSchemas
=
1
;
pTable
->
schema
[
0
]
=
tdDupSchema
(
pCfg
->
schema
);
if
(
pTable
->
schema
[
0
]
==
NULL
)
{
if
(
tsdbAddSchema
(
pTable
,
tdDupSchema
(
pCfg
->
schema
))
<
0
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
}
...
...
@@ -842,7 +835,8 @@ static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper, STable *pST
}
pTable
->
tagVal
=
NULL
;
STColumn
*
pCol
=
schemaColAt
(
pTable
->
tagSchema
,
DEFAULT_TAG_INDEX_COLUMN
);
pTable
->
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
colType
(
pCol
),
(
uint8_t
)(
colBytes
(
pCol
)),
NULL
,
SL_ALLOW_DUP_KEY
,
getTagIndexKey
);
pTable
->
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
colType
(
pCol
),
(
uint8_t
)(
colBytes
(
pCol
)),
NULL
,
SL_ALLOW_DUP_KEY
,
getTagIndexKey
);
if
(
pTable
->
pIndex
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
...
...
@@ -871,9 +865,7 @@ static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper, STable *pST
}
}
else
{
TABLE_SUID
(
pTable
)
=
-
1
;
pTable
->
numOfSchemas
=
1
;
pTable
->
schema
[
0
]
=
tdDupSchema
(
pCfg
->
schema
);
if
(
pTable
->
schema
[
0
]
==
NULL
)
{
if
(
tsdbAddSchema
(
pTable
,
tdDupSchema
(
pCfg
->
schema
))
<
0
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
}
...
...
@@ -907,9 +899,7 @@ static void tsdbFreeTable(STable *pTable) {
TABLE_UID
(
pTable
));
tfree
(
TABLE_NAME
(
pTable
));
if
(
TABLE_TYPE
(
pTable
)
!=
TSDB_CHILD_TABLE
)
{
for
(
int
i
=
0
;
i
<
TSDB_MAX_TABLE_SCHEMAS
;
i
++
)
{
tdFreeSchema
(
pTable
->
schema
[
i
]);
}
tsdbFreeTableSchema
(
pTable
);
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_SUPER_TABLE
)
{
tdFreeSchema
(
pTable
->
tagSchema
);
...
...
@@ -1261,9 +1251,10 @@ static int tsdbEncodeTable(void **buf, STable *pTable) {
tlen
+=
taosEncodeFixedU64
(
buf
,
TABLE_SUID
(
pTable
));
tlen
+=
tdEncodeKVRow
(
buf
,
pTable
->
tagVal
);
}
else
{
tlen
+=
taosEncodeFixedU8
(
buf
,
pTable
->
numOfSchemas
);
for
(
int
i
=
0
;
i
<
pTable
->
numOfSchemas
;
i
++
)
{
tlen
+=
tdEncodeSchema
(
buf
,
pTable
->
schema
[
i
]);
tlen
+=
taosEncodeFixedU8
(
buf
,
(
uint8_t
)
taosArrayGetSize
(
pTable
->
schema
));
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTable
->
schema
);
i
++
)
{
STSchema
*
pSchema
=
taosArrayGetP
(
pTable
->
schema
,
i
);
tlen
+=
tdEncodeSchema
(
buf
,
pSchema
);
}
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_SUPER_TABLE
)
{
...
...
@@ -1294,9 +1285,12 @@ static void *tsdbDecodeTable(void *buf, STable **pRTable) {
buf
=
taosDecodeFixedU64
(
buf
,
&
TABLE_SUID
(
pTable
));
buf
=
tdDecodeKVRow
(
buf
,
&
(
pTable
->
tagVal
));
}
else
{
buf
=
taosDecodeFixedU8
(
buf
,
&
(
pTable
->
numOfSchemas
));
for
(
int
i
=
0
;
i
<
pTable
->
numOfSchemas
;
i
++
)
{
buf
=
tdDecodeSchema
(
buf
,
&
(
pTable
->
schema
[
i
]));
uint8_t
nSchemas
;
buf
=
taosDecodeFixedU8
(
buf
,
&
nSchemas
);
for
(
int
i
=
0
;
i
<
nSchemas
;
i
++
)
{
STSchema
*
pSchema
;
buf
=
tdDecodeSchema
(
buf
,
&
pSchema
);
tsdbAddSchema
(
pTable
,
pSchema
);
}
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_SUPER_TABLE
)
{
...
...
@@ -1458,3 +1452,38 @@ static int tsdbCheckTableTagVal(SKVRow *pKVRow, STSchema *pSchema) {
return
0
;
}
static
int
tsdbAddSchema
(
STable
*
pTable
,
STSchema
*
pSchema
)
{
ASSERT
(
TABLE_TYPE
(
pTable
)
!=
TSDB_CHILD_TABLE
);
if
(
pTable
->
schema
==
NULL
)
{
pTable
->
schema
=
taosArrayInit
(
TSDB_MAX_TABLE_SCHEMAS
,
sizeof
(
SSchema
*
));
if
(
pTable
->
schema
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
}
ASSERT
(
taosArrayGetSize
(
pTable
->
schema
)
==
0
||
schemaVersion
(
pSchema
)
>
schemaVersion
(
*
(
STSchema
**
)
taosArrayGetLast
(
pTable
->
schema
)));
if
(
taosArrayPush
(
pTable
->
schema
,
&
pSchema
)
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
return
0
;
}
static
void
tsdbFreeTableSchema
(
STable
*
pTable
)
{
ASSERT
(
pTable
!=
NULL
);
if
(
pTable
->
schema
)
{
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
pTable
->
schema
);
i
++
)
{
STSchema
*
pSchema
=
taosArrayGetP
(
pTable
->
schema
,
i
);
tdFreeSchema
(
pSchema
);
}
taosArrayDestroy
(
pTable
->
schema
);
}
}
\ No newline at end of file
tests/pytest/alter/alterColMultiTimes.py
0 → 100644
浏览文件 @
1a87c8f4
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
random
import
string
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.dnodes
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
genColList
(
self
):
'''
generate column list
'''
col_list
=
list
()
for
i
in
range
(
1
,
18
):
col_list
.
append
(
f
'c
{
i
}
'
)
return
col_list
def
genIncreaseValue
(
self
,
input_value
):
'''
add ', 1' to end of value every loop
'''
value_list
=
list
(
input_value
)
value_list
.
insert
(
-
1
,
", 1"
)
return
''
.
join
(
value_list
)
def
insertAlter
(
self
):
'''
after each alter and insert, when execute 'select * from {tbname};' taosd will coredump
'''
tbname
=
''
.
join
(
random
.
choice
(
string
.
ascii_letters
.
lower
())
for
i
in
range
(
7
))
input_value
=
'(now, 1)'
tdSql
.
execute
(
f
'create table
{
tbname
}
(ts timestamp, c0 int);'
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values
{
input_value
}
;'
)
for
col
in
self
.
genColList
():
input_value
=
self
.
genIncreaseValue
(
input_value
)
tdSql
.
execute
(
f
'alter table
{
tbname
}
add column
{
col
}
int;'
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values
{
input_value
}
;'
)
tdSql
.
query
(
f
'select * from
{
tbname
}
;'
)
tdSql
.
checkRows
(
18
)
def
run
(
self
):
tdSql
.
prepare
()
self
.
insertAlter
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/fulltest.sh
浏览文件 @
1a87c8f4
...
...
@@ -380,6 +380,7 @@ python3 ./test.py -f query/querySession.py
python3 test.py
-f
alter/alter_create_exception.py
python3 ./test.py
-f
insert/flushwhiledrop.py
python3 ./test.py
-f
insert/schemalessInsert.py
python3 ./test.py
-f
alter/alterColMultiTimes.py
#======================p4-end===============
...
...
tests/pytest/insert/schemalessInsert.py
浏览文件 @
1a87c8f4
...
...
@@ -705,7 +705,7 @@ class TDTestCase:
case no id when stb exist
"""
self
.
cleanStb
()
input_sql
,
stb_name
=
self
.
genFullTypeSql
(
t0
=
"f"
,
c0
=
"f"
)
input_sql
,
stb_name
=
self
.
genFullTypeSql
(
t
b_name
=
"sub_table_0123456"
,
t
0
=
"f"
,
c0
=
"f"
)
self
.
resCmp
(
input_sql
,
stb_name
)
input_sql
,
stb_name
=
self
.
genFullTypeSql
(
stb_name
=
stb_name
,
id_noexist_tag
=
True
,
t0
=
"f"
,
c0
=
"f"
)
self
.
resCmp
(
input_sql
,
stb_name
,
condition
=
'where tbname like "t_%"'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录