From 1a2cf476007f2409526c84841914d0e4e4923487 Mon Sep 17 00:00:00 2001 From: wangyunlai Date: Wed, 31 May 2023 10:55:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dclang=2014=20compile=20error?= =?UTF-8?q?=20(#193)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem were solved in this pull request? Issue Number: close #192 Problem: clang 14编译失败 ### What is changed and how it works? 修复编译错误 ### Other information --- .../sql/operator/insert_physical_operator.cpp | 2 +- .../operator/table_scan_physical_operator.cpp | 2 +- src/observer/sql/optimizer/optimize_stage.cpp | 18 +- .../sql/optimizer/physical_plan_generator.cpp | 26 +- src/observer/sql/parser/lex_sql.cpp | 52 ++-- src/observer/sql/parser/lex_sql.h | 9 +- src/observer/sql/parser/yacc_sql.cpp | 231 +++++++++--------- src/observer/sql/parser/yacc_sql.y | 1 + 8 files changed, 173 insertions(+), 168 deletions(-) diff --git a/src/observer/sql/operator/insert_physical_operator.cpp b/src/observer/sql/operator/insert_physical_operator.cpp index 682b9dc..2bb1508 100644 --- a/src/observer/sql/operator/insert_physical_operator.cpp +++ b/src/observer/sql/operator/insert_physical_operator.cpp @@ -21,7 +21,7 @@ See the Mulan PSL v2 for more details. */ using namespace std; InsertPhysicalOperator::InsertPhysicalOperator(Table *table, vector &&values) - : table_(table), values_(move(values)) + : table_(table), values_(std::move(values)) {} RC InsertPhysicalOperator::open(Trx *trx) diff --git a/src/observer/sql/operator/table_scan_physical_operator.cpp b/src/observer/sql/operator/table_scan_physical_operator.cpp index d5ea9e0..db656bf 100644 --- a/src/observer/sql/operator/table_scan_physical_operator.cpp +++ b/src/observer/sql/operator/table_scan_physical_operator.cpp @@ -75,7 +75,7 @@ string TableScanPhysicalOperator::param() const void TableScanPhysicalOperator::set_predicates(vector> &&exprs) { - predicates_ = move(exprs); + predicates_ = std::move(exprs); } RC TableScanPhysicalOperator::filter(RowTuple &tuple, bool &result) diff --git a/src/observer/sql/optimizer/optimize_stage.cpp b/src/observer/sql/optimizer/optimize_stage.cpp index bb95a60..a25a42c 100644 --- a/src/observer/sql/optimizer/optimize_stage.cpp +++ b/src/observer/sql/optimizer/optimize_stage.cpp @@ -262,10 +262,10 @@ RC OptimizeStage::create_select_logical_plan( unique_ptr project_oper(new ProjectLogicalOperator(all_fields)); if (predicate_oper) { - predicate_oper->add_child(move(table_oper)); - project_oper->add_child(move(predicate_oper)); + predicate_oper->add_child(std::move(table_oper)); + project_oper->add_child(std::move(predicate_oper)); } else { - project_oper->add_child(move(table_oper)); + project_oper->add_child(std::move(table_oper)); } logical_operator.swap(project_oper); @@ -296,10 +296,10 @@ RC OptimizeStage::create_predicate_logical_plan( unique_ptr predicate_oper; if (!cmp_exprs.empty()) { unique_ptr conjunction_expr(new ConjunctionExpr(ConjunctionExpr::Type::AND, cmp_exprs)); - predicate_oper = unique_ptr(new PredicateLogicalOperator(move(conjunction_expr))); + predicate_oper = unique_ptr(new PredicateLogicalOperator(std::move(conjunction_expr))); } - logical_operator = move(predicate_oper); + logical_operator = std::move(predicate_oper); return RC::SUCCESS; } @@ -335,13 +335,13 @@ RC OptimizeStage::create_delete_logical_plan( unique_ptr delete_oper(new DeleteLogicalOperator(table)); if (predicate_oper) { - predicate_oper->add_child(move(table_get_oper)); - delete_oper->add_child(move(predicate_oper)); + predicate_oper->add_child(std::move(table_get_oper)); + delete_oper->add_child(std::move(predicate_oper)); } else { - delete_oper->add_child(move(table_get_oper)); + delete_oper->add_child(std::move(table_get_oper)); } - logical_operator = move(delete_oper); + logical_operator = std::move(delete_oper); return rc; } diff --git a/src/observer/sql/optimizer/physical_plan_generator.cpp b/src/observer/sql/optimizer/physical_plan_generator.cpp index 6b0ffc4..8546de3 100644 --- a/src/observer/sql/optimizer/physical_plan_generator.cpp +++ b/src/observer/sql/optimizer/physical_plan_generator.cpp @@ -12,6 +12,8 @@ See the Mulan PSL v2 for more details. */ // Created by Wangyunlai on 2022/12/14. // +#include + #include "sql/optimizer/physical_plan_generator.h" #include "sql/operator/table_get_logical_operator.h" #include "sql/operator/table_scan_physical_operator.h" @@ -128,12 +130,12 @@ RC PhysicalPlanGenerator::create_plan(TableGetLogicalOperator &table_get_oper, u &tuple_cell, true /*left_inclusive*/, &tuple_cell, true /*right_inclusive*/); - index_scan_oper->set_predicates(move(predicates)); + index_scan_oper->set_predicates(std::move(predicates)); oper = unique_ptr(index_scan_oper); LOG_TRACE("use index scan"); } else { auto table_scan_oper = new TableScanPhysicalOperator(table, table_get_oper.readonly()); - table_scan_oper->set_predicates(move(predicates)); + table_scan_oper->set_predicates(std::move(predicates)); oper = unique_ptr(table_scan_oper); LOG_TRACE("use table scan"); } @@ -158,9 +160,9 @@ RC PhysicalPlanGenerator::create_plan(PredicateLogicalOperator &pred_oper, uniqu vector> &expressions = pred_oper.expressions(); ASSERT(expressions.size() == 1, "predicate logical operator's children should be 1"); - unique_ptr expression = move(expressions.front()); - oper = unique_ptr(new PredicatePhysicalOperator(move(expression))); - oper->add_child(move(child_phy_oper)); + unique_ptr expression = std::move(expressions.front()); + oper = unique_ptr(new PredicatePhysicalOperator(std::move(expression))); + oper->add_child(std::move(child_phy_oper)); return rc; } @@ -187,7 +189,7 @@ RC PhysicalPlanGenerator::create_plan(ProjectLogicalOperator &project_oper, uniq } if (child_phy_oper) { - project_operator->add_child(move(child_phy_oper)); + project_operator->add_child(std::move(child_phy_oper)); } oper = unique_ptr(project_operator); @@ -200,7 +202,7 @@ RC PhysicalPlanGenerator::create_plan(InsertLogicalOperator &insert_oper, unique { Table *table = insert_oper.table(); vector &values = insert_oper.values(); - InsertPhysicalOperator *insert_phy_oper = new InsertPhysicalOperator(table, move(values)); + InsertPhysicalOperator *insert_phy_oper = new InsertPhysicalOperator(table, std::move(values)); oper.reset(insert_phy_oper); return RC::SUCCESS; } @@ -224,7 +226,7 @@ RC PhysicalPlanGenerator::create_plan(DeleteLogicalOperator &delete_oper, unique oper = unique_ptr(new DeletePhysicalOperator(delete_oper.table())); if (child_physical_oper) { - oper->add_child(move(child_physical_oper)); + oper->add_child(std::move(child_physical_oper)); } return rc; } @@ -243,10 +245,10 @@ RC PhysicalPlanGenerator::create_plan(ExplainLogicalOperator &explain_oper, uniq return rc; } - explain_physical_oper->add_child(move(child_physical_oper)); + explain_physical_oper->add_child(std::move(child_physical_oper)); } - oper = move(explain_physical_oper); + oper = std::move(explain_physical_oper); return rc; } @@ -269,9 +271,9 @@ RC PhysicalPlanGenerator::create_plan(JoinLogicalOperator &join_oper, unique_ptr return rc; } - join_physical_oper->add_child(move(child_physical_oper)); + join_physical_oper->add_child(std::move(child_physical_oper)); } - oper = move(join_physical_oper); + oper = std::move(join_physical_oper); return rc; } diff --git a/src/observer/sql/parser/lex_sql.cpp b/src/observer/sql/parser/lex_sql.cpp index a0c61d1..c8162f1 100644 --- a/src/observer/sql/parser/lex_sql.cpp +++ b/src/observer/sql/parser/lex_sql.cpp @@ -47,6 +47,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -170,6 +171,11 @@ typedef void* yyscan_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -192,11 +198,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state @@ -214,7 +215,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -293,7 +294,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); void *yyalloc (yy_size_t ,yyscan_t yyscanner ); void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); @@ -344,7 +345,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; @@ -625,7 +626,7 @@ extern double atof(); /* 1. 匹配的规则长的优先 */ /* 2. 写在最前面的优先 */ /* yylval 就可以认为是 yacc 中 %union 定义的结构体(union 结构) */ -#line 629 "lex_sql.cpp" +#line 630 "lex_sql.cpp" #define INITIAL 0 #define STR 1 @@ -655,8 +656,8 @@ struct yyguts_t size_t yy_buffer_stack_max; /**< capacity of stack. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; - int yy_n_chars; - int yyleng_r; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; @@ -713,7 +714,7 @@ FILE *yyget_out (yyscan_t yyscanner ); void yyset_out (FILE * out_str ,yyscan_t yyscanner ); -int yyget_leng (yyscan_t yyscanner ); +yy_size_t yyget_leng (yyscan_t yyscanner ); char *yyget_text (yyscan_t yyscanner ); @@ -769,7 +770,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -780,7 +781,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -868,7 +869,7 @@ YY_DECL #line 55 "lex_sql.l" -#line 872 "lex_sql.cpp" +#line 873 "lex_sql.cpp" yylval = yylval_param; @@ -1223,7 +1224,7 @@ YY_RULE_SETUP #line 113 "lex_sql.l" ECHO; YY_BREAK -#line 1227 "lex_sql.cpp" +#line 1228 "lex_sql.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(STR): yyterminate(); @@ -1411,7 +1412,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1425,7 +1426,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1456,7 +1457,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); + yyg->yy_n_chars, num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } @@ -1581,7 +1582,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -1605,7 +1606,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) case EOB_ACT_END_OF_FILE: { if ( yywrap(yyscanner ) ) - return EOF; + return 0; if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; @@ -1865,7 +1866,7 @@ void yypop_buffer_state (yyscan_t yyscanner) */ static void yyensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -1963,12 +1964,11 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; - yy_size_t n; - int i; + yy_size_t n, i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; @@ -2078,7 +2078,7 @@ FILE *yyget_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int yyget_leng (yyscan_t yyscanner) +yy_size_t yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; diff --git a/src/observer/sql/parser/lex_sql.h b/src/observer/sql/parser/lex_sql.h index c45a4d0..8ef56c6 100644 --- a/src/observer/sql/parser/lex_sql.h +++ b/src/observer/sql/parser/lex_sql.h @@ -51,6 +51,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -161,7 +162,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -205,7 +206,7 @@ void yypop_buffer_state (yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); void *yyalloc (yy_size_t ,yyscan_t yyscanner ); void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); @@ -261,7 +262,7 @@ FILE *yyget_out (yyscan_t yyscanner ); void yyset_out (FILE * out_str ,yyscan_t yyscanner ); -int yyget_leng (yyscan_t yyscanner ); +yy_size_t yyget_leng (yyscan_t yyscanner ); char *yyget_text (yyscan_t yyscanner ); @@ -341,6 +342,6 @@ extern int yylex \ #line 113 "lex_sql.l" -#line 345 "lex_sql.h" +#line 346 "lex_sql.h" #undef yyIN_HEADER #endif /* yyHEADER_H */ diff --git a/src/observer/sql/parser/yacc_sql.cpp b/src/observer/sql/parser/yacc_sql.cpp index 261aa75..f47b3f5 100644 --- a/src/observer/sql/parser/yacc_sql.cpp +++ b/src/observer/sql/parser/yacc_sql.cpp @@ -586,12 +586,12 @@ static const yytype_int16 yyrline[] = { 0, 142, 142, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, - 167, 171, 176, 181, 187, 193, 199, 205, 212, 218, - 226, 240, 250, 269, 272, 285, 293, 303, 306, 307, - 308, 311, 327, 330, 341, 346, 351, 361, 373, 388, - 411, 418, 430, 435, 446, 449, 463, 466, 479, 482, - 488, 491, 496, 503, 515, 527, 539, 554, 555, 556, - 557, 558, 559, 563, 573, 580, 581 + 167, 171, 177, 182, 188, 194, 200, 206, 213, 219, + 227, 241, 251, 270, 273, 286, 294, 304, 307, 308, + 309, 312, 328, 331, 342, 347, 352, 362, 374, 389, + 412, 419, 431, 436, 447, 450, 464, 467, 480, 483, + 489, 492, 497, 504, 516, 528, 540, 555, 556, 557, + 558, 559, 560, 564, 574, 581, 582 }; #endif @@ -1648,81 +1648,82 @@ yyreduce: case 21: /* exit: EXIT */ #line 171 "yacc_sql.y" { + (void)yynerrs; (yyval.command) = new Command(SCF_EXIT); } -#line 1654 "yacc_sql.cpp" +#line 1655 "yacc_sql.cpp" break; case 22: /* help: HELP */ -#line 176 "yacc_sql.y" +#line 177 "yacc_sql.y" { (yyval.command) = new Command(SCF_HELP); } -#line 1662 "yacc_sql.cpp" +#line 1663 "yacc_sql.cpp" break; case 23: /* sync: SYNC */ -#line 181 "yacc_sql.y" +#line 182 "yacc_sql.y" { (yyval.command) = new Command(SCF_SYNC); } -#line 1670 "yacc_sql.cpp" +#line 1671 "yacc_sql.cpp" break; case 24: /* begin: TRX_BEGIN */ -#line 187 "yacc_sql.y" +#line 188 "yacc_sql.y" { (yyval.command) = new Command(SCF_BEGIN); } -#line 1678 "yacc_sql.cpp" +#line 1679 "yacc_sql.cpp" break; case 25: /* commit: TRX_COMMIT */ -#line 193 "yacc_sql.y" +#line 194 "yacc_sql.y" { (yyval.command) = new Command(SCF_COMMIT); } -#line 1686 "yacc_sql.cpp" +#line 1687 "yacc_sql.cpp" break; case 26: /* rollback: TRX_ROLLBACK */ -#line 199 "yacc_sql.y" +#line 200 "yacc_sql.y" { (yyval.command) = new Command(SCF_ROLLBACK); } -#line 1694 "yacc_sql.cpp" +#line 1695 "yacc_sql.cpp" break; case 27: /* drop_table: DROP TABLE ID */ -#line 205 "yacc_sql.y" +#line 206 "yacc_sql.y" { (yyval.command) = new Command(SCF_DROP_TABLE); (yyval.command)->drop_table.relation_name = (yyvsp[0].string); free((yyvsp[0].string)); } -#line 1704 "yacc_sql.cpp" +#line 1705 "yacc_sql.cpp" break; case 28: /* show_tables: SHOW TABLES */ -#line 212 "yacc_sql.y" +#line 213 "yacc_sql.y" { (yyval.command) = new Command(SCF_SHOW_TABLES); } -#line 1712 "yacc_sql.cpp" +#line 1713 "yacc_sql.cpp" break; case 29: /* desc_table: DESC ID */ -#line 218 "yacc_sql.y" +#line 219 "yacc_sql.y" { (yyval.command) = new Command(SCF_DESC_TABLE); (yyval.command)->desc_table.relation_name = (yyvsp[0].string); free((yyvsp[0].string)); } -#line 1722 "yacc_sql.cpp" +#line 1723 "yacc_sql.cpp" break; case 30: /* create_index: CREATE INDEX ID ON ID LBRACE ID RBRACE */ -#line 227 "yacc_sql.y" +#line 228 "yacc_sql.y" { (yyval.command) = new Command(SCF_CREATE_INDEX); CreateIndex &create_index = (yyval.command)->create_index; @@ -1733,11 +1734,11 @@ yyreduce: free((yyvsp[-3].string)); free((yyvsp[-1].string)); } -#line 1737 "yacc_sql.cpp" +#line 1738 "yacc_sql.cpp" break; case 31: /* drop_index: DROP INDEX ID ON ID */ -#line 241 "yacc_sql.y" +#line 242 "yacc_sql.y" { (yyval.command) = new Command(SCF_DROP_INDEX); (yyval.command)->drop_index.index_name = (yyvsp[-2].string); @@ -1745,11 +1746,11 @@ yyreduce: free((yyvsp[-2].string)); free((yyvsp[0].string)); } -#line 1749 "yacc_sql.cpp" +#line 1750 "yacc_sql.cpp" break; case 32: /* create_table: CREATE TABLE ID LBRACE attr_def attr_def_list RBRACE */ -#line 251 "yacc_sql.y" +#line 252 "yacc_sql.y" { (yyval.command) = new Command(SCF_CREATE_TABLE); CreateTable &create_table = (yyval.command)->create_table; @@ -1765,19 +1766,19 @@ yyreduce: std::reverse(create_table.attr_infos.begin(), create_table.attr_infos.end()); delete (yyvsp[-2].attr_info); } -#line 1769 "yacc_sql.cpp" +#line 1770 "yacc_sql.cpp" break; case 33: /* attr_def_list: %empty */ -#line 269 "yacc_sql.y" +#line 270 "yacc_sql.y" { (yyval.attr_infos) = nullptr; } -#line 1777 "yacc_sql.cpp" +#line 1778 "yacc_sql.cpp" break; case 34: /* attr_def_list: COMMA attr_def attr_def_list */ -#line 273 "yacc_sql.y" +#line 274 "yacc_sql.y" { if ((yyvsp[0].attr_infos) != nullptr) { (yyval.attr_infos) = (yyvsp[0].attr_infos); @@ -1787,11 +1788,11 @@ yyreduce: (yyval.attr_infos)->emplace_back(*(yyvsp[-1].attr_info)); delete (yyvsp[-1].attr_info); } -#line 1791 "yacc_sql.cpp" +#line 1792 "yacc_sql.cpp" break; case 35: /* attr_def: ID type LBRACE number RBRACE */ -#line 286 "yacc_sql.y" +#line 287 "yacc_sql.y" { (yyval.attr_info) = new AttrInfo; (yyval.attr_info)->type = (AttrType)(yyvsp[-3].number); @@ -1799,11 +1800,11 @@ yyreduce: (yyval.attr_info)->length = (yyvsp[-1].number); free((yyvsp[-4].string)); } -#line 1803 "yacc_sql.cpp" +#line 1804 "yacc_sql.cpp" break; case 36: /* attr_def: ID type */ -#line 294 "yacc_sql.y" +#line 295 "yacc_sql.y" { (yyval.attr_info) = new AttrInfo; (yyval.attr_info)->type = (AttrType)(yyvsp[0].number); @@ -1811,35 +1812,35 @@ yyreduce: (yyval.attr_info)->length = 4; free((yyvsp[-1].string)); } -#line 1815 "yacc_sql.cpp" +#line 1816 "yacc_sql.cpp" break; case 37: /* number: NUMBER */ -#line 303 "yacc_sql.y" +#line 304 "yacc_sql.y" {(yyval.number) = (yyvsp[0].number);} -#line 1821 "yacc_sql.cpp" +#line 1822 "yacc_sql.cpp" break; case 38: /* type: INT_T */ -#line 306 "yacc_sql.y" +#line 307 "yacc_sql.y" { (yyval.number)=INTS; } -#line 1827 "yacc_sql.cpp" +#line 1828 "yacc_sql.cpp" break; case 39: /* type: STRING_T */ -#line 307 "yacc_sql.y" +#line 308 "yacc_sql.y" { (yyval.number)=CHARS; } -#line 1833 "yacc_sql.cpp" +#line 1834 "yacc_sql.cpp" break; case 40: /* type: FLOAT_T */ -#line 308 "yacc_sql.y" +#line 309 "yacc_sql.y" { (yyval.number)=FLOATS; } -#line 1839 "yacc_sql.cpp" +#line 1840 "yacc_sql.cpp" break; case 41: /* insert: INSERT INTO ID VALUES LBRACE value value_list RBRACE */ -#line 312 "yacc_sql.y" +#line 313 "yacc_sql.y" { (yyval.command) = new Command(SCF_INSERT); (yyval.command)->insertion.relation_name = (yyvsp[-5].string); @@ -1851,19 +1852,19 @@ yyreduce: delete (yyvsp[-2].value); free((yyvsp[-5].string)); } -#line 1855 "yacc_sql.cpp" +#line 1856 "yacc_sql.cpp" break; case 42: /* value_list: %empty */ -#line 327 "yacc_sql.y" +#line 328 "yacc_sql.y" { (yyval.value_list) = nullptr; } -#line 1863 "yacc_sql.cpp" +#line 1864 "yacc_sql.cpp" break; case 43: /* value_list: COMMA value value_list */ -#line 330 "yacc_sql.y" +#line 331 "yacc_sql.y" { if ((yyvsp[0].value_list) != nullptr) { (yyval.value_list) = (yyvsp[0].value_list); @@ -1873,31 +1874,31 @@ yyreduce: (yyval.value_list)->emplace_back(*(yyvsp[-1].value)); delete (yyvsp[-1].value); } -#line 1877 "yacc_sql.cpp" +#line 1878 "yacc_sql.cpp" break; case 44: /* value: NUMBER */ -#line 341 "yacc_sql.y" +#line 342 "yacc_sql.y" { (yyval.value) = new Value; (yyval.value)->type = INTS; (yyval.value)->int_value = (yyvsp[0].number); } -#line 1887 "yacc_sql.cpp" +#line 1888 "yacc_sql.cpp" break; case 45: /* value: FLOAT */ -#line 346 "yacc_sql.y" +#line 347 "yacc_sql.y" { (yyval.value) = new Value; (yyval.value)->type = FLOATS; (yyval.value)->float_value = (yyvsp[0].floats); } -#line 1897 "yacc_sql.cpp" +#line 1898 "yacc_sql.cpp" break; case 46: /* value: SSS */ -#line 351 "yacc_sql.y" +#line 352 "yacc_sql.y" { char *tmp = common::substr((yyvsp[0].string),1,strlen((yyvsp[0].string))-2); (yyval.value) = new Value; @@ -1905,11 +1906,11 @@ yyreduce: (yyval.value)->string_value = tmp; free(tmp); } -#line 1909 "yacc_sql.cpp" +#line 1910 "yacc_sql.cpp" break; case 47: /* delete: DELETE FROM ID where */ -#line 362 "yacc_sql.y" +#line 363 "yacc_sql.y" { (yyval.command) = new Command(SCF_DELETE); (yyval.command)->deletion.relation_name = (yyvsp[-1].string); @@ -1919,11 +1920,11 @@ yyreduce: } free((yyvsp[-1].string)); } -#line 1923 "yacc_sql.cpp" +#line 1924 "yacc_sql.cpp" break; case 48: /* update: UPDATE ID SET ID EQ value where */ -#line 374 "yacc_sql.y" +#line 375 "yacc_sql.y" { (yyval.command) = new Command(SCF_UPDATE); (yyval.command)->update.relation_name = (yyvsp[-5].string); @@ -1936,11 +1937,11 @@ yyreduce: free((yyvsp[-5].string)); free((yyvsp[-3].string)); } -#line 1940 "yacc_sql.cpp" +#line 1941 "yacc_sql.cpp" break; case 49: /* select: SELECT select_attr FROM ID rel_list where */ -#line 389 "yacc_sql.y" +#line 390 "yacc_sql.y" { (yyval.command) = new Command(SCF_SELECT); if ((yyvsp[-4].rel_attr_list) != nullptr) { @@ -1960,11 +1961,11 @@ yyreduce: } free((yyvsp[-2].string)); } -#line 1964 "yacc_sql.cpp" +#line 1965 "yacc_sql.cpp" break; case 50: /* select_attr: STAR */ -#line 411 "yacc_sql.y" +#line 412 "yacc_sql.y" { (yyval.rel_attr_list) = new std::vector; RelAttr attr; @@ -1972,11 +1973,11 @@ yyreduce: attr.attribute_name = "*"; (yyval.rel_attr_list)->emplace_back(attr); } -#line 1976 "yacc_sql.cpp" +#line 1977 "yacc_sql.cpp" break; case 51: /* select_attr: rel_attr attr_list */ -#line 418 "yacc_sql.y" +#line 419 "yacc_sql.y" { if ((yyvsp[0].rel_attr_list) != nullptr) { (yyval.rel_attr_list) = (yyvsp[0].rel_attr_list); @@ -1986,21 +1987,21 @@ yyreduce: (yyval.rel_attr_list)->emplace_back(*(yyvsp[-1].rel_attr)); delete (yyvsp[-1].rel_attr); } -#line 1990 "yacc_sql.cpp" +#line 1991 "yacc_sql.cpp" break; case 52: /* rel_attr: ID */ -#line 430 "yacc_sql.y" +#line 431 "yacc_sql.y" { (yyval.rel_attr) = new RelAttr; (yyval.rel_attr)->attribute_name = (yyvsp[0].string); free((yyvsp[0].string)); } -#line 2000 "yacc_sql.cpp" +#line 2001 "yacc_sql.cpp" break; case 53: /* rel_attr: ID DOT ID */ -#line 435 "yacc_sql.y" +#line 436 "yacc_sql.y" { (yyval.rel_attr) = new RelAttr; (yyval.rel_attr)->relation_name = (yyvsp[-2].string); @@ -2008,19 +2009,19 @@ yyreduce: free((yyvsp[-2].string)); free((yyvsp[0].string)); } -#line 2012 "yacc_sql.cpp" +#line 2013 "yacc_sql.cpp" break; case 54: /* attr_list: %empty */ -#line 446 "yacc_sql.y" +#line 447 "yacc_sql.y" { (yyval.rel_attr_list) = nullptr; } -#line 2020 "yacc_sql.cpp" +#line 2021 "yacc_sql.cpp" break; case 55: /* attr_list: COMMA rel_attr attr_list */ -#line 449 "yacc_sql.y" +#line 450 "yacc_sql.y" { if ((yyvsp[0].rel_attr_list) != nullptr) { (yyval.rel_attr_list) = (yyvsp[0].rel_attr_list); @@ -2031,19 +2032,19 @@ yyreduce: (yyval.rel_attr_list)->emplace_back(*(yyvsp[-1].rel_attr)); delete (yyvsp[-1].rel_attr); } -#line 2035 "yacc_sql.cpp" +#line 2036 "yacc_sql.cpp" break; case 56: /* rel_list: %empty */ -#line 463 "yacc_sql.y" +#line 464 "yacc_sql.y" { (yyval.relation_list) = nullptr; } -#line 2043 "yacc_sql.cpp" +#line 2044 "yacc_sql.cpp" break; case 57: /* rel_list: COMMA ID rel_list */ -#line 466 "yacc_sql.y" +#line 467 "yacc_sql.y" { if ((yyvsp[0].relation_list) != nullptr) { (yyval.relation_list) = (yyvsp[0].relation_list); @@ -2054,55 +2055,55 @@ yyreduce: (yyval.relation_list)->push_back((yyvsp[-1].string)); free((yyvsp[-1].string)); } -#line 2058 "yacc_sql.cpp" +#line 2059 "yacc_sql.cpp" break; case 58: /* where: %empty */ -#line 479 "yacc_sql.y" +#line 480 "yacc_sql.y" { (yyval.condition_list) = nullptr; } -#line 2066 "yacc_sql.cpp" +#line 2067 "yacc_sql.cpp" break; case 59: /* where: WHERE condition_list */ -#line 482 "yacc_sql.y" +#line 483 "yacc_sql.y" { (yyval.condition_list) = (yyvsp[0].condition_list); } -#line 2074 "yacc_sql.cpp" +#line 2075 "yacc_sql.cpp" break; case 60: /* condition_list: %empty */ -#line 488 "yacc_sql.y" +#line 489 "yacc_sql.y" { (yyval.condition_list) = nullptr; } -#line 2082 "yacc_sql.cpp" +#line 2083 "yacc_sql.cpp" break; case 61: /* condition_list: condition */ -#line 491 "yacc_sql.y" +#line 492 "yacc_sql.y" { (yyval.condition_list) = new std::vector; (yyval.condition_list)->emplace_back(*(yyvsp[0].condition)); delete (yyvsp[0].condition); } -#line 2092 "yacc_sql.cpp" +#line 2093 "yacc_sql.cpp" break; case 62: /* condition_list: condition AND condition_list */ -#line 496 "yacc_sql.y" +#line 497 "yacc_sql.y" { (yyval.condition_list) = (yyvsp[0].condition_list); (yyval.condition_list)->emplace_back(*(yyvsp[-2].condition)); delete (yyvsp[-2].condition); } -#line 2102 "yacc_sql.cpp" +#line 2103 "yacc_sql.cpp" break; case 63: /* condition: rel_attr comp_op value */ -#line 504 "yacc_sql.y" +#line 505 "yacc_sql.y" { (yyval.condition) = new Condition; (yyval.condition)->left_is_attr = 1; @@ -2114,11 +2115,11 @@ yyreduce: delete (yyvsp[-2].rel_attr); delete (yyvsp[0].value); } -#line 2118 "yacc_sql.cpp" +#line 2119 "yacc_sql.cpp" break; case 64: /* condition: value comp_op value */ -#line 516 "yacc_sql.y" +#line 517 "yacc_sql.y" { (yyval.condition) = new Condition; (yyval.condition)->left_is_attr = 0; @@ -2130,11 +2131,11 @@ yyreduce: delete (yyvsp[-2].value); delete (yyvsp[0].value); } -#line 2134 "yacc_sql.cpp" +#line 2135 "yacc_sql.cpp" break; case 65: /* condition: rel_attr comp_op rel_attr */ -#line 528 "yacc_sql.y" +#line 529 "yacc_sql.y" { (yyval.condition) = new Condition; (yyval.condition)->left_is_attr = 1; @@ -2146,11 +2147,11 @@ yyreduce: delete (yyvsp[-2].rel_attr); delete (yyvsp[0].rel_attr); } -#line 2150 "yacc_sql.cpp" +#line 2151 "yacc_sql.cpp" break; case 66: /* condition: value comp_op rel_attr */ -#line 540 "yacc_sql.y" +#line 541 "yacc_sql.y" { (yyval.condition) = new Condition; (yyval.condition)->left_is_attr = 0; @@ -2162,67 +2163,67 @@ yyreduce: delete (yyvsp[-2].value); delete (yyvsp[0].rel_attr); } -#line 2166 "yacc_sql.cpp" +#line 2167 "yacc_sql.cpp" break; case 67: /* comp_op: EQ */ -#line 554 "yacc_sql.y" +#line 555 "yacc_sql.y" { (yyval.comp) = EQUAL_TO; } -#line 2172 "yacc_sql.cpp" +#line 2173 "yacc_sql.cpp" break; case 68: /* comp_op: LT */ -#line 555 "yacc_sql.y" +#line 556 "yacc_sql.y" { (yyval.comp) = LESS_THAN; } -#line 2178 "yacc_sql.cpp" +#line 2179 "yacc_sql.cpp" break; case 69: /* comp_op: GT */ -#line 556 "yacc_sql.y" +#line 557 "yacc_sql.y" { (yyval.comp) = GREAT_THAN; } -#line 2184 "yacc_sql.cpp" +#line 2185 "yacc_sql.cpp" break; case 70: /* comp_op: LE */ -#line 557 "yacc_sql.y" +#line 558 "yacc_sql.y" { (yyval.comp) = LESS_EQUAL; } -#line 2190 "yacc_sql.cpp" +#line 2191 "yacc_sql.cpp" break; case 71: /* comp_op: GE */ -#line 558 "yacc_sql.y" +#line 559 "yacc_sql.y" { (yyval.comp) = GREAT_EQUAL; } -#line 2196 "yacc_sql.cpp" +#line 2197 "yacc_sql.cpp" break; case 72: /* comp_op: NE */ -#line 559 "yacc_sql.y" +#line 560 "yacc_sql.y" { (yyval.comp) = NOT_EQUAL; } -#line 2202 "yacc_sql.cpp" +#line 2203 "yacc_sql.cpp" break; case 73: /* load_data: LOAD DATA INFILE SSS INTO TABLE ID */ -#line 564 "yacc_sql.y" +#line 565 "yacc_sql.y" { (yyval.command) = new Command(SCF_LOAD_DATA); (yyval.command)->load_data.relation_name = (yyvsp[0].string); (yyval.command)->load_data.file_name = (yyvsp[-3].string); free((yyvsp[0].string)); } -#line 2213 "yacc_sql.cpp" +#line 2214 "yacc_sql.cpp" break; case 74: /* explain: EXPLAIN command_wrapper */ -#line 574 "yacc_sql.y" +#line 575 "yacc_sql.y" { (yyval.command) = new Command(SCF_EXPLAIN); (yyval.command)->explain.cmd = std::unique_ptr((yyvsp[0].command)); } -#line 2222 "yacc_sql.cpp" +#line 2223 "yacc_sql.cpp" break; -#line 2226 "yacc_sql.cpp" +#line 2227 "yacc_sql.cpp" default: break; } @@ -2452,7 +2453,7 @@ yyreturn: return yyresult; } -#line 583 "yacc_sql.y" +#line 584 "yacc_sql.y" //_____________________________________________________________________ extern void scan_string(const char *str, yyscan_t scanner); diff --git a/src/observer/sql/parser/yacc_sql.y b/src/observer/sql/parser/yacc_sql.y index b3a4210..f1afc25 100644 --- a/src/observer/sql/parser/yacc_sql.y +++ b/src/observer/sql/parser/yacc_sql.y @@ -169,6 +169,7 @@ command_wrapper: exit: EXIT { + (void)yynerrs; // 这么写为了消除yynerrs未使用的告警。如果你有更好的方法欢迎提PR $$ = new Command(SCF_EXIT); }; -- GitLab