parserUtil.h 2.8 KB
Newer Older
H
Haojun Liao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * 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 TDENGINE_PARSERUTIL_H
#define TDENGINE_PARSERUTIL_H

#ifdef __cplusplus
extern "C" {
#endif

23 24
#include "os.h"
#include "ttoken.h"
25
#include "parserInt.h"
26

27 28 29 30 31 32 33 34 35 36 37 38
#define UTIL_TABLE_IS_SUPER_TABLE(metaInfo) \
  (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_SUPER_TABLE))

#define UTIL_TABLE_IS_CHILD_TABLE(metaInfo) \
  (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_CHILD_TABLE))

#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo) \
  (!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo)))

#define UTIL_TABLE_IS_TMP_TABLE(metaInfo) \
  (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_TEMP_TABLE))

39
TAOS_FIELD createField(const SSchema* pSchema);
40
void setColumn(SColumn* pColumn, uint64_t uid, const char* tableName, int8_t flag, const SSchema* pSchema);
41 42
SColumn createColumn(uint64_t uid, const char* tableName, int8_t flag, const SSchema* pSchema);

43 44 45
SInternalField* insertFieldInfo(SFieldInfo* pFieldInfo, int32_t index, SSchema* field);
int32_t getNumOfFields(SFieldInfo* pFieldInfo);
SInternalField* getInternalField(SFieldInfo* pFieldInfo, int32_t index);
46

47
int32_t parserValidateIdToken(SToken* pToken);
48
int32_t parserValidatePassword(SToken* pToken, SMsgBuf* pMsgBuf);
H
Haojun Liao 已提交
49
int32_t parserValidateNameToken(SToken* pToken);
50

51
int32_t buildInvalidOperationMsg(SMsgBuf* pMsgBuf, const char* msg);
52
int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo,  const char* sourceStr);
H
Haojun Liao 已提交
53

54
STableMetaInfo* addEmptyMetaInfo(SQueryStmtInfo* pQueryInfo);
55 56

void columnListCopyAll(SArray* dst, const SArray* src);
57

58
SColumn* columnListInsert(SArray* pColumnList, uint64_t uid, SSchema* pSchema, int32_t flag);
59
SColumn* insertPrimaryTsColumn(SArray* pColumnList, const char* colName, uint64_t tableUid);
60

61 62 63
void cleanupTagCond(STagCond* pTagCond);
void cleanupColumnCond(SArray** pCond);

64
uint32_t convertRelationalOperator(SToken *pToken);
65
int32_t    getExprFunctionId(SExprInfo *pExprInfo);
66

67 68
STableMeta* tableMetaDup(const STableMeta* pTableMeta);

69
bool isDclSqlStatement(SSqlInfo* pSqlInfo);
H
Haojun Liao 已提交
70
bool isDdlSqlStatement(SSqlInfo* pSqlInfo);
71
bool isDqlSqlStatement(SSqlInfo* pSqlInfo);
72

H
Haojun Liao 已提交
73 74 75 76 77
#ifdef __cplusplus
}
#endif

#endif  // TDENGINE_PARSERUTIL_H