Thread: Getting vacuum results

Getting vacuum results

From
Joseph Shraibman
Date:
If I run VACUUM VERBOSE from jdbc, how do I get the output?  There are
no SQLWarnings attached to the resultset.

Re: Getting vacuum results

From
Kris Jurka
Date:

On Thu, 1 Sep 2005, Joseph Shraibman wrote:

> If I run VACUUM VERBOSE from jdbc, how do I get the output?  There are no
> SQLWarnings attached to the resultset.
>

SQLWarnings are attached to the Statement because VACUUM does not produce
a query result.  The attached test case shows this working
fine for me.  The one complication is that vacuum puts out
some of its interesting information in the Detail: part of the
log message.  The JDBC driver doesn't normally put this
information into the warning message, so you must either
increase the loglevel URL parameter or use the 8.1 series and
write pg specific code to access the individual fields of the
ServerErrorMessage class.  We plan to increase the number of fields
used to construct the error string to include the Detail field, but
haven't gotten around to it yet.

Kris Jurka

Attachment

Re: Getting vacuum results

From
Joseph Shraibman
Date:
It's funny.  Your test program works, but in my server I get this:

Got SQLException: Something unusual has occured to cause the driver to
fail. Please report this exception.

... and nothing else.

Kris Jurka wrote:
>
>
> On Thu, 1 Sep 2005, Joseph Shraibman wrote:
>
>> If I run VACUUM VERBOSE from jdbc, how do I get the output?  There are
>> no SQLWarnings attached to the resultset.
>>
>
> SQLWarnings are attached to the Statement because VACUUM does not
> produce a query result.  The attached test case shows this working fine
> for me.  The one complication is that vacuum puts out some of its
> interesting information in the Detail: part of the log message.  The
> JDBC driver doesn't normally put this information into the warning
> message, so you must either increase the loglevel URL parameter or use
> the 8.1 series and write pg specific code to access the individual
> fields of the ServerErrorMessage class.  We plan to increase the number
> of fields used to construct the error string to include the Detail
> field, but haven't gotten around to it yet.
>
> Kris Jurka
>
>
> ------------------------------------------------------------------------
>
> import java.sql.*;
>
> public class Vacuum {
>
>     public static void main(String args[]) throws Exception {
>         Class.forName("org.postgresql.Driver");
>         Connection conn =
DriverManager.getConnection("jdbc:postgresql://localhost:5432/jurka?loglevel=1","jurka","");
>         Statement stmt = conn.createStatement();
>         stmt.execute("VACUUM VERBOSE");
>         SQLWarning warn = stmt.getWarnings();
>         System.out.println(warn);
>         while (warn != null) {
>             warn = warn.getNextWarning();
>             System.out.println(warn);
>         }
>         stmt.close();
>         conn.close();
>     }
> }
>
>

Re: Getting vacuum results

From
Kris Jurka
Date:

On Tue, 13 Sep 2005, Joseph Shraibman wrote:

> It's funny.  Your test program works, but in my server I get this:
>
> Got SQLException: Something unusual has occured to cause the driver to fail.
> Please report this exception.
>

What's the stacktrace coming from this?

Kris Jurka


Re: Getting vacuum results

From
Joseph Shraibman
Date:
Something unusual has occured to cause the driver to fail. Please report
this exception.
org.postgresql.util.PSQLException: Something unusual has occured to
cause the driver to fail. Please report this exception.
         at org.postgresql.Driver.connect(Driver.java:249)
         at java.sql.DriverManager.getConnection(DriverManager.java:525)
         at java.sql.DriverManager.getConnection(DriverManager.java:171)
         at <snip>
Caused by: java.security.AccessControlException: access denied
(java.sql.SQLPermission setLog)
         at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
         at
java.security.AccessController.checkPermission(AccessController.java:427)
         at
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         at java.sql.DriverManager.setLogWriter(DriverManager.java:109)
         at
org.postgresql.jdbc2.AbstractJdbc2Connection.enableDriverManagerLogging(AbstractJdbc2Connection.java:1086)
         at
org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:98)
         at
org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
         at
org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
         at org.postgresql.Driver.connect(Driver.java:235)
         ... 7 more


Kris Jurka wrote:
>
>
> On Tue, 13 Sep 2005, Joseph Shraibman wrote:
>
>> It's funny.  Your test program works, but in my server I get this:
>>
>> Got SQLException: Something unusual has occured to cause the driver to
>> fail. Please report this exception.
>>
>
> What's the stacktrace coming from this?
>
> Kris Jurka

Re: Getting vacuum results

From
Joseph Shraibman
Date:
OK from the stack trace I figured out that I had to add a permission to
java.policy.

FYI this doesn't work:

  ResultSet rs = stmt.executeQuery("VACUUM VERBOSE profuser;");
             SQLWarning warn = rs.getWarnings();

Kris Jurka wrote:
>
>
> On Tue, 13 Sep 2005, Joseph Shraibman wrote:
>
>> It's funny.  Your test program works, but in my server I get this:
>>
>> Got SQLException: Something unusual has occured to cause the driver to
>> fail. Please report this exception.
>>
>
> What's the stacktrace coming from this?
>
> Kris Jurka

Re: Getting vacuum results

From
Kris Jurka
Date:

On Tue, 13 Sep 2005, Joseph Shraibman wrote:

> OK from the stack trace I figured out that I had to add a permission to
> java.policy.
>
> FYI this doesn't work:
>
> ResultSet rs = stmt.executeQuery("VACUUM VERBOSE profuser;");
>            SQLWarning warn = rs.getWarnings();
>


With both 8.0 and 8.1dev I get:

Exception in thread "main" org.postgresql.util.PSQLException: No results
were returned by the query.
     at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:232)
     at Vacuum.main(Vacuum.java:9)

and this is the result that I would expect.

Kris Jurka