[MDEV-19892] LEAD and LAG return binary data on text fields Created: 2019-06-27  Updated: 2019-06-27  Resolved: 2019-06-27

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.3.7
Fix Version/s: 10.3.16

Type: Bug Priority: Minor
Reporter: Cristian Scutaru Assignee: Anel Husakovic
Resolution: Cannot Reproduce Votes: 0
Labels: lag, lead,
Environment:

Windows 10



 Description   

Repro: try a LEAD(field, 1) or LAG(field, 1) OVER(), where field is text, not number --> the result will likely be some BINARY data, instead of some legit text field values, as expected.



 Comments   
Comment by Alice Sherepa [ 2019-06-27 ]

I could not repeat it on 10.3.7, ubuntu 16.04. It might be also dependent on configuration. Please note also that LEAD and LAG should have ORDER BY. On 10.3.16 such query returns "ERROR 4018 (HY000): No order list in window specification for 'lead'"

MariaDB [test]> create table t1 (f text);
Query OK, 0 rows affected (0.045 sec)
 
MariaDB [test]> insert into t1 values ('text'),('foo'),('abc');
Query OK, 3 rows affected (0.007 sec)
Records: 3  Duplicates: 0  Warnings: 0
 
MariaDB [test]> select lead(f,1) over () from t1;
+-------------------+
| lead(f,1) over () |
+-------------------+
| NULL              |
| text              |
| foo               |
+-------------------+
3 rows in set (0.002 sec)
 
MariaDB [test]> select version();
+----------------+
| version()      |
+----------------+
| 10.3.7-MariaDB |
+----------------+
1 row in set (0.000 sec)
 
MariaDB [test]> select lag(f,1) over () from t1;
+------------------+
| lag(f,1) over () |
+------------------+
| foo              |
| abc              |
| NULL             |
+------------------+
3 rows in set (0.001 sec)

Comment by Cristian Scutaru [ 2019-06-27 ]

yes, it had ORDER BY.

I also tried this: https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=b10144c945758b92ba02dd37e3bc67de

it says MariaDB 10.3 and it worked.

with t1 as (select 'a1' AS "name"
UNION SELECT 'a2'
UNION SELECT 'a3')

SELECT lag(name, 1) over (order by name) from t1;

-------------------------------------------------------------------
I'll install now 10.3.16 and try again.

I'll close the issue if no repro.

Comment by Cristian Scutaru [ 2019-06-27 ]

ok, so on the same Windows 10 with v10.3.16 I got the same wrong result.

but v10.3.16 newly installed on a Windows 7 computer worked fine.

it could be a config issue on my Win 10 computer, I'd love to find out what...

but anyway, I'd say no repro and close the issue.

Comment by Anel Husakovic [ 2019-06-27 ]

Hi cristiscu,
so if you are ok to close the issue, why changing the priority level ?

Comment by Cristian Scutaru [ 2019-06-27 ]

because we determined this happened only on my computer, so it's not Critical anymore.

...I don't know how to close it anyway, do I have the rights? could someone do it?

Comment by Anel Husakovic [ 2019-06-27 ]

Ok thank you, I will close it for you.
Thanks!

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