// Now run the query
r = connection.ExecSQL(sql.toString());
- byte remarks[];
-
while (r.next())
{
byte[][] tuple = new byte[5][0];
// Fetch the description for the table (if any)
- java.sql.ResultSet dr = connection.ExecSQL("select description from pg_description where objoid="+r.getInt(2));
+ String getDescriptionStatement =
+ connection.haveMinimumServerVersion("7.2") ?
+ "select obj_description("+r.getInt(2)+",'pg_class')" :
+ "select description from pg_description where objoid=" + r.getInt(2);
+
+ java.sql.ResultSet dr = connection.ExecSQL(getDescriptionStatement);
+
+ byte remarks[] = null;
+
if(((org.postgresql.ResultSet)dr).getTupleCount()==1) {
dr.next();
remarks = dr.getBytes(1);
- } else
- remarks = defaultRemarks;
+ }
dr.close();
String relKind;
if (columnNamePattern == null) columnNamePattern="%";
// Now form the query
- // Modified by Stefan Andreasen
- r = connection.ExecSQL("select a.oid,c.relname,a.attname,a.atttypid,a.attnum,a.attnotnull,a.attlen,a.atttypmod,d.adsrc from pg_class c,pg_attribute a,pg_attrdef d where a.attrelid=c.oid and c.relname like '"+tableNamePattern.toLowerCase()+"' and a.attname like '"+columnNamePattern.toLowerCase()+"' and a.attnum>0 and c.oid=d.adrelid and d.adnum=a.attnum order by c.relname,a.attnum");
-
- byte remarks[];
+ String query =
+ "select " +
+ (connection.haveMinimumServerVersion("7.2") ? "a.attrelid" : "a.oid") +
+ ",c.relname,a.attname,a.atttypid," +
+ "a.attnum,a.attnotnull,a.attlen,a.atttypmod,d.adsrc from pg_class c," +
+ "pg_attribute a,pg_attrdef d where a.attrelid=c.oid and " +
+ "c.relname like '"+tableNamePattern.toLowerCase()+"' and " +
+ "a.attname like '"+columnNamePattern.toLowerCase()+"' and " +
+ "a.attnum>0 and c.oid=d.adrelid and d.adnum=a.attnum " +
+ "order by c.relname,a.attnum";
+
+ r = connection.ExecSQL(query);
while(r.next()) {
byte[][] tuple = new byte[18][0];
// Fetch the description for the table (if any)
- java.sql.ResultSet dr = connection.ExecSQL("select description from pg_description where objoid="+r.getInt(1));
+ String getDescriptionStatement =
+ connection.haveMinimumServerVersion("7.2") ?
+ "select col_description(" + r.getInt(1) + "," + r.getInt(5) + ")" :
+ "select description from pg_description where objoid=" + r.getInt(1);
+
+ java.sql.ResultSet dr = connection.ExecSQL(getDescriptionStatement);
+
if(((org.postgresql.ResultSet)dr).getTupleCount()==1) {
dr.next();
tuple[11] = dr.getBytes(1);
} else
- tuple[11] = defaultRemarks;
-
+ tuple[11] = null;
dr.close();
tuple[0] = "".getBytes(); // Catalog name
r.close();
return new ResultSet(connection, f, v, "OK", 1);
}
-
/**
* Get a description of the access rights for a table's columns.
*