parser.h 2.4 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 24
#include "querynodes.h"

D
stmt  
dapan1121 已提交
25 26
typedef struct SStmtCallback {
  TAOS_STMT* pStmt;
D
stmt  
dapan1121 已提交
27 28 29 30
  int32_t (*getTbNameFn)(TAOS_STMT*, char**);
  int32_t (*setBindInfoFn)(TAOS_STMT*, STableMeta*, void*);
  int32_t (*setExecInfoFn)(TAOS_STMT*, SHashObj*, SHashObj*);
  int32_t (*getExecInfoFn)(TAOS_STMT*, SHashObj**, SHashObj**);
D
stmt  
dapan1121 已提交
31 32
} SStmtCallback;

X
Xiaoyu Wang 已提交
33 34 35 36
typedef struct SParseContext {
  uint64_t         requestId;
  int32_t          acctId;
  const char      *db;
X
Xiaoyu Wang 已提交
37
  bool             topicQuery;
X
Xiaoyu Wang 已提交
38 39 40 41 42 43 44
  void            *pTransporter;
  SEpSet           mgmtEpSet;
  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;
D
stmt  
dapan1121 已提交
45
  SStmtCallback   *pStmtCb;
X
Xiaoyu Wang 已提交
46 47
} SParseContext;

48 49 50
typedef struct SCmdMsgInfo {
  int16_t msgType;
  SEpSet epSet;
51
  void* pMsg;
52
  int32_t msgLen;
53
  void* pExtension;  // todo remove it soon
54 55
} SCmdMsgInfo;

X
Xiaoyu Wang 已提交
56 57 58 59 60 61 62
typedef enum EQueryExecMode {
  QUERY_EXEC_MODE_LOCAL = 1,
  QUERY_EXEC_MODE_RPC,
  QUERY_EXEC_MODE_SCHEDULE,
  QUERY_EXEC_MODE_EMPTY_RESULT
} EQueryExecMode;

X
Xiaoyu Wang 已提交
63
typedef struct SQuery {
X
Xiaoyu Wang 已提交
64
  EQueryExecMode execMode;
65
  bool haveResultSet;
X
Xiaoyu Wang 已提交
66 67 68
  SNode* pRoot;
  int32_t numOfResCols;
  SSchema* pResSchema;
69
  SCmdMsgInfo* pCmdMsg;
70
  int32_t msgType;
X
Xiaoyu Wang 已提交
71 72
  SArray* pDbList;
  SArray* pTableList;
D
dapan1121 已提交
73
  bool showRewrite;
X
Xiaoyu Wang 已提交
74 75 76 77 78 79
} SQuery;

int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery);

void qDestroyQuery(SQuery* pQueryNode);

H
Haojun Liao 已提交
80 81
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);

H
refact  
Hongze Cheng 已提交
82 83 84 85
#ifdef __cplusplus
}
#endif

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