[MDEV-15630] uuid() function evaluates at wrong time in query Created: 2018-03-22  Updated: 2018-04-03  Resolved: 2018-04-03

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 5.5, 10.0, 10.1, 10.2.13, 10.2, 10.3
Fix Version/s: 5.5.60, 10.0.35, 10.1.33, 10.2.15, 10.3.6

Type: Bug Priority: Major
Reporter: Martin Häcker Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: upstream-fixed
Environment:

Darwin crest.fritz.box 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64


Issue Links:
Relates
relates to MDEV-15624 Changing the default character set to... Closed

 Description   

The following code returns one uuid with count 10 instead of 10 uuids with count 1 for each line.

mysql test --execute 'select count(1), uuid() as uid from seq_0_to_9 group by uid;'

This seems as if the uuid function is only ever actually called once, instead of once for each element in the sequence.

This does not happen fi you leave of the group by like this:

mysql yeepa_test --execute 'select seq, uuid() as uid from seq_0_to_9;'

To my understanding this is wrong and the sequence should return 10 uuids with a count of one each.



 Comments   
Comment by Martin Häcker [ 2018-03-28 ]

Hi there, can you reproduce this?

Comment by Elena Stepanova [ 2018-04-01 ]

Reproducible on MariaDB 5.5-10.3 and MySQL 5.5-5.7. Not reproducible on MySQL 8.0.

cvicentiu, bar, see also MDEV-15624, so that you don't do double work.

Comment by Alexander Barkov [ 2018-04-03 ]

The same problem is repeatable with a real table instead of a sequence:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT COUNT(1), UUID() as uid FROM t1 GROUP BY uid;

+----------+--------------------------------------+
| COUNT(1) | uid                                  |
+----------+--------------------------------------+
|        3 | 339b0600-3735-11e8-95ee-902b3433f757 |
+----------+--------------------------------------+

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