|
|
| version 1.34, 2008/12/25 02:33:56 | version 1.35, 2010/10/27 22:48:51 |
|---|---|
| Line 232 public: | Line 232 public: |
| return PQstatus(connection.conn)==CONNECTION_OK; | return PQstatus(connection.conn)==CONNECTION_OK; |
| } | } |
| const char* quote(void *aconnection, const char *from, unsigned int length){ | // charset here is services.request_charset(), not connection.client_charset |
| // thus we can't use the sql server quoting support | |
| const char* quote(void *aconnection, const char *str, unsigned int length) | |
| { | |
| const char* from; | |
| const char* from_end=str+length; | |
| size_t quoted=0; | |
| for(from=str; from<from_end; from++){ | |
| switch (*from) { | |
| case '\'': | |
| case '\\': | |
| quoted++; | |
| } | |
| } | |
| if(!quoted) | |
| return str; | |
| Connection& connection=*static_cast<Connection*>(aconnection); | Connection& connection=*static_cast<Connection*>(aconnection); |
| char *result=(char*)connection.services->malloc_atomic(length + quoted + 1); | |
| char *to = result; | |
| char *result=(char*)connection.services->malloc_atomic(length*2+1); | for(from=str; from<from_end; from++){ |
| int err=0; | switch (*from) { |
| PQescapeStringConn(connection.conn, result, from, length, &err); | case '\'': // "'" -> "''" |
| *to++='\''; | |
| break; | |
| case '\\': // "\" -> "\\" | |
| *to++='\\'; | |
| break; | |
| } | |
| *to++=*from; | |
| } | |
| *to=0; | |
| return result; | return result; |
| } | } |
| void query(void *aconnection, | void query(void *aconnection, |
| const char *astatement, | const char *astatement, |
| size_t placeholders_count, Placeholder* placeholders, | size_t placeholders_count, Placeholder* placeholders, |