* psycopg/utils.c (psycopg_escape_string): same here.

* psycopg/adapter_binary.c (binary_escape): simplify PostgreSQL
	version check.

	* setup.py (psycopg_build_ext.finalize_options): use a single
	define of the PostgreSQL version in a form that can easily be used
	by #ifdefs.
This commit is contained in:
James Henstridge 2009-02-17 16:00:52 +09:00
parent 2a94dfae47
commit 9067bde803
4 changed files with 15 additions and 11 deletions

View File

@ -1,5 +1,14 @@
2009-02-17 James Henstridge <james@jamesh.id.au> 2009-02-17 James Henstridge <james@jamesh.id.au>
* psycopg/utils.c (psycopg_escape_string): same here.
* psycopg/adapter_binary.c (binary_escape): simplify PostgreSQL
version check.
* setup.py (psycopg_build_ext.finalize_options): use a single
define of the PostgreSQL version in a form that can easily be used
by #ifdefs.
* tests/test_dates.py (DatetimeTests, mxDateTimeTests): full test * tests/test_dates.py (DatetimeTests, mxDateTimeTests): full test
coverage for datetime and time strings with and without time zone coverage for datetime and time strings with and without time zone
information. information.

View File

@ -42,9 +42,7 @@ static unsigned char *
binary_escape(unsigned char *from, size_t from_length, binary_escape(unsigned char *from, size_t from_length,
size_t *to_length, PGconn *conn) size_t *to_length, PGconn *conn)
{ {
#if PG_MAJOR_VERSION > 8 || \ #if PG_VERSION_HEX >= 0x080104
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
if (conn) if (conn)
return PQescapeByteaConn(conn, from, from_length, to_length); return PQescapeByteaConn(conn, from, from_length, to_length);
else else

View File

@ -31,9 +31,7 @@ psycopg_escape_string(PyObject *obj, const char *from, Py_ssize_t len,
#ifndef PSYCOPG_OWN_QUOTING #ifndef PSYCOPG_OWN_QUOTING
{ {
#if PG_MAJOR_VERSION > 8 || \ #if PG_VERSION_HEX >= 0x080104
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
int err; int err;
if (conn && conn->pgconn) if (conn && conn->pgconn)
ql = PQescapeStringConn(conn->pgconn, to+eq+1, from, len, &err); ql = PQescapeStringConn(conn->pgconn, to+eq+1, from, len, &err);

View File

@ -204,12 +204,11 @@ class psycopg_build_ext(build_ext):
# *at least* PostgreSQL 7.4 is available (this is the only # *at least* PostgreSQL 7.4 is available (this is the only
# 7.x series supported by psycopg 2) # 7.x series supported by psycopg 2)
pgversion = self.get_pg_config("version").split()[1] pgversion = self.get_pg_config("version").split()[1]
pgmajor, pgminor, pgpatch = pgversion.split('.')
except: except:
pgmajor, pgminor, pgpatch = 7, 4, 0 pgversion = "7.4.0"
define_macros.append(("PG_MAJOR_VERSION", pgmajor)) pgmajor, pgminor, pgpatch = pgversion.split('.')
define_macros.append(("PG_MINOR_VERSION", pgminor)) define_macros.append(("PG_VERSION_HEX", "0x%02X%02X%02X" %
define_macros.append(("PG_PATCH_VERSION", pgpatch)) (int(pgmajor), int(pgminor), int(pgpatch))))
except Warning, w: except Warning, w:
if self.pg_config == self.DEFAULT_PG_CONFIG: if self.pg_config == self.DEFAULT_PG_CONFIG:
sys.stderr.write("Warning: %s" % str(w)) sys.stderr.write("Warning: %s" % str(w))