Hi all,
I have a patch which enables communication with Postgresql servers
running v8.0. See attached.
--
Andres
Description: This patch enables support for communicating with Postgresql
servers running v8.0.
Author: Andres Mejia <mej...@amazon.com>
--- PyGreSQL.orig/pygresql/pgdb.py 2016-07-02 00:12:48.087781259 +0000
+++ PyGreSQL/pygresql/pgdb.py 2016-07-02 00:22:26.281943852 +0000
@@ -641,9 +641,14 @@
key = '"%s"' % key
oid = "'%s'::regtype" % self._escape_string(key)
try:
- self._src.execute("SELECT oid, typname,"
- " typlen, typtype, typcategory, typdelim, typrelid"
- " FROM pg_type WHERE oid=%s" % oid)
+ if self._src.pgcnx.server_version < 90000:
+ self._src.execute("SELECT oid, typname,"
+ " typlen, typtype, NULL as typcategory, typdelim, typrelid"
+ " FROM pg_type WHERE oid=%s" % oid)
+ else:
+ self._src.execute("SELECT oid, typname,"
+ " typlen, typtype, typcategory, typdelim, typrelid"
+ " FROM pg_type WHERE oid=%s" % oid)
except ProgrammingError:
res = None
else:
--- PyGreSQL.orig/pygresql/pg.py 2016-07-02 00:12:48.087781259 +0000
+++ PyGreSQL/pygresql/pg.py 2016-07-02 00:22:26.281943852 +0000
@@ -1104,10 +1104,16 @@
def __missing__(self, key):
"""Get the type info from the database if it is not cached."""
try:
- res = self.query("SELECT oid, typname, typname::regtype,"
- " typtype, typcategory, typdelim, typrelid"
- " FROM pg_type WHERE oid=%s::regtype" %
- (_quote_if_unqualified('$1', key),), (key,)).getresult()
+ if self._typecasts.connection.server_version < 90000:
+ res = self.query("SELECT oid, typname, typname::regtype,"
+ " typtype, NULL as typcategory, typdelim, typrelid"
+ " FROM pg_type WHERE oid=%s::regtype" %
+ (_quote_if_unqualified('$1', key),), (key,)).getresult()
+ else:
+ res = self.query("SELECT oid, typname, typname::regtype,"
+ " typtype, typcategory, typdelim, typrelid"
+ " FROM pg_type WHERE oid=%s::regtype" %
+ (_quote_if_unqualified('$1', key),), (key,)).getresult()
except ProgrammingError:
res = None
if not res:
@@ -1805,13 +1811,22 @@
q = "a.attnum > 0"
if with_oid:
q = "(%s OR a.attname = 'oid')" % q
- q = ("SELECT a.attname, t.oid, t.typname, t.typname::regtype,"
- " t.typtype, t.typcategory, t.typdelim, t.typrelid"
- " FROM pg_attribute a"
- " JOIN pg_type t ON t.oid = a.atttypid"
- " WHERE a.attrelid = %s::regclass AND %s"
- " AND NOT a.attisdropped ORDER BY a.attnum") % (
- _quote_if_unqualified('$1', table), q)
+ if self.db.server_version < 90000:
+ q = ("SELECT a.attname, t.oid, t.typname, t.typname::regtype,"
+ " t.typtype, NULL as typcategory, t.typdelim, t.typrelid"
+ " FROM pg_attribute a"
+ " JOIN pg_type t ON t.oid = a.atttypid"
+ " WHERE a.attrelid = %s::regclass AND %s"
+ " AND NOT a.attisdropped ORDER BY a.attnum") % (
+ _quote_if_unqualified('$1', table), q)
+ else:
+ q = ("SELECT a.attname, t.oid, t.typname, t.typname::regtype,"
+ " t.typtype, t.typcategory, t.typdelim, t.typrelid"
+ " FROM pg_attribute a"
+ " JOIN pg_type t ON t.oid = a.atttypid"
+ " WHERE a.attrelid = %s::regclass AND %s"
+ " AND NOT a.attisdropped ORDER BY a.attnum") % (
+ _quote_if_unqualified('$1', table), q)
names = self.db.query(q, (table,)).getresult()
types = self.dbtypes
names = ((name[0], types.add(*name[1:])) for name in names)
_______________________________________________
PyGreSQL mailing list
PyGreSQL@vex.net
https://mail.vex.net/mailman/listinfo.cgi/pygresql