提交 77094cc5 编写于 作者: H Haojun Liao

[td-10529]fix compiler error.

上级 36ccd827
...@@ -24,7 +24,7 @@ extern "C" { ...@@ -24,7 +24,7 @@ extern "C" {
#ifdef TSDB_SQL_C #ifdef TSDB_SQL_C
#define TSDB_DEFINE_SQL_TYPE( name, msg ) msg, #define TSDB_DEFINE_SQL_TYPE( name, msg ) msg,
char *sqlCmd[] = { char *sqlMsgType[] = {
"null", "null",
#else #else
#define TSDB_DEFINE_SQL_TYPE( name, msg ) name, #define TSDB_DEFINE_SQL_TYPE( name, msg ) name,
...@@ -103,15 +103,13 @@ enum { ...@@ -103,15 +103,13 @@ enum {
}; };
// create table operation type // create table operation type
enum TSQL_TYPE { enum TSQL_CREATE_TABLE_TYPE {
TSQL_CREATE_TABLE = 0x1, TSQL_CREATE_TABLE = 0x1,
TSQL_CREATE_STABLE = 0x2, TSQL_CREATE_STABLE = 0x2,
TSQL_CREATE_TABLE_FROM_STABLE = 0x3, TSQL_CREATE_CTABLE = 0x3,
TSQL_CREATE_STREAM = 0x4, TSQL_CREATE_STREAM = 0x4,
}; };
extern char *sqlCmd[];
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -38,7 +38,7 @@ typedef struct SVariant { ...@@ -38,7 +38,7 @@ typedef struct SVariant {
bool taosVariantIsValid(SVariant *pVar); bool taosVariantIsValid(SVariant *pVar);
//void taosVariantCreate(SVariant *pVar, SToken *token); void taosVariantCreate(SVariant *pVar, char* z, int32_t n, int32_t type);
void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type); void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type);
......
...@@ -183,7 +183,7 @@ bool qIsInsertSql(const char* pStr, size_t length); ...@@ -183,7 +183,7 @@ bool qIsInsertSql(const char* pStr, size_t length);
* @param msg extended error message if exists. * @param msg extended error message if exists.
* @return error code * @return error code
*/ */
int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo** pQueryInfo, int64_t id, char* msg); int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo** pQueryInfo, int64_t id, char* msg, int32_t msgLen);
/** /**
* Parse the insert sql statement. * Parse the insert sql statement.
...@@ -194,7 +194,7 @@ int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo** ...@@ -194,7 +194,7 @@ int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo**
* @param msg extended error message if exists to help avoid the problem in sql statement. * @param msg extended error message if exists to help avoid the problem in sql statement.
* @return * @return
*/ */
int32_t qParseInsertSql(const char* pStr, size_t length, struct SInsertStmtInfo** pInsertInfo, int64_t id, char* msg); int32_t qParseInsertSql(const char* pStr, size_t length, struct SInsertStmtInfo** pInsertInfo, int64_t id, char* msg, int32_t msgLen);
/** /**
* Convert a normal sql statement to only query tags information to enable that the subscribe client can be aware quickly of the true vgroup ids that * Convert a normal sql statement to only query tags information to enable that the subscribe client can be aware quickly of the true vgroup ids that
......
...@@ -15,4 +15,4 @@ ...@@ -15,4 +15,4 @@
#define TSDB_SQL_C #define TSDB_SQL_C
#include "tcmdtype.h" #include "tmsgtype.h"
...@@ -29,18 +29,16 @@ ...@@ -29,18 +29,16 @@
if ((res) > (maxv)) { *exti = 1; break; } \ if ((res) > (maxv)) { *exti = 1; break; } \
assert(0); \ assert(0); \
} while (0) } while (0)
#if 0
void tVariantCreate(SVariant *pVar, SToken *token) {
int32_t ret = 0;
int32_t type = token->type;
void taosVariantCreate(SVariant *pVar, char* z, int32_t n, int32_t type) {
int32_t ret = 0;
memset(pVar, 0, sizeof(SVariant)); memset(pVar, 0, sizeof(SVariant));
switch (token->type) { switch (type) {
case TSDB_DATA_TYPE_BOOL: { case TSDB_DATA_TYPE_BOOL: {
if (strncasecmp(token->z, "true", 4) == 0) { if (strncasecmp(z, "true", 4) == 0) {
pVar->i64 = TSDB_TRUE; pVar->i64 = TSDB_TRUE;
} else if (strncasecmp(token->z, "false", 5) == 0) { } else if (strncasecmp(z, "false", 5) == 0) {
pVar->i64 = TSDB_FALSE; pVar->i64 = TSDB_FALSE;
} else { } else {
return; return;
...@@ -53,35 +51,35 @@ void tVariantCreate(SVariant *pVar, SToken *token) { ...@@ -53,35 +51,35 @@ void tVariantCreate(SVariant *pVar, SToken *token) {
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_INT:{ case TSDB_DATA_TYPE_INT:{
ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, true); // ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, true);
if (ret != 0) { // if (ret != 0) {
SToken t = {0}; // SToken t = {0};
tGetToken(token->z, &t.type); // tGetToken(token->z, &t.type);
if (t.type == TK_MINUS) { // it is a signed number which is greater than INT64_MAX or less than INT64_MIN // if (t.type == TK_MINUS) { // it is a signed number which is greater than INT64_MAX or less than INT64_MIN
pVar->nType = -1; // -1 means error type // pVar->nType = -1; // -1 means error type
return; // return;
} // }
//
// data overflow, try unsigned parse the input number // // data overflow, try unsigned parse the input number
ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, false); // ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, false);
if (ret != 0) { // if (ret != 0) {
pVar->nType = -1; // -1 means error type // pVar->nType = -1; // -1 means error type
return; // return;
} // }
} // }
break; break;
} }
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
pVar->d = strtod(token->z, NULL); pVar->d = strtod(z, NULL);
break; break;
} }
case TSDB_DATA_TYPE_BINARY: { case TSDB_DATA_TYPE_BINARY: {
pVar->pz = strndup(token->z, token->n); pVar->pz = strndup(z, n);
pVar->nLen = strRmquote(pVar->pz, token->n); pVar->nLen = strRmquote(pVar->pz, n);
break; break;
} }
case TSDB_DATA_TYPE_TIMESTAMP: { case TSDB_DATA_TYPE_TIMESTAMP: {
...@@ -96,7 +94,7 @@ void tVariantCreate(SVariant *pVar, SToken *token) { ...@@ -96,7 +94,7 @@ void tVariantCreate(SVariant *pVar, SToken *token) {
pVar->nType = type; pVar->nType = type;
} }
#endif
/** /**
* create SVariant from binary string, not ascii data * create SVariant from binary string, not ascii data
...@@ -105,7 +103,7 @@ void tVariantCreate(SVariant *pVar, SToken *token) { ...@@ -105,7 +103,7 @@ void tVariantCreate(SVariant *pVar, SToken *token) {
* @param len * @param len
* @param type * @param type
*/ */
void tVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type) { void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type) {
switch (type) { switch (type) {
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT: { case TSDB_DATA_TYPE_TINYINT: {
...@@ -183,7 +181,7 @@ void tVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32 ...@@ -183,7 +181,7 @@ void tVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32
pVar->nType = type; pVar->nType = type;
} }
void tVariantDestroy(SVariant *pVar) { void taosVariantDestroy(SVariant *pVar) {
if (pVar == NULL) return; if (pVar == NULL) return;
if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) { if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) {
...@@ -206,12 +204,12 @@ void tVariantDestroy(SVariant *pVar) { ...@@ -206,12 +204,12 @@ void tVariantDestroy(SVariant *pVar) {
} }
} }
bool tVariantIsValid(SVariant *pVar) { bool taosVariantIsValid(SVariant *pVar) {
assert(pVar != NULL); assert(pVar != NULL);
return isValidDataType(pVar->nType); return isValidDataType(pVar->nType);
} }
void tVariantAssign(SVariant *pDst, const SVariant *pSrc) { void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
if (pSrc == NULL || pDst == NULL) return; if (pSrc == NULL || pDst == NULL) return;
pDst->nType = pSrc->nType; pDst->nType = pSrc->nType;
...@@ -255,7 +253,7 @@ void tVariantAssign(SVariant *pDst, const SVariant *pSrc) { ...@@ -255,7 +253,7 @@ void tVariantAssign(SVariant *pDst, const SVariant *pSrc) {
} }
} }
int32_t tVariantCompare(const SVariant* p1, const SVariant* p2) { int32_t taosVariantCompare(const SVariant* p1, const SVariant* p2) {
if (p1->nType == TSDB_DATA_TYPE_NULL && p2->nType == TSDB_DATA_TYPE_NULL) { if (p1->nType == TSDB_DATA_TYPE_NULL && p2->nType == TSDB_DATA_TYPE_NULL) {
return 0; return 0;
} }
...@@ -295,7 +293,7 @@ int32_t tVariantCompare(const SVariant* p1, const SVariant* p2) { ...@@ -295,7 +293,7 @@ int32_t tVariantCompare(const SVariant* p1, const SVariant* p2) {
} }
} }
int32_t tVariantToString(SVariant *pVar, char *dst) { int32_t taosVariantToString(SVariant *pVar, char *dst) {
if (pVar == NULL || dst == NULL) return 0; if (pVar == NULL || dst == NULL) return 0;
switch (pVar->nType) { switch (pVar->nType) {
...@@ -893,7 +891,7 @@ int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool inc ...@@ -893,7 +891,7 @@ int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool inc
* transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType * transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType
* to column type defined in schema * to column type defined in schema
*/ */
int32_t tVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix) { int32_t taosVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix) {
return tVariantDumpEx(pVariant, payload, type, includeLengthPrefix, NULL, NULL); return tVariantDumpEx(pVariant, payload, type, includeLengthPrefix, NULL, NULL);
} }
...@@ -974,4 +972,4 @@ int32_t tVariantTypeSetType(SVariant *pVariant, char type) { ...@@ -974,4 +972,4 @@ int32_t tVariantTypeSetType(SVariant *pVariant, char type) {
} }
return 0; return 0;
} }
\ No newline at end of file
...@@ -117,7 +117,7 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)) { ...@@ -117,7 +117,7 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)) {
if (pNode->nodeType == TSQL_NODE_EXPR) { if (pNode->nodeType == TSQL_NODE_EXPR) {
doExprTreeDestroy(&pNode, fp); doExprTreeDestroy(&pNode, fp);
} else if (pNode->nodeType == TSQL_NODE_VALUE) { } else if (pNode->nodeType == TSQL_NODE_VALUE) {
tVariantDestroy(pNode->pVal); taosVariantDestroy(pNode->pVal);
} else if (pNode->nodeType == TSQL_NODE_COL) { } else if (pNode->nodeType == TSQL_NODE_COL) {
tfree(pNode->pSchema); tfree(pNode->pSchema);
} }
...@@ -138,7 +138,7 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) { ...@@ -138,7 +138,7 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) {
fp((*pExpr)->_node.info); fp((*pExpr)->_node.info);
} }
} else if ((*pExpr)->nodeType == TSQL_NODE_VALUE) { } else if ((*pExpr)->nodeType == TSQL_NODE_VALUE) {
tVariantDestroy((*pExpr)->pVal); taosVariantDestroy((*pExpr)->pVal);
free((*pExpr)->pVal); free((*pExpr)->pVal);
} else if ((*pExpr)->nodeType == TSQL_NODE_COL) { } else if ((*pExpr)->nodeType == TSQL_NODE_COL) {
free((*pExpr)->pSchema); free((*pExpr)->pSchema);
...@@ -492,8 +492,8 @@ void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) { ...@@ -492,8 +492,8 @@ void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) {
uint32_t type = tbufReadUint32(&br); uint32_t type = tbufReadUint32(&br);
SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false); SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false);
taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(type)); // taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(type));
int dummy = -1; int dummy = -1;
int32_t sz = tbufReadInt32(&br); int32_t sz = tbufReadInt32(&br);
for (int32_t i = 0; i < sz; i++) { for (int32_t i = 0; i < sz; i++) {
...@@ -528,7 +528,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t ...@@ -528,7 +528,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t
uint32_t sType = tbufReadUint32(&br); uint32_t sType = tbufReadUint32(&br);
SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(tType), true, false); SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(tType), true, false);
taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(tType)); // taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(tType));
int dummy = -1; int dummy = -1;
SVariant tmpVar = {0}; SVariant tmpVar = {0};
...@@ -603,7 +603,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t ...@@ -603,7 +603,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t
return; return;
} }
tVariantCreateFromBinary(&tmpVar, (char *)pvar, t, sType); taosVariantCreateFromBinary(&tmpVar, (char *)pvar, t, sType);
if (bufLen < t) { if (bufLen < t) {
tmp = realloc(tmp, t * TSDB_NCHAR_SIZE); tmp = realloc(tmp, t * TSDB_NCHAR_SIZE);
...@@ -686,7 +686,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t ...@@ -686,7 +686,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t
} }
taosHashPut(pObj, (char *)pvar, t, &dummy, sizeof(dummy)); taosHashPut(pObj, (char *)pvar, t, &dummy, sizeof(dummy));
tVariantDestroy(&tmpVar); taosVariantDestroy(&tmpVar);
memset(&tmpVar, 0, sizeof(tmpVar)); memset(&tmpVar, 0, sizeof(tmpVar));
} }
...@@ -694,7 +694,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t ...@@ -694,7 +694,7 @@ void convertFilterSetFromBinary(void **q, const char *buf, int32_t len, uint32_t
pObj = NULL; pObj = NULL;
err_ret: err_ret:
tVariantDestroy(&tmpVar); taosVariantDestroy(&tmpVar);
taosHashCleanup(pObj); taosHashCleanup(pObj);
tfree(tmp); tfree(tmp);
} }
...@@ -716,7 +716,7 @@ tExprNode* exprdup(tExprNode* pNode) { ...@@ -716,7 +716,7 @@ tExprNode* exprdup(tExprNode* pNode) {
pCloned->_node.hasPK = pNode->_node.hasPK; pCloned->_node.hasPK = pNode->_node.hasPK;
} else if (pNode->nodeType == TSQL_NODE_VALUE) { } else if (pNode->nodeType == TSQL_NODE_VALUE) {
pCloned->pVal = calloc(1, sizeof(SVariant)); pCloned->pVal = calloc(1, sizeof(SVariant));
tVariantAssign(pCloned->pVal, pNode->pVal); taosVariantAssign(pCloned->pVal, pNode->pVal);
} else if (pNode->nodeType == TSQL_NODE_COL) { } else if (pNode->nodeType == TSQL_NODE_COL) {
pCloned->pSchema = calloc(1, sizeof(SSchema)); pCloned->pSchema = calloc(1, sizeof(SSchema));
*pCloned->pSchema = *pNode->pSchema; *pCloned->pSchema = *pNode->pSchema;
......
...@@ -285,8 +285,7 @@ int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right); ...@@ -285,8 +285,7 @@ int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right);
SCreateTableSql *tSetCreateTableInfo(SArray *pCols, SArray *pTags, SSqlNode *pSelect, int32_t type); SCreateTableSql *tSetCreateTableInfo(SArray *pCols, SArray *pTags, SSqlNode *pSelect, int32_t type);
SAlterTableInfo * tSetAlterTableInfo(SToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, SAlterTableInfo * tSetAlterTableInfo(SToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableType);
int16_t tableTable);
SCreatedTableInfo createNewChildTableInfo(SToken *pTableName, SArray *pTagNames, SArray *pTagVals, SToken *pToken, SCreatedTableInfo createNewChildTableInfo(SToken *pTableName, SArray *pTagNames, SArray *pTagVals, SToken *pToken,
SToken *igExists); SToken *igExists);
...@@ -299,6 +298,7 @@ SArray *setSubclause(SArray *pList, void *pSqlNode); ...@@ -299,6 +298,7 @@ SArray *setSubclause(SArray *pList, void *pSqlNode);
SArray *appendSelectClause(SArray *pList, void *pSubclause); SArray *appendSelectClause(SArray *pList, void *pSubclause);
void setCreatedTableName(SSqlInfo *pInfo, SToken *pTableNameToken, SToken *pIfNotExists); void setCreatedTableName(SSqlInfo *pInfo, SToken *pTableNameToken, SToken *pIfNotExists);
void* destroyCreateTableSql(SCreateTableSql* pCreate);
void SqlInfoDestroy(SSqlInfo *pInfo); void SqlInfoDestroy(SSqlInfo *pInfo);
...@@ -351,7 +351,7 @@ void *ParseAlloc(void *(*mallocProc)(size_t)); ...@@ -351,7 +351,7 @@ void *ParseAlloc(void *(*mallocProc)(size_t));
* @param str sql string * @param str sql string
* @return sql ast * @return sql ast
*/ */
SSqlInfo genAST(const char *str); SSqlInfo doGenerateAST(const char *str);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -21,13 +21,13 @@ bool qIsInsertSql(const char* pStr, size_t length) { ...@@ -21,13 +21,13 @@ bool qIsInsertSql(const char* pStr, size_t length) {
return false; return false;
} }
int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo** pQueryInfo, int64_t id, char* msg) { int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo** pQueryInfo, int64_t id, char* msg, int32_t msgLen) {
*pQueryInfo = calloc(1, sizeof(SQueryStmtInfo)); *pQueryInfo = calloc(1, sizeof(SQueryStmtInfo));
if (*pQueryInfo == NULL) { if (*pQueryInfo == NULL) {
return -1; // set correct error code. return -1; // set correct error code.
} }
SSqlInfo info = genAST(pStr); SSqlInfo info = doGenerateAST(pStr);
if (!info.valid) { if (!info.valid) {
strcpy(msg, info.msg); strcpy(msg, info.msg);
return -1; // set correct error code. return -1; // set correct error code.
...@@ -42,7 +42,7 @@ int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo** ...@@ -42,7 +42,7 @@ int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo**
return 0; return 0;
} }
int32_t qParseInsertSql(const char* pStr, size_t length, struct SInsertStmtInfo** pInsertInfo, int64_t id, char* msg) { int32_t qParseInsertSql(const char* pStr, size_t length, struct SInsertStmtInfo** pInsertInfo, int64_t id, char* msg, int32_t msgLen) {
return 0; return 0;
} }
......
...@@ -36,7 +36,7 @@ extern "C" { ...@@ -36,7 +36,7 @@ extern "C" {
#include "qSqlparser.h" #include "qSqlparser.h"
#include "qTsbuf.h" #include "qTsbuf.h"
#include "qUtil.h" #include "qUtil.h"
#include "tcmdtype.h" #include "tmsgtype.h"
typedef enum { typedef enum {
TAOS_REQ_FROM_SHELL, TAOS_REQ_FROM_SHELL,
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include "os.h" #include "os.h"
#include "qPlan.h" #include "qPlan.h"
#include "qTableMeta.h" #include "qTableMeta.h"
#include "tcmdtype.h"
#include "tlockfree.h" #include "tlockfree.h"
#include "tmsgtype.h"
#include "trpc.h" #include "trpc.h"
#include "tscGlobalmerge.h" #include "tscGlobalmerge.h"
#include "tscLog.h" #include "tscLog.h"
......
...@@ -259,7 +259,7 @@ acct_optr(Y) ::= pps(C) tseries(D) storage(P) streams(F) qtime(Q) dbs(E) users(K ...@@ -259,7 +259,7 @@ acct_optr(Y) ::= pps(C) tseries(D) storage(P) streams(F) qtime(Q) dbs(E) users(K
intitemlist(A) ::= intitemlist(X) COMMA intitem(Y). { A = tVariantListAppend(X, &Y, -1); } intitemlist(A) ::= intitemlist(X) COMMA intitem(Y). { A = tVariantListAppend(X, &Y, -1); }
intitemlist(A) ::= intitem(X). { A = tVariantListAppend(NULL, &X, -1); } intitemlist(A) ::= intitem(X). { A = tVariantListAppend(NULL, &X, -1); }
intitem(A) ::= INTEGER(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } intitem(A) ::= INTEGER(X). { toTSDBType(X.type); taosVariantCreate(&A, &X); }
%type keep {SArray*} %type keep {SArray*}
%destructor keep {taosArrayDestroy($$);} %destructor keep {taosArrayDestroy($$);}
...@@ -444,39 +444,39 @@ column(A) ::= ids(X) typename(Y). { ...@@ -444,39 +444,39 @@ column(A) ::= ids(X) typename(Y). {
tagitemlist(A) ::= tagitemlist(X) COMMA tagitem(Y). { A = tVariantListAppend(X, &Y, -1); } tagitemlist(A) ::= tagitemlist(X) COMMA tagitem(Y). { A = tVariantListAppend(X, &Y, -1); }
tagitemlist(A) ::= tagitem(X). { A = tVariantListAppend(NULL, &X, -1); } tagitemlist(A) ::= tagitem(X). { A = tVariantListAppend(NULL, &X, -1); }
tagitem(A) ::= INTEGER(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } tagitem(A) ::= INTEGER(X). { toTSDBType(X.type); taosVariantCreate(&A, &X); }
tagitem(A) ::= FLOAT(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } tagitem(A) ::= FLOAT(X). { toTSDBType(X.type); taosVariantCreate(&A, &X); }
tagitem(A) ::= STRING(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } tagitem(A) ::= STRING(X). { toTSDBType(X.type); taosVariantCreate(&A, &X); }
tagitem(A) ::= BOOL(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } tagitem(A) ::= BOOL(X). { toTSDBType(X.type); taosVariantCreate(&A, &X); }
tagitem(A) ::= NULL(X). { X.type = 0; tVariantCreate(&A, &X); } tagitem(A) ::= NULL(X). { X.type = 0; taosVariantCreate(&A, &X); }
tagitem(A) ::= NOW(X). { X.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&A, &X);} tagitem(A) ::= NOW(X). { X.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&A, &X);}
tagitem(A) ::= MINUS(X) INTEGER(Y).{ tagitem(A) ::= MINUS(X) INTEGER(Y).{
X.n += Y.n; X.n += Y.n;
X.type = Y.type; X.type = Y.type;
toTSDBType(X.type); toTSDBType(X.type);
tVariantCreate(&A, &X); taosVariantCreate(&A, &X);
} }
tagitem(A) ::= MINUS(X) FLOAT(Y). { tagitem(A) ::= MINUS(X) FLOAT(Y). {
X.n += Y.n; X.n += Y.n;
X.type = Y.type; X.type = Y.type;
toTSDBType(X.type); toTSDBType(X.type);
tVariantCreate(&A, &X); taosVariantCreate(&A, &X);
} }
tagitem(A) ::= PLUS(X) INTEGER(Y). { tagitem(A) ::= PLUS(X) INTEGER(Y). {
X.n += Y.n; X.n += Y.n;
X.type = Y.type; X.type = Y.type;
toTSDBType(X.type); toTSDBType(X.type);
tVariantCreate(&A, &X); taosVariantCreate(&A, &X);
} }
tagitem(A) ::= PLUS(X) FLOAT(Y). { tagitem(A) ::= PLUS(X) FLOAT(Y). {
X.n += Y.n; X.n += Y.n;
X.type = Y.type; X.type = Y.type;
toTSDBType(X.type); toTSDBType(X.type);
tVariantCreate(&A, &X); taosVariantCreate(&A, &X);
} }
//////////////////////// The SELECT statement ///////////////////////////////// //////////////////////// The SELECT statement /////////////////////////////////
...@@ -599,7 +599,7 @@ fill_opt(N) ::= . { N = 0; } ...@@ -599,7 +599,7 @@ fill_opt(N) ::= . { N = 0; }
fill_opt(N) ::= FILL LP ID(Y) COMMA tagitemlist(X) RP. { fill_opt(N) ::= FILL LP ID(Y) COMMA tagitemlist(X) RP. {
tVariant A = {0}; tVariant A = {0};
toTSDBType(Y.type); toTSDBType(Y.type);
tVariantCreate(&A, &Y); taosVariantCreate(&A, &Y);
tVariantListInsert(X, &A, -1, 0); tVariantListInsert(X, &A, -1, 0);
N = X; N = X;
...@@ -639,7 +639,7 @@ item(A) ::= ids(X) cpxName(Y). { ...@@ -639,7 +639,7 @@ item(A) ::= ids(X) cpxName(Y). {
toTSDBType(X.type); toTSDBType(X.type);
X.n += Y.n; X.n += Y.n;
tVariantCreate(&A, &X); taosVariantCreate(&A, &X);
} }
%type sortorder {int} %type sortorder {int}
...@@ -719,7 +719,7 @@ expr(A) ::= BOOL(X). { A = tSqlExprCreateIdValue(&X, TK_BOOL);} ...@@ -719,7 +719,7 @@ expr(A) ::= BOOL(X). { A = tSqlExprCreateIdValue(&X, TK_BOOL);}
expr(A) ::= NULL(X). { A = tSqlExprCreateIdValue(&X, TK_NULL);} expr(A) ::= NULL(X). { A = tSqlExprCreateIdValue(&X, TK_NULL);}
// ordinary functions: min(x), max(x), top(k, 20) // ordinary functions: min(x), max(x), top(k, 20)
expr(A) ::= ID(X) LP exprlist(Y) RP(E). { tStrTokenAppend(pInfo->funcs, &X); A = tSqlExprCreateFunction(Y, &X, &E, X.type); } expr(A) ::= ID(X) LP exprlist(Y) RP(E). { (pInfo->funcs, &X); A = tSqlExprCreateFunction(Y, &X, &E, X.type); }
// for parsing sql functions with wildcard for parameters. e.g., count(*)/first(*)/last(*) operation // for parsing sql functions with wildcard for parameters. e.g., count(*)/first(*)/last(*) operation
expr(A) ::= ID(X) LP STAR RP(Y). { tStrTokenAppend(pInfo->funcs, &X); A = tSqlExprCreateFunction(NULL, &X, &Y, X.type); } expr(A) ::= ID(X) LP STAR RP(Y). { tStrTokenAppend(pInfo->funcs, &X); A = tSqlExprCreateFunction(NULL, &X, &Y, X.type); }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "os.h" #include "os.h"
#include "taosdef.h" #include "taosdef.h"
#include "taosmsg.h" #include "taosmsg.h"
#include "tcmdtype.h" #include "tmsgtype.h"
#include "tstrbuild.h" #include "tstrbuild.h"
#include "ttoken.h" #include "ttoken.h"
#include "ttokendef.h" #include "ttokendef.h"
......
...@@ -27,13 +27,13 @@ ...@@ -27,13 +27,13 @@
/************ Begin %include sections from the grammar ************************/ /************ Begin %include sections from the grammar ************************/
#line 23 "sql.y" #line 23 "sql.y"
#include <assert.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <stdbool.h>
#include "qSqlparser.h" #include "qSqlparser.h"
#include "tcmdtype.h" #include "tmsgtype.h"
#include "ttoken.h" #include "ttoken.h"
#include "ttokendef.h" #include "ttokendef.h"
#include "tutil.h" #include "tutil.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册