Re: [Fwd: Array.getArray ()]

From: Barry Lind <blind(at)xythos(dot)com>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [Fwd: Array.getArray ()]
Date: 2003-07-21 20:48:59
Message-ID: 3F1C51BB.1070200@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Patch applied (finally).

--Barry

Dmitry Tkach wrote:
>
> I sent this patch about a month ago, but have never received any reply...
> Did it get lost?
>
> Thanks!
>
> Dima
>
> -------- Original Message --------
>
> Hi, everybody!
>
> I have run into a couple of problems having to do with parsing text
> arrays in jdbc (Array.getArray ()):
>
> - First of all, it skips backslashes, but does not really use them as
> escape characters
> (for example, if the array element has a string, looking like \"blah\",
> it will (incorrectly) strip the double quotes;
> - Secondly, it refuses to parse lines, that contains (properly escaped)
> curly braces - for example {"{blah}", "{blah}"} or {\{blah\}, \{blah\}}...
>
> The attached patch seems to fix those two problems (it is against
> REL7_3_STABLE, but applies to the HEAD with no problems too).
> Please let me know if you find anything wrong with it.
>
> Thanks a lot!
>
> Dima.
>
>
>
>
> ------------------------------------------------------------------------
>
> Index: Array.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc2/Array.java,v
> retrieving revision 1.18
> diff -C10 -r1.18 Array.java
> *** Array.java 6 Sep 2002 21:23:06 -0000 1.18
> --- Array.java 29 May 2003 19:37:19 -0000
> ***************
> *** 84,116 ****
> {
> char[] chars = rawString.toCharArray();
> StringBuffer sbuf = new StringBuffer();
> boolean foundOpen = false;
> boolean insideString = false;
> for ( int i = 0; i < chars.length; i++ )
> {
> if ( chars[i] == '\\' )
> //escape character that we need to skip
> i++;
> ! if ( chars[i] == '{' )
> {
> if ( foundOpen ) // Only supports 1-D arrays for now
> throw org.postgresql.Driver.notImplemented();
> foundOpen = true;
> continue;
> }
> ! if ( chars[i] == '"' )
> {
> insideString = !insideString;
> continue;
> }
> ! if ( (!insideString && chars[i] == ',') || chars[i] == '}' || i == chars.length - 1)
> {
> if ( chars[i] != '"' && chars[i] != '}' && chars[i] != ',' )
> sbuf.append(chars[i]);
> array.add( sbuf.toString() );
> sbuf = new StringBuffer();
> continue;
> }
> sbuf.append( chars[i] );
> }
> }
> --- 84,117 ----
> {
> char[] chars = rawString.toCharArray();
> StringBuffer sbuf = new StringBuffer();
> boolean foundOpen = false;
> boolean insideString = false;
> for ( int i = 0; i < chars.length; i++ )
> {
> if ( chars[i] == '\\' )
> //escape character that we need to skip
> i++;
> ! else if (!insideString && chars[i] == '{' )
> {
> if ( foundOpen ) // Only supports 1-D arrays for now
> throw org.postgresql.Driver.notImplemented();
> foundOpen = true;
> continue;
> }
> ! else if (chars[i] == '"')
> {
> insideString = !insideString;
> continue;
> }
> ! else if (!insideString && (chars[i] == ',' || chars[i] == '}') ||
> ! i == chars.length - 1)
> {
> if ( chars[i] != '"' && chars[i] != '}' && chars[i] != ',' )
> sbuf.append(chars[i]);
> array.add( sbuf.toString() );
> sbuf = new StringBuffer();
> continue;
> }
> sbuf.append( chars[i] );
> }
> }
>
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Fernando Nasser 2003-07-21 21:13:30 Re: IN clauses via setObject(Collection) [Was: Re: Prepare
Previous Message Barry Lind 2003-07-21 20:33:48 Re: jdbc batch performance problem