This commit is contained in:
parent
087d2adf91
commit
1a2b98c526
|
@ -33,7 +33,7 @@ extern "C" {
|
||||||
(((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->tableType == TSDB_TABLE_TYPE_SUPER_TABLE))
|
(((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->tableType == TSDB_TABLE_TYPE_SUPER_TABLE))
|
||||||
#define UTIL_METER_IS_NOMRAL_METER(metaInfo) (!(UTIL_METER_IS_SUPERTABLE(metaInfo)))
|
#define UTIL_METER_IS_NOMRAL_METER(metaInfo) (!(UTIL_METER_IS_SUPERTABLE(metaInfo)))
|
||||||
#define UTIL_METER_IS_CREATE_FROM_METRIC(metaInfo) \
|
#define UTIL_METER_IS_CREATE_FROM_METRIC(metaInfo) \
|
||||||
(((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->tableType == TSDB_TABLE_TYPE_CREATE_FROM_STABLE))
|
(((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->tableType == TSDB_TABLE_TYPE_CHILD_TABLE))
|
||||||
|
|
||||||
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
|
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
|
||||||
|
|
||||||
|
|
|
@ -2992,7 +2992,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
|
||||||
int32_t tagLen = 0;
|
int32_t tagLen = 0;
|
||||||
SSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
SSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
||||||
|
|
||||||
if (pMeta->tableType == TSDB_TABLE_TYPE_CREATE_FROM_STABLE) {
|
if (pMeta->tableType == TSDB_TABLE_TYPE_CHILD_TABLE) {
|
||||||
for (int32_t i = 0; i < pMeta->numOfTags; ++i) {
|
for (int32_t i = 0; i < pMeta->numOfTags; ++i) {
|
||||||
tagLen += pTagsSchema[i].bytes;
|
tagLen += pTagsSchema[i].bytes;
|
||||||
}
|
}
|
||||||
|
@ -3107,7 +3107,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
|
||||||
int32_t tagLen = 0;
|
int32_t tagLen = 0;
|
||||||
SSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
SSchema *pTagsSchema = tsGetTagSchema(pMeta);
|
||||||
|
|
||||||
if (pMeta->tableType == TSDB_TABLE_TYPE_CREATE_FROM_STABLE) {
|
if (pMeta->tableType == TSDB_TABLE_TYPE_CHILD_TABLE) {
|
||||||
for (int32_t j = 0; j < pMeta->numOfTags; ++j) {
|
for (int32_t j = 0; j < pMeta->numOfTags; ++j) {
|
||||||
tagLen += pTagsSchema[j].bytes;
|
tagLen += pTagsSchema[j].bytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "taosmsg.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if table already exists
|
* Check if table already exists
|
||||||
*/
|
*/
|
||||||
|
@ -28,7 +33,7 @@ int32_t dnodeCheckTableExist(int vid, int sid, int64_t uid);
|
||||||
/*
|
/*
|
||||||
* Create table with specified configuration and open it
|
* Create table with specified configuration and open it
|
||||||
*/
|
*/
|
||||||
int32_t dnodeCreateTable(int vid, int sid, SMeterObj *table);
|
int32_t dnodeCreateTable(int vid, int sid, SCreateMsg *table);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modify table configuration information
|
* Modify table configuration information
|
||||||
|
|
|
@ -14,4 +14,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "dnodeWrite.h"
|
||||||
|
|
||||||
|
int32_t dnodeCreateTable(int vid, int sid, SCreateTableMsg *table) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -98,12 +98,12 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t sid;
|
int32_t sid;
|
||||||
int32_t vgId; // vnode group ID
|
int32_t vgId; // vnode group ID
|
||||||
} SMeterGid;
|
} STableGid;
|
||||||
|
|
||||||
typedef struct _tab_obj {
|
typedef struct _tab_obj {
|
||||||
char meterId[TSDB_TABLE_ID_LEN + 1];
|
char meterId[TSDB_TABLE_ID_LEN + 1];
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
SMeterGid gid;
|
STableGid gid;
|
||||||
|
|
||||||
int32_t sversion; // schema version
|
int32_t sversion; // schema version
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _tsdb_global_header_
|
#ifndef TDENGINE_TAOS_DEF_H
|
||||||
#define _tsdb_global_header_
|
#define TDENGINE_TAOS_DEF_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
|
@ -181,9 +181,9 @@ enum _mgmt_table {
|
||||||
|
|
||||||
#define TSDB_KILL_MSG_LEN 30
|
#define TSDB_KILL_MSG_LEN 30
|
||||||
|
|
||||||
enum {
|
typedef enum {
|
||||||
TSDB_TABLE_TYPE_SUPER_TABLE = 0, // super table
|
TSDB_TABLE_TYPE_SUPER_TABLE = 0, // super table
|
||||||
TSDB_TABLE_TYPE_CREATE_FROM_STABLE = 1, // table created from super table
|
TSDB_TABLE_TYPE_CHILD_TABLE = 1, // table created from super table
|
||||||
TSDB_TABLE_TYPE_NORMAL_TABLE = 2, // ordinary table
|
TSDB_TABLE_TYPE_NORMAL_TABLE = 2, // ordinary table
|
||||||
TSDB_TABLE_TYPE_STREAM_TABLE = 3, // table created from stream computing
|
TSDB_TABLE_TYPE_STREAM_TABLE = 3, // table created from stream computing
|
||||||
TSDB_TABLE_TYPE_MAX = 4
|
TSDB_TABLE_TYPE_MAX = 4
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TBASE_MNODE_CHILD_TABLE_H
|
||||||
|
#define TBASE_MNODE_CHILD_TABLE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "taosdef.h"
|
||||||
|
|
||||||
|
struct SSuperTableObj;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char tableId[TSDB_TABLE_ID_LEN + 1];
|
||||||
|
char superTableId[TSDB_TABLE_ID_LEN + 1];
|
||||||
|
int64_t uid;
|
||||||
|
int32_t sid;
|
||||||
|
int32_t vgId;
|
||||||
|
int64_t createdTime;
|
||||||
|
int32_t sversion;
|
||||||
|
char reserved[3];
|
||||||
|
char updateEnd[1];
|
||||||
|
struct SSuperTableObj *superTable;
|
||||||
|
} SChildTableObj;
|
||||||
|
|
||||||
|
int32_t mgmtInitChildTables();
|
||||||
|
void mgmtCleanUpChildTables();
|
||||||
|
int32_t mgmtCreateChildTable(SDbObj *pDb, SCreateTableMsg *pCreate);
|
||||||
|
int32_t mgmtDropChildTable(SDbObj *pDb, char *meterId, int ignore);
|
||||||
|
int32_t mgmtAlterChildTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
||||||
|
SChildTableObj* mgmtGetChildTable(char *tableId);
|
||||||
|
SSchema* mgmtGetChildTableSchema(SChildTableObj *pTable);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TBASE_MNODE_NORMAL_TABLE_H
|
||||||
|
#define TBASE_MNODE_NORMAL_TABLE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char tableId[TSDB_TABLE_ID_LEN + 1];
|
||||||
|
int64_t uid;
|
||||||
|
int32_t sid;
|
||||||
|
int32_t vgId;
|
||||||
|
int32_t sversion; // schema version
|
||||||
|
int32_t createdTime;
|
||||||
|
|
||||||
|
int32_t numOfTags; // for metric
|
||||||
|
int32_t numOfMeters; // for metric
|
||||||
|
int32_t numOfColumns;
|
||||||
|
int32_t schemaSize;
|
||||||
|
short nextColId;
|
||||||
|
char tableType : 4;
|
||||||
|
char status : 3;
|
||||||
|
char isDirty : 1; // if the table change tag column 1 value
|
||||||
|
char reserved[15];
|
||||||
|
char updateEnd[1];
|
||||||
|
|
||||||
|
pthread_rwlock_t rwLock;
|
||||||
|
tSkipList * pSkipList;
|
||||||
|
struct _tab_obj *pHead; // for metric, a link list for all meters created
|
||||||
|
// according to this metric
|
||||||
|
char *pTagData; // TSDB_TABLE_ID_LEN(metric_name)+
|
||||||
|
// tags_value1/tags_value2/tags_value3
|
||||||
|
struct _tab_obj *prev, *next;
|
||||||
|
char * pSql; // pointer to SQL, for SC, null-terminated string
|
||||||
|
char * pReserve1;
|
||||||
|
char * pReserve2;
|
||||||
|
char * schema;
|
||||||
|
// SSchema schema[];
|
||||||
|
} SNormalTableObj;
|
||||||
|
|
||||||
|
|
||||||
|
int32_t mgmtInitSTable();
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TBASE_MNODE_STABLE_H
|
||||||
|
#define TBASE_MNODE_STABLE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char meterId[TSDB_TABLE_ID_LEN + 1];
|
||||||
|
uint64_t uid;
|
||||||
|
STableGid gid;
|
||||||
|
|
||||||
|
int32_t sversion; // schema version
|
||||||
|
int32_t createdTime;
|
||||||
|
|
||||||
|
int32_t numOfTags; // for metric
|
||||||
|
int32_t numOfMeters; // for metric
|
||||||
|
int32_t numOfColumns;
|
||||||
|
int32_t schemaSize;
|
||||||
|
short nextColId;
|
||||||
|
char tableType : 4;
|
||||||
|
char status : 3;
|
||||||
|
char isDirty : 1; // if the table change tag column 1 value
|
||||||
|
char reserved[15];
|
||||||
|
char updateEnd[1];
|
||||||
|
|
||||||
|
pthread_rwlock_t rwLock;
|
||||||
|
tSkipList * pSkipList;
|
||||||
|
struct _tab_obj *pHead; // for metric, a link list for all meters created
|
||||||
|
// according to this metric
|
||||||
|
char *pTagData; // TSDB_TABLE_ID_LEN(metric_name)+
|
||||||
|
// tags_value1/tags_value2/tags_value3
|
||||||
|
struct _tab_obj *prev, *next;
|
||||||
|
char * pSql; // pointer to SQL, for SC, null-terminated string
|
||||||
|
char * pReserve1;
|
||||||
|
char * pReserve2;
|
||||||
|
char * schema;
|
||||||
|
// SSchema schema[];
|
||||||
|
} STabObj;
|
||||||
|
|
||||||
|
|
||||||
|
int32_t mgmtInitSTable();
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TBASE_MNODE_SUPER_TABLE_H
|
||||||
|
#define TBASE_MNODE_SUPER_TABLE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "taosdef.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char superTableId[TSDB_TABLE_ID_LEN + 1];
|
||||||
|
int64_t uid;
|
||||||
|
int32_t sid;
|
||||||
|
int32_t vgId;
|
||||||
|
int32_t sversion;
|
||||||
|
int32_t createdTime;
|
||||||
|
char reserved[7];
|
||||||
|
char updateEnd[1];
|
||||||
|
} SSuperTableObj;
|
||||||
|
|
||||||
|
int32_t mgmtInitSuperTables();
|
||||||
|
void mgmtCleanUpSuperTables();
|
||||||
|
int32_t mgmtCreateSuperTable(SDbObj *pDb, SCreateTableMsg *pCreate);
|
||||||
|
int32_t mgmtDropSuperTable(SDbObj *pDb, char *meterId, int ignore);
|
||||||
|
int32_t mgmtAlterSuperTable(SDbObj *pDb, SAlterTableMsg *pAlter);
|
||||||
|
SSuperTableObj* mgmtGetSuperTable(char *tableId);
|
||||||
|
SSchema* mgmtGetSuperTableSchema(SSuperTableObj *pTable);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -13,23 +13,25 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TBASE_MNODE_STABLE_H
|
#define _DEFAULT_SOURCE
|
||||||
#define TBASE_MNODE_STABLE_H
|
#include "os.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
|
#include "mgmtAcct.h"
|
||||||
|
#include "mgmtGrant.h"
|
||||||
|
#include "mgmtUtil.h"
|
||||||
|
#include "mgmtDb.h"
|
||||||
|
#include "mgmtDnodeInt.h"
|
||||||
|
#include "mgmtVgroup.h"
|
||||||
|
#include "mgmtSupertableQuery.h"
|
||||||
|
#include "mgmtTable.h"
|
||||||
|
#include "taosmsg.h"
|
||||||
|
#include "tast.h"
|
||||||
|
#include "textbuffer.h"
|
||||||
|
#include "tschemautil.h"
|
||||||
|
#include "tscompression.h"
|
||||||
|
#include "tskiplist.h"
|
||||||
|
#include "tsqlfunction.h"
|
||||||
|
#include "ttime.h"
|
||||||
|
#include "tstatus.h"
|
||||||
|
|
||||||
int32_t mgmtInitSTable();
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
|
#include "mnode.h"
|
||||||
|
#include "mgmtAcct.h"
|
||||||
|
#include "mgmtGrant.h"
|
||||||
|
#include "mgmtUtil.h"
|
||||||
|
#include "mgmtDb.h"
|
||||||
|
#include "mgmtDnodeInt.h"
|
||||||
|
#include "mgmtVgroup.h"
|
||||||
|
#include "mgmtSupertableQuery.h"
|
||||||
|
#include "mgmtTable.h"
|
||||||
|
#include "taosmsg.h"
|
||||||
|
#include "tast.h"
|
||||||
|
#include "textbuffer.h"
|
||||||
|
#include "tschemautil.h"
|
||||||
|
#include "tscompression.h"
|
||||||
|
#include "tskiplist.h"
|
||||||
|
#include "tsqlfunction.h"
|
||||||
|
#include "ttime.h"
|
||||||
|
#include "tstatus.h"
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
|
#include "mnode.h"
|
||||||
|
#include "mgmtAcct.h"
|
||||||
|
#include "mgmtGrant.h"
|
||||||
|
#include "mgmtUtil.h"
|
||||||
|
#include "mgmtDb.h"
|
||||||
|
#include "mgmtDnodeInt.h"
|
||||||
|
#include "mgmtVgroup.h"
|
||||||
|
#include "mgmtSupertableQuery.h"
|
||||||
|
#include "mgmtTable.h"
|
||||||
|
#include "taosmsg.h"
|
||||||
|
#include "tast.h"
|
||||||
|
#include "textbuffer.h"
|
||||||
|
#include "tschemautil.h"
|
||||||
|
#include "tscompression.h"
|
||||||
|
#include "tskiplist.h"
|
||||||
|
#include "tsqlfunction.h"
|
||||||
|
#include "ttime.h"
|
||||||
|
#include "tstatus.h"
|
||||||
|
|
|
@ -35,6 +35,12 @@
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "tstatus.h"
|
#include "tstatus.h"
|
||||||
|
|
||||||
|
#include "mgmtSuperTable.h"
|
||||||
|
#include "mgmtChildTable.h"
|
||||||
|
#include "mgmtNormalTable.h"
|
||||||
|
#include "mgmtStreamTable.h"
|
||||||
|
|
||||||
|
|
||||||
extern int64_t sdbVersion;
|
extern int64_t sdbVersion;
|
||||||
|
|
||||||
#define mgmtDestroyMeter(pTable) \
|
#define mgmtDestroyMeter(pTable) \
|
||||||
|
@ -564,15 +570,24 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
|
||||||
if (pTable == NULL) return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
if (pTable == NULL) return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
||||||
memset(pTable, 0, sizeof(STabObj));
|
memset(pTable, 0, sizeof(STabObj));
|
||||||
|
|
||||||
if (pCreate->numOfColumns == 0 && pCreate->numOfTags == 0) { // MTABLE
|
//
|
||||||
pTable->tableType = TSDB_TABLE_TYPE_CREATE_FROM_STABLE;
|
ETableType tableType = TSDB_TABLE_TYPE_MAX;
|
||||||
char *pTagData = (char *)pCreate->schema; // it is a tag key
|
char *tagData = NULL;
|
||||||
pMetric = mgmtGetTable(pTagData);
|
int32_t tagDataSize = 0;
|
||||||
if (pMetric == NULL) {
|
|
||||||
|
if (pCreate->numOfColumns == 0 && pCreate->numOfTags == 0) {
|
||||||
|
tableType = TSDB_TABLE_TYPE_CHILD_TABLE;
|
||||||
|
tagData = (char *)pCreate->schema; // it is a tag key
|
||||||
|
|
||||||
|
SSuperTableObj *pSuperTable = mgmtGetSuperTable(tagData);
|
||||||
|
if (pSuperTable == NULL) {
|
||||||
mError("table:%s, corresponding super table does not exist", pCreate->meterId);
|
mError("table:%s, corresponding super table does not exist", pCreate->meterId);
|
||||||
return TSDB_CODE_INVALID_TABLE;
|
return TSDB_CODE_INVALID_TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tagDataSize = mgmtGetTagsLength(pMetric, INT_MAX) + (uint32_t)TSDB_TABLE_ID_LEN;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* for meters created according to metrics, the schema of this meter isn't needed.
|
* for meters created according to metrics, the schema of this meter isn't needed.
|
||||||
* so, we don't allocate memory for it in order to save a huge amount of
|
* so, we don't allocate memory for it in order to save a huge amount of
|
||||||
|
@ -1667,7 +1682,7 @@ int32_t mgmtFindColumnIndex(STabObj *pTable, const char *colName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (pTable->tableType == TSDB_TABLE_TYPE_CREATE_FROM_STABLE) {
|
} else if (pTable->tableType == TSDB_TABLE_TYPE_CHILD_TABLE) {
|
||||||
pMetric = mgmtGetTable(pTable->pTagData);
|
pMetric = mgmtGetTable(pTable->pTagData);
|
||||||
if (pMetric == NULL) {
|
if (pMetric == NULL) {
|
||||||
mError("MTable not belongs to any metric, meter: %s", pTable->meterId);
|
mError("MTable not belongs to any metric, meter: %s", pTable->meterId);
|
||||||
|
@ -1688,7 +1703,7 @@ int32_t mgmtMeterAddColumn(STabObj *pTable, SSchema schema[], int ncols) {
|
||||||
SAcctObj *pAcct = NULL;
|
SAcctObj *pAcct = NULL;
|
||||||
SDbObj * pDb = NULL;
|
SDbObj * pDb = NULL;
|
||||||
|
|
||||||
if (pTable == NULL || pTable->tableType == TSDB_TABLE_TYPE_CREATE_FROM_STABLE || pTable->tableType == TSDB_TABLE_TYPE_STREAM_TABLE || ncols <= 0)
|
if (pTable == NULL || pTable->tableType == TSDB_TABLE_TYPE_CHILD_TABLE || pTable->tableType == TSDB_TABLE_TYPE_STREAM_TABLE || ncols <= 0)
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
|
|
||||||
// ASSUMPTION: no two tags are the same
|
// ASSUMPTION: no two tags are the same
|
||||||
|
@ -1745,7 +1760,7 @@ int32_t mgmtMeterDropColumnByName(STabObj *pTable, const char *name) {
|
||||||
SAcctObj *pAcct = NULL;
|
SAcctObj *pAcct = NULL;
|
||||||
SDbObj * pDb = NULL;
|
SDbObj * pDb = NULL;
|
||||||
|
|
||||||
if (pTable == NULL || pTable->tableType == TSDB_TABLE_TYPE_CREATE_FROM_STABLE || pTable->tableType == TSDB_TABLE_TYPE_STREAM_TABLE)
|
if (pTable == NULL || pTable->tableType == TSDB_TABLE_TYPE_CHILD_TABLE || pTable->tableType == TSDB_TABLE_TYPE_STREAM_TABLE)
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
|
|
||||||
int32_t index = mgmtFindColumnIndex(pTable, name);
|
int32_t index = mgmtFindColumnIndex(pTable, name);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "tschemautil.h"
|
#include "tschemautil.h"
|
||||||
|
|
||||||
bool mgmtTableCreateFromSuperTable(STabObj* pTableObj) {
|
bool mgmtTableCreateFromSuperTable(STabObj* pTableObj) {
|
||||||
return pTableObj->tableType == TSDB_TABLE_TYPE_CREATE_FROM_STABLE;
|
return pTableObj->tableType == TSDB_TABLE_TYPE_CHILD_TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mgmtIsSuperTable(STabObj* pTableObj) {
|
bool mgmtIsSuperTable(STabObj* pTableObj) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ static void mgmtRetrieveByMeterName(tQueryResultset* pRes, char* str, STabObj* p
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not a table created from metric, ignore */
|
/* not a table created from metric, ignore */
|
||||||
if (pMeterObj->tableType != TSDB_TABLE_TYPE_CREATE_FROM_STABLE) {
|
if (pMeterObj->tableType != TSDB_TABLE_TYPE_CHILD_TABLE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue