Re: patch for JDBC PreparedStatement - Mailing list pgsql-patches
| From | Barry Lind |
|---|---|
| Subject | Re: patch for JDBC PreparedStatement |
| Date | |
| Msg-id | 3B7951E9.5090509@xythos.com Whole thread Raw |
| In response to | patch for JDBC PreparedStatement (Alexander Litvinov <lan@ac-sw.com>) |
| Responses |
Re: patch for JDBC PreparedStatement
|
| List | pgsql-patches |
I do not understand the need for this patch. Can you more clearly
explain the problem you think exists in the current code that you are
trying to fix? I don't understand why this patch is needed and I don't
think it should be applied until more clarification is provided.
A specific test case would be great.
thanks,
--Barry
Alexander Litvinov wrote:
> Hello,
>
> I don't know the correct way to post patches so I will try this.
>
> I have found the following bug:
> When I try to insert strings using class PreparedStatement from JDBC with
> non-printable chars it sometimes fail. During my investigations I have found
> that current version of PreparedStatement quotes only ' (ampersand) and \
> (slash). I have made some changes and now PreparedStatement change all
> non-printable (possible some printable too) chars to \xxx where xxx is octal
> code of char.
>
> folder : src/interfaces/jdbc/org/postgresql/jdbc2
> file : PreparedStatement.java
>
>
> ------------------------------------------------------------------------
>
> --- PreparedStatement.java.orig Fri Feb 16 22:45:00 2001
> +++ PreparedStatement.java Tue Jul 17 15:32:09 2001
> @@ -285,13 +285,22 @@
> int i;
>
> sbuf.append('\'');
> - for (i = 0 ; i < x.length() ; ++i)
> - {
> - char c = x.charAt(i);
> - if (c == '\\' || c == '\'')
> - sbuf.append((char)'\\');
> - sbuf.append(c);
> - }
> + for (i = 0 ; i < x.length() ; ++i)
> + {
> + char c = x.charAt(i);
> + if (c == '\\' || c == '\'') {
> + sbuf.append((char)'\\');
> + sbuf.append(c);
> + }
> + else if (Character.isLetterOrDigit(c) || c == ' ' || c == ',' || c == '.' || c == '@' || c == '-' || c ==
'+'|| c =='/' || c == '%')
> + sbuf.append(c);
> + else {
> + String oct = Integer.toOctalString(c);
> + if (oct.length() == 1) sbuf.append("\\00" + oct);
> + else if (oct.length() == 2) sbuf.append("\\0" + oct);
> + else if (oct.length() == 3) sbuf.append("\\" + oct);
> + }
> + }
> sbuf.append('\'');
> set(parameterIndex, sbuf.toString());
> }
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
> PreparedStatement.java.patch
>
> Content-Type:
>
> text/x-diff
> Content-Encoding:
>
> base64
>
>
> ------------------------------------------------------------------------
> Part 1.3
>
> Content-Type:
>
> text/plain
> Content-Encoding:
>
> binary
>
>
pgsql-patches by date: