Commit 0ee6f7fd authored by unknown's avatar unknown

hanged UDF interface to use clear() instead of reset()


BUILD/FINISH.sh:
  Add just_clean option (for cleanup script)
scripts/mysql_fix_privilege_tables.sql:
  Added 'USE mysql' for easer use on windows
sql/item_sum.cc:
  Changed UDF interface to use clear() instead of reset()
sql/item_sum.h:
  Changed UDF interface to use clear() instead of reset()
sql/slave.cc:
  Fixed checking of eof for slave/master protocol. (Bug #887)
sql/sql_udf.cc:
  Changed UDF interface to use clear() instead of reset()
sql/sql_udf.h:
  Changed UDF interface to use clear() instead of reset()
sql/sql_yacc.yy:
  ERRORS and WARNINGS should not be reserved words
sql/udf_example.cc:
  Changed UDF interface to use clear() instead of reset()
parent 91dc31d3
......@@ -23,12 +23,16 @@ autoconf || (echo \"Can't execute autoconf\" && exit 1)
if [ -d gemini ]
then
(cd gemini && aclocal && autoheader && aclocal && automake && autoconf)
fi
fi"
if [ -z "$just_clean" ]
then
commands="$commands
CFLAGS=\"$cflags\" CXX=\"$CXX\" CXXFLAGS=\"$cxxflags\" CXXLDFLAGS=\"$CXXLDFLAGS\" \
$configure"
fi
if [ -z "$just_configure" ]
if [ -z "$just_configure" -a -z "$just_clean" ]
then
commands="$commands
......
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
just_clean=1;
. "$path/FINISH.sh"
-- This script converts any old privilege tables to privilege tables suitable
-- for MySQL 4.0.
-- You can safely ignore all 'Duplicate column' and 'Unknown column' errors"
-- as this just means that your tables where already up to date.
-- This script is safe to run even if your tables are already up to date!
-- On unix, you should use the mysql_fix_privilege_tables script to execute
-- this sql script.
-- On windows you should do 'mysql --force < mysql_fix_privilege_tables.sql'
USE mysql;
ALTER TABLE user type=MyISAM;
ALTER TABLE db type=MyISAM;
ALTER TABLE host type=MyISAM;
......
......@@ -1353,10 +1353,10 @@ longlong Item_sum_count_distinct::val_int()
#ifdef HAVE_DLOPEN
bool Item_udf_sum::reset()
bool Item_udf_sum::clear()
{
DBUG_ENTER("Item_udf_sum::reset");
udf.reset(&null_value);
udf.clear();
DBUG_RETURN(0);
}
......
......@@ -509,7 +509,8 @@ class Item_udf_sum : public Item_sum
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
virtual bool have_field_update(void) const { return 0; }
bool reset();
bool reset() { return 0; } /* TO BE FIXED */
bool clear();
bool add();
void reset_field() {};
void update_field(int offset_arg) {};
......
......@@ -2303,9 +2303,10 @@ server_errno=%d)",
return packet_error;
}
if (len == 1)
/* Check if eof packet */
if (len < 8 && mysql->net.read_pos[0] == 254)
{
sql_print_error("Slave: received 0 length packet from server, apparent\
sql_print_error("Slave: received end packet from server, apparent\
master shutdown: %s",
mysql_error(mysql));
return packet_error;
......
......@@ -92,10 +92,13 @@ static void init_syms(udf_func *tmp)
tmp->func_deinit = dlsym(tmp->dlhandle, nm);
if (tmp->type == UDFTYPE_AGGREGATE)
{
(void)strmov( end, "_reset" );
tmp->func_reset = dlsym( tmp->dlhandle, nm );
(void)strmov( end, "_clear" );
tmp->func_clear = dlsym( tmp->dlhandle, nm );
(void)strmov( end, "_add" );
tmp->func_add = dlsym( tmp->dlhandle, nm );
/* Give error if _clear and _add doesn't exists */
if (!tmp->func_clear || ! tmp->func_add)
tmp->func= 0;
}
}
......@@ -417,7 +420,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
u_d->func=udf->func;
u_d->func_init=udf->func_init;
u_d->func_deinit=udf->func_deinit;
u_d->func_reset=udf->func_reset;
u_d->func_clear=udf->func_clear;
u_d->func_add=udf->func_add;
/* create entry in mysql/func table */
......@@ -429,7 +432,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
if (!(table = open_ltable(thd,&tables,TL_WRITE)))
goto err;
restore_record(table,default_values); // Get default values for fields
restore_record(table,default_values); // Default values for fields
table->field[0]->store(u_d->name.str, u_d->name.length, system_charset_info);
table->field[1]->store((longlong) u_d->returns);
table->field[2]->store(u_d->dl,(uint) strlen(u_d->dl), system_charset_info);
......
......@@ -33,7 +33,7 @@ typedef struct st_udf_func
void *func;
void *func_init;
void *func_deinit;
void *func_reset;
void *func_clear;
void *func_add;
ulong usage_count;
} udf_func;
......@@ -49,7 +49,7 @@ class udf_handler :public Sql_alloc
UDF_ARGS f_args;
UDF_INIT initid;
char *num_buffer;
uchar error;
uchar error, is_null;
bool initialized;
Item **args;
......@@ -57,7 +57,7 @@ class udf_handler :public Sql_alloc
table_map used_tables_cache;
bool const_item_cache;
udf_handler(udf_func *udf_arg) :u_d(udf_arg), buffers(0), error(0),
initialized(0)
is_null(0), initialized(0)
{}
~udf_handler();
const char *name() const { return u_d ? u_d->name.str : "?"; }
......@@ -73,7 +73,6 @@ class udf_handler :public Sql_alloc
*null_value=1;
return 0.0;
}
uchar is_null=0;
double (*func)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)=
(double (*)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)) u_d->func;
double tmp=func(&initid, &f_args, &is_null, &error);
......@@ -92,7 +91,6 @@ class udf_handler :public Sql_alloc
*null_value=1;
return LL(0);
}
uchar is_null=0;
longlong (*func)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)=
(longlong (*)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)) u_d->func;
longlong tmp=func(&initid, &f_args, &is_null, &error);
......@@ -104,22 +102,15 @@ class udf_handler :public Sql_alloc
*null_value=0;
return tmp;
}
void reset(my_bool *null_value)
void clear()
{
uchar is_null=0;
if (get_arguments())
{
*null_value=1;
return;
}
void (*func)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)=
(void (*)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)) u_d->func_reset;
func(&initid, &f_args, &is_null, &error);
*null_value= (my_bool) (is_null || error);
is_null= 0;
void (*func)(UDF_INIT *, uchar *, uchar *)=
(void (*)(UDF_INIT *, uchar *, uchar *)) u_d->func_clear;
func(&initid, &is_null, &error);
}
void add(my_bool *null_value)
{
uchar is_null=0;
if (get_arguments())
{
*null_value=1;
......
......@@ -4409,6 +4409,7 @@ keyword:
| DYNAMIC_SYM {}
| END {}
| ENUM {}
| ERRORS {}
| ESCAPE_SYM {}
| EVENTS_SYM {}
| EXECUTE_SYM {}
......@@ -4546,6 +4547,7 @@ keyword:
| USE_FRM {}
| VARIABLES {}
| VALUE_SYM {}
| WARNINGS {}
| WORK_SYM {}
| X509_SYM {}
| YEAR_SYM {}
......
......@@ -149,6 +149,7 @@ longlong sequence(UDF_INIT *initid, UDF_ARGS *args, char *is_null,
my_bool avgcost_init( UDF_INIT* initid, UDF_ARGS* args, char* message );
void avgcost_deinit( UDF_INIT* initid );
void avgcost_reset( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char *error );
void avgcost_clear( UDF_INIT* initid, char* is_null, char *error );
void avgcost_add( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char *error );
double avgcost( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char *error );
}
......@@ -902,21 +903,29 @@ avgcost_deinit( UDF_INIT* initid )
delete initid->ptr;
}
/* This is only for MySQL 4.0 compability */
void
avgcost_reset( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* message )
avgcost_reset(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* message)
{
struct avgcost_data* data = (struct avgcost_data*)initid->ptr;
data->totalprice = 0.0;
data->totalquantity = 0;
data->count = 0;
avgcost_clear(initid, is_null, message);
avgcost_add(initid, args, is_null, message);
}
*is_null = 0;
avgcost_add( initid, args, is_null, message );
/* This is needed to get things to work in MySQL 4.1.1 and above */
void
avgcost_clear(UDF_INIT* initid, char* is_null, char* message)
{
struct avgcost_data* data = (struct avgcost_data*)initid->ptr;
data->totalprice= 0.0;
data->totalquantity= 0;
data->count= 0;
}
void
avgcost_add( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* message )
avgcost_add(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* message)
{
if (args->args[0] && args->args[1])
{
......
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