WL#3565: Functions call with IGNORE_SPACE
Affects: Server-5.1
—
Status: Complete
This Work Log is to track an incompatible change introduced by the fix for BUG#21114. The current implementation of SQL_MODE=IGNORE_SPACE is causing undesirable side effects in the parser, as noted in BUG#21114. To fix the bug correctly, the parser need to *not* honor IGNORE_SPACE, but to rely on context so that the following syntaxes : - "foo" "(" - "foo""(" will both refer to the same function when a function call is expected, or will both refer to the proper construct (like "CREATE TABLE foo (..." or "REFECENCES foo (" when a function call is not expected, regardless of the SQL_MODE used (with or without IGNORE_SPACE) In the long term, the SQL_MODE IGNORE_SPACE needs to be obsoleted, but this is not the scope of the present Work Log. For the functions impacted by the implementation of BUG#21114, the fix introduces the following incompatible change: for code that : - would run only with IGNORE_SPACE=FALSE - would use the "foo" "(" syntax to refer to a stored function foo, as opposed to the native MySQL function foo - would fail to run in IGNORE_SPACE=TRUE mode (ANSI, TRADITIONAL, all the other vendors) Such code will need to be changed to use a db.foo() syntax to refer to the stored function, and foo() to refer to the native function (unless SQL PATH is implemented, which is another Work Log).
Fixing this work log consist of limiting the effect of the implementation of SQL_MODE=IGNORE_SPACE. There is impact on: - the lexical parser - the syntactic parser - the item creation process used by the parser (item_create.cc) In sql/lex.h, the array : static SYMBOL sql_functions[] = { { "ADDDATE", SYM(ADDDATE_SYM)}, { "BIT_AND", SYM(BIT_AND)}, ... must be reduced. The lexical parser must *not* return different tokens for functions, and must return an "identifier" token instead. The bison grammar must be changed to treat UDF, Stored Functions and Native functions with the *same* rule, since the *syntax* of the call is identical. The logic involved on the action is responsible for creating the correct item based on the function name. Today, the action must resolve functions in this order: - Native functions - User Defined Functions - Stored Functions to maintain the current behavior. SQL PATH (WL#2128) may change that name resolution when implemented. BUG#21114 fixes *most* functions but not *all* of them. Fixed by Bug21114: 191 native functions Remaining issues : 34 entries in sql_functions[] in lex.h Documentation impact for WL#3565 ================================ 1) Incompatible change All the functions listed in sql/item_create.cc, in the following array: static Native_func_registry func_array[] = ... (191 entries) do *not* honor IGNORE_SPACE, For any user running with SQL_MODE=IGNORE_SPACE, which is the default in most cases, no changes are needed. For any user running with the SQL_MODE IGNORE_SPACE *not* set, any user code that would declare a stored function using a name in this list (example: ABS, X, Y), and call this stored function using the syntax "select abs (...)" need to: - either rename the stored function, and change all calls - or change the invocation to use the syntax "select db.abs(...)" 2) SQL_MODE=IGNORE_SPACE This mode now only affect a very limited list of functions names. The functions affected are listed in sql/lex.h, in the following array : static SYMBOL sql_functions[] = ... (34 entries) Note that the previous documentation for SQL_MODE=IGNORE space was incorrect, since some functions even before the change were not honoring this mode in the parser. 3) Sections in the doc This list does not intend to be complete, only the known area affected are listed. http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
The following describes the changes introduced by BUG#21114 Before the change, A) MySQL native functions Depending on the exact name of the function, 1 or more of the following could happen for a given name: - "foo" "(" was always interpreted by the parser as a function call - "foo""(", depending on the sql_mode (IGNORE_SPACE), was: - sometime a native function call, - sometime a UDF, - sometime a stored function in the current
Copyright (c) 2000, 2024, Oracle Corporation and/or its affiliates. All rights reserved.