Bug #22687 Functions UNIQUE_USERS, GROUP_UNIQUE_USERS
Submitted: 25 Sep 2006 22:07 Modified: 16 Jan 2007 20:40
Reporter: Marc ALFF Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1 BK OS:Linux (Linux)
Assigned to: Marc ALFF CPU Architecture:Any
Tags: rt_q1_2007

[25 Sep 2006 22:07] Marc ALFF
Description:
There appear to be several issues with these functions.

1) They are not documented
2) They are not covered by the test suite
3) The implementation, using hard-coded litterals for parameters,
has limitations explained in Bug#22694
4) Having a different name for the aggregate / non aggregate function
is inconsistent with other functions.

Expected result:
Either complete the implementation, including review, tests, and documentation,
or remove from the code base.

How to repeat:
select UNIQUE_USERS(?, ?, ?, ?) from T group by GROUP_UNIQUE_USERS(?, ?, ?, ?);

Suggested fix:
See expected result
[25 Sep 2006 22:10] Marc ALFF
Description:
There appear to be several issues with these functions.

1) They are not documented
2) They are not covered by the test suite
3) The implementation, using hard-coded litterals for parameters,
has limitations explained in Bug#22684
4) Having a different name for the aggregate / non aggregate function
is inconsistent with other functions.

Expected result:
Either complete the implementation, including review, tests, and documentation,
or remove from the code base.

How to repeat:
select UNIQUE_USERS(?, ?, ?, ?) from T group by GROUP_UNIQUE_USERS(?, ?, ?, ?);

Suggested fix:
See expected result
[26 Sep 2006 8:15] Sveta Smirnova
Thank you for the report.

Could you please provide working test case for this bug?
[26 Sep 2006 14:36] Marc ALFF
Sorry for the double submission, I tried to edit the submission to fix the bug referenced, but a new post was done instead.

Tests cases below

mysql> select version();
+-----------------------+
| version()             |
+-----------------------+
| 5.1.12-beta-debug-log |
+-----------------------+
1 row in set (0.00 sec)

mysql> select UNIQUE_USERS("foo", 2, 3, 4);
+------------------------------+
| UNIQUE_USERS("foo", 2, 3, 4) |
+------------------------------+
|                            0 |
+------------------------------+
1 row in set (0.00 sec)

mysql> select UNIQUE_USERS("foo", 2, 3, 4, 5, 6);
+------------------------------------+
| UNIQUE_USERS("foo", 2, 3, 4, 5, 6) |
+------------------------------------+
|                                  0 |
+------------------------------------+
1 row in set (0.00 sec)

mysql> select GROUP_UNIQUE_USERS("foo", 2, 3, 4);
+------------------------------------+
| GROUP_UNIQUE_USERS("foo", 2, 3, 4) |
+------------------------------------+
|                                  0 |
+------------------------------------+
1 row in set (0.00 sec)
[26 Sep 2006 18:28] Sveta Smirnova
Verified as described on Linux.
[21 Dec 2006 20:19] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/17279

ChangeSet@1.2361, 2006-12-21 13:18:43-07:00, malff@weblab.(none) +11 -0
  Bug#22687 (Functions UNIQUE_USERS, GROUP_UNIQUE_USERS)
  
  The native functions UNIQUE_USERS and GROUP_UNIQUE_USERS are basically
  dead code:
  - they are not documented
  - they are not tested
  - they are not properly implemented (input arguments are not expressions)
  - they have no functional use (arguments are ignored, the result is always 0)
  - they pollute the parser, by making the two names reserved keywords
  
  This fix removes the implementation from the code base, to improve the
  general code health.
[11 Jan 2007 17:44] Peter Gulutzan
I can't find references to these functions in the manuals for
Oracle, SQL Server, or DB2. They're certainly not standard.
I approve of removing support for them.
[11 Jan 2007 19:08] Tomash Brechko
Reviewed by e-mail.
[11 Jan 2007 21:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/17998

ChangeSet@1.2361, 2007-01-11 14:58:05-07:00, malff@weblab.(none) +11 -0
  Bug#22687 (Functions UNIQUE_USERS, GROUP_UNIQUE_USERS)
  
  According to some internal communication, these two functions are place
  holders for future enhancements. Because they use a variable number of
  parameters, the implementation defined a reserved keyword for them in the
  parser grammar.
  
  Unfortunately, doing so creates a bug similar to Bug 21114 reported for the
  function FORMAT.
  
  In the 5.1 code base, due to improvements in the code implemented with bug
  21114, having a reserved keyword for functions with a variable number of
  arguments is not needed any more by the implementation.
  
  As a result, this fix removes the place-holder implementation, and removes
  the unnecessary reserved keywords. Should the functions UNIQUE_USERS and
  GROUP_UNIQUE_USERS be finally implemented in a later release, the
  implementation should sub class Create_native_func in sql/item_create.cc.
  For example, see the class Create_func_concat.
[16 Jan 2007 20:40] Paul DuBois
Noted in 5.1.15 changelog.

The (undocumented) UNIQUE_USERS() and and GROUP_UNIQUE_USERS()
functions were removed.