parser.h 1.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_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
typedef struct SQuery {
48 49
  bool directRpc;
  bool haveResultSet;
X
Xiaoyu Wang 已提交
50 51 52
  SNode* pRoot;
  int32_t numOfResCols;
  SSchema* pResSchema;
53
  SCmdMsgInfo* pCmdMsg;
54
  int32_t msgType;
X
Xiaoyu Wang 已提交
55 56
  SArray* pDbList;
  SArray* pTableList;
X
Xiaoyu Wang 已提交
57 58 59 60 61 62
} SQuery;

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

void qDestroyQuery(SQuery* pQueryNode);

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

H
refact  
Hongze Cheng 已提交
65 66 67 68
#ifdef __cplusplus
}
#endif

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