tname.h 2.9 KB
Newer Older
H
Haojun Liao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

H
hjxilinx 已提交
16 17 18
#ifndef TDENGINE_NAME_H
#define TDENGINE_NAME_H

19 20
#include "os.h"
#include "taosmsg.h"
H
Haojun Liao 已提交
21
#include "tstoken.h"
22
#include "tvariant.h"
23 24 25 26 27 28 29 30 31 32 33

typedef struct SDataStatis {
  int16_t colId;
  int64_t sum;
  int64_t max;
  int64_t min;
  int16_t maxIndex;
  int16_t minIndex;
  int16_t numOfNull;
} SDataStatis;

H
hjxilinx 已提交
34
typedef struct SColumnInfoData {
35
  SColumnInfo info;
H
Haojun Liao 已提交
36
  char* pData;    // the corresponding block data in memory
H
hjxilinx 已提交
37
} SColumnInfoData;
38

39 40 41 42 43
typedef struct SResPair {
  TSKEY  key;
  double avg;
} SResPair;

44 45 46 47 48 49 50 51 52 53 54 55 56 57
#define TSDB_DB_NAME_T     1
#define TSDB_TABLE_NAME_T  2

#define T_NAME_ACCT     0x1u
#define T_NAME_DB       0x2u
#define T_NAME_TABLE    0x4u

typedef struct SName {
  uint8_t type;  //db_name_t, table_name_t
  char acctId[TSDB_ACCT_ID_LEN];
  char dbname[TSDB_DB_NAME_LEN];
  char tname[TSDB_TABLE_NAME_LEN];
} SName;

58
void extractTableName(const char *tableId, char *name);
H
hjxilinx 已提交
59 60 61

char* extractDBName(const char *tableId, char *name);

62
size_t tableIdPrefix(const char* name, char* prefix, int32_t len);
63

H
Haojun Liao 已提交
64
void extractTableNameFromToken(SStrToken *pToken, SStrToken* pTable);
H
Haojun Liao 已提交
65

66
//SSchema tGetTbnameColumnSchema();
H
Haojun Liao 已提交
67

Y
yihaoDeng 已提交
68 69
SSchema tGetBlockDistColumnSchema();

H
Haojun Liao 已提交
70
SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, SStrToken* exprStr, const char* name);
H
Haojun Liao 已提交
71

H
Haojun Liao 已提交
72
bool tscValidateTableNameLength(size_t len);
73

74
SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters);
H
Haojun Liao 已提交
75

76
SSchema* tGetTbnameColumnSchema();
H
Haojun Liao 已提交
77

H
Haojun Liao 已提交
78 79 80 81 82 83 84 85 86 87 88 89
/**
 * check if the schema is valid or not, including following aspects:
 * 1. number of columns
 * 2. column types
 * 3. column length
 * 4. column names
 * 5. total length
 *
 * @param pSchema
 * @param numOfCols
 * @return
 */
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags);

int32_t tNameExtractFullName(const SName* name, char* dst);
int32_t tNameLen(const SName* name);

SName* tNameDup(const SName* name);

bool tIsValidName(const SName* name);

const char* tNameGetTableName(const SName* name);

int32_t tNameGetDbName(const SName* name, char* dst);
int32_t tNameGetFullDbName(const SName* name, char* dst);

bool tNameIsEmpty(const SName* name);

void tNameAssign(SName* dst, const SName* src);

int32_t tNameFromString(SName* dst, const char* str, uint32_t type);

int32_t tNameSetAcctId(SName* dst, const char* acct);

int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken);
H
Haojun Liao 已提交
113

H
hjxilinx 已提交
114
#endif  // TDENGINE_NAME_H