diff options
author | Blake Rouse <blake.rouse@canonical.com> | 2014-09-08 12:05:28 -0400 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2014-12-25 15:06:18 +0100 |
commit | cd67d3d2fe085b207268be649ef282fc6032a8cc (patch) | |
tree | 1346cede4416632b751902bc5998db1ec296c8c0 /psycopg/lobject_int.c | |
parent | e13ec67da393480e7cec408f94f21a8e9d266bc3 (diff) | |
download | psycopg2-cd67d3d2fe085b207268be649ef282fc6032a8cc.tar.gz |
Modify truncate to use lo_truncate64. Use HAVE_LO64 define to use new lo_*64 methods. Check size of offset and length for versions without LO64.
Diffstat (limited to 'psycopg/lobject_int.c')
-rw-r--r-- | psycopg/lobject_int.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/psycopg/lobject_int.c b/psycopg/lobject_int.c index 731d3da..19d1b9d 100644 --- a/psycopg/lobject_int.c +++ b/psycopg/lobject_int.c @@ -389,7 +389,11 @@ lobject_seek(lobjectObject *self, long pos, int whence) Py_BEGIN_ALLOW_THREADS; pthread_mutex_lock(&(self->conn->lock)); +#if HAVE_LO64 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); @@ -416,7 +420,11 @@ lobject_tell(lobjectObject *self) Py_BEGIN_ALLOW_THREADS; pthread_mutex_lock(&(self->conn->lock)); +#if HAVE_LO64 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); @@ -473,7 +481,11 @@ lobject_truncate(lobjectObject *self, size_t len) Py_BEGIN_ALLOW_THREADS; pthread_mutex_lock(&(self->conn->lock)); +#if HAVE_LO64 + 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); |