2021-09-23 07:50:12 +00:00
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
|
|
2021-10-06 15:46:48 +00:00
|
|
|
#include "catalog.h"
|
|
|
|
|
#include "tname.h"
|
2021-10-08 02:23:44 +00:00
|
|
|
#include "astGenerator.h"
|
2021-10-06 15:46:48 +00:00
|
|
|
|
2021-10-08 02:23:44 +00:00
|
|
|
struct SSqlNode;
|
2021-10-06 15:46:48 +00:00
|
|
|
|
|
|
|
|
|
2021-10-21 03:06:52 +00:00
|
|
|
typedef struct SInternalField {
|
|
|
|
|
TAOS_FIELD field;
|
|
|
|
|
bool visible;
|
|
|
|
|
SExprInfo *pExpr;
|
|
|
|
|
} SInternalField;
|
|
|
|
|
|
2021-10-23 04:51:29 +00:00
|
|
|
typedef struct SMsgBuf {
|
|
|
|
|
int32_t len;
|
|
|
|
|
char *buf;
|
|
|
|
|
} SMsgBuf;
|
|
|
|
|
|
2021-10-21 03:06:52 +00:00
|
|
|
void clearTableMetaInfo(STableMetaInfo* pTableMetaInfo);
|
|
|
|
|
|
|
|
|
|
void clearAllTableMetaInfo(SQueryStmtInfo* pQueryInfo, bool removeMeta, uint64_t id);
|
|
|
|
|
|
2021-10-06 15:46:48 +00:00
|
|
|
/**
|
2021-10-08 02:23:44 +00:00
|
|
|
* Validate the sql info, according to the corresponding metadata info from catalog.
|
2022-01-07 09:17:47 +00:00
|
|
|
* @param pCtx
|
|
|
|
|
* @param pInfo
|
|
|
|
|
* @param pQueryInfo
|
|
|
|
|
* @param msgBuf
|
|
|
|
|
* @param msgBufLen
|
2021-10-08 02:23:44 +00:00
|
|
|
* @return
|
2021-10-06 15:46:48 +00:00
|
|
|
*/
|
2022-01-12 02:53:53 +00:00
|
|
|
int32_t qParserValidateSqlNode(SParseContext *pCtx, SSqlInfo* pInfo, SQueryStmtInfo* pQueryInfo, char* msgBuf, int32_t msgBufLen);
|
2021-10-06 15:46:48 +00:00
|
|
|
|
2021-12-15 11:34:36 +00:00
|
|
|
/**
|
|
|
|
|
* validate the ddl ast, and convert the ast to the corresponding message format
|
|
|
|
|
* @param pSqlInfo
|
|
|
|
|
* @param output
|
|
|
|
|
* @param type
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-01-12 02:53:53 +00:00
|
|
|
SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, char* msgBuf, int32_t msgBufLen);
|
2021-12-31 10:57:57 +00:00
|
|
|
|
2022-01-07 09:17:47 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param pInfo
|
|
|
|
|
* @param pCtx
|
|
|
|
|
* @param msgBuf
|
|
|
|
|
* @param msgBufLen
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-01-12 02:53:53 +00:00
|
|
|
SVnodeModifOpStmtInfo* qParserValidateCreateTbSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, char* msgBuf, int32_t msgBufLen);
|
2021-12-15 11:34:36 +00:00
|
|
|
|
2021-10-11 07:49:10 +00:00
|
|
|
/**
|
2021-10-12 07:01:05 +00:00
|
|
|
* Evaluate the numeric and timestamp arithmetic expression in the WHERE clause.
|
2021-10-11 07:49:10 +00:00
|
|
|
* @param pNode
|
|
|
|
|
* @param tsPrecision
|
|
|
|
|
* @param msg
|
|
|
|
|
* @param msgBufLen
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2021-10-23 04:51:29 +00:00
|
|
|
int32_t evaluateSqlNode(SSqlNode* pNode, int32_t tsPrecision, SMsgBuf* pMsgBuf);
|
2021-10-11 07:49:10 +00:00
|
|
|
|
2021-10-26 09:39:37 +00:00
|
|
|
int32_t validateSqlNode(SSqlNode* pSqlNode, SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);
|
2021-10-27 09:23:58 +00:00
|
|
|
|
2021-10-28 08:16:42 +00:00
|
|
|
SQueryStmtInfo* createQueryInfo();
|
|
|
|
|
|
|
|
|
|
void destroyQueryInfo(SQueryStmtInfo* pQueryInfo);
|
2021-10-26 09:39:37 +00:00
|
|
|
|
2021-10-27 09:23:58 +00:00
|
|
|
int32_t checkForInvalidExpr(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);
|
|
|
|
|
|
2021-10-06 15:46:48 +00:00
|
|
|
/**
|
2021-10-12 07:01:05 +00:00
|
|
|
* Extract request meta info from the sql statement
|
|
|
|
|
* @param pSqlInfo
|
2021-10-06 15:46:48 +00:00
|
|
|
* @param pMetaInfo
|
2021-10-12 07:01:05 +00:00
|
|
|
* @param msg
|
|
|
|
|
* @param msgBufLen
|
2021-10-06 15:46:48 +00:00
|
|
|
* @return
|
|
|
|
|
*/
|
2022-01-12 02:53:53 +00:00
|
|
|
int32_t qParserExtractRequestedMetaInfo(const SSqlInfo* pSqlInfo, SCatalogReq* pMetaInfo, SParseContext *pCtx, char* msg, int32_t msgBufLen);
|
2021-10-06 15:46:48 +00:00
|
|
|
|
2021-10-28 08:16:42 +00:00
|
|
|
/**
|
|
|
|
|
* Destroy the meta data request structure.
|
|
|
|
|
* @param pMetaInfo
|
|
|
|
|
*/
|
2021-12-30 07:19:09 +00:00
|
|
|
void qParserCleanupMetaRequestInfo(SCatalogReq* pMetaInfo);
|
2021-10-28 08:16:42 +00:00
|
|
|
|
2021-09-23 07:50:12 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /*_TD_PARSER_INT_H_*/
|