TDengine/include/libs/parser/parser.h

122 lines
5.1 KiB
C
Raw Normal View History

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_H_
#define _TD_PARSER_H_
#ifdef __cplusplus
extern "C" {
#endif
2022-04-16 11:41:18 +00:00
#include "query.h"
2022-05-05 06:49:00 +00:00
#include "querynodes.h"
2022-02-28 09:02:43 +00:00
struct SCatalogReq;
struct SMetaData;
2022-04-14 12:14:52 +00:00
typedef struct SStmtCallback {
TAOS_STMT* pStmt;
2022-04-16 07:59:19 +00:00
int32_t (*getTbNameFn)(TAOS_STMT*, char**);
2022-07-10 10:54:58 +00:00
int32_t (*setInfoFn)(TAOS_STMT*, STableMeta*, void*, char*, bool, SHashObj*, SHashObj*, const char*);
2022-04-16 07:59:19 +00:00
int32_t (*getExecInfoFn)(TAOS_STMT*, SHashObj**, SHashObj**);
2022-04-14 12:14:52 +00:00
} SStmtCallback;
typedef struct SParseCsvCxt {
TdFilePtr fp; // last parsed file
int32_t tableNo; // last parsed table
SName tableName; // last parsed table
const char* pLastSqlPos; // the location of the last parsed sql
} SParseCsvCxt;
2022-02-28 09:02:43 +00:00
typedef struct SParseContext {
uint64_t requestId;
2022-06-10 09:07:24 +00:00
int64_t requestRid;
2022-02-28 09:02:43 +00:00
int32_t acctId;
2022-05-05 06:49:00 +00:00
const char* db;
2022-03-19 07:02:31 +00:00
bool topicQuery;
2022-05-05 06:49:00 +00:00
void* pTransporter;
2022-02-28 09:02:43 +00:00
SEpSet mgmtEpSet;
2022-05-05 06:49:00 +00:00
const char* pSql; // sql string
size_t sqlLen; // length of the sql string
char* pMsg; // extended error message if exists to help identifying the problem in sql statement.
int32_t msgLen; // max length of the msg
struct SCatalog* pCatalog;
SStmtCallback* pStmtCb;
const char* pUser;
bool isSuperUser;
2022-08-24 09:36:10 +00:00
bool enableSysInfo;
bool async;
2022-05-30 10:00:03 +00:00
int8_t schemalessType;
2022-06-24 07:18:40 +00:00
const char* svrVer;
bool nodeOffline;
2022-08-10 09:47:28 +00:00
SArray* pTableMetaPos; // sql table pos => catalog data pos
SArray* pTableVgroupPos; // sql table pos => catalog data pos
int64_t allocatorId;
2022-02-28 09:02:43 +00:00
} SParseContext;
2022-05-12 12:33:52 +00:00
int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery);
2022-07-05 13:12:10 +00:00
bool qIsInsertValuesSql(const char* pStr, size_t length);
2022-02-28 09:02:43 +00:00
// for async mode
int32_t qParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, struct SCatalogReq* pCatalogReq);
int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCatalogReq,
const struct SMetaData* pMetaData, SQuery* pQuery);
2022-11-04 07:21:38 +00:00
int32_t qContinueParseSql(SParseContext* pCxt, struct SCatalogReq* pCatalogReq, const struct SMetaData* pMetaData,
SQuery* pQuery);
void qDestroyParseContext(SParseContext* pCxt);
2022-02-28 09:02:43 +00:00
void qDestroyQuery(SQuery* pQueryNode);
2022-03-25 04:46:26 +00:00
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
2022-06-11 02:53:52 +00:00
int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid);
2022-06-14 07:43:56 +00:00
void qCleanupKeywordsTable();
2022-03-25 04:46:26 +00:00
2022-05-12 12:33:52 +00:00
int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash);
int32_t qResetStmtDataBlock(void* block, bool keepBuf);
int32_t qCloneStmtDataBlock(void** pDst, void* pSrc);
void qFreeStmtDataBlock(void* pDataBlock);
int32_t qRebuildStmtDataBlock(void** pDst, void* pSrc, uint64_t uid, int32_t vgId);
void qDestroyStmtDataBlock(void* pBlock);
STableMeta* qGetTableMetaInDataBlock(void* pDataBlock);
2022-05-06 03:28:34 +00:00
int32_t qStmtBindParams(SQuery* pQuery, TAOS_MULTI_BIND* pParams, int32_t colIdx);
2022-05-12 12:33:52 +00:00
int32_t qStmtParseQuerySql(SParseContext* pCxt, SQuery* pQuery);
2022-05-05 06:49:00 +00:00
int32_t qBindStmtColsValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen);
int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen, int32_t colIdx,
int32_t rowNum);
2022-05-31 13:03:47 +00:00
int32_t qBuildStmtColFields(void* pDataBlock, int32_t* fieldNum, TAOS_FIELD_E** fields);
int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD_E** fields);
2022-08-10 09:47:28 +00:00
int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName,
TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen);
2022-04-29 09:39:33 +00:00
void destroyBoundColumnInfo(void* pBoundInfo);
2022-05-05 06:49:00 +00:00
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
int32_t msgBufLen);
2022-04-18 02:19:15 +00:00
2022-05-10 12:59:10 +00:00
void* smlInitHandle(SQuery* pQuery);
void smlDestroyHandle(void* pHandle);
int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta,
2022-07-10 10:54:58 +00:00
char* tableName, const char* sTableName, int32_t sTableNameLen, char* msgBuf, int16_t msgBufLen);
2022-04-27 13:29:25 +00:00
int32_t smlBuildOutput(void* handle, SHashObj* pVgHash);
2022-04-18 02:19:15 +00:00
2022-07-08 10:37:47 +00:00
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap);
SArray* serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap);
2021-09-23 07:50:12 +00:00
#ifdef __cplusplus
}
#endif
2021-12-28 09:01:09 +00:00
#endif /*_TD_PARSER_H_*/