diff -u psycopg2-2.5.3+dfsg/debian/changelog psycopg2-2.5.3+dfsg/debian/changelog --- psycopg2-2.5.3+dfsg/debian/changelog +++ psycopg2-2.5.3+dfsg/debian/changelog @@ -1,3 +1,10 @@ +psycopg2 (2.5.3+dfsg-1ubuntu1~ppa1) utopic; urgency=medium + + * debian/patches/99_allow_large_objects.patch: Allow large objects + greater than 2GB. (LP: #1366104) + + -- Andres Rodriguez Fri, 19 Sep 2014 12:30:26 -0500 + psycopg2 (2.5.3+dfsg-1) unstable; urgency=medium * Team upload diff -u psycopg2-2.5.3+dfsg/debian/control psycopg2-2.5.3+dfsg/debian/control --- psycopg2-2.5.3+dfsg/debian/control +++ psycopg2-2.5.3+dfsg/debian/control @@ -5,7 +5,8 @@ python-all-dbg (>= 2.6.6-3~), python3-all-dev, python3-all-dbg, python-egenix-mx-base-dev, libpq-dev, python-sphinx (>= 1.0.7+dfsg-1~), quilt (>= 0.46-7) Build-Depends-Indep: python-doc, python3-doc -Maintainer: Fabio Tranchitella +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Fabio Tranchitella Uploaders: Debian Python Modules Team Standards-Version: 3.9.5 Vcs-Svn: svn://anonscm.debian.org/python-modules/packages/psycopg2/trunk/ diff -u psycopg2-2.5.3+dfsg/debian/patches/series psycopg2-2.5.3+dfsg/debian/patches/series --- psycopg2-2.5.3+dfsg/debian/patches/series +++ psycopg2-2.5.3+dfsg/debian/patches/series @@ -1,0 +2 @@ +99_allow_large_objects.patch only in patch2: unchanged: --- psycopg2-2.5.3+dfsg.orig/debian/patches/99_allow_large_objects.patch +++ psycopg2-2.5.3+dfsg/debian/patches/99_allow_large_objects.patch @@ -0,0 +1,259 @@ +Index: psycopg2-2.5.3+dfsg/psycopg/lobject.h +=================================================================== +--- psycopg2-2.5.3+dfsg.orig/psycopg/lobject.h 2014-09-19 12:29:54.153823813 -0500 ++++ psycopg2-2.5.3+dfsg/psycopg/lobject.h 2014-09-19 12:29:54.149823813 -0500 +@@ -60,8 +60,8 @@ + RAISES_NEG HIDDEN Py_ssize_t lobject_read(lobjectObject *self, char *buf, size_t len); + RAISES_NEG HIDDEN Py_ssize_t lobject_write(lobjectObject *self, const char *buf, + size_t len); +-RAISES_NEG HIDDEN int lobject_seek(lobjectObject *self, int pos, int whence); +-RAISES_NEG HIDDEN int lobject_tell(lobjectObject *self); ++RAISES_NEG HIDDEN long lobject_seek(lobjectObject *self, long pos, int whence); ++RAISES_NEG HIDDEN long lobject_tell(lobjectObject *self); + RAISES_NEG HIDDEN int lobject_truncate(lobjectObject *self, size_t len); + RAISES_NEG HIDDEN int lobject_close(lobjectObject *self); + +Index: psycopg2-2.5.3+dfsg/psycopg/lobject_int.c +=================================================================== +--- psycopg2-2.5.3+dfsg.orig/psycopg/lobject_int.c 2014-09-19 12:29:54.153823813 -0500 ++++ psycopg2-2.5.3+dfsg/psycopg/lobject_int.c 2014-09-19 12:29:54.149823813 -0500 +@@ -378,21 +378,29 @@ + + /* lobject_seek - move the current position in the lo */ + +-RAISES_NEG int +-lobject_seek(lobjectObject *self, int pos, int whence) ++RAISES_NEG long ++lobject_seek(lobjectObject *self, long pos, int whence) + { + PGresult *pgres = NULL; + char *error = NULL; +- int where; ++ long where; + +- Dprintf("lobject_seek: fd = %d, pos = %d, whence = %d", ++ Dprintf("lobject_seek: fd = %d, pos = %ld, whence = %d", + self->fd, pos, whence); + + Py_BEGIN_ALLOW_THREADS; + pthread_mutex_lock(&(self->conn->lock)); + +- where = lo_lseek(self->conn->pgconn, self->fd, pos, whence); +- Dprintf("lobject_seek: where = %d", where); ++#ifdef HAVE_LO64 ++ if (self->conn->server_version < 90300) { ++ where = (long)lo_lseek(self->conn->pgconn, self->fd, (int)pos, whence); ++ } else { ++ where = lo_lseek64(self->conn->pgconn, self->fd, pos, whence); ++ } ++#else ++ where = (long)lo_lseek(self->conn->pgconn, self->fd, (int)pos, whence); ++#endif ++ Dprintf("lobject_seek: where = %ld", where); + if (where < 0) + collect_error(self->conn, &error); + +@@ -406,20 +414,28 @@ + + /* lobject_tell - tell the current position in the lo */ + +-RAISES_NEG int ++RAISES_NEG long + lobject_tell(lobjectObject *self) + { + PGresult *pgres = NULL; + char *error = NULL; +- int where; ++ long where; + + Dprintf("lobject_tell: fd = %d", self->fd); + + Py_BEGIN_ALLOW_THREADS; + pthread_mutex_lock(&(self->conn->lock)); + +- where = lo_tell(self->conn->pgconn, self->fd); +- Dprintf("lobject_tell: where = %d", where); ++#ifdef HAVE_LO64 ++ if (self->conn->server_version < 90300) { ++ where = (long)lo_tell(self->conn->pgconn, self->fd); ++ } else { ++ where = lo_tell64(self->conn->pgconn, self->fd); ++ } ++#else ++ where = (long)lo_tell(self->conn->pgconn, self->fd); ++#endif ++ Dprintf("lobject_tell: where = %ld", where); + if (where < 0) + collect_error(self->conn, &error); + +@@ -475,7 +491,15 @@ + Py_BEGIN_ALLOW_THREADS; + pthread_mutex_lock(&(self->conn->lock)); + ++#ifdef HAVE_LO64 ++ if (self->conn->server_version < 90300) { ++ retvalue = lo_truncate(self->conn->pgconn, self->fd, len); ++ } else { ++ retvalue = lo_truncate64(self->conn->pgconn, self->fd, len); ++ } ++#else + retvalue = lo_truncate(self->conn->pgconn, self->fd, len); ++#endif + Dprintf("lobject_truncate: result = %d", retvalue); + if (retvalue < 0) + collect_error(self->conn, &error); +Index: psycopg2-2.5.3+dfsg/psycopg/lobject_type.c +=================================================================== +--- psycopg2-2.5.3+dfsg.orig/psycopg/lobject_type.c 2014-09-19 12:29:54.153823813 -0500 ++++ psycopg2-2.5.3+dfsg/psycopg/lobject_type.c 2014-09-19 12:30:02.053824114 -0500 +@@ -123,7 +123,7 @@ + psyco_lobj_read(lobjectObject *self, PyObject *args) + { + PyObject *res; +- int where, end; ++ long where, end; + Py_ssize_t size = -1; + char *buffer; + +@@ -167,20 +167,39 @@ + static PyObject * + psyco_lobj_seek(lobjectObject *self, PyObject *args) + { +- int offset, whence=0; +- int pos=0; ++ long offset, pos=0; ++ int whence=0; + +- if (!PyArg_ParseTuple(args, "i|i", &offset, &whence)) +- return NULL; ++ if (!PyArg_ParseTuple(args, "l|i", &offset, &whence)) ++ return NULL; + + EXC_IF_LOBJ_CLOSED(self); + EXC_IF_LOBJ_LEVEL0(self); + EXC_IF_LOBJ_UNMARKED(self); + ++#ifdef HAVE_LO64 ++ if ((offset < INT_MIN || offset > INT_MAX) ++ && self->conn->server_version < 90300) { ++ PyErr_Format(NotSupportedError, ++ "offset out of range (%ld): server version %d " ++ "does not support the lobject 64 API", ++ offset, self->conn->server_version); ++ return NULL; ++ } ++#else ++ if (offset < INT_MIN || offset > INT_MAX) { ++ PyErr_Format(InterfaceError, ++ "offset out of range (%ld): this psycopg version was not built " ++ "with lobject 64 API support", ++ offset); ++ return NULL; ++ } ++#endif ++ + if ((pos = lobject_seek(self, offset, whence)) < 0) + return NULL; + +- return PyInt_FromLong((long)pos); ++ return PyLong_FromLong(pos); + } + + /* tell method - tell current position in the lobject */ +@@ -191,7 +210,7 @@ + static PyObject * + psyco_lobj_tell(lobjectObject *self, PyObject *args) + { +- int pos; ++ long pos; + + EXC_IF_LOBJ_CLOSED(self); + EXC_IF_LOBJ_LEVEL0(self); +@@ -200,7 +219,7 @@ + if ((pos = lobject_tell(self)) < 0) + return NULL; + +- return PyInt_FromLong((long)pos); ++ return PyLong_FromLong(pos); + } + + /* unlink method - unlink (destroy) the lobject */ +@@ -257,15 +276,33 @@ + static PyObject * + psyco_lobj_truncate(lobjectObject *self, PyObject *args) + { +- int len = 0; ++ long len = 0; + +- if (!PyArg_ParseTuple(args, "|i", &len)) ++ if (!PyArg_ParseTuple(args, "|l", &len)) + return NULL; + + EXC_IF_LOBJ_CLOSED(self); + EXC_IF_LOBJ_LEVEL0(self); + EXC_IF_LOBJ_UNMARKED(self); + ++#ifdef HAVE_LO64 ++ if (len > INT_MAX && self->conn->server_version < 90300) { ++ PyErr_Format(NotSupportedError, ++ "len out of range (%ld): server version %d " ++ "does not support the lobject 64 API", ++ len, self->conn->server_version); ++ return NULL; ++ } ++#else ++ if (len > INT_MAX) { ++ PyErr_Format(InterfaceError, ++ "len out of range (%ld): this psycopg version was not built " ++ "with lobject 64 API support", ++ len); ++ return NULL; ++ } ++#endif ++ + if (lobject_truncate(self, len) < 0) + return NULL; + +Index: psycopg2-2.5.3+dfsg/setup.py +=================================================================== +--- psycopg2-2.5.3+dfsg.orig/setup.py 2014-09-19 12:29:54.153823813 -0500 ++++ psycopg2-2.5.3+dfsg/setup.py 2014-09-19 12:29:54.149823813 -0500 +@@ -404,6 +404,9 @@ + pgmajor, pgminor, pgpatch = m.group(1, 2, 3) + if pgpatch is None or not pgpatch.isdigit(): + pgpatch = 0 ++ pgmajor = int(pgmajor) ++ pgminor = int(pgminor) ++ pgpatch = int(pgpatch) + else: + sys.stderr.write( + "Error: could not determine PostgreSQL version from '%s'" +@@ -411,7 +414,27 @@ + sys.exit(1) + + define_macros.append(("PG_VERSION_HEX", "0x%02X%02X%02X" % +- (int(pgmajor), int(pgminor), int(pgpatch)))) ++ (pgmajor, pgminor, pgpatch))) ++ ++ if sys.version_info[:2] >= (3, 0): ++ maxint = sys.maxsize ++ else: ++ maxint = sys.maxint ++ ++ # enable lo64 if libpq >= 9.3 and Python 64 bits ++ if (pgmajor, pgminor) >= (9, 3) and maxint > (1 << 32): ++ define_macros.append(("HAVE_LO64", "1")) ++ ++ # Inject the flag in the version string already packed up ++ # because we didn't know the version before. ++ # With distutils everything is complicated. ++ for i, t in enumerate(define_macros): ++ if t[0] == 'PSYCOPG_VERSION': ++ n = t[1].find(')') ++ if n > 0: ++ define_macros[i] = ( ++ t[0], t[1][:n] + ' lo64' + t[1][n:]) ++ + except Warning: + w = sys.exc_info()[1] # work around py 2/3 different syntax + sys.stderr.write("Error: %s\n" % w)