* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/Driver.java.in,v 1.33 2003/07/22 05:17:09 barry Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/Driver.java.in,v 1.34 2003/07/24 00:30:38 barry Exp $
*
*-------------------------------------------------------------------------
*/
//The build number should be incremented for every new build
- private static int m_buildNumber = 207;
+ private static int m_buildNumber = 208;
}
import java.sql.Types;
import java.util.Vector;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.28 2003/07/22 05:17:09 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.29 2003/07/24 00:30:39 barry Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
sbuf.setLength(0);
sbuf.ensureCapacity(x.length() + (int)(x.length() / 10));
sbuf.append('\'');
- escapeString(x, sbuf);
+ escapeString(x, sbuf, true);
sbuf.append('\'');
bind(parameterIndex, sbuf.toString(), type);
}
{
sbuf.setLength(0);
sbuf.ensureCapacity(p_input.length());
- escapeString(p_input, sbuf);
+ escapeString(p_input, sbuf, false);
return sbuf.toString();
}
}
- private void escapeString(String p_input, StringBuffer p_output) {
+ private void escapeString(String p_input, StringBuffer p_output, boolean p_allowStatementTerminator) {
for (int i = 0 ; i < p_input.length() ; ++i)
{
char c = p_input.charAt(i);
- if (c == '\\' || c == '\'')
- p_output.append((char)'\\');
- p_output.append(c);
+ switch (c)
+ {
+ case '\\':
+ case '\'':
+ p_output.append('\\');
+ p_output.append(c);
+ break;
+ case '\0':
+ throw new IllegalArgumentException("\\0 not allowed");
+ case ';':
+ if (!p_allowStatementTerminator)
+ throw new IllegalArgumentException("semicolon not allowed");
+ default:
+ p_output.append(c);
+ }
}
}