--- parser3/src/sql/mysql/Attic/parser3mysql.C 2001/06/29 08:35:26 1.24 +++ parser3/src/sql/mysql/Attic/parser3mysql.C 2001/07/23 13:59:52 1.26 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) */ -static const char *RCSId="$Id: parser3mysql.C,v 1.24 2001/06/29 08:35:26 parser Exp $"; +static const char *RCSId="$Id: parser3mysql.C,v 1.26 2001/07/23 13:59:52 parser Exp $"; #include "config_includes.h" @@ -46,7 +46,8 @@ public: int api_version() { return SQL_DRIVER_API_VERSION; } /// initialize driver by loading sql dynamic link library const char *initialize(const char *dlopen_file_spec) { - return dlink(dlopen_file_spec); + return dlopen_file_spec? + dlink(dlopen_file_spec):"client library column is empty"; } /** connect @param used_only_in_connect_url @@ -120,8 +121,7 @@ public: void query( SQL_Driver_services& services, void *connection, const char *astatement, unsigned long offset, unsigned long limit, - unsigned int *column_count, Cell **columns, - unsigned long *row_count, Cell ***rows) { + SQL_Driver_query_event_handlers& handlers) { MYSQL *mysql=(MYSQL *)connection; MYSQL_RES *res=NULL; @@ -146,49 +146,42 @@ public: services._throw(mysql_error(mysql)); if(!(res=mysql_store_result(mysql)) && mysql_field_count(mysql)) services._throw(mysql_error(mysql)); - if(!res) { - // empty result - *row_count=0; - *column_count=0; + if(!res) // empty result: insert|delete|update|... return; - } - *column_count=mysql_num_fields(res); - if(!*column_count) // old client - *column_count=mysql_field_count(mysql); + int column_count=mysql_num_fields(res); + if(!column_count) // old client + column_count=mysql_field_count(mysql); - if(!*column_count) + if(!column_count) services._throw("result contains no columns"); - *columns=(Cell *)services.malloc(sizeof(Cell)*(*column_count)); - for(unsigned int i=0; i<(*column_count); i++){ + for(int i=0; iname); - (*columns)[i].size=size; - (*columns)[i].ptr=services.malloc(size); - memcpy((*columns)[i].ptr, field->name, size); + void *ptr=services.malloc(size); + memcpy(ptr, field->name, size); + handlers.add_column(ptr, size); } + + handlers.before_rows(); - if(*row_count=(unsigned long)mysql_num_rows(res)) { - *rows=(Cell **)services.malloc(sizeof(Cell *)*(*row_count)); - - for(unsigned long r=0; r<(*row_count); r++) + if(unsigned long row_count=(unsigned long)mysql_num_rows(res)) + for(unsigned long r=0; r