diff options
author | unknown <monty@narttu.mysql.fi> | 2003-08-27 22:30:50 +0300 |
---|---|---|
committer | unknown <monty@narttu.mysql.fi> | 2003-08-27 22:30:50 +0300 |
commit | 0ee6f7fde0c5737b2a0b703b1c2755186d7d319b (patch) | |
tree | 20979ee2d8e2b0c2cb5d979c17fcb2a620ae17a1 | |
parent | 91dc31d38334cddc0b47c9ac0c0be338fc8cfd20 (diff) | |
download | mariadb-git-0ee6f7fde0c5737b2a0b703b1c2755186d7d319b.tar.gz |
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()
-rw-r--r-- | BUILD/FINISH.sh | 8 | ||||
-rwxr-xr-x | BUILD/cleanup | 8 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sql | 12 | ||||
-rw-r--r-- | sql/item_sum.cc | 4 | ||||
-rw-r--r-- | sql/item_sum.h | 3 | ||||
-rw-r--r-- | sql/slave.cc | 5 | ||||
-rw-r--r-- | sql/sql_udf.cc | 11 | ||||
-rw-r--r-- | sql/sql_udf.h | 25 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 2 | ||||
-rw-r--r-- | sql/udf_example.cc | 25 |
10 files changed, 67 insertions, 36 deletions
diff --git a/BUILD/FINISH.sh b/BUILD/FINISH.sh index 32a4efefdfb..72188b9c24b 100644 --- a/BUILD/FINISH.sh +++ b/BUILD/FINISH.sh @@ -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 diff --git a/BUILD/cleanup b/BUILD/cleanup new file mode 100755 index 00000000000..518c5722d87 --- /dev/null +++ b/BUILD/cleanup @@ -0,0 +1,8 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +just_clean=1; + +. "$path/FINISH.sh" diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index 43dc6d89481..7af97b9fad5 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -1,3 +1,15 @@ +-- 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; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 0d05d05f0af..4680be828c3 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -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); } diff --git a/sql/item_sum.h b/sql/item_sum.h index ebb90c05215..bd946609745 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -509,7 +509,8 @@ public: 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) {}; diff --git a/sql/slave.cc b/sql/slave.cc index d45cf1aa8b9..d5da8325c93 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -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; diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index d191550f396..99410bb34ac 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -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); diff --git a/sql/sql_udf.h b/sql/sql_udf.h index 29a351ac52f..7b10b80f148 100644 --- a/sql/sql_udf.h +++ b/sql/sql_udf.h @@ -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; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b0d0565d2e3..b2b4bd206c2 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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 {} diff --git a/sql/udf_example.cc b/sql/udf_example.cc index 7f4417bf8fe..ba056a9d2fd 100644 --- a/sql/udf_example.cc +++ b/sql/udf_example.cc @@ -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]) { |