--- sql/pgsql/parser3pgsql.C 2001/11/11 11:01:47 1.3 +++ sql/pgsql/parser3pgsql.C 2002/03/22 15:50:25 1.7 @@ -1,13 +1,13 @@ /** @file Parser PgSQL 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 PgSQL 7.1.2 */ -static const char *RCSId="$Id: parser3pgsql.C,v 1.3 2001/11/11 11:01:47 paf Exp $"; +static const char *RCSId="$Id: parser3pgsql.C,v 1.7 2002/03/22 15:50:25 paf Exp $"; #include "config_includes.h" @@ -86,7 +86,7 @@ public: char *port=lsplit(host, ':'); PGconn *conn=PQsetdbLogin( - strcasecmp(host, "local")==0?NULL/* local Unix domain socket */:host, port, + (host&&strcasecmp(host, "local")==0)?NULL/* local Unix domain socket */:host, port, NULL, NULL, db, user, pwd); if(!conn) services._throw("PQsetdbLogin failed"); @@ -123,22 +123,22 @@ public: unsigned int quote( SQL_Driver_services&, void *connection, char *to, const char *from, unsigned int length) { - /* - it's already UNTAINT_TIMES_BIGGER - */ - unsigned int result=length; - while(length--) { - switch(*from) { - case '\'': // "'" -> "''" - *to++='\''; - break; - case '\\': // "\" -> "\\" - *to++='\''; - break; + if(to) { // store mode + unsigned int result=length; + while(length--) { + switch(*from) { + case '\'': // "'" -> "''" + *to++='\''; result++; + break; + case '\\': // "\" -> "\\" + *to++='\''; result++; + break; + } + *to++=*from++; } - *to++=*from++; - } - return result; + return result; + } else // estimate mode + return length*2; } void query( SQL_Driver_services& services, void *connection,