Bug #114315 Field_name has one more space when using ignore_space

Submitted: 12 Mar 2024 9:16 Modified: 12 Mar 2024 9:54
Reporter: hao chen Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Information schema Severity:S2 (Serious)
Version:8.0.25 8.0.30 OS:Any
Assigned to: CPU Architecture:Any
Tags: IGNORE_SPACE, SQL_MODE, whitespace

[12 Mar 2024 9:16] hao chen
Description:
Field_name has one more space when setting sql_mode=ignore_space.

How to repeat:
➜  ~ mysql -uroot --column-type-info

mysql> set sql_mode='ignore_space';
mysql> select current_timestamp from dual;
Field   1:  `current_timestamp `   <--one more whitespace
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       DATETIME
Collation:  binary (63)
Length:     19
Max_length: 19
Decimals:   0
Flags:      NOT_NULL BINARY

+---------------------+
| current_timestamp   |
+---------------------+
| 2024-03-12 17:00:36 |
+---------------------+
1 row in set (0.00 sec)

mysql> set sql_mode='STRICT_TRANS_TABLES';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> select current_timestamp from dual;
Field   1:  `current_timestamp`   <-- no whitespace
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       DATETIME
Collation:  binary (63)
Length:     19
Max_length: 19
Decimals:   0
Flags:      NOT_NULL BINARY

+---------------------+
| current_timestamp   |
+---------------------+
| 2024-03-12 17:02:05 |
+---------------------+
1 row in set (0.00 sec)

Suggested fix:
I have read the mysql refernece manual section about ignore_space: 'Permit spaces between a function name and the ( character. '.The above phenomenon is inconsistent with this description and will lead to error when getting value by actual field_name.

FIX: right trim whitespace if no spectified alias
[12 Mar 2024 9:54] MySQL Verification Team
Hello hao chen,

Thank you for the report and test case.

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.