[MDEV-12478] CONCAT function inside view casts values incorrectly with Oracle sql_mode Created: 2017-04-10  Updated: 2020-08-25  Resolved: 2017-04-12

Status: Closed
Project: MariaDB Server
Component/s: Parser, Views
Affects Version/s: 10.2.5
Fix Version/s: 10.3.0

Type: Bug Priority: Major
Reporter: Will Fong Assignee: Alexander Barkov
Resolution: Fixed Votes: 1
Labels: None


 Description   

With Oracle sql_mode enabled, we're seeing CONCAT() function cast strings as numbers (integer and doubles) only inside a view:

MariaDB [test]> SELECT VERSION();
+----------------+
| VERSION()      |
+----------------+
| 10.2.5-MariaDB |
+----------------+
1 row in set (0.00 sec)
 
MariaDB [test]> SELECT @@sql_mode;
+-------------------------------------------------------------------------------------------+
| @@sql_mode                                                                                |
+-------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> SELECT CONCAT('FOO','BAR');
+---------------------+
| CONCAT('FOO','BAR') |
+---------------------+
| FOOBAR              |
+---------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> CREATE OR REPLACE VIEW t AS SELECT CONCAT('FOO','BAR');
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> SELECT * FROM t;
+---------------------+
| CONCAT('FOO','BAR') |
+---------------------+
| FOOBAR              |
+---------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> SET sql_mode='Oracle';
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> SELECT CONCAT('FOO','BAR');
+---------------------+
| CONCAT('FOO','BAR') |
+---------------------+
| FOOBAR              |
+---------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> CREATE OR REPLACE VIEW t AS SELECT CONCAT('FOO','BAR');
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> SELECT * FROM t;
+---------------------+
| CONCAT('FOO','BAR') |
+---------------------+
|                   0 |
+---------------------+
1 row in set, 4 warnings (0.00 sec)
 
MariaDB [test]> SHOW WARNINGS;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'FOO' |
| Warning | 1292 | Truncated incorrect INTEGER value: 'BAR' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'FOO'  |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'BAR'  |
+---------+------+------------------------------------------+
4 rows in set (0.00 sec)
 
MariaDB [test]> 



 Comments   
Comment by Alexander Barkov [ 2017-04-11 ]

Pushed into bb-10.2-compatibility.

Comment by Alexander Barkov [ 2017-04-12 ]

Merged to 10.3.

Generated at Thu Feb 08 07:58:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.