parser.c 1.7 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * 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/>.
H
Haojun Liao 已提交
14 15 16
 */

#include "parserInt.h"
17 18 19 20 21 22 23
#include "ttoken.h"
#include "astGenerator.h"

bool qIsInsertSql(const char* pStr, size_t length) {
  return false;
}

H
Haojun Liao 已提交
24
int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo** pQueryInfo, int64_t id, char* msg, int32_t msgLen) {
25 26
  *pQueryInfo = calloc(1, sizeof(SQueryStmtInfo));
  if (*pQueryInfo == NULL) {
27
    return TSDB_CODE_TSC_OUT_OF_MEMORY; // set correct error code.
28 29
  }

H
Haojun Liao 已提交
30
  SSqlInfo info = doGenerateAST(pStr);
31
  if (!info.valid) {
32 33
    strncpy(msg, info.msg, msgLen);
    return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
34 35 36
  }

  struct SCatalog* pCatalog = getCatalogHandle(NULL);
37
  int32_t code = qParserValidateSqlNode(pCatalog, &info, *pQueryInfo, id, msg, msgLen);
38 39 40 41 42 43 44
  if (code != 0) {
    return code;
  }

  return 0;
}

H
Haojun Liao 已提交
45
int32_t qParseInsertSql(const char* pStr, size_t length, struct SInsertStmtInfo** pInsertInfo, int64_t id, char* msg, int32_t msgLen) {
46 47 48 49 50 51 52
  return 0;
}

int32_t qParserConvertSql(const char* pStr, size_t length, char** pConvertSql) {
  return 0;
}

53
int32_t qParserExtractRequestedMetaInfo(const SArray* pSqlNodeList, SMetaReq* pMetaInfo) {
54 55
  return 0;
}