diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 75eceedb1b1113b5b186fa8083a2b6899d1b7ac3..6c090a07901c1d96a567961b8a2ec3daabaaedf8 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -15,11 +15,15 @@ #include #include +#define ALLOW_FORBID_FUNC + #include "functionMgt.h" #include "nodes.h" #include "parToken.h" #include "ttokendef.h" #include "parAst.h" + +#define YYSTACKDEPTH 0 } %syntax_error { diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index bb70458f983832533fe8fa18ab58b58ca38558a6..c2e1eba4727281a54b778d64afc25ea159a11880 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -76,28 +76,8 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { int32_t inputSize = (NULL != pParam->length ? *(pParam->length) : tDataTypes[pParam->buffer_type].bytes); pVal->node.resType.type = pParam->buffer_type; pVal->node.resType.bytes = inputSize; + switch (pParam->buffer_type) { - case TSDB_DATA_TYPE_BOOL: - pVal->datum.b = *((bool*)pParam->buffer); - break; - case TSDB_DATA_TYPE_TINYINT: - pVal->datum.i = *((int8_t*)pParam->buffer); - break; - case TSDB_DATA_TYPE_SMALLINT: - pVal->datum.i = *((int16_t*)pParam->buffer); - break; - case TSDB_DATA_TYPE_INT: - pVal->datum.i = *((int32_t*)pParam->buffer); - break; - case TSDB_DATA_TYPE_BIGINT: - pVal->datum.i = *((int64_t*)pParam->buffer); - break; - case TSDB_DATA_TYPE_FLOAT: - pVal->datum.d = *((float*)pParam->buffer); - break; - case TSDB_DATA_TYPE_DOUBLE: - pVal->datum.d = *((double*)pParam->buffer); - break; case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); @@ -124,28 +104,13 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { pVal->node.resType.bytes = output + VARSTR_HEADER_SIZE; break; } - case TSDB_DATA_TYPE_TIMESTAMP: - pVal->datum.i = *((int64_t*)pParam->buffer); - break; - case TSDB_DATA_TYPE_UTINYINT: - pVal->datum.u = *((uint8_t*)pParam->buffer); - break; - case TSDB_DATA_TYPE_USMALLINT: - pVal->datum.u = *((uint16_t*)pParam->buffer); - break; - case TSDB_DATA_TYPE_UINT: - pVal->datum.u = *((uint32_t*)pParam->buffer); - break; - case TSDB_DATA_TYPE_UBIGINT: - pVal->datum.u = *((uint64_t*)pParam->buffer); - break; - case TSDB_DATA_TYPE_JSON: - case TSDB_DATA_TYPE_DECIMAL: - case TSDB_DATA_TYPE_BLOB: - case TSDB_DATA_TYPE_MEDIUMBLOB: - // todo - default: + default: { + int32_t code = nodesSetValueNodeValue(pVal, pParam->buffer); + if (code) { + return code; + } break; + } } pVal->translate = true; return TSDB_CODE_SUCCESS; diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 7fb89bdd7c820e2046d71287b331602172a2b315..ff4fe4032e9be6ab95696bf41d6e1f398983e7b1 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -32,11 +32,15 @@ #include #include +#define ALLOW_FORBID_FUNC + #include "functionMgt.h" #include "nodes.h" #include "parToken.h" #include "ttokendef.h" #include "parAst.h" + +#define YYSTACKDEPTH 0 /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols ** in a format understandable to "makeheaders". This section is blank unless @@ -136,6 +140,7 @@ typedef union { #define YYFALLBACK 1 #define YYNSTATE 612 #define YYNRULE 451 +#define YYNRULE_WITH_ACTION 451 #define YYNTOKEN 237 #define YY_MAX_SHIFT 611 #define YY_MIN_SHIFTREDUCE 898 @@ -640,7 +645,31 @@ static const YYCODETYPE yy_lookahead[] = { /* 2090 */ 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, /* 2100 */ 328, 329, 330, 357, 332, 357, 357, 335, 357, 357, /* 2110 */ 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, - /* 2120 */ 348, 357, 357, 357, 352, + /* 2120 */ 348, 357, 357, 357, 352, 237, 237, 237, 237, 237, + /* 2130 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2140 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2150 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2160 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2170 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2180 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2190 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2200 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2210 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2220 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2230 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2240 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2250 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2260 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2270 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2280 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2290 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2300 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2310 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2320 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2330 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2340 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2350 */ 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, + /* 2360 */ 237, 237, }; #define YY_SHIFT_COUNT (611) #define YY_SHIFT_MIN (0) @@ -2382,15 +2411,18 @@ static YYACTIONTYPE yy_find_shift_action( do{ i = yy_shift_ofst[stateno]; assert( i>=0 ); - /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */ + assert( i<=YY_ACTTAB_COUNT ); + assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){ + assert( i<(int)YY_NLOOKAHEAD ); + if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - if( iLookAhead %s\n", @@ -2405,16 +2437,8 @@ static YYACTIONTYPE yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - if( -#if YY_SHIFT_MIN+YYWILDCARD<0 - j>=0 && -#endif -#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j0 - ){ + assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); + if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -2428,6 +2452,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ + assert( i>=0 && iyytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfo[yyruleno].nrhs; + yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno); + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -4406,9 +4886,9 @@ static YYACTIONTYPE yy_reduce( break; /********** End reduce actions ************************************************/ }; - assert( yyruleno