summaryrefslogtreecommitdiff
path: root/psycopg/adapter_qstring.c
diff options
context:
space:
mode:
Diffstat (limited to 'psycopg/adapter_qstring.c')
-rw-r--r--psycopg/adapter_qstring.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c
index 7caed9a..2eaf7f3 100644
--- a/psycopg/adapter_qstring.c
+++ b/psycopg/adapter_qstring.c
@@ -45,13 +45,11 @@ qstring_escape(char *to, char *from, size_t len, PGconn *conn)
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
int err;
- return PQescapeStringConn(conn, to, from, len, &err);
-#else
-#ifdef __GNUC__
-#warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
-#endif
- return PQescapeString(to, from, len);
+ if (conn)
+ return PQescapeStringConn(conn, to, from, len, &err);
+ else
#endif
+ return PQescapeString(to, from, len);
}
#else
static size_t
@@ -149,7 +147,7 @@ qstring_quote(qstringObject *self)
Py_BEGIN_ALLOW_THREADS;
len = qstring_escape(buffer+1, s, len,
- ((connectionObject*)self->conn)->pgconn);
+ self->conn ? ((connectionObject*)self->conn)->pgconn : NULL);
buffer[0] = '\'' ; buffer[len+1] = '\'';
Py_END_ALLOW_THREADS;