summaryrefslogtreecommitdiff
path: root/psycopg/adapter_binary.c
diff options
context:
space:
mode:
Diffstat (limited to 'psycopg/adapter_binary.c')
-rw-r--r--psycopg/adapter_binary.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c
index b853890..e380b2b 100644
--- a/psycopg/adapter_binary.c
+++ b/psycopg/adapter_binary.c
@@ -44,13 +44,11 @@ binary_escape(unsigned char *from, unsigned int from_length,
#if PG_MAJOR_VERSION > 8 || \
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
- return PQescapeByteaConn(conn, from, from_length, to_length);
-#else
-#ifdef __GNUC__
-#warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
-#endif
- return PQescapeBytea(from, from_length, to_length);
+ if (conn)
+ return PQescapeByteaConn(conn, from, from_length, to_length);
+ else
#endif
+ return PQescapeBytea(from, from_length, to_length);
}
#else
static unsigned char *
@@ -144,7 +142,7 @@ binary_quote(binaryObject *self)
/* escape and build quoted buffer */
PyObject_AsCharBuffer(self->wrapped, &buffer, &buffer_len);
to = (char *)binary_escape((unsigned char*)buffer, buffer_len, &len,
- ((connectionObject*)self->conn)->pgconn);
+ self->conn ? ((connectionObject*)self->conn)->pgconn : NULL);
if (to == NULL) {
PyErr_NoMemory();
return NULL;