[MDEV-8109] unexpected CAST result Created: 2015-05-06 Updated: 2022-09-12 Resolved: 2022-09-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | OTHER |
| Affects Version/s: | 10.0.17 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Mikhail Gavrilov | Assignee: | Alexander Barkov |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | cast, types | ||
| Environment: |
Linux |
||
| Attachments: |
|
||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||
| Sprint: | 10.1.8-3, 10.1.8-4, 10.1.9-3 | ||||||||||||||||||||||||
| Description |
|
More expected that result '' + 0 and CAST('' AS DECIMAL(10,2)) would be same.
|
| Comments |
| Comment by Mikhail Gavrilov [ 2015-05-06 ] | ||||||||||||||||||||||||
|
I am prefer that COLUMN_GET(@aaa, 'price' AS DECIMAL) considered all illegal decimal as 0 | ||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2015-05-06 ] | ||||||||||||||||||||||||
|
Hi Mikhail, Could you please clarify what is the "major complaint" here? I understand you have a concern about '' + 0 vs CAST('' AS DECIMAL(10,2)) (the latter produces a warning/error, and the former does not); but it doesn't explain the presence of dynamic column operations in the description. At the same time if the major problem is what you mentioned in the comment, then it's not clear how it relates to all other statements. If you have several concerns that you wanted to group in this report, could you please state clearly which results you consider wrong, and what you expect instead? Thanks. | ||||||||||||||||||||||||
| Comment by Mikhail Gavrilov [ 2015-05-07 ] | ||||||||||||||||||||||||
|
I'm very disappointed because I can retrieve data in the right type from dynamic column to the application server.
But I can't extract the data in the correct type for user defined SQL functions.
| ||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2015-05-07 ] | ||||||||||||||||||||||||
|
The first one also doesn't go totally smoothly, it actually produces a warning:
But I agree that the behavior is inconsistent. bar, | ||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2015-06-15 ] | ||||||||||||||||||||||||
|
The problem happens because stored procedure (SP) variables, including parameters, use the Field class under the hood to store values and thus copy behavior from table fields. So this example query fails:
because there is a Field_new_decimal that stands behind the 'par_aaa' parameter of the function. Field::store() should check field->table->s->db_plugin to distinguish between a real table field and a SP variable, to decide whether escalate a warning to an error in case of strict mode. However, there are some open questions: 1. Some tests in mysql-test/t/* (e.g. sp-vars.test) rely on this behavior of SP variables. 2. Currently some Field_xxx:::val_xxx() can escalate warnings to errors, even if the value of the field is not going into some other field. This issue should be studying carefully. 3. It's not clear what to do when an SP variable is assigned to a field and the other way around:
Which of them should translate warnings to errors? Perhaps only the former should. 4. We believe that MDEV-8300 should be fixed in the same version with this issue, for consistent behavior and flexibility. Summary: this change would be too huge and dangerous for 10.0. | ||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2015-07-15 ] | ||||||||||||||||||||||||
|
Bar proposed that for the explicit column conversion in this script:
the correct behavior would be:
Sergei replied:
| ||||||||||||||||||||||||
| Comment by Mohit Chandel [ 2017-09-07 ] | ||||||||||||||||||||||||
|
Hi, I think that I am also affected by this Bug. I have an event which basically does the following:
Issue is that my warnings are being converted into error and my event is not being executed.
| ||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2017-09-13 ] | ||||||||||||||||||||||||
|
Mohit, can you please paste SHOW CREATE TABLE for t1, t2 and t3? | ||||||||||||||||||||||||
| Comment by Mohit Chandel [ 2017-09-13 ] | ||||||||||||||||||||||||
|
Hi Alexander, I have uploaded actual create table and the event to ftp.askmonty.org/private. File name is | ||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2017-09-14 ] | ||||||||||||||||||||||||
|
Can you please also send the structure for a_alarm_code to bar@mariadb.org? | ||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2022-09-12 ] | ||||||||||||||||||||||||
|
10.0 was EOLed in March 2019 |