parser.h 2.1 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 25 26 27 28
#include "querynodes.h"

typedef struct SParseContext {
  uint64_t         requestId;
  int32_t          acctId;
  const char      *db;
X
Xiaoyu Wang 已提交
29
  bool             topicQuery;
X
Xiaoyu Wang 已提交
30 31 32 33 34 35 36 37 38
  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;
} SParseContext;

39 40 41
typedef struct SCmdMsgInfo {
  int16_t msgType;
  SEpSet epSet;
42
  void* pMsg;
43
  int32_t msgLen;
44
  void* pExtension;  // todo remove it soon
45 46
} SCmdMsgInfo;

X
Xiaoyu Wang 已提交
47 48 49 50 51 52 53
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 已提交
54
typedef struct SQuery {
X
Xiaoyu Wang 已提交
55
  EQueryExecMode execMode;
56
  bool haveResultSet;
X
Xiaoyu Wang 已提交
57 58 59
  SNode* pRoot;
  int32_t numOfResCols;
  SSchema* pResSchema;
60
  SCmdMsgInfo* pCmdMsg;
61
  int32_t msgType;
X
Xiaoyu Wang 已提交
62 63
  SArray* pDbList;
  SArray* pTableList;
D
dapan1121 已提交
64
  bool showRewrite;
X
Xiaoyu Wang 已提交
65 66 67 68 69 70
} SQuery;

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

void qDestroyQuery(SQuery* pQueryNode);

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

H
refact  
Hongze Cheng 已提交
73 74 75 76
#ifdef __cplusplus
}
#endif

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