--- sql/mysql/parser3mysql.C 2001/11/11 10:43:22 1.4 +++ sql/mysql/parser3mysql.C 2002/12/09 11:07:46 1.8 @@ -1,16 +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.4 2001/11/11 10:43:22 paf Exp $"; +static const char *RCSId="$Id: parser3mysql.C,v 1.8 2002/12/09 11:07:46 paf Exp $"; #include "config_includes.h" @@ -159,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, @@ -203,31 +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(); - - while(MYSQL_ROW mysql_row=mysql_fetch_row(res)) { - handlers.add_row(); - unsigned long *lengths=mysql_fetch_lengths(res); - for(int i=0; i