Skip to content

Commit

Permalink
SYMMETRICDS-172: Statement too complex error with large number of col…
Browse files Browse the repository at this point in the history
…umns on a table
  • Loading branch information
erilong committed Jan 14, 2010
1 parent 979f093 commit 56b11e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Expand Up @@ -10,6 +10,7 @@
import java.util.Hashtable;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
import org.apache.derby.impl.jdbc.EmbedConnection;

Expand Down Expand Up @@ -88,6 +89,13 @@ public static void insertData(String schemaName, String prefixName, String table
}
}

public static String escape(String str) {
if (str != null) {
return "\"" + StringUtils.replace(StringUtils.replace(str, "\\", "\\\\"), "\"", "\\\"") + "\"";
}
return "";
}

public static String blobToString(String columnName, String tableName, String whereClause) throws SQLException {
Connection conn = DriverManager.getConnection(CURRENT_CONNECTION_URL);
String sql = "select " + columnName + " from " + tableName + " where " + whereClause;
Expand Down
Expand Up @@ -22,12 +22,12 @@
</property>
<property name="functionTemplatesToInstall">
<map>
<entry key="replace">
<entry key="escape">
<value>
<![CDATA[
CREATE FUNCTION $(functionName)(STR VARCHAR(10000), OLD VARCHAR(10000), NEW VARCHAR(10000)) RETURNS
CREATE FUNCTION $(functionName)(STR VARCHAR(10000)) RETURNS
VARCHAR(10000) PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA EXTERNAL NAME
'org.apache.commons.lang.StringUtils.replace'
'org.jumpmind.symmetric.db.derby.DerbyFunctions.escape'
]]>
</value>
</entry>
Expand Down Expand Up @@ -102,7 +102,7 @@
</property>
<property name="stringColumnTemplate" >
<value>
<![CDATA[ case when $(tableAlias)."$(columnName)" is null then '' else '"' || $[sym.sync.table.prefix]_replace($[sym.sync.table.prefix]_replace($(tableAlias)."$(columnName)",'\','\\'),'"','\"') || '"' end ||','||]]>
<![CDATA[$[sym.sync.table.prefix]_escape($(tableAlias)."$(columnName)") ||','||]]>
</value>
</property>
<property name="clobColumnTemplate">
Expand Down

0 comments on commit 56b11e9

Please sign in to comment.