connectivity/source/parse/sqlbison.y |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

New commits:
commit 016a58d2f586d05fa0b0df433a7695ab2952a37b
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sat Apr 25 15:30:19 2020 +0200
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Sun Apr 26 12:56:17 2020 +0200

    tdf#132385: sql parser: don't drop clauses from window specification
    
    bison rule
    
    window_specification:
            '(' window_specification_details ')'
            {
                    $$ = SQL_NEW_RULE;
                    $$->append(newNode("(", SQLNodeType::Punctuation));
                    $$->append($2);
                    $$->append(newNode(")", SQLNodeType::Punctuation));
            }
            ;
    
    makes it look like rule "window_specification_details" is a single
    node, but in reality it is a sequence of four nodes:
    
    window_specification_details:
            opt_existing_window_name
            opt_window_partition_clause
            opt_order_by_clause
            opt_window_frame_clause
            ;
    
    The result is that only the "opt_existing_window_name" clause was
    being put in the parse tree, and the other three were simply
    discarded.
    
    Since that will forever be a trap, and this is the only place
    where window_specification_details is used, we inline it into
    window_specification and remove it.
    
    Change-Id: I568904355174d2bc36155bde1d4dd09f57759cd2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92894
    Reviewed-by: Lionel Elie Mamane <lio...@mamane.lu>
    Tested-by: Jenkins

diff --git a/connectivity/source/parse/sqlbison.y 
b/connectivity/source/parse/sqlbison.y
index 1d9a0d36a36d..d14f36e7794f 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -250,7 +250,7 @@ using namespace connectivity;
 %type <pParseNode> window_function window_function_type ntile_function 
number_of_tiles lead_or_lag_function lead_or_lag lead_or_lag_extent offset 
default_expression null_treatment
 %type <pParseNode> first_or_last_value_function first_or_last_value 
nth_value_function nth_row from_first_or_last window_name_or_specification 
in_line_window_specification opt_lead_or_lag_function
 %type <pParseNode> opt_null_treatment opt_from_first_or_last 
simple_value_specification dynamic_parameter_specification window_name 
window_clause window_definition_list window_definition
-%type <pParseNode> new_window_name window_specification_details 
existing_window_name window_partition_clause 
window_partition_column_reference_list window_partition_column_reference 
window_frame_clause
+%type <pParseNode> new_window_name existing_window_name 
window_partition_clause window_partition_column_reference_list 
window_partition_column_reference window_frame_clause
 %type <pParseNode> window_frame_units window_frame_extent window_frame_start 
window_frame_preceding window_frame_between window_frame_bound_1 
window_frame_bound_2 window_frame_bound window_frame_following 
window_frame_exclusion
 %type <pParseNode> opt_window_frame_clause opt_window_partition_clause 
opt_existing_window_name window_specification opt_window_frame_exclusion 
opt_window_clause opt_offset
 %type <pParseNode> opt_fetch_first_row_count fetch_first_clause 
offset_row_count fetch_first_row_count first_or_next row_or_rows 
opt_result_offset_clause result_offset_clause
@@ -2202,11 +2202,19 @@ new_window_name:
        window_name
        ;
 window_specification:
-       '(' window_specification_details ')'
+       '('
+               opt_existing_window_name
+               opt_window_partition_clause
+               opt_order_by_clause
+               opt_window_frame_clause
+       ')'
        {
                $$ = SQL_NEW_RULE;
                $$->append(newNode("(", SQLNodeType::Punctuation));
                $$->append($2);
+               $$->append($3);
+               $$->append($4);
+               $$->append($5);
                $$->append(newNode(")", SQLNodeType::Punctuation));
        }
        ;
@@ -2222,12 +2230,6 @@ opt_window_frame_clause:
        /* empty */      {$$ = SQL_NEW_RULE;}
        |       window_frame_clause
        ;
-window_specification_details:
-       opt_existing_window_name
-       opt_window_partition_clause
-       opt_order_by_clause
-       opt_window_frame_clause
-       ;
 existing_window_name:
        window_name
        ;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to