From: | Felipe Schnack <felipes(at)ritterdosreis(dot)br> |
---|---|
To: | Barry Lind <blind(at)xythos(dot)com> |
Cc: | Oliver Jowett <oliver(at)opencloud(dot)com>, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: patch: tiny patch to correct stringbuffer size estimate |
Date: | 2003-07-22 16:36:48 |
Message-ID: | 20030722133648.2dc7e1f5.felipes@ritterdosreis.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Looking at this case I don't think they are unnecessary. But I would like to just raise some questions for clarification
- The JDBC spec doesn't say these objects should be used in a thread-safe way? What I mean: your application/container shouldn't use a single PreparedStatement in multiple threads)... I think I saw this somewhere, but I might be wrong
- Maybe the unnecessary synch'ing is the one stringbuffer does internally?
On Tue, 22 Jul 2003 09:10:00 -0700
Barry Lind <blind(at)xythos(dot)com> wrote:
> Felipe,
>
> Why do you think the synchronizations are unnecessary?
>
> Consider the following code:
>
> synchronized (sbuf)
> {
> sbuf.setLength(0);
> sbuf.ensureCapacity(x.length() + (int)(x.length() / 10));
> sbuf.append('\'');
> escapeString(x, sbuf);
> sbuf.append('\'');
> bind(parameterIndex, sbuf.toString(), type);
> }
>
> If two thread where to perform this code at the same time using the same
> sbuf the results would be garbage even if the methods on sbuf are all
> syncronized. It is the set of actions on sbuf here that needs to be
> syncronized, not each individual call. I beleive all the uses of
> synchronization in the driver are of a similar usage pattern.
>
> thanks,
> --Barry
>
> Felipe Schnack wrote:
> > These StringBuffer woes remember of an old request we made to this list... The last time I checked driver's sources, all acess to preparedstatement's stringbuffer are synchronized... this isn't necessary as jre's Stringbuffer already has all of its methods synchronized.
> > The driver is still doing that? Just curious.
> >
> > On Wed, 23 Jul 2003 01:54:53 +1200
> > Oliver Jowett <oliver(at)opencloud(dot)com> wrote:
> >
> >
> >>This patch tweaks the size estimate when escaping strings to count the
> >>enclosing quotes.
> >>
> >>-O
> >>
> >
> >
> >
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
--
/~\ The ASCII Felipe Schnack (felipes(at)ritterdosreis(dot)br)
\ / Ribbon Campaign Analista de Sistemas
X Against HTML Cel.: 51-91287530
/ \ Email! Linux Counter #281893
Centro Universitário Ritter dos Reis
http://www.ritterdosreis.br
ritter(at)ritterdosreis(dot)br
Fone: 51-32303341
From | Date | Subject | |
---|---|---|---|
Next Message | David Wall | 2003-07-22 17:04:25 | Re: Detecting 'socket errors' - closing the Connection object |
Previous Message | Barry Lind | 2003-07-22 16:10:00 | Re: patch: tiny patch to correct stringbuffer size estimate |