--- sql/mysql/parser3mysql.C 2001/10/02 14:52:10 1.2 +++ sql/mysql/parser3mysql.C 2002/12/09 11:07:46 1.8 @@ -1,13 +1,16 @@ /** @file Parser MySQL driver. - Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) + Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + Author: Alexandr Petrosian (http://paf.design.ru) 2001.07.30 using MySQL 3.23.22b + + 2001.11.06 numrows on "HP-UX istok1 B.11.00 A 9000/869 448594332 two-user license" + 3.23.42 & 4.0.0.alfa never worked, both subst & .sl version returned 0 */ -static const char *RCSId="$Id: parser3mysql.C,v 1.2 2001/10/02 14:52:10 parser Exp $"; +static const char *RCSId="$Id: parser3mysql.C,v 1.8 2002/12/09 11:07:46 paf Exp $"; #include "config_includes.h" @@ -55,7 +58,7 @@ public: /// get api version int api_version() { return SQL_DRIVER_API_VERSION; } /// initialize driver by loading sql dynamic link library - const char *initialize(const char *dlopen_file_spec) { + const char *initialize(char *dlopen_file_spec) { return dlopen_file_spec? dlink(dlopen_file_spec):"client library column is empty"; } @@ -156,10 +159,11 @@ public: You must allocate the to buffer to be at least length*2+1 bytes long. (In the worse case, each character may need to be encoded as using two bytes, and you need room for the terminating null byte.) - - it's already UNTAINT_TIMES_BIGGER */ - return (*mysql_escape_string)(to, from, length); + if(to) // store mode + return mysql_escape_string(to, from, length); + else // estimate mode + return length*2+1; } void query( SQL_Driver_services& services, void *connection, @@ -200,33 +204,41 @@ public: mysql_free_result(res); services._throw("result contains no columns"); } + + try { - for(int i=0; iname); - void *ptr=services.malloc(size); - memcpy(ptr, field->name, size); - handlers.add_column(ptr, size); - } + for(int i=0; iname); + void *ptr=services.malloc(size); + memcpy(ptr, field->name, size); + handlers.add_column(ptr, size); + } - handlers.before_rows(); - - if(unsigned long row_count=(unsigned long)mysql_num_rows(res)) - for(unsigned long r=0; rrow_count; } - typedef unsigned int (STDCALL *t_mysql_num_fields)(MYSQL_RES *); t_mysql_num_fields mysql_num_fields; static unsigned int STDCALL subst_mysql_num_fields(MYSQL_RES *res) { return res->field_count; } @@ -304,7 +313,6 @@ private: // mysql client library funcs l DLINK(mysql_fetch_lengths); DLINK(mysql_fetch_row); DLINK(mysql_fetch_field); - SLINK(mysql_num_rows); SLINK(mysql_num_fields); SLINK(mysql_field_count); return 0;