diff -ur pgjdbc.orig/doc/pgjdbc.xml pgjdbc/doc/pgjdbc.xml --- pgjdbc.orig/doc/pgjdbc.xml 2009-06-20 17:19:40.000000000 +0200 +++ pgjdbc/doc/pgjdbc.xml 2009-08-05 17:50:25.110472000 +0200 @@ -669,6 +669,14 @@ + + role = String + + + Set the initial role of the session upon connection. + + + diff -ur pgjdbc.orig/org/postgresql/jdbc2/AbstractJdbc2Connection.java pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java --- pgjdbc.orig/org/postgresql/jdbc2/AbstractJdbc2Connection.java 2009-07-01 07:00:40.000000000 +0200 +++ pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java 2009-08-05 17:43:52.702374000 +0200 @@ -175,6 +175,17 @@ openStackTrace = new Throwable("Connection was created at this point:"); enableDriverManagerLogging(); } + + // Set role if supplied: + String role = info.getProperty("role"); + if (role != null) + { + if (logger.logDebug()) + { + logger.debug(" role = " + role); + } + execSQLUpdate("SET ROLE '" + escapeString(role) + "'"); + } } private final TimestampUtils timestampUtils;