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.
parent c5586269
...@@ -51,7 +51,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \ ...@@ -51,7 +51,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
hostname.cc init.cc password.c \ hostname.cc init.cc password.c \
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \ item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \ item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
item_geofunc.cc item_uniq.cc item_subselect.cc item_row.cc\ item_geofunc.cc item_subselect.cc item_row.cc\
item_xmlfunc.cc \ item_xmlfunc.cc \
key.cc lock.cc log.cc log_event.cc sql_state.c \ key.cc lock.cc log.cc log_event.cc sql_state.c \
protocol.cc net_serv.cc opt_range.cc \ protocol.cc net_serv.cc opt_range.cc \
......
...@@ -49,7 +49,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -49,7 +49,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
create table GROUP_CONCAT (a int); create table GROUP_CONCAT (a int);
drop table GROUP_CONCAT; drop table GROUP_CONCAT;
create table GROUP_UNIQUE_USERS(a int); create table GROUP_UNIQUE_USERS(a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP_UNIQUE_USERS(a int)' at line 1 drop table GROUP_UNIQUE_USERS;
create table GROUP_UNIQUE_USERS (a int); create table GROUP_UNIQUE_USERS (a int);
drop table GROUP_UNIQUE_USERS; drop table GROUP_UNIQUE_USERS;
create table MAX(a int); create table MAX(a int);
...@@ -121,7 +121,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -121,7 +121,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
create table TRIM (a int); create table TRIM (a int);
drop table TRIM; drop table TRIM;
create table UNIQUE_USERS(a int); create table UNIQUE_USERS(a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNIQUE_USERS(a int)' at line 1 drop table UNIQUE_USERS;
create table UNIQUE_USERS (a int); create table UNIQUE_USERS (a int);
drop table UNIQUE_USERS; drop table UNIQUE_USERS;
create table VARIANCE(a int); create table VARIANCE(a int);
...@@ -186,9 +186,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -186,9 +186,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
create table GROUP_CONCAT (a int); create table GROUP_CONCAT (a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP_CONCAT (a int)' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP_CONCAT (a int)' at line 1
create table GROUP_UNIQUE_USERS(a int); create table GROUP_UNIQUE_USERS(a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP_UNIQUE_USERS(a int)' at line 1 drop table GROUP_UNIQUE_USERS;
create table GROUP_UNIQUE_USERS (a int); create table GROUP_UNIQUE_USERS (a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP_UNIQUE_USERS (a int)' at line 1 drop table GROUP_UNIQUE_USERS;
create table MAX(a int); create table MAX(a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MAX(a int)' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MAX(a int)' at line 1
create table MAX (a int); create table MAX (a int);
...@@ -258,9 +258,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -258,9 +258,9 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
create table TRIM (a int); create table TRIM (a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIM (a int)' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIM (a int)' at line 1
create table UNIQUE_USERS(a int); create table UNIQUE_USERS(a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNIQUE_USERS(a int)' at line 1 drop table UNIQUE_USERS;
create table UNIQUE_USERS (a int); create table UNIQUE_USERS (a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNIQUE_USERS (a int)' at line 1 drop table UNIQUE_USERS;
create table VARIANCE(a int); create table VARIANCE(a int);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARIANCE(a int)' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARIANCE(a int)' at line 1
create table VARIANCE (a int); create table VARIANCE (a int);
......
...@@ -77,8 +77,9 @@ create table GROUP_CONCAT(a int); ...@@ -77,8 +77,9 @@ create table GROUP_CONCAT(a int);
create table GROUP_CONCAT (a int); create table GROUP_CONCAT (a int);
drop table GROUP_CONCAT; drop table GROUP_CONCAT;
--error ER_PARSE_ERROR # Limitation removed in 5.1
create table GROUP_UNIQUE_USERS(a int); create table GROUP_UNIQUE_USERS(a int);
drop table GROUP_UNIQUE_USERS;
create table GROUP_UNIQUE_USERS (a int); create table GROUP_UNIQUE_USERS (a int);
drop table GROUP_UNIQUE_USERS; drop table GROUP_UNIQUE_USERS;
...@@ -167,8 +168,9 @@ create table TRIM(a int); ...@@ -167,8 +168,9 @@ create table TRIM(a int);
create table TRIM (a int); create table TRIM (a int);
drop table TRIM; drop table TRIM;
--error ER_PARSE_ERROR # Limitation removed in 5.1
create table UNIQUE_USERS(a int); create table UNIQUE_USERS(a int);
drop table UNIQUE_USERS;
create table UNIQUE_USERS (a int); create table UNIQUE_USERS (a int);
drop table UNIQUE_USERS; drop table UNIQUE_USERS;
...@@ -249,10 +251,11 @@ create table GROUP_CONCAT(a int); ...@@ -249,10 +251,11 @@ create table GROUP_CONCAT(a int);
--error ER_PARSE_ERROR --error ER_PARSE_ERROR
create table GROUP_CONCAT (a int); create table GROUP_CONCAT (a int);
--error ER_PARSE_ERROR # Limitation removed in 5.1
create table GROUP_UNIQUE_USERS(a int); create table GROUP_UNIQUE_USERS(a int);
--error ER_PARSE_ERROR drop table GROUP_UNIQUE_USERS;
create table GROUP_UNIQUE_USERS (a int); create table GROUP_UNIQUE_USERS (a int);
drop table GROUP_UNIQUE_USERS;
--error ER_PARSE_ERROR --error ER_PARSE_ERROR
create table MAX(a int); create table MAX(a int);
...@@ -339,10 +342,11 @@ create table TRIM(a int); ...@@ -339,10 +342,11 @@ create table TRIM(a int);
--error ER_PARSE_ERROR --error ER_PARSE_ERROR
create table TRIM (a int); create table TRIM (a int);
--error ER_PARSE_ERROR # Limitation removed in 5.1
create table UNIQUE_USERS(a int); create table UNIQUE_USERS(a int);
--error ER_PARSE_ERROR drop table UNIQUE_USERS;
create table UNIQUE_USERS (a int); create table UNIQUE_USERS (a int);
drop table UNIQUE_USERS;
--error ER_PARSE_ERROR --error ER_PARSE_ERROR
create table VARIANCE(a int); create table VARIANCE(a int);
......
...@@ -43,7 +43,7 @@ mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \ ...@@ -43,7 +43,7 @@ mysqld_LDADD = @MYSQLD_EXTRA_LDFLAGS@ \
$(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \ $(LDADD) $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \
@yassl_libs@ @openssl_libs@ @yassl_libs@ @openssl_libs@
noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
item_strfunc.h item_timefunc.h item_uniq.h \ item_strfunc.h item_timefunc.h \
item_xmlfunc.h \ item_xmlfunc.h \
item_create.h item_subselect.h item_row.h \ item_create.h item_subselect.h item_row.h \
mysql_priv.h item_geofunc.h sql_bitmap.h \ mysql_priv.h item_geofunc.h sql_bitmap.h \
...@@ -83,7 +83,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ ...@@ -83,7 +83,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \
sql_base.cc table.cc sql_select.cc sql_insert.cc \ sql_base.cc table.cc sql_select.cc sql_insert.cc \
sql_prepare.cc sql_error.cc sql_locale.cc \ sql_prepare.cc sql_error.cc sql_locale.cc \
sql_update.cc sql_delete.cc uniques.cc sql_do.cc \ sql_update.cc sql_delete.cc uniques.cc sql_do.cc \
procedure.cc item_uniq.cc sql_test.cc \ procedure.cc sql_test.cc \
log.cc log_event.cc init.cc derror.cc sql_acl.cc \ log.cc log_event.cc init.cc derror.cc sql_acl.cc \
unireg.cc des_key_file.cc \ unireg.cc des_key_file.cc \
discover.cc time.cc opt_range.cc opt_sum.cc \ discover.cc time.cc opt_range.cc opt_sum.cc \
......
...@@ -2135,7 +2135,6 @@ public: ...@@ -2135,7 +2135,6 @@ public:
#include "item_strfunc.h" #include "item_strfunc.h"
#include "item_geofunc.h" #include "item_geofunc.h"
#include "item_timefunc.h" #include "item_timefunc.h"
#include "item_uniq.h"
#include "item_subselect.h" #include "item_subselect.h"
#include "item_xmlfunc.h" #include "item_xmlfunc.h"
#endif #endif
......
...@@ -223,7 +223,7 @@ class Item_sum :public Item_result_field ...@@ -223,7 +223,7 @@ class Item_sum :public Item_result_field
public: public:
enum Sumfunctype enum Sumfunctype
{ COUNT_FUNC, COUNT_DISTINCT_FUNC, SUM_FUNC, SUM_DISTINCT_FUNC, AVG_FUNC, { COUNT_FUNC, COUNT_DISTINCT_FUNC, SUM_FUNC, SUM_DISTINCT_FUNC, AVG_FUNC,
AVG_DISTINCT_FUNC, MIN_FUNC, MAX_FUNC, UNIQUE_USERS_FUNC, STD_FUNC, AVG_DISTINCT_FUNC, MIN_FUNC, MAX_FUNC, STD_FUNC,
VARIANCE_FUNC, SUM_BIT_FUNC, UDF_SUM_FUNC, GROUP_CONCAT_FUNC VARIANCE_FUNC, SUM_BIT_FUNC, UDF_SUM_FUNC, GROUP_CONCAT_FUNC
}; };
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Compability file */
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#include "mysql_priv.h"
Field *Item_sum_unique_users::create_tmp_field(bool group, TABLE *table,
uint convert_blob_length)
{
Field *field= new Field_long(9, maybe_null, name, 1);
if (field)
field->init(table);
return field;
}
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Compability file ; This file only contains dummy functions */
#ifdef USE_PRAGMA_INTERFACE
#pragma interface
#endif
#include <queues.h>
class Item_func_unique_users :public Item_real_func
{
public:
Item_func_unique_users(Item *name_arg,int start,int end,List<Item> &list)
:Item_real_func(list) {}
double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
void fix_length_and_dec() { decimals=0; max_length=6; }
void print(String *str) { str->append(STRING_WITH_LEN("0.0")); }
const char *func_name() const { return "unique_users"; }
};
class Item_sum_unique_users :public Item_sum_num
{
public:
Item_sum_unique_users(Item *name_arg,int start,int end,Item *item_arg)
:Item_sum_num(item_arg) {}
Item_sum_unique_users(THD *thd, Item_sum_unique_users *item)
:Item_sum_num(thd, item) {}
double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
enum Sumfunctype sum_func () const {return UNIQUE_USERS_FUNC;}
void clear() {}
bool add() { return 0; }
void reset_field() {}
void update_field() {}
bool fix_fields(THD *thd, Item **ref)
{
DBUG_ASSERT(fixed == 0);
fixed= 1;
return FALSE;
}
Item *copy_or_same(THD* thd)
{
return new Item_sum_unique_users(thd, this);
}
void print(String *str) { str->append(STRING_WITH_LEN("0.0")); }
Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length);
const char *func_name() const { return "sum_unique_users"; }
};
...@@ -593,7 +593,6 @@ static SYMBOL sql_functions[] = { ...@@ -593,7 +593,6 @@ static SYMBOL sql_functions[] = {
{ "DATE_SUB", SYM(DATE_SUB_INTERVAL)}, { "DATE_SUB", SYM(DATE_SUB_INTERVAL)},
{ "EXTRACT", SYM(EXTRACT_SYM)}, { "EXTRACT", SYM(EXTRACT_SYM)},
{ "GROUP_CONCAT", SYM(GROUP_CONCAT_SYM)}, { "GROUP_CONCAT", SYM(GROUP_CONCAT_SYM)},
{ "GROUP_UNIQUE_USERS", SYM(GROUP_UNIQUE_USERS)},
{ "MAX", SYM(MAX_SYM)}, { "MAX", SYM(MAX_SYM)},
{ "MID", SYM(SUBSTRING)}, /* unireg function */ { "MID", SYM(SUBSTRING)}, /* unireg function */
{ "MIN", SYM(MIN_SYM)}, { "MIN", SYM(MIN_SYM)},
...@@ -611,7 +610,6 @@ static SYMBOL sql_functions[] = { ...@@ -611,7 +610,6 @@ static SYMBOL sql_functions[] = {
{ "SYSDATE", SYM(SYSDATE)}, { "SYSDATE", SYM(SYSDATE)},
{ "SYSTEM_USER", SYM(USER)}, { "SYSTEM_USER", SYM(USER)},
{ "TRIM", SYM(TRIM)}, { "TRIM", SYM(TRIM)},
{ "UNIQUE_USERS", SYM(UNIQUE_USERS)},
{ "VARIANCE", SYM(VARIANCE_SYM)}, { "VARIANCE", SYM(VARIANCE_SYM)},
{ "VAR_POP", SYM(VARIANCE_SYM)}, { "VAR_POP", SYM(VARIANCE_SYM)},
{ "VAR_SAMP", SYM(VAR_SAMP_SYM)}, { "VAR_SAMP", SYM(VAR_SAMP_SYM)},
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <signal.h> #include <signal.h>
#include <thr_lock.h> #include <thr_lock.h>
#include <my_base.h> /* Needed by field.h */ #include <my_base.h> /* Needed by field.h */
#include <queues.h>
#include "sql_bitmap.h" #include "sql_bitmap.h"
#include "sql_array.h" #include "sql_array.h"
......
...@@ -537,7 +537,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -537,7 +537,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token GRANTS %token GRANTS
%token GROUP /* SQL-2003-R */ %token GROUP /* SQL-2003-R */
%token GROUP_CONCAT_SYM %token GROUP_CONCAT_SYM
%token GROUP_UNIQUE_USERS
%token GT_SYM /* OPERATOR */ %token GT_SYM /* OPERATOR */
%token HANDLER_SYM %token HANDLER_SYM
%token HASH_SYM %token HASH_SYM
...@@ -864,7 +863,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -864,7 +863,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token UNINSTALL_SYM %token UNINSTALL_SYM
%token UNION_SYM /* SQL-2003-R */ %token UNION_SYM /* SQL-2003-R */
%token UNIQUE_SYM %token UNIQUE_SYM
%token UNIQUE_USERS
%token UNKNOWN_SYM /* SQL-2003-R */ %token UNKNOWN_SYM /* SQL-2003-R */
%token UNLOCK_SYM %token UNLOCK_SYM
%token UNSIGNED %token UNSIGNED
...@@ -6279,10 +6277,6 @@ simple_expr: ...@@ -6279,10 +6277,6 @@ simple_expr:
} }
$$= new (YYTHD->mem_root) Item_func_interval((Item_row *)$1); $$= new (YYTHD->mem_root) Item_func_interval((Item_row *)$1);
} }
| UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' expr_list ')'
{
$$= new Item_func_unique_users($3,atoi($5.str),atoi($7.str), * $9);
}
; ;
/* /*
...@@ -6769,8 +6763,6 @@ sum_expr: ...@@ -6769,8 +6763,6 @@ sum_expr:
{ Select->in_sum_expr--; } { Select->in_sum_expr--; }
')' ')'
{ $$=new Item_sum_count_distinct(* $5); } { $$=new Item_sum_count_distinct(* $5); }
| GROUP_UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' in_sum_expr ')'
{ $$= new Item_sum_unique_users($3,atoi($5.str),atoi($7.str),$9); }
| MIN_SYM '(' in_sum_expr ')' | MIN_SYM '(' in_sum_expr ')'
{ $$=new Item_sum_min($3); } { $$=new Item_sum_min($3); }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment