--- sql/pgsql/parser3pgsql.C 2003/01/21 15:51:30 1.12 +++ sql/pgsql/parser3pgsql.C 2003/09/26 15:37:21 1.14 @@ -7,7 +7,7 @@ 2001.07.30 using PgSQL 7.1.2 */ -static const char *RCSId="$Id: parser3pgsql.C,v 1.12 2003/01/21 15:51:30 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