[MDEV-23625] Specifying a space before the parenthesis can break some built-in functions Created: 2020-08-28  Updated: 2020-09-02  Resolved: 2020-09-02

Status: Closed
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.2.33, 10.3.24, 10.4.14, 10.5.5
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Ralf Gebhardt
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

If you specify a space before the parenthesis, then some built-in functions will fail.

For example, see TRIM():

MariaDB [(none)]> SELECT TRIM ( 'foo' );
ERROR 1305 (42000): FUNCTION TRIM does not exist
MariaDB [(none)]> SELECT TRIM( 'foo' );
+---------------+
| TRIM( 'foo' ) |
+---------------+
| foo           |
+---------------+
1 row in set (0.000 sec)

And NOW():

MariaDB [(none)]> SELECT NOW ();
ERROR 1305 (42000): FUNCTION NOW does not exist
MariaDB [(none)]> SELECT NOW();
+---------------------+
| NOW()               |
+---------------------+
| 2020-08-28 23:02:43 |
+---------------------+
1 row in set (0.005 sec)

However, some built-in functions seem to work just fine in this case.

For example, see TRUNCATE():

MariaDB [(none)]> SELECT TRUNCATE ( 0.01, 2 );
+----------------------+
| TRUNCATE ( 0.01, 2 ) |
+----------------------+
|                 0.01 |
+----------------------+
1 row in set (0.000 sec)
MariaDB [(none)]> SELECT TRUNCATE(0.01, 2);
+-------------------+
| TRUNCATE(0.01, 2) |
+-------------------+
|              0.01 |
+-------------------+
1 row in set (0.000 sec)



 Comments   
Comment by Elena Stepanova [ 2020-08-28 ]

This is an old (and unarguably very unfortunate) legacy.
https://dev.mysql.com/doc/refman/8.0/en/function-resolution.html

Comment by Sergei Golubchik [ 2020-08-29 ]

Also, in KB: https://mariadb.com/kb/en/sql-mode/#ignore_space

Generated at Thu Feb 08 09:23:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.