提交 5501982f 编写于 作者: H Haojun Liao

[td-2895] refactor.

上级 e313cf3b
此差异已折叠。
...@@ -181,19 +181,32 @@ typedef struct SSqlInfo { ...@@ -181,19 +181,32 @@ typedef struct SSqlInfo {
}; };
} SSqlInfo; } SSqlInfo;
#define NON_ARITHMEIC_EXPR 0
#define NORMAL_ARITHMETIC 1
#define AGG_ARIGHTMEIC 2
enum SQL_NODE_TYPE {
SQL_NODE_TABLE_COLUMN= 1,
SQL_NODE_SQLFUNCTION = 2,
SQL_NODE_VALUE = 3,
SQL_NODE_EXPR = 4,
};
typedef struct tSQLExpr { typedef struct tSQLExpr {
uint32_t nSQLOptr; // TK_FUNCTION: sql function, TK_LE: less than(binary expr) uint16_t type; // sql node type
uint32_t tokenId; // TK_FUNCTION: sql function, TK_LE: less than(binary expr)
// the full sql string of function(col, param), which is actually the raw // the whole string of the function(col, param), while the function name is kept in token
// field name, since the function name is kept in nSQLOptr already
SStrToken operand; SStrToken operand;
SStrToken colInfo; // field id uint32_t functionId; // function id
tVariant val; // value only for string, float, int
SStrToken colInfo; // table column info
tVariant value; // the use input value
SStrToken token; // original sql expr string SStrToken token; // original sql expr string
struct tSQLExpr *pLeft; // left child struct tSQLExpr *pLeft; // left child
struct tSQLExpr *pRight; // right child struct tSQLExpr *pRight; // right child
struct tSQLExprList *pParam; // function parameters struct tSQLExprList *pParam; // function parameters list
} tSQLExpr; } tSQLExpr;
// used in select clause. select <tSQLExprList> from xxx // used in select clause. select <tSQLExprList> from xxx
...@@ -287,16 +300,6 @@ void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type); ...@@ -287,16 +300,6 @@ void tSqlSetColumnType(TAOS_FIELD *pField, SStrToken *type);
void *ParseAlloc(void *(*mallocProc)(size_t)); void *ParseAlloc(void *(*mallocProc)(size_t));
enum {
TSQL_NODE_TYPE_EXPR = 0x1,
TSQL_NODE_TYPE_ID = 0x2,
TSQL_NODE_TYPE_VALUE = 0x4,
};
#define NON_ARITHMEIC_EXPR 0
#define NORMAL_ARITHMETIC 1
#define AGG_ARIGHTMEIC 2
SSqlInfo qSQLParse(const char *str); SSqlInfo qSQLParse(const char *str);
#ifdef __cplusplus #ifdef __cplusplus
......
此差异已折叠。
...@@ -126,28 +126,33 @@ tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) { ...@@ -126,28 +126,33 @@ tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
if (optrType == TK_INTEGER || optrType == TK_STRING || optrType == TK_FLOAT || optrType == TK_BOOL) { if (optrType == TK_INTEGER || optrType == TK_STRING || optrType == TK_FLOAT || optrType == TK_BOOL) {
toTSDBType(pToken->type); toTSDBType(pToken->type);
tVariantCreate(&pSqlExpr->val, pToken); tVariantCreate(&pSqlExpr->value, pToken);
pSqlExpr->nSQLOptr = optrType; pSqlExpr->tokenId = optrType;
pSqlExpr->type = SQL_NODE_VALUE;
} else if (optrType == TK_NOW) { } else if (optrType == TK_NOW) {
// use microsecond by default // use microsecond by default
pSqlExpr->val.i64 = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO); pSqlExpr->value.i64 = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO);
pSqlExpr->val.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pSqlExpr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond pSqlExpr->tokenId = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
pSqlExpr->type = SQL_NODE_VALUE;
} else if (optrType == TK_VARIABLE) { } else if (optrType == TK_VARIABLE) {
int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->val.i64); int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
} }
pSqlExpr->val.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pSqlExpr->nSQLOptr = TK_TIMESTAMP; pSqlExpr->tokenId = TK_TIMESTAMP;
} else { // it must be the column name (tk_id) if it is not the number pSqlExpr->type = SQL_NODE_VALUE;
} else {
// Here it must be the column name (tk_id) if it is not a number or string.
assert(optrType == TK_ID || optrType == TK_ALL); assert(optrType == TK_ID || optrType == TK_ALL);
if (pToken != NULL) { if (pToken != NULL) {
pSqlExpr->colInfo = *pToken; pSqlExpr->colInfo = *pToken;
} }
pSqlExpr->nSQLOptr = optrType; pSqlExpr->tokenId = optrType;
pSqlExpr->type = SQL_NODE_TABLE_COLUMN;
} }
return pSqlExpr; return pSqlExpr;
...@@ -162,18 +167,18 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt ...@@ -162,18 +167,18 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt
return NULL; return NULL;
} }
assert(optType == TK_ID);
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr)); tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr));
pExpr->nSQLOptr = TK_FUNCTION; pExpr->tokenId = optType;
pExpr->type = SQL_NODE_SQLFUNCTION;
pExpr->pParam = pList; pExpr->pParam = pList;
int32_t len = (int32_t)((endToken->z + endToken->n) - pFuncToken->z); int32_t len = (int32_t)((endToken->z + endToken->n) - pFuncToken->z);
pExpr->operand.z = pFuncToken->z; pExpr->operand = (*pFuncToken);
pExpr->operand.n = len; // raw field name
pExpr->operand.type = pFuncToken->type; pExpr->token.n = len;
pExpr->token.z = pFuncToken->z;
pExpr->token.type = pFuncToken->type;
pExpr->token = (*pFuncToken);
return pExpr; return pExpr;
} }
...@@ -184,6 +189,7 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt ...@@ -184,6 +189,7 @@ tSQLExpr *tSqlExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SSt
tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr)); tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr));
pExpr->type = SQL_NODE_EXPR;
if (pLeft != NULL && pRight != NULL && (optrType != TK_IN)) { if (pLeft != NULL && pRight != NULL && (optrType != TK_IN)) {
char* endPos = pRight->token.z + pRight->token.n; char* endPos = pRight->token.z + pRight->token.n;
pExpr->token.z = pLeft->token.z; pExpr->token.z = pLeft->token.z;
...@@ -197,32 +203,33 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { ...@@ -197,32 +203,33 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
* if a token is noted as the TK_TIMESTAMP, the time precision is microsecond * if a token is noted as the TK_TIMESTAMP, the time precision is microsecond
* Otherwise, the time precision is adaptive, determined by the time precision from databases. * Otherwise, the time precision is adaptive, determined by the time precision from databases.
*/ */
if ((pLeft->nSQLOptr == TK_INTEGER && pRight->nSQLOptr == TK_INTEGER) || if ((pLeft->tokenId == TK_INTEGER && pRight->tokenId == TK_INTEGER) ||
(pLeft->nSQLOptr == TK_TIMESTAMP && pRight->nSQLOptr == TK_TIMESTAMP)) { (pLeft->tokenId == TK_TIMESTAMP && pRight->tokenId == TK_TIMESTAMP)) {
pExpr->val.nType = TSDB_DATA_TYPE_BIGINT; pExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pExpr->nSQLOptr = pLeft->nSQLOptr; pExpr->tokenId = pLeft->tokenId;
pExpr->type = SQL_NODE_VALUE;
switch (optrType) { switch (optrType) {
case TK_PLUS: { case TK_PLUS: {
pExpr->val.i64 = pLeft->val.i64 + pRight->val.i64; pExpr->value.i64 = pLeft->value.i64 + pRight->value.i64;
break; break;
} }
case TK_MINUS: { case TK_MINUS: {
pExpr->val.i64 = pLeft->val.i64 - pRight->val.i64; pExpr->value.i64 = pLeft->value.i64 - pRight->value.i64;
break; break;
} }
case TK_STAR: { case TK_STAR: {
pExpr->val.i64 = pLeft->val.i64 * pRight->val.i64; pExpr->value.i64 = pLeft->value.i64 * pRight->value.i64;
break; break;
} }
case TK_DIVIDE: { case TK_DIVIDE: {
pExpr->nSQLOptr = TK_FLOAT; pExpr->tokenId = TK_FLOAT;
pExpr->val.nType = TSDB_DATA_TYPE_DOUBLE; pExpr->value.nType = TSDB_DATA_TYPE_DOUBLE;
pExpr->val.dKey = (double)pLeft->val.i64 / pRight->val.i64; pExpr->value.dKey = (double)pLeft->value.i64 / pRight->value.i64;
break; break;
} }
case TK_REM: { case TK_REM: {
pExpr->val.i64 = pLeft->val.i64 % pRight->val.i64; pExpr->value.i64 = pLeft->value.i64 % pRight->value.i64;
break; break;
} }
} }
...@@ -230,33 +237,35 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { ...@@ -230,33 +237,35 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
tSqlExprDestroy(pLeft); tSqlExprDestroy(pLeft);
tSqlExprDestroy(pRight); tSqlExprDestroy(pRight);
} else if ((pLeft->nSQLOptr == TK_FLOAT && pRight->nSQLOptr == TK_INTEGER) || (pLeft->nSQLOptr == TK_INTEGER && pRight->nSQLOptr == TK_FLOAT) || } else if ((pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_INTEGER) ||
(pLeft->nSQLOptr == TK_FLOAT && pRight->nSQLOptr == TK_FLOAT)) { (pLeft->tokenId == TK_INTEGER && pRight->tokenId == TK_FLOAT) ||
pExpr->val.nType = TSDB_DATA_TYPE_DOUBLE; (pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_FLOAT)) {
pExpr->nSQLOptr = TK_FLOAT; pExpr->value.nType = TSDB_DATA_TYPE_DOUBLE;
pExpr->tokenId = TK_FLOAT;
pExpr->type = SQL_NODE_VALUE;
double left = (pLeft->val.nType == TSDB_DATA_TYPE_DOUBLE) ? pLeft->val.dKey : pLeft->val.i64; double left = (pLeft->value.nType == TSDB_DATA_TYPE_DOUBLE) ? pLeft->value.dKey : pLeft->value.i64;
double right = (pRight->val.nType == TSDB_DATA_TYPE_DOUBLE) ? pRight->val.dKey : pRight->val.i64; double right = (pRight->value.nType == TSDB_DATA_TYPE_DOUBLE) ? pRight->value.dKey : pRight->value.i64;
switch (optrType) { switch (optrType) {
case TK_PLUS: { case TK_PLUS: {
pExpr->val.dKey = left + right; pExpr->value.dKey = left + right;
break; break;
} }
case TK_MINUS: { case TK_MINUS: {
pExpr->val.dKey = left - right; pExpr->value.dKey = left - right;
break; break;
} }
case TK_STAR: { case TK_STAR: {
pExpr->val.dKey = left * right; pExpr->value.dKey = left * right;
break; break;
} }
case TK_DIVIDE: { case TK_DIVIDE: {
pExpr->val.dKey = left / right; pExpr->value.dKey = left / right;
break; break;
} }
case TK_REM: { case TK_REM: {
pExpr->val.dKey = left - ((int64_t)(left / right)) * right; pExpr->value.dKey = left - ((int64_t)(left / right)) * right;
break; break;
} }
} }
...@@ -265,21 +274,21 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { ...@@ -265,21 +274,21 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
tSqlExprDestroy(pRight); tSqlExprDestroy(pRight);
} else { } else {
pExpr->nSQLOptr = optrType; pExpr->tokenId = optrType;
pExpr->pLeft = pLeft; pExpr->pLeft = pLeft;
pExpr->pRight = pRight; pExpr->pRight = pRight;
} }
} else if (optrType == TK_IN) { } else if (optrType == TK_IN) {
pExpr->nSQLOptr = optrType; pExpr->tokenId = optrType;
pExpr->pLeft = pLeft; pExpr->pLeft = pLeft;
tSQLExpr *pRSub = calloc(1, sizeof(tSQLExpr)); tSQLExpr *pRSub = calloc(1, sizeof(tSQLExpr));
pRSub->nSQLOptr = TK_SET; // TODO refactor ..... pRSub->tokenId = TK_SET; // TODO refactor .....
pRSub->pParam = (tSQLExprList *)pRight; pRSub->pParam = (tSQLExprList *)pRight;
pExpr->pRight = pRSub; pExpr->pRight = pRSub;
} else { } else {
pExpr->nSQLOptr = optrType; pExpr->tokenId = optrType;
pExpr->pLeft = pLeft; pExpr->pLeft = pLeft;
if (pLeft != NULL && pRight == NULL) { if (pLeft != NULL && pRight == NULL) {
...@@ -297,8 +306,8 @@ void tSqlExprNodeDestroy(tSQLExpr *pExpr) { ...@@ -297,8 +306,8 @@ void tSqlExprNodeDestroy(tSQLExpr *pExpr) {
return; return;
} }
if (pExpr->nSQLOptr == TK_STRING) { if (pExpr->tokenId == TK_STRING) {
tVariantDestroy(&pExpr->val); tVariantDestroy(&pExpr->value);
} }
tSqlExprListDestroy(pExpr->pParam); tSqlExprListDestroy(pExpr->pParam);
......
...@@ -268,7 +268,7 @@ int tSQLKeywordCode(const char* z, int n) { ...@@ -268,7 +268,7 @@ int tSQLKeywordCode(const char* z, int n) {
* Return the length of the token that begins at z[0]. * Return the length of the token that begins at z[0].
* Store the token type in *type before returning. * Store the token type in *type before returning.
*/ */
uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { uint32_t tSQLGetToken(char* z, uint32_t* tokenId) {
uint32_t i; uint32_t i;
switch (*z) { switch (*z) {
case ' ': case ' ':
...@@ -278,121 +278,121 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -278,121 +278,121 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
case '\r': { case '\r': {
for (i = 1; isspace(z[i]); i++) { for (i = 1; isspace(z[i]); i++) {
} }
*tokenType = TK_SPACE; *tokenId = TK_SPACE;
return i; return i;
} }
case ':': { case ':': {
*tokenType = TK_COLON; *tokenId = TK_COLON;
return 1; return 1;
} }
case '-': { case '-': {
if (z[1] == '-') { if (z[1] == '-') {
for (i = 2; z[i] && z[i] != '\n'; i++) { for (i = 2; z[i] && z[i] != '\n'; i++) {
} }
*tokenType = TK_COMMENT; *tokenId = TK_COMMENT;
return i; return i;
} }
*tokenType = TK_MINUS; *tokenId = TK_MINUS;
return 1; return 1;
} }
case '(': { case '(': {
*tokenType = TK_LP; *tokenId = TK_LP;
return 1; return 1;
} }
case ')': { case ')': {
*tokenType = TK_RP; *tokenId = TK_RP;
return 1; return 1;
} }
case ';': { case ';': {
*tokenType = TK_SEMI; *tokenId = TK_SEMI;
return 1; return 1;
} }
case '+': { case '+': {
*tokenType = TK_PLUS; *tokenId = TK_PLUS;
return 1; return 1;
} }
case '*': { case '*': {
*tokenType = TK_STAR; *tokenId = TK_STAR;
return 1; return 1;
} }
case '/': { case '/': {
if (z[1] != '*' || z[2] == 0) { if (z[1] != '*' || z[2] == 0) {
*tokenType = TK_SLASH; *tokenId = TK_SLASH;
return 1; return 1;
} }
for (i = 3; z[i] && (z[i] != '/' || z[i - 1] != '*'); i++) { for (i = 3; z[i] && (z[i] != '/' || z[i - 1] != '*'); i++) {
} }
if (z[i]) i++; if (z[i]) i++;
*tokenType = TK_COMMENT; *tokenId = TK_COMMENT;
return i; return i;
} }
case '%': { case '%': {
*tokenType = TK_REM; *tokenId = TK_REM;
return 1; return 1;
} }
case '=': { case '=': {
*tokenType = TK_EQ; *tokenId = TK_EQ;
return 1 + (z[1] == '='); return 1 + (z[1] == '=');
} }
case '<': { case '<': {
if (z[1] == '=') { if (z[1] == '=') {
*tokenType = TK_LE; *tokenId = TK_LE;
return 2; return 2;
} else if (z[1] == '>') { } else if (z[1] == '>') {
*tokenType = TK_NE; *tokenId = TK_NE;
return 2; return 2;
} else if (z[1] == '<') { } else if (z[1] == '<') {
*tokenType = TK_LSHIFT; *tokenId = TK_LSHIFT;
return 2; return 2;
} else { } else {
*tokenType = TK_LT; *tokenId = TK_LT;
return 1; return 1;
} }
} }
case '>': { case '>': {
if (z[1] == '=') { if (z[1] == '=') {
*tokenType = TK_GE; *tokenId = TK_GE;
return 2; return 2;
} else if (z[1] == '>') { } else if (z[1] == '>') {
*tokenType = TK_RSHIFT; *tokenId = TK_RSHIFT;
return 2; return 2;
} else { } else {
*tokenType = TK_GT; *tokenId = TK_GT;
return 1; return 1;
} }
} }
case '!': { case '!': {
if (z[1] != '=') { if (z[1] != '=') {
*tokenType = TK_ILLEGAL; *tokenId = TK_ILLEGAL;
return 2; return 2;
} else { } else {
*tokenType = TK_NE; *tokenId = TK_NE;
return 2; return 2;
} }
} }
case '|': { case '|': {
if (z[1] != '|') { if (z[1] != '|') {
*tokenType = TK_BITOR; *tokenId = TK_BITOR;
return 1; return 1;
} else { } else {
*tokenType = TK_CONCAT; *tokenId = TK_CONCAT;
return 2; return 2;
} }
} }
case ',': { case ',': {
*tokenType = TK_COMMA; *tokenId = TK_COMMA;
return 1; return 1;
} }
case '&': { case '&': {
*tokenType = TK_BITAND; *tokenId = TK_BITAND;
return 1; return 1;
} }
case '~': { case '~': {
*tokenType = TK_BITNOT; *tokenId = TK_BITNOT;
return 1; return 1;
} }
case '?': { case '?': {
*tokenType = TK_QUESTION; *tokenId = TK_QUESTION;
return 1; return 1;
} }
case '\'': case '\'':
...@@ -418,7 +418,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -418,7 +418,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
if (z[i]) i++; if (z[i]) i++;
if (strEnd) { if (strEnd) {
*tokenType = TK_STRING; *tokenId = TK_STRING;
return i; return i;
} }
...@@ -442,10 +442,10 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -442,10 +442,10 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
} }
} }
*tokenType = TK_FLOAT; *tokenId = TK_FLOAT;
return i; return i;
} else { } else {
*tokenType = TK_DOT; *tokenId = TK_DOT;
return 1; return 1;
} }
} }
...@@ -454,7 +454,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -454,7 +454,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
char next = z[1]; char next = z[1];
if (next == 'b') { // bin number if (next == 'b') { // bin number
*tokenType = TK_BIN; *tokenId = TK_BIN;
for (i = 2; (z[i] == '0' || z[i] == '1'); ++i) { for (i = 2; (z[i] == '0' || z[i] == '1'); ++i) {
} }
...@@ -464,7 +464,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -464,7 +464,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
return i; return i;
} else if (next == 'x') { //hex number } else if (next == 'x') { //hex number
*tokenType = TK_HEX; *tokenId = TK_HEX;
for (i = 2; isdigit(z[i]) || (z[i] >= 'a' && z[i] <= 'f') || (z[i] >= 'A' && z[i] <= 'F'); ++i) { for (i = 2; isdigit(z[i]) || (z[i] >= 'a' && z[i] <= 'f') || (z[i] >= 'A' && z[i] <= 'F'); ++i) {
} }
...@@ -484,7 +484,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -484,7 +484,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
case '7': case '7':
case '8': case '8':
case '9': { case '9': {
*tokenType = TK_INTEGER; *tokenId = TK_INTEGER;
for (i = 1; isdigit(z[i]); i++) { for (i = 1; isdigit(z[i]); i++) {
} }
...@@ -494,7 +494,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -494,7 +494,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
z[i] == 'U' || z[i] == 'A' || z[i] == 'S' || z[i] == 'M' || z[i] == 'H' || z[i] == 'D' || z[i] == 'N' || z[i] == 'U' || z[i] == 'A' || z[i] == 'S' || z[i] == 'M' || z[i] == 'H' || z[i] == 'D' || z[i] == 'N' ||
z[i] == 'Y' || z[i] == 'W') && z[i] == 'Y' || z[i] == 'W') &&
(isIdChar[(uint8_t)z[i + 1]] == 0)) { (isIdChar[(uint8_t)z[i + 1]] == 0)) {
*tokenType = TK_VARIABLE; *tokenId = TK_VARIABLE;
i += 1; i += 1;
return i; return i;
} }
...@@ -505,12 +505,12 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -505,12 +505,12 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
while (isdigit(z[i])) { while (isdigit(z[i])) {
i++; i++;
} }
*tokenType = TK_FLOAT; *tokenId = TK_FLOAT;
seg++; seg++;
} }
if (seg == 4) { // ip address if (seg == 4) { // ip address
*tokenType = TK_IPTOKEN; *tokenId = TK_IPTOKEN;
return i; return i;
} }
...@@ -520,14 +520,14 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -520,14 +520,14 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
while (isdigit(z[i])) { while (isdigit(z[i])) {
i++; i++;
} }
*tokenType = TK_FLOAT; *tokenId = TK_FLOAT;
} }
return i; return i;
} }
case '[': { case '[': {
for (i = 1; z[i] && z[i - 1] != ']'; i++) { for (i = 1; z[i] && z[i - 1] != ']'; i++) {
} }
*tokenType = TK_ID; *tokenId = TK_ID;
return i; return i;
} }
case 'T': case 'T':
...@@ -538,7 +538,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -538,7 +538,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
} }
if ((i == 4 && strncasecmp(z, "true", 4) == 0) || (i == 5 && strncasecmp(z, "false", 5) == 0)) { if ((i == 4 && strncasecmp(z, "true", 4) == 0) || (i == 5 && strncasecmp(z, "false", 5) == 0)) {
*tokenType = TK_BOOL; *tokenId = TK_BOOL;
return i; return i;
} }
} }
...@@ -548,12 +548,12 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { ...@@ -548,12 +548,12 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
} }
for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(uint8_t) z[i]]; i++) { for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(uint8_t) z[i]]; i++) {
} }
*tokenType = tSQLKeywordCode(z, i); *tokenId = tSQLKeywordCode(z, i);
return i; return i;
} }
} }
*tokenType = TK_ILLEGAL; *tokenId = TK_ILLEGAL;
return 0; return 0;
} }
......
run general/parser/alter.sim #run general/parser/alter.sim
sleep 100 #sleep 100
run general/parser/alter1.sim #run general/parser/alter1.sim
sleep 100 #sleep 100
run general/parser/alter_stable.sim #run general/parser/alter_stable.sim
sleep 100 #sleep 100
run general/parser/auto_create_tb.sim #run general/parser/auto_create_tb.sim
sleep 100 #sleep 100
run general/parser/auto_create_tb_drop_tb.sim #run general/parser/auto_create_tb_drop_tb.sim
sleep 100 #sleep 100
run general/parser/col_arithmetic_operation.sim #run general/parser/col_arithmetic_operation.sim
sleep 100 #sleep 100
run general/parser/columnValue.sim #run general/parser/columnValue.sim
sleep 100 #sleep 100
run general/parser/commit.sim #run general/parser/commit.sim
sleep 100 #sleep 100
run general/parser/create_db.sim #run general/parser/create_db.sim
sleep 100 #sleep 100
run general/parser/create_mt.sim #run general/parser/create_mt.sim
sleep 100 #sleep 100
run general/parser/create_tb.sim #run general/parser/create_tb.sim
sleep 100 #sleep 100
run general/parser/dbtbnameValidate.sim #run general/parser/dbtbnameValidate.sim
sleep 100 #sleep 100
run general/parser/fill.sim #run general/parser/fill.sim
sleep 100 #sleep 100
run general/parser/fill_stb.sim #run general/parser/fill_stb.sim
sleep 100 #sleep 100
#run general/parser/fill_us.sim # ##run general/parser/fill_us.sim #
sleep 100 #sleep 100
run general/parser/first_last.sim #run general/parser/first_last.sim
sleep 100 #sleep 100
run general/parser/import_commit1.sim #run general/parser/import_commit1.sim
sleep 100 #sleep 100
run general/parser/import_commit2.sim #run general/parser/import_commit2.sim
sleep 100 #sleep 100
run general/parser/import_commit3.sim #run general/parser/import_commit3.sim
sleep 100 #sleep 100
#run general/parser/import_file.sim ##run general/parser/import_file.sim
sleep 100 #sleep 100
run general/parser/insert_tb.sim #run general/parser/insert_tb.sim
sleep 100 #sleep 100
run general/parser/tags_dynamically_specifiy.sim #run general/parser/tags_dynamically_specifiy.sim
sleep 100 #sleep 100
run general/parser/interp.sim #run general/parser/interp.sim
sleep 100 #sleep 100
run general/parser/lastrow.sim #run general/parser/lastrow.sim
sleep 100 #sleep 100
run general/parser/limit.sim #run general/parser/limit.sim
sleep 100 #sleep 100
run general/parser/limit1.sim #run general/parser/limit1.sim
sleep 100 #sleep 100
run general/parser/limit1_tblocks100.sim #run general/parser/limit1_tblocks100.sim
sleep 100 #sleep 100
run general/parser/limit2.sim #run general/parser/limit2.sim
sleep 100 #sleep 100
run general/parser/mixed_blocks.sim #run general/parser/mixed_blocks.sim
sleep 100 #sleep 100
run general/parser/nchar.sim #run general/parser/nchar.sim
sleep 100 #sleep 100
run general/parser/null_char.sim #run general/parser/null_char.sim
sleep 100 #sleep 100
run general/parser/selectResNum.sim #run general/parser/selectResNum.sim
sleep 100 #sleep 100
run general/parser/select_across_vnodes.sim #run general/parser/select_across_vnodes.sim
sleep 100 #sleep 100
run general/parser/select_from_cache_disk.sim #run general/parser/select_from_cache_disk.sim
sleep 100 #sleep 100
run general/parser/set_tag_vals.sim #run general/parser/set_tag_vals.sim
sleep 100 #sleep 100
run general/parser/single_row_in_tb.sim #run general/parser/single_row_in_tb.sim
sleep 100 #sleep 100
run general/parser/slimit.sim #run general/parser/slimit.sim
sleep 100 #sleep 100
run general/parser/slimit1.sim #run general/parser/slimit1.sim
sleep 100 #sleep 100
run general/parser/slimit_alter_tags.sim #run general/parser/slimit_alter_tags.sim
sleep 100 #sleep 100
run general/parser/tbnameIn.sim #run general/parser/tbnameIn.sim
sleep 100 #sleep 100
run general/parser/slimit_alter_tags.sim # persistent failed #run general/parser/slimit_alter_tags.sim # persistent failed
sleep 100 #sleep 100
run general/parser/join.sim #run general/parser/join.sim
sleep 100 #sleep 100
run general/parser/join_multivnode.sim #run general/parser/join_multivnode.sim
sleep 100 #sleep 100
run general/parser/projection_limit_offset.sim run general/parser/projection_limit_offset.sim
sleep 100 sleep 100
run general/parser/select_with_tags.sim run general/parser/select_with_tags.sim
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册