https://bugs.documentfoundation.org/show_bug.cgi?id=118817
--- Comment #14 from Julien Nabet <[email protected]> --- (In reply to Lionel Elie Mamane from comment #9) > I think the EXTRACT function needs to be added to the SQL grammar of > LibreOffice it seems EXTRACT is known by SQL grammar, sqlbison.y:156:%token <pParseNode> SQL_TOKEN_DAYNAME SQL_TOKEN_DAYOFMONTH SQL_TOKEN_DAYOFWEEK SQL_TOKEN_DAYOFYEAR SQL_TOKEN_EXTRACT sqlbison.y:1774: SQL_TOKEN_EXTRACT '(' extract_field SQL_TOKEN_FROM value_exp ')' sqlbison.y:3877: | SQL_TOKEN_EXTRACT sqlflex.l:218:EXTRACT {SQL_NEW_KEYWORD(SQL_TOKEN_EXTRACT); } the rule which is concerned is: 2958 non_second_datetime_field: 2959 SQL_TOKEN_YEAR 2960 | SQL_TOKEN_MONTH 2961 | SQL_TOKEN_DAY 2962 | SQL_TOKEN_HOUR 2963 | SQL_TOKEN_MINUTE 2964 ; (see https://opengrok.libreoffice.org/xref/core/connectivity/source/parse/sqlbison.y?r=e469a171#2958) We could add SQL_TOKEN_WEEK, SQL_TOKEN_WEEKDAY, SQL_TOKEN_YEARDAY and SQL_TOKEN_MILLISECOND but it would be wrong for HSQLDB. I gave a try, just for "WEEK", with this patch: diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 0c5d359d083e..f50d136782ab 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -2958,6 +2958,7 @@ interval_value_exp: non_second_datetime_field: SQL_TOKEN_YEAR | SQL_TOKEN_MONTH + | SQL_TOKEN_WEEK | SQL_TOKEN_DAY | SQL_TOKEN_HOUR | SQL_TOKEN_MINUTE in hsqldb, the query can be saved but when executing it, we got this: SQL Status: 37000 Error code: -11 Unexpected token: WEEK in statement [SELECT EXTRACT( WEEK FROM "test" ) AS "Year" FROM "Table2"] at /home/julien/lo/libreoffice/connectivity/source/drivers/jdbc/Object.cxx:172 as expected of course. With Firebird example from Drew, it works. So should we go ahead with this patch (+ adding the other missing Extract elements) or is there some other way? -- You are receiving this mail because: You are the assignee for the bug.
