X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C690C32A518 for ; Fri, 22 Oct 2004 13:45:52 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03642-07 for ; Fri, 22 Oct 2004 12:45:36 +0000 (GMT) Received: from hqex2k.francoudi.com (hqex2k.francoudi.com [217.27.32.8]) by svr1.postgresql.org (Postfix) with ESMTP id C4BFD329F2F for ; Fri, 22 Oct 2004 13:45:41 +0100 (BST) X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable Subject: Re: Problems with protocol V3 after migration to latest driver Date: Fri, 22 Oct 2004 15:45:42 +0300 Message-ID: <8BCBF9DB739F034B87FE7C7D30EAE55C026AC202@hqex2k.francoudi.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [JDBC] Problems with protocol V3 after migration to latest driver Thread-Index: AcS4La8EiZduDE+FQp61GNUfpfLdKAABHnLw From: "Alexey Yudichev" To: Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/230 X-Sequence-Number: 11335 So=20 is "SELECT count(*) FROM XXX WHERE ? IS NULL OR animated=3D?" allowed in th= e spec or not? is "SELECT date_trunc('day', m.created AT TIME ZONE INTERVAL ?) FROM messag= e m" allowed or not? Both work perfectly with V2 but not with V3. > You are stating in the setparameter that the oid type is varbinary,=20 > when it is actually an oid. So what is the correct JDBC type for oid? NUMERIC? I am using JBoss and jav= a.lang.Object is mapped to VARBINARY and it works well with protocolVersion= =3DV2 and compatible=3D7.1, jboss uses ResultSet.setBinaryStream()/getBinar= yStream() for that. If I configure the mapping as java.lang.Object->JDBC NU= MERIC, then setNull() inside JBoss will probably work fine, but JBoss will = not be able to store array of bytes as NUMERIC. Any known workaround for th= at, apart of using V2 and using bytea? As for server logs from the problem 1, they are not enabled on production s= erver. Once I have some spare time, I'll try to simulate it on development = server. -----Original Message----- From: Dave Cramer [mailto:pg@fastcrypt.com] Sent: Friday, October 22, 2004 2:53 PM To: pg@fastcrypt.com Cc: Alexey Yudichev; pgsql-jdbc@postgresql.org Subject: Re: [JDBC] Problems with protocol V3 after migration to latest driver Actually, I mis-spoke, you can have parameters in the where clause. --dave Dave Cramer wrote: > > > Alexey Yudichev wrote: > >> I have recently tried to migrate to pgdev.307.jdbc3 driver and got=20 >> several problems. The main purpose of upgrade was to eliminate "idle=20 >> in transaction" effect, because it caused the value of now() function=20 >> to return values up to 30 minutes back the actual statement execution=20 >> (due to connection being "idle in transaction" in the pool). >> Server version is 7.4.5 and I am connecting with compatible=3D7.1=20 >> because I use OIDs. >> Setting protocolVersion to 2 fixed all the problems 2-4, however I'd=20 >> like to know what is wrong with V3. >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3DProblem 1 (Most severe) >> It may seem strange, but once I installed a new driver on production=20 >> servers, I got database server overload: update showed 16.0 and more,=20 >> simple one-row updates by primary key executed for several minutes!.=20 >> If I switched to my second client node where the new driver was not=20 >> yet installed, database load was becoming normal. It looks like=20 >> somehow statements executed through the new driver caused a high=20 >> database server CPU load. >>=20=20 >> > > Can we see the server logs for this problem ? > >> =3D=3D=3D=3D=3D=3D=3D=3D=3DProblem 2. The following statement=20 >> PreparedStatement st =3D c.prepareStatement("SELECT count(*) FROM= =20 >> XXX WHERE ? IS NULL OR animated=3D?"); >> st.setNull(1, Types.BOOLEAN); >> st.setNull(2, Types.BOOLEAN); >> ResultSet rs =3D st.executeQuery(); >> >> fails with V3 throwing an exception java.sql.SQLException: ERROR:=20 >> could not determine data type of parameter $1 >> at=20 >> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecu= torImpl.java:1187)=20 >> >> at=20 >> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImp= l.java:990)=20 >> >> at=20 >> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:= 138)=20 >> >> at=20 >> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stateme= nt.java:347)=20 >> >> at=20 >> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdb= c2Statement.java:294)=20 >> >> at=20 >> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2St= atement.java:209)=20 >> >> >>=20=20 >> > This is not allowed in the spec. > >> =3D=3D=3D=3D=3D=3D=3D=3D=3DProblem 3. >> trying to use expression date_trunc('day', m.created AT TIME ZONE=20 >> INTERVAL ?) >> gives ERROR: syntax error at or near "$1" >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3DProblem 4 >> Table "public.binaryobject" >> Column | Type | Modifiers >> ------------------------+------+----------- >> id | text | not null >> data | oid | >> sound_previewobject | text | >> sound_srcobject | text | >> mmsmessage_messagedata | text | >> object | oid | >> >> Executing SQL: INSERT INTO binaryobject (id, data, object) VALUES (?,=20 >> ?, ?) >> Set parameter: index=3D1, jdbcType=3DVARCHAR,=20 >> value=3Dbo2782808080808080808080808080DB80 >> Set parameter: index=3D2, jdbcType=3DVARBINARY, value=3D[B@4735a0 >> Set parameter: index=3D3, jdbcType=3DVARBINARY, value=3DNULL (here=20 >> setNull(3, Types.VARBINARY) is invoked) >> java.sql.SQLException: ERROR: column "object" is of type oid but=20 >> expression is of type bytea >> at=20 >> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecu= torImpl.java:1187)=20 >> >> at=20 >> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImp= l.java:990)=20 >> >> at=20 >> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:= 138)=20 >> >> at=20 >> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stateme= nt.java:347)=20 >> >> at=20 >> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdb= c2Statement.java:294)=20 >> >> at=20 >> org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2S= tatement.java:249)=20 >> >>=20=20 >> > You are stating in the setparameter that the oid type is varbinary,=20 > when it is actually an oid. > >> Is there a workaround for Promlems 2-4 other than using protocol V2? >> Any comments on Problem 1? >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 7: don't forget to increase your free space map settings >> >> >>=20=20 >> > --=20 Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561