parser.h 3.3 KB
Newer Older
H
refact  
Hongze Cheng 已提交
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 _TD_PARSER_H_
#define _TD_PARSER_H_

#ifdef __cplusplus
extern "C" {
#endif

X
Xiaoyu Wang 已提交
23
#include "parsenodes.h"
24

25
typedef struct SParseContext {
H
Haojun Liao 已提交
26 27 28 29 30
  uint64_t         requestId;
  int32_t          acctId;
  const char      *db;
  void            *pTransporter;
  SEpSet           mgmtEpSet;
H
Haojun Liao 已提交
31 32
  const char      *pSql;           // sql string
  size_t           sqlLen;         // length of the sql string
33
  char            *pMsg;           // extended error message if exists to help identifying the problem in sql statement.
H
Haojun Liao 已提交
34
  int32_t          msgLen;         // max length of the msg
H
Haojun Liao 已提交
35 36

  struct SCatalog *pCatalog;
37 38
} SParseContext;

39 40 41 42 43 44 45 46
/**
 * Parse the sql statement and then return the SQueryStmtInfo as the result of bounded AST.
 * @param pSql     sql string
 * @param length   length of the sql string
 * @param id       operator id, generated by uuid generator
 * @param msg      extended error message if exists.
 * @return         error code
 */
H
Haojun Liao 已提交
47
int32_t qParseQuerySql(SParseContext* pContext, SQueryNode** pQueryNode);
48

H
Haojun Liao 已提交
49 50 51 52 53 54
/**
 * Return true if it is a ddl/dcl sql statement
 * @param pQuery
 * @return
 */
bool qIsDdlQuery(const SQueryNode* pQueryNode);
X
Xiaoyu Wang 已提交
55

H
Haojun Liao 已提交
56 57 58 59
/**
 * Destroy logic query plan
 * @param pQueryNode
 */
60
void qDestroyQuery(SQueryNode* pQueryNode);
61 62 63 64 65 66 67 68 69 70 71

/**
 * Convert a normal sql statement to only query tags information to enable that the subscribe client can be aware quickly of the true vgroup ids that
 * involved in the subscribe procedure.
 * @param pSql
 * @param length
 * @param pConvertSql
 * @return
 */
int32_t qParserConvertSql(const char* pStr, size_t length, char** pConvertSql);

72 73 74 75
void assignExprInfo(SExprInfo* dst, const SExprInfo* src);
void columnListCopy(SArray* dst, const SArray* src, uint64_t uid);
void columnListDestroy(SArray* pColumnList);

76
void dropAllExprInfo(SArray** pExprInfo, int32_t numOfLevel);
77 78

typedef struct SSourceParam {
H
Haojun Liao 已提交
79 80
  SArray    *pExprNodeList; //Array<struct tExprNode*>
  SArray    *pColumnList;   //Array<struct SColumn>
81 82 83
  int32_t    num;
} SSourceParam;

84
SExprInfo* createExprInfo(STableMetaInfo* pTableMetaInfo, const char* funcName, SSourceParam* pSource, SSchema* pResSchema, int16_t interSize);
85
int32_t copyExprInfoList(SArray* dst, const SArray* src, uint64_t uid, bool deepcopy);
86
int32_t copyAllExprInfo(SArray* dst, const SArray* src, bool deepcopy);
X
Xiaoyu Wang 已提交
87
int32_t getExprFunctionLevel(const SQueryStmtInfo* pQueryInfo);
88

X
Xiaoyu Wang 已提交
89
STableMetaInfo* getMetaInfo(const SQueryStmtInfo* pQueryInfo, int32_t tableIndex);
H
Haojun Liao 已提交
90 91
SSchema *getOneColumnSchema(const STableMeta* pTableMeta, int32_t colIndex);

92
int32_t getNewResColId();
93
void addIntoSourceParam(SSourceParam* pSourceParam, tExprNode* pNode, SColumn* pColumn);
H
Haojun Liao 已提交
94
SExprInfo* createBinaryExprInfo(struct tExprNode* pNode, SSchema* pResSchema);
95

H
refact  
Hongze Cheng 已提交
96 97 98 99
#ifdef __cplusplus
}
#endif

L
Liu Jicong 已提交
100
#endif /*_TD_PARSER_H_*/