From 73d17e3c5e80c66738435cd6733e999cb9c21ca7 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Tue, 2 Jun 2015 10:54:08 +0100 Subject: [PATCH] Dropped PG_VERSION_HEX constant At PostgreSQL 10.0 it would have become awkward. --- psycopg/adapter_binary.c | 2 +- psycopg/lobject_int.c | 4 ++-- psycopg/lobject_type.c | 6 +++--- psycopg/psycopgmodule.c | 4 ++-- psycopg/utils.c | 2 +- setup.py | 3 --- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c index 485dc5a4..597048d2 100644 --- a/psycopg/adapter_binary.c +++ b/psycopg/adapter_binary.c @@ -39,7 +39,7 @@ static unsigned char * binary_escape(unsigned char *from, size_t from_length, size_t *to_length, PGconn *conn) { -#if PG_VERSION_HEX >= 0x080104 +#if PG_VERSION_NUM >= 80104 if (conn) return PQescapeByteaConn(conn, from, from_length, to_length); else diff --git a/psycopg/lobject_int.c b/psycopg/lobject_int.c index 6b55d42b..8788c100 100644 --- a/psycopg/lobject_int.c +++ b/psycopg/lobject_int.c @@ -474,7 +474,7 @@ lobject_export(lobjectObject *self, const char *filename) return retvalue; } -#if PG_VERSION_HEX >= 0x080300 +#if PG_VERSION_NUM >= 80300 RAISES_NEG int lobject_truncate(lobjectObject *self, size_t len) @@ -511,4 +511,4 @@ lobject_truncate(lobjectObject *self, size_t len) } -#endif /* PG_VERSION_HEX >= 0x080300 */ +#endif /* PG_VERSION_NUM >= 80300 */ diff --git a/psycopg/lobject_type.c b/psycopg/lobject_type.c index ec95b5cf..a43325d4 100644 --- a/psycopg/lobject_type.c +++ b/psycopg/lobject_type.c @@ -266,7 +266,7 @@ psyco_lobj_get_closed(lobjectObject *self, void *closure) return closed; } -#if PG_VERSION_HEX >= 0x080300 +#if PG_VERSION_NUM >= 80300 #define psyco_lobj_truncate_doc \ "truncate(len=0) -- Truncate large object to given size." @@ -327,10 +327,10 @@ static struct PyMethodDef lobjectObject_methods[] = { METH_NOARGS, psyco_lobj_unlink_doc}, {"export",(PyCFunction)psyco_lobj_export, METH_VARARGS, psyco_lobj_export_doc}, -#if PG_VERSION_HEX >= 0x080300 +#if PG_VERSION_NUM >= 80300 {"truncate",(PyCFunction)psyco_lobj_truncate, METH_VARARGS, psyco_lobj_truncate_doc}, -#endif /* PG_VERSION_HEX >= 0x080300 */ +#endif /* PG_VERSION_NUM >= 80300 */ {NULL} }; diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c index 63abb03d..34fc25e8 100644 --- a/psycopg/psycopgmodule.c +++ b/psycopg/psycopgmodule.c @@ -185,7 +185,7 @@ psyco_libcrypto_threads_init(void) if (PyImport_ImportModule("ssl") != NULL) { /* disable libcrypto setup in libpq, so it won't stomp on the callbacks that have already been set up */ -#if PG_VERSION_HEX >= 0x080400 +#if PG_VERSION_NUM >= 80400 PQinitOpenSSL(1, 0); #endif } @@ -305,7 +305,7 @@ exit: static PyObject* psyco_libpq_version(PyObject *self) { -#if PG_VERSION_HEX >= 0x090100 +#if PG_VERSION_NUM >= 90100 return PyInt_FromLong(PQlibVersion()); #else PyErr_SetString(NotSupportedError, "version discovery is not supported in libpq < 9.1"); diff --git a/psycopg/utils.c b/psycopg/utils.c index 6b035cfa..836f6129 100644 --- a/psycopg/utils.c +++ b/psycopg/utils.c @@ -62,7 +62,7 @@ psycopg_escape_string(connectionObject *conn, const char *from, Py_ssize_t len, } { - #if PG_VERSION_HEX >= 0x080104 + #if PG_VERSION_NUM >= 80104 int err; if (conn && conn->pgconn) ql = PQescapeStringConn(conn->pgconn, to+eq+1, from, len, &err); diff --git a/setup.py b/setup.py index e42a5c1a..2de8c5ef 100644 --- a/setup.py +++ b/setup.py @@ -419,9 +419,6 @@ class psycopg_build_ext(build_ext): define_macros.append(("PG_VERSION_NUM", "%d%02d%02d" % (pgmajor, pgminor, pgpatch))) - define_macros.append(("PG_VERSION_HEX", "0x%02X%02X%02X" % - (pgmajor, pgminor, pgpatch))) - # enable lo64 if libpq >= 9.3 and Python 64 bits if (pgmajor, pgminor) >= (9, 3) and is_py_64(): define_macros.append(("HAVE_LO64", "1"))