Skip site navigation (1) Skip section navigation (2)

Re: JDBC access is broken in 7.3 beta

From: Barry Lind <blind(at)xythos(dot)com>
To: Mats Lofkvist <mal(at)algonet(dot)se>
Cc: pgsql-patches(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: JDBC access is broken in 7.3 beta
Date: 2002-11-14 10:56:43
Message-ID: 3DD3816B.80307@xythos.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Mats,

Patch applied.  (I also fixed the 'length' problem you reported as well).

thanks,
--Barry


Mats Lofkvist wrote:
> (I posted this on the bugs and jdbc newsgroups last week
> but have seen no response. Imho, this really needs to
> be fixed since the bug makes it impossible to use the
> driver in a multithreaded environment so I'm reposting
> to hackers and patches.)
> 
>       _
> Mats Lofkvist
> mal(at)algonet(dot)se
> 
> 
> 
> 
> The optimization added in
> src/interfaces/jdbc/org/postgresql/core/Encoding.java
> version 1.7 breaks JDBC since it is not thread safe.
> 
> The new method decodeUTF8() uses a static (i.e. class member)
> but is synchronized on the instance so it won't work with multiple
> instances used in parallel by multiple threads.
> (Quick and dirty patch below.)
> 
> (The method also isn't using the 'length' parameter correctly,
> but since offset always seems to be zero, this bug doesn't show up.)
> 
>       _
> Mats Lofkvist
> mal(at)algonet(dot)se
> 
> 
> *** org/postgresql/core/Encoding.java~  Sun Oct 20 04:55:50 2002
> --- org/postgresql/core/Encoding.java   Fri Nov  8 16:13:20 2002
> ***************
> *** 233,239 ****
>          */
>         private static final int pow2_6 = 64;           // 26
>         private static final int pow2_12 = 4096;        // 212
> !       private static char[] cdata = new char[50];
>   
>         private synchronized String decodeUTF8(byte data[], int offset, int length) {
>                 char[] l_cdata = cdata;
> --- 233,239 ----
>          */
>         private static final int pow2_6 = 64;           // 26
>         private static final int pow2_12 = 4096;        // 212
> !       private char[] cdata = new char[50];
>   
>         private synchronized String decodeUTF8(byte data[], int offset, int length) {
>                 char[] l_cdata = cdata;
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 



In response to

pgsql-hackers by date

Next:From: Michael MeskesDate: 2002-11-14 11:07:25
Subject: Re: ecpg "problem" ...
Previous:From: Christopher Kings-LynneDate: 2002-11-14 07:53:53
Subject: Re: RI_FKey_check: foreign key constraint blocks

pgsql-patches by date

Next:From: William AhernDate: 2002-11-14 21:16:24
Subject: openbsd getpeereid(), local ident
Previous:From: Bruce MomjianDate: 2002-11-14 04:57:19
Subject: Re: Domain Check Constraints

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group