Index: AbstractJdbc2Statement.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v retrieving revision 1.85 diff -c -r1.85 AbstractJdbc2Statement.java *** AbstractJdbc2Statement.java 24 Nov 2005 06:18:29 -0000 1.85 --- AbstractJdbc2Statement.java 1 Dec 2005 23:02:11 -0000 *************** *** 103,108 **** --- 103,111 ---- protected Object []callResult; protected int maxfieldSize = 0; + /** The last thread to start an execute method. Useful in the cancel method. */ + private volatile Thread executionThread; + public ResultSet createDriverResultSet(Field[] fields, Vector tuples) throws SQLException { *************** *** 394,399 **** --- 397,404 ---- } protected void execute(Query queryToExecute, ParameterList queryParameters, int flags) throws SQLException { + executionThread = Thread.currentThread(); + // Every statement execution clears any previous warnings. clearWarnings(); *************** *** 2556,2561 **** --- 2561,2569 ---- */ public void cancel() throws SQLException { + // Quick exit for cancel from execution thread. + if (Thread.currentThread() == executionThread) + return; connection.cancelQuery(); }