[MDEV-26853] Confusing row numbers upon ER_TRUNCATED_WRONG_VALUE with ROLLUP Created: 2021-10-18  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Trivial
Reporter: Elena Stepanova Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Blocks
is blocked by MDEV-27143 Different result when group by with c... Open

 Description   

create table t (c int);
insert into t values (20121212),(9),(19800101),(20121212),(19800101);
select c, count(*) from t group by convert(c, date) desc with rollup;
 
# Cleanup
drop table t;

10.2 ceb40ef4

+----------+----------+
| c        | count(*) |
+----------+----------+
| 20121212 |        2 |
| 19800101 |        2 |
|        9 |        1 |
|        9 |        5 |
+----------+----------+
4 rows in set, 3 warnings (0.002 sec)
 
MariaDB [test]> show warnings;
+---------+------+------------------------------------------------------------------+
| Level   | Code | Message                                                          |
+---------+------+------------------------------------------------------------------+
| Warning | 1292 | Incorrect datetime value: '9' for column `test`.`t`.`c` at row 1 |
| Warning | 1292 | Incorrect datetime value: '9' for column `test`.`t`.`c` at row 5 |
| Warning | 1292 | Incorrect datetime value: '9' for column `test`.`t`.`c` at row 5 |
+---------+------+------------------------------------------------------------------+
3 rows in set (0.000 sec)

Maybe the values are even correct from the internal perspective, but they look rather weird.

ROW_NUMBER from MDEV-10075 in 10.7 returns the same value as included in the error message.

The test case is a bit artificial, it's because the error messages contain the row number only in some specific cases. For example, this one doesn't display row numbers, even though according to ROW_NUMBER from MDEV-10075, at least in 10.7 they are the same as above:

MariaDB [test]> create table t (c varchar(10));
ERROR 1050 (42S01): Table 't' already exists
MariaDB [test]> create or replace table t (c varchar(10));
Query OK, 0 rows affected (0.074 sec)
 
MariaDB [test]> insert into t values ('2012-12-12'),('foo'),('1980-01-01'),('2012-12-12'),('1980-01-01');
Query OK, 5 rows affected (0.015 sec)
Records: 5  Duplicates: 0  Warnings: 0
 
MariaDB [test]> select c, count(*) from t group by convert(c, date) desc with rollup;
+------------+----------+
| c          | count(*) |
+------------+----------+
| 2012-12-12 |        2 |
| 1980-01-01 |        2 |
| foo        |        1 |
| foo        |        5 |
+------------+----------+
4 rows in set, 3 warnings (0.002 sec)

MariaDB [test]> show warnings;
+---------+------+---------------------------------+
| Level   | Code | Message                         |
+---------+------+---------------------------------+
| Warning | 1292 | Incorrect datetime value: 'foo' |
| Warning | 1292 | Incorrect datetime value: 'foo' |
| Warning | 1292 | Incorrect datetime value: 'foo' |
+---------+------+---------------------------------+
3 rows in set (0.000 sec)

bb-10.7-row_number c27f04ede5

MariaDB [test]> get diagnostics condition 1 @n1 = row_number;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> get diagnostics condition 2 @n2 = row_number;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> get diagnostics condition 3 @n3 = row_number;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> select @n1, @n2, @n3;
+------+------+------+
| @n1  | @n2  | @n3  |
+------+------+------+
|    1 |    5 |    5 |
+------+------+------+
1 row in set (0.001 sec)



 Comments   
Comment by Marco Zhang [ 2021-11-26 ]

Hi,Stepanova
I meet the similar situation like you ,I think the value of the filed c in rowup should be NULL whatever the sql command with or without convert,right?

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