Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 8729 invoked from network); 3 Jul 2010 00:01:56 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Jul 2010 00:01:56 -0000 Received: (qmail 4635 invoked by uid 500); 3 Jul 2010 00:01:56 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 4597 invoked by uid 500); 3 Jul 2010 00:01:55 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 4589 invoked by uid 99); 3 Jul 2010 00:01:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Jul 2010 00:01:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Jul 2010 00:01:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D311C2388BF1; Sat, 3 Jul 2010 00:00:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r960136 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java Date: Sat, 03 Jul 2010 00:00:29 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100703000029.D311C2388BF1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Sat Jul 3 00:00:29 2010 New Revision: 960136 URL: http://svn.apache.org/viewvc?rev=960136&view=rev Log: DERBY-4731 XA two phase commit with active GLOBAL TEMPORARY TABLE causes An internal error identified by RawStore module just checking in fixtures for the RawStore error and the the Assert case to XATest. The fixtures are xtestXATempTableD4731_RawStore() and xtestXATempTableD4731_Assert and can be enabled by removing the 'x' in front. Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java?rev=960136&r1=960135&r2=960136&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java Sat Jul 3 00:00:29 2010 @@ -1079,6 +1079,90 @@ public class XATest extends BaseJDBCTest } /** + * DERBY-4731 + * test using a GLOBAL TEMPORARY TABLE table in an + * XA transaction adn leaving it active during two phase commit + * @throws XAException + * @throws SQLException + * + */ + public void xtestXATempTableD4731_RawStore() throws SQLException, XAException { + doXATempTableD4731Work(true); + } + + + /** + * DERBY-4731 Temp tables with XA transactions + * an Assert will occur on prepare if only + * temp table work is done in the xact. + * @throws XAException + * @throws SQLException + * + */ + public void xtestXATempTableD4731_Assert() throws SQLException, XAException { + doXATempTableD4731Work(false); + } + + + /** + * The two cases for DERBY-4371 do essentially the same thing. Except doing + * logged work causes the RawStore error and doing only temp table operations + * causes the assert. + * + * @param doLoggedWorkInXact + * @throws SQLException + * @throws XAException + */ + private void doXATempTableD4731Work(boolean doLoggedWorkInXact) throws SQLException, XAException{ + XADataSource xads = J2EEDataSource.getXADataSource(); + XAConnection xaconn = xads.getXAConnection(); + XAResource xar = xaconn.getXAResource(); + + Xid xid = XATestUtil.getXid(996, 9, 48); + xar.start(xid, XAResource.TMNOFLAGS); + Connection conn = xaconn.getConnection(); + Statement s = conn.createStatement(); + if (doLoggedWorkInXact){ + // need to do some real work in our transaction + // so make a table + makeARealTable(s); + } + + // make the temp table + s.executeUpdate("DECLARE GLOBAL TEMPORARY TABLE SESSION.T1 ( XWSID INT, XCTID INT, XIID CHAR(26), XVID SMALLINT, XLID CHAR(8) FOR BIT DATA) ON COMMIT DELETE ROWS NOT LOGGED ON ROLLBACK DELETE ROWS"); + // insert a row + PreparedStatement ps = conn.prepareStatement("INSERT INTO SESSION.T1 VALUES (?,?,?,?,?)"); + ps.setInt(1,1); + ps.setInt(2,1); + ps.setString(3,"hello"); + ps.setShort(4, (short) 1); + ps.setBytes(5, new byte[] {0x0,0x1}); + ps.executeUpdate(); + ResultSet rs = s.executeQuery("SELECT count(*) FROM SESSION.t1"); + JDBC.assertFullResultSet(rs, new String[][] {{"1"}}); + // You could work arond the issue by dropping the TEMP table + //s.executeUpdate("DROP TABLE SESSION.T1"); + xar.end(xid, XAResource.TMSUCCESS); + assertEquals(XAResource.XA_OK,xar.prepare(xid)); + xar.commit(xid,false); + s.close(); + conn.close(); + xaconn.close(); + } + + private void makeARealTable(Statement s) throws SQLException { + try { + s.executeUpdate("DROP TABLE REALTABLE1"); + } catch (SQLException se) { + { + s.executeUpdate("CREATE TABLE REALTABLE1 (i int)"); + } + } + } + + + + /** * Check the held state of a ResultSet by fetching one row, executing a * commit and then fetching the next. Checks the held state matches the * behaviour.