diff -u -r1.6 DatabaseMetaData.java --- src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java 2000/09/12 18:56:04 1.6 +++ src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java 2000/09/13 19:15:06 @@ -167,19 +167,23 @@ /** * What is the version of this database product. * - *

Note that PostgreSQL 6.3 has a system catalog called pg_version - - * however, select * from pg_version on any database retrieves - * no rows. - * - *

For now, we will return the version 6.3 (in the hope that we change - * this driver as often as we change the database) - * * @return the database version * @exception SQLException if a database access error occurs */ public String getDatabaseProductVersion() throws SQLException { - return ("7.0.2"); + /* The function "version()" has had the format "PostgreSQL X.Y.Z on ..." + * since at least 6.5.x, so this should be a safe assumption. + */ + + java.sql.ResultSet resultSet = connection.ExecSQL("select version()"); + resultSet.next(); + + StringTokenizer versionParts = new StringTokenizer(resultSet.getString(1)); + versionParts.nextToken(); /* "PostgreSQL" */ + String versionNumber = versionParts.nextToken(); /* "X.Y.Z" */ + + return versionNumber; } /**