Author: jolee
Date: 2014-05-28 14:52:11 -0400 (Wed, 28 May 2014)
New Revision: 4644
Modified:
branches/mvnTest/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
branches/mvnTest/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
Log:
TEIID-2930: reprise SCROLL keyword for DECLARE CURSOR not being parsed correctly
Modified: branches/mvnTest/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
---
branches/mvnTest/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2014-05-28
18:52:04 UTC (rev 4643)
+++
branches/mvnTest/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2014-05-28
18:52:11 UTC (rev 4644)
@@ -149,8 +149,7 @@
private static Pattern preparedAutoIncrement = Pattern.compile("select 1 \\s*from
pg_catalog.pg_attrdef \\s*where adrelid = \\$1 AND adnum = \\$2 " + //$NON-NLS-1$
"\\s*and pg_catalog.pg_get_expr\\(adbin, adrelid\\) \\s*like
'%nextval\\(%'", Pattern.DOTALL|Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
-
- private static Pattern cursorSelectPattern =
Pattern.compile("DECLARE\\s+\"(\\w+)\"(?:\\s+INSENSITIVE)?(\\s+(NO\\s+)?SCROLL)?\\s+CURSOR\\s+FOR\\s+(.*)",
Pattern.CASE_INSENSITIVE|Pattern.DOTALL); //$NON-NLS-1$
+ private static Pattern cursorSelectPattern =
Pattern.compile("DECLARE\\s+\"(\\w+)\"(?:\\s+INSENSITIVE)?(\\s+(NO\\s+)?SCROLL)?\\s+CURSOR\\s+(?:WITH(?:OUT)?
HOLD\\s+)?FOR\\s+(.*)", Pattern.CASE_INSENSITIVE|Pattern.DOTALL); //$NON-NLS-1$
private static Pattern fetchPattern = Pattern.compile("FETCH (\\d+) IN
\"(\\w+)\".*", Pattern.DOTALL|Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
private static Pattern movePattern = Pattern.compile("MOVE (\\d+) IN
\"(\\w+)\".*", Pattern.DOTALL|Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
private static Pattern closePattern = Pattern.compile("CLOSE
\"(\\w+)\"", Pattern.DOTALL|Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
Modified:
branches/mvnTest/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
===================================================================
---
branches/mvnTest/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2014-05-28
18:52:04 UTC (rev 4643)
+++
branches/mvnTest/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2014-05-28
18:52:11 UTC (rev 4644)
@@ -312,12 +312,11 @@
assertEquals("oid", rs.getArray("proargtypes").getBaseTypeName());
}
- // this does not work as JDBC always sends the queries in prepared form
- public void testPgDeclareCursor() throws Exception {
- Statement stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery("begin;declare \"foo\" cursor for
select * from pg_proc;fetch 10 in \"foo\"; close \"foo\"");
- rs.next();
- }
+// @Test public void testCursor() throws Exception {
+// Statement stmt = conn.createStatement();
+// ResultSet rs = stmt.executeQuery("begin;declare \"foo\" cursor for
select * from pg_proc;fetch 10 in \"foo\"; close \"foo\"");
+// rs.next();
+// }
// Introduces too many upstream dependencies, manual test against patched server
needed.
// @Test public void testScrollCursor() throws Exception {
@@ -340,6 +339,26 @@
//
// }
+// Introduces too many upstream dependencies, manual test against patched server
needed.
+// @Test public void testScrollCursorWithHold() throws Exception {
+// Statement stmt = conn.createStatement();
+// ExtendedQueryExectutorImpl.simplePortal = "foo";
+// try {
+// assertFalse(stmt.execute("declare \"foo\" insensitive scroll cursor
with hold for select * from pg_proc;"));
+// assertFalse(stmt.execute("move 5 in \"foo\""));
+// stmt.execute("fetch 10 in \"foo\"");
+// ResultSet rs = stmt.getResultSet();
+// int rowCount = 0;
+// while (rs.next()) {
+// rowCount++;
+// }
+// assertEquals(6, rowCount);
+// stmt.execute("close \"foo\"");
+// } finally {
+// ExtendedQueryExectutorImpl.simplePortal = null;
+// }
+// }
+
@Test public void testPgProcedure() throws Exception {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select has_function_privilege(100,
'foo')");