From: | Barry Lind <barry(at)xythos(dot)com> |
---|---|
To: | lan(at)ac-sw(dot)com |
Cc: | pgsql-patches(at)postgresql(dot)org |
Subject: | Re: patch for JDBC PreparedStatement |
Date: | 2001-08-14 16:29:29 |
Message-ID: | 3B7951E9.5090509@xythos.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc 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
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Robert J. Sanford, Jr. | 2001-08-15 03:07:15 | result sets from functions... |
Previous Message | Gunnar Rønning | 2001-08-14 14:45:53 | Re: Which JDK to build jdbc1 driver on Linux? |
From | Date | Subject | |
---|---|---|---|
Next Message | Marc G. Fournier | 2001-08-14 17:40:14 | Re: Patch: use SCM_CREDS authentication over PF_LOCAL sockets |
Previous Message | Paul Ramsey | 2001-08-14 00:08:54 | Re: PostGIS spatial extensions |