Author: shawkins
Date: 2012-06-21 07:44:43 -0400 (Thu, 21 Jun 2012)
New Revision: 4193
Modified:
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
Log:
TEIID-2080 fix for set statement handling
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-06-20 19:49:33 UTC
(rev 4192)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-06-21 11:44:43 UTC
(rev 4193)
@@ -434,8 +434,8 @@
String value = match.group(3);
if (value == null) {
value = match.group(4);
+ value = value.substring(1, value.length() - 1);
value = StringUtil.replaceAll(value, "''",
"'"); //$NON-NLS-1$ //$NON-NLS-2$
- value = value.substring(1, value.length() - 1);
}
if (match.group(1) != null) {
//payload case
Modified: trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2012-06-20
19:49:33 UTC (rev 4192)
+++ trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2012-06-21
11:44:43 UTC (rev 4193)
@@ -69,7 +69,7 @@
public class ODBCServerRemoteImpl implements ODBCServerRemote {
private static final String UNNAMED = "UNNAMED"; //$NON-NLS-1$
- private static Pattern setPattern =
Pattern.compile("(SET|set)\\s+(\\w+)\\s+(TO|to)\\s+'(\\w+\\d*)'");//$NON-NLS-1$
+ private static Pattern setPattern =
Pattern.compile("set\\s+(\\w+)\\s+to\\s+((?:'[^']*')+)",
Pattern.DOTALL|Pattern.CASE_INSENSITIVE);//$NON-NLS-1$
private static Pattern pkPattern = Pattern.compile("select ta.attname, ia.attnum,
ic.relname, n.nspname, tc.relname " +//$NON-NLS-1$
"from pg_catalog.pg_attribute ta, pg_catalog.pg_attribute ia, pg_catalog.pg_class
tc, pg_catalog.pg_index i, " +//$NON-NLS-1$
@@ -603,7 +603,7 @@
return "select 63"; //$NON-NLS-1$
}
else if ((m = setPattern.matcher(sql)).matches()) {
- return "SET " + m.group(2) + " " + m.group(4); //$NON-NLS-1$
//$NON-NLS-2$
+ return "SET " + m.group(1) + " " + m.group(2); //$NON-NLS-1$
//$NON-NLS-2$
}
else if (modified.equalsIgnoreCase("BEGIN")) { //$NON-NLS-1$
return "START TRANSACTION"; //$NON-NLS-1$
@@ -693,7 +693,7 @@
}
}
- private void errorOccurred(Throwable error) {
+ public void errorOccurred(Throwable error) {
this.client.errorOccurred(error);
synchronized (this) {
this.errorOccurred = true;
Modified: trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2012-06-20
19:49:33 UTC (rev 4192)
+++ trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2012-06-21
11:44:43 UTC (rev 4193)
@@ -130,7 +130,7 @@
throw e.getCause();
}
} catch (Throwable e) {
- this.client.errorOccurred(e);
+ this.server.errorOccurred(e);
}
}
Modified:
trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2012-06-20
19:49:33 UTC (rev 4192)
+++
trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2012-06-21
11:44:43 UTC (rev 4193)
@@ -363,4 +363,13 @@
String str = rs.getString(1);
assertTrue(str.startsWith("ProjectNode\n + Output Columns:expr1 (integer)\n +
Statistics:\n 0: Node Output Rows: 1"));
}
+
+ @Test public void testSetEmptyLiteral() throws Exception {
+ Statement s = conn.createStatement();
+ assertFalse(s.execute("SET min_client_messages TO ''"));
+ assertTrue(s.execute("SHOW min_client_messages"));
+ ResultSet rs = s.getResultSet();
+ assertTrue(rs.next());
+ assertEquals("", rs.getString(1));
+ }
}
Show replies by date