Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4a54b80c
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4a54b80c
编写于
7月 06, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update table schema and tag value
上级
e8933e23
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
21 addition
and
46 deletion
+21
-46
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-1
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+16
-26
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+3
-18
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
4a54b80c
...
...
@@ -4490,7 +4490,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pUpdateMsg
->
tid
=
htonl
(
pTableMeta
->
sid
);
pUpdateMsg
->
uid
=
htobe64
(
pTableMeta
->
uid
);
pUpdateMsg
->
colId
=
htons
(
pTagsSchema
->
colId
);
pUpdateMsg
->
type
=
htons
(
pTagsSchema
->
type
)
;
pUpdateMsg
->
type
=
pTagsSchema
->
type
;
pUpdateMsg
->
bytes
=
htons
(
pTagsSchema
->
bytes
);
pUpdateMsg
->
tversion
=
htons
(
pTableMeta
->
tversion
);
pUpdateMsg
->
numOfTags
=
htons
(
numOfTags
);
...
...
src/inc/taosmsg.h
浏览文件 @
4a54b80c
...
...
@@ -284,7 +284,7 @@ typedef struct {
int32_t
tid
;
int16_t
tversion
;
int16_t
colId
;
int
16_t
type
;
int
8_t
type
;
int16_t
bytes
;
int32_t
tagValLen
;
int16_t
numOfTags
;
...
...
src/tsdb/inc/tsdbMain.h
浏览文件 @
4a54b80c
...
...
@@ -294,38 +294,12 @@ typedef struct {
#define TABLE_SUID(t) (t)->suid
#define TABLE_LASTKEY(t) (t)->lastKey
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchema
(
STable
*
pTable
)
{
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
// check child table first
STable
*
pSuper
=
pTable
->
pSuper
;
if
(
pSuper
==
NULL
)
return
NULL
;
return
pSuper
->
schema
[
pSuper
->
numOfSchemas
-
1
];
}
else
if
(
pTable
->
type
==
TSDB_NORMAL_TABLE
||
pTable
->
type
==
TSDB_SUPER_TABLE
||
pTable
->
type
==
TSDB_STREAM_TABLE
)
{
return
pTable
->
schema
[
pTable
->
numOfSchemas
-
1
];
}
else
{
return
NULL
;
}
}
static
FORCE_INLINE
STSchema
*
tsdbGetTableTagSchema
(
STable
*
pTable
)
{
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
// check child table first
STable
*
pSuper
=
pTable
->
pSuper
;
if
(
pSuper
==
NULL
)
return
NULL
;
return
pSuper
->
tagSchema
;
}
else
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
return
pTable
->
tagSchema
;
}
else
{
return
NULL
;
}
}
STsdbMeta
*
tsdbNewMeta
(
STsdbCfg
*
pCfg
);
void
tsdbFreeMeta
(
STsdbMeta
*
pMeta
);
int
tsdbOpenMeta
(
STsdbRepo
*
pRepo
);
int
tsdbCloseMeta
(
STsdbRepo
*
pRepo
);
STable
*
tsdbGetTableByUid
(
STsdbMeta
*
pMeta
,
uint64_t
uid
);
STSchema
*
tsdbGetTableSchemaByVersion
(
STable
*
pTable
,
int16_t
version
);
STSchema
*
tsdbGetTableTagSchema
(
STable
*
pTable
);
// int tsdbUpdateTable(STsdbRepo* pRepo, STable* pTable, STableCfg* pCfg);
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbRLockRepoMeta
(
STsdbRepo
*
pRepo
);
int
tsdbUnlockRepoMeta
(
STsdbRepo
*
pRepo
);
...
...
@@ -374,6 +348,22 @@ _exit:
return
pSchema
;
}
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchema
(
STable
*
pTable
)
{
return
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
}
static
FORCE_INLINE
STSchema
*
tsdbGetTableTagSchema
(
STable
*
pTable
)
{
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
// check child table first
STable
*
pSuper
=
pTable
->
pSuper
;
if
(
pSuper
==
NULL
)
return
NULL
;
return
pSuper
->
tagSchema
;
}
else
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
return
pTable
->
tagSchema
;
}
else
{
return
NULL
;
}
}
// ------------------ tsdbBuffer.c
STsdbBufPool
*
tsdbNewBufPool
();
void
tsdbFreeBufPool
(
STsdbBufPool
*
pBufPool
);
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
4a54b80c
...
...
@@ -282,7 +282,6 @@ int tsdbUpdateTableTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg) {
pMsg
->
tid
=
htonl
(
pMsg
->
tid
);
pMsg
->
tversion
=
htons
(
pMsg
->
tversion
);
pMsg
->
colId
=
htons
(
pMsg
->
colId
);
pMsg
->
type
=
htons
(
pMsg
->
type
);
pMsg
->
bytes
=
htons
(
pMsg
->
bytes
);
pMsg
->
tagValLen
=
htonl
(
pMsg
->
tagValLen
);
pMsg
->
numOfTags
=
htons
(
pMsg
->
numOfTags
);
...
...
@@ -358,15 +357,15 @@ int tsdbUpdateTableTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg) {
}
bool
isChangeIndexCol
=
(
pMsg
->
colId
==
colColId
(
schemaColAt
(
pTable
->
pSuper
->
tagSchema
,
0
)));
STColumn
*
pCol
=
bsearch
(
&
(
pMsg
->
colId
),
pMsg
->
data
,
pMsg
->
numOfTags
,
sizeof
(
STColumn
),
colIdCompar
);
ASSERT
(
pCol
!=
NULL
);
//
STColumn *pCol = bsearch(&(pMsg->colId), pMsg->data, pMsg->numOfTags, sizeof(STColumn), colIdCompar);
//
ASSERT(pCol != NULL);
if
(
isChangeIndexCol
)
{
tsdbWLockRepoMeta
(
pRepo
);
tsdbRemoveTableFromIndex
(
pMeta
,
pTable
);
}
taosWLockLatch
(
&
(
pTable
->
latch
));
tdSetKVRowDataOfCol
(
&
(
pTable
->
tagVal
),
pMsg
->
colId
,
p
Col
->
type
,
POINTER_SHIFT
(
pMsg
->
data
,
pMsg
->
schemaLen
));
tdSetKVRowDataOfCol
(
&
(
pTable
->
tagVal
),
pMsg
->
colId
,
p
Msg
->
type
,
POINTER_SHIFT
(
pMsg
->
data
,
pMsg
->
schemaLen
));
taosWUnLockLatch
(
&
(
pTable
->
latch
));
if
(
isChangeIndexCol
)
{
tsdbAddTableIntoIndex
(
pMeta
,
pTable
,
false
);
...
...
@@ -486,8 +485,6 @@ int tsdbCloseMeta(STsdbRepo *pRepo) {
return
0
;
}
STSchema
*
tsdbGetTableSchema
(
STable
*
pTable
)
{
return
tsdbGetTableSchemaImpl
(
pTable
,
true
,
false
,
-
1
);
}
STable
*
tsdbGetTableByUid
(
STsdbMeta
*
pMeta
,
uint64_t
uid
)
{
void
*
ptr
=
taosHashGet
(
pMeta
->
uidMap
,
(
char
*
)(
&
uid
),
sizeof
(
uid
));
...
...
@@ -500,18 +497,6 @@ STSchema *tsdbGetTableSchemaByVersion(STable *pTable, int16_t version) {
return
tsdbGetTableSchemaImpl
(
pTable
,
true
,
false
,
version
);
}
STSchema
*
tsdbGetTableTagSchema
(
STable
*
pTable
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
return
pTable
->
tagSchema
;
}
else
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
STable
*
pSuper
=
pTable
->
pSuper
;
if
(
pSuper
==
NULL
)
return
NULL
;
return
pSuper
->
tagSchema
;
}
else
{
return
NULL
;
}
}
int
tsdbWLockRepoMeta
(
STsdbRepo
*
pRepo
)
{
int
code
=
pthread_rwlock_wrlock
(
&
(
pRepo
->
tsdbMeta
->
rwLock
));
if
(
code
!=
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录