diff options
author | monty@narttu.mysql.fi <> | 2003-08-27 22:30:50 +0300 |
---|---|---|
committer | monty@narttu.mysql.fi <> | 2003-08-27 22:30:50 +0300 |
commit | 60dd8a2c4f6a64be933a82a1c0103c0a23879583 (patch) | |
tree | 20979ee2d8e2b0c2cb5d979c17fcb2a620ae17a1 /sql/udf_example.cc | |
parent | 1d0b539263dc18e742cca84dac56916f29290dad (diff) | |
download | mariadb-git-60dd8a2c4f6a64be933a82a1c0103c0a23879583.tar.gz |
hanged UDF interface to use clear() instead of reset()
Diffstat (limited to 'sql/udf_example.cc')
-rw-r--r-- | sql/udf_example.cc | 25 |
1 files changed, 17 insertions, 8 deletions
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]) { |