[MDEV-30774] RPAD result varies on row order Created: 2023-03-02  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.5.17, 10.3, 10.4, 11.0.1, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Timo Raitalaakso Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: wrong_result


 Description   

RPAD result incorrect on following first example. Desired result on the second run wher result order different.
{{Server version: 11.0.1-MariaDB-1:11.0.1+maria~ubu2204 mariadb.org binary distribution

MariaDB [beta]> select rpad('zzz',length(a),'*'),a
-> from (
-> select 'a' a union select 'bb' union select 'cccc'
-> ) as a
-> order by a
-> ;
-------------------------------+

rpad('zzz',length(a),'*') a

-------------------------------+

z a
z* bb
z*** cccc

-------------------------------+
3 rows in set (0.001 sec)

MariaDB [beta]> select rpad('zzz',length(a),'*'),a
-> from (
-> select 'a' a union select 'bb' union select 'cccc'
; -> ) as a
-> order by a desc
-> ;
-------------------------------+

rpad('zzz',length(a),'*') a

-------------------------------+

zzz* cccc
zz bb
z a

-------------------------------+
3 rows in set (0.001 sec)}}



 Comments   
Comment by Alice Sherepa [ 2023-03-02 ]

Thanks! I repeated on 10.3-10.11:

MariaDB [test]> select rpad('zzz',seq,'*'),seq from seq_1_to_5 ;
+---------------------+-----+
| rpad('zzz',seq,'*') | seq |
+---------------------+-----+
| z                   |   1 |
| z*                  |   2 |
| z**                 |   3 |
| z***                |   4 |
| z****               |   5 |
+---------------------+-----+
5 rows in set (0,000 sec)
 
MariaDB [test]> select rpad('zzz',5,'*') ;
+-------------------+
| rpad('zzz',5,'*') |
+-------------------+
| zzz**             |
+-------------------+
1 row in set (0,000 sec)
 
MariaDB [test]> select lpad('zzz',seq,'*'),seq from seq_1_to_5 ;
+---------------------+-----+
| lpad('zzz',seq,'*') | seq |
+---------------------+-----+
| z                   |   1 |
| *z                  |   2 |
| **z                 |   3 |
| ***z                |   4 |
| ****z               |   5 |
+---------------------+-----+
5 rows in set (0,000 sec)

Generated at Thu Feb 08 10:18:47 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.