--- sql/pgsql/parser3pgsql.C 2003/01/15 10:55:38 1.11 +++ sql/pgsql/parser3pgsql.C 2003/09/26 15:37:21 1.14 @@ -1,13 +1,13 @@ /** @file Parser PgSQL driver. - Copyright(c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright(c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) 2001.07.30 using PgSQL 7.1.2 */ -static const char *RCSId="$Id: parser3pgsql.C,v 1.11 2003/01/15 10:55:38 paf Exp $"; +static const char *RCSId="$Id: parser3pgsql.C,v 1.14 2003/09/26 15:37:21 paf Exp $"; #include "config_includes.h" @@ -175,26 +175,25 @@ public: return PQstatus((PGconn *)connection)==CONNECTION_OK; } - unsigned int quote( - SQL_Driver_services&, void *connection, - char *to, const char *from, unsigned int length) { - if(to) { // store mode - unsigned int result=length; - while(length--) { - switch(*from) { - case '\'': // "'" -> "''" - *to++='\''; result++; - break; - case '\\': // "\" -> "\\" - *to++='\\'; result++; - break; - } - *to++=*from++; + const char* quote( + SQL_Driver_services& services, void *connection, + const char *from, unsigned int length) { + char *result=(char*)services.malloc_atomic(length*2+1); + char *to=result; + while(length--) { + switch(*from) { + case '\'': // "'" -> "''" + *to++='\''; + break; + case '\\': // "\" -> "\\" + *to++='\\'; + break; } - return result; - } else // estimate mode - return length*2; - } + *to++=*from++; + } + *to=0; + return result; + } void query( SQL_Driver_services& services, void *connection, const char *astatement, unsigned long offset, unsigned long limit, @@ -240,9 +239,9 @@ public: for(int i=0; i