Author: jolee
Date: 2014-08-26 09:46:21 -0400 (Tue, 26 Aug 2014)
New Revision: 4652
Modified:
branches/7.7.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
branches/7.7.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
Log:
TEIID-2930 adding back with hold (commented out some new tests due to pulling back
upstream ExtendedQueryExectutorImpl)
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
---
branches/7.7.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2014-06-25
16:13:39 UTC (rev 4651)
+++
branches/7.7.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2014-08-26
13:46:21 UTC (rev 4652)
@@ -150,7 +150,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
\"(\\w+)\" CURSOR(\\s(WITH HOLD|SCROLL))? FOR (.*)",
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/7.7.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
===================================================================
---
branches/7.7.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2014-06-25
16:13:39 UTC (rev 4651)
+++
branches/7.7.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2014-08-26
13:46:21 UTC (rev 4652)
@@ -312,12 +312,57 @@
}
// this does not work as JDBC always sends the queries in prepared form
- public void testPgDeclareCursor() throws Exception {
+ //public void testPgDeclareCursor() throws Exception {
+ /*
+ @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();
}
+
+ @Test public void testScrollCursor() throws Exception {
+ Statement stmt = conn.createStatement();
+ ExtendedQueryExectutorImpl.simplePortal = "foo";
+ try {
+ assertFalse(stmt.execute("declare \"foo\" insensitive scroll cursor 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 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')");
Show replies by date