parserInt.h 2.9 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_INT_H_
#define _TD_PARSER_INT_H_

#ifdef __cplusplus
extern "C" {
#endif

H
Haojun Liao 已提交
23 24
#include "catalog.h"
#include "tname.h"
25
#include "astGenerator.h"
H
Haojun Liao 已提交
26

27
struct SSqlNode;
H
Haojun Liao 已提交
28 29


30 31 32 33 34 35
typedef struct SInternalField {
  TAOS_FIELD      field;
  bool            visible;
  SExprInfo      *pExpr;
} SInternalField;

36 37 38 39 40
typedef struct SMsgBuf {
  int32_t len;
  char   *buf;
} SMsgBuf;

41 42 43 44
void clearTableMetaInfo(STableMetaInfo* pTableMetaInfo);

void clearAllTableMetaInfo(SQueryStmtInfo* pQueryInfo, bool removeMeta, uint64_t id);

H
Haojun Liao 已提交
45
/**
46
 * Validate the sql info, according to the corresponding metadata info from catalog.
H
Haojun Liao 已提交
47 48 49 50 51
 * @param pCtx
 * @param pInfo
 * @param pQueryInfo
 * @param msgBuf
 * @param msgBufLen
52
 * @return
H
Haojun Liao 已提交
53
 */
H
Haojun Liao 已提交
54
int32_t qParserValidateSqlNode(SParseBasicCtx *pCtx, SSqlInfo* pInfo, SQueryStmtInfo* pQueryInfo, char* msgBuf, int32_t msgBufLen);
H
Haojun Liao 已提交
55

56 57 58 59 60 61 62
/**
 * validate the ddl ast, and convert the ast to the corresponding message format
 * @param pSqlInfo
 * @param output
 * @param type
 * @return
 */
63 64
SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, char* msgBuf, int32_t msgBufLen);

H
Haojun Liao 已提交
65 66 67 68 69 70 71 72
/**
 *
 * @param pInfo
 * @param pCtx
 * @param msgBuf
 * @param msgBufLen
 * @return
 */
H
Haojun Liao 已提交
73
SVnodeModifOpStmtInfo* qParserValidateCreateTbSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, char* msgBuf, int32_t msgBufLen);
74

75
/**
76
 * Evaluate the numeric and timestamp arithmetic expression in the WHERE clause.
77 78 79 80 81 82
 * @param pNode
 * @param tsPrecision
 * @param msg
 * @param msgBufLen
 * @return
 */
83
int32_t evaluateSqlNode(SSqlNode* pNode, int32_t tsPrecision, SMsgBuf* pMsgBuf);
84

85
int32_t validateSqlNode(SSqlNode* pSqlNode, SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);
86

87 88 89
SQueryStmtInfo* createQueryInfo();

void destroyQueryInfo(SQueryStmtInfo* pQueryInfo);
90

91 92
int32_t checkForInvalidExpr(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);

H
Haojun Liao 已提交
93
/**
94 95
 * Extract request meta info from the sql statement
 * @param pSqlInfo
H
Haojun Liao 已提交
96
 * @param pMetaInfo
97 98
 * @param msg
 * @param msgBufLen
H
Haojun Liao 已提交
99 100
 * @return
 */
H
Haojun Liao 已提交
101
int32_t qParserExtractRequestedMetaInfo(const SSqlInfo* pSqlInfo, SCatalogReq* pMetaInfo, SParseBasicCtx *pCtx, char* msg, int32_t msgBufLen);
H
Haojun Liao 已提交
102

103 104 105 106
/**
 * Destroy the meta data request structure.
 * @param pMetaInfo
 */
107
void qParserCleanupMetaRequestInfo(SCatalogReq* pMetaInfo);
108

H
refact  
Hongze Cheng 已提交
109 110 111 112 113
#ifdef __cplusplus
}
#endif

#endif /*_TD_PARSER_INT_H_*/