X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 374E8DA26A for ; Tue, 25 Oct 2005 21:42:21 -0300 (ADT) 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 00352-03 for ; Wed, 26 Oct 2005 00:42:16 +0000 (GMT) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.200]) by svr1.postgresql.org (Postfix) with ESMTP id ACBBFD6D96 for ; Tue, 25 Oct 2005 21:42:18 -0300 (ADT) Received: by xproxy.gmail.com with SMTP id t14so74916wxc for ; Tue, 25 Oct 2005 17:42:22 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=uVKlkw74Y2bl+one44ZwHzrkCnqyTJBfNOrEckb1I7zG0/b9/zTovI7TBMszy2sdLh1OomTLY88zcQFdff9+YM5FSCA1P7Zbi+/xpn55xbFe+aTcFjsoXfjJ7uJkguF4AB5IkdfDl++xeoHeY4dnK7y8uyhCpPv3GEK2fIGl6rU= Received: by 10.65.141.6 with SMTP id t6mr217617qbn; Tue, 25 Oct 2005 17:42:22 -0700 (PDT) Received: by 10.65.204.17 with HTTP; Tue, 25 Oct 2005 17:42:22 -0700 (PDT) Message-ID: <7159e12c0510251742y79d58679l@mail.gmail.com> Date: Wed, 26 Oct 2005 02:42:22 +0200 From: andy petrella To: pgsql-jdbc@postgresql.org Subject: Re: largeobjects deadlock ? In-Reply-To: <7159e12c0510251649r48a52bady@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_11253_21243021.1130287342751" References: <7159e12c0510251649r48a52bady@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.025 required=5 tests=[HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200510/134 X-Sequence-Number: 14065 ------=_Part_11253_21243021.1130287342751 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Oh, finally it seems rigth but my problem comes with the insertion in a function written in plpgsql... so how may I do to insert a bytea receive with an ROW ? CREATE OR REPLACE FUNCTION rule_dvd (FICHES.DVD) RETURNS INT AS $Func$ DECLARE fiche_dvd ALIAS FOR $1; [...] INSERT INTO INFORMATIONS.FILMS ( id, titre_o, titre_f, sortie, affiche, duree, genre, resume, visites, cote, imdb ) VALUES ( default, fiche_dvd.titre_o, fiche_dvd.titre_f, fiche_dvd.sortie, fiche_dvd.affiche, //?????????????? fiche_dvd.duree, fiche_dvd.genre, fiche_dvd.resume, 1, 0, fiche_dvd.imdb ); [...] I think that's my problem... but how can I do else ? Thx (and apologize my english...) andy 2005/10/26, andy petrella : > > HI all, > > I have somme problem with largeobjects setting in a preparedstatement, > here is the code with the problem in comment // : > > [...] > db.setAutoCommit(false); > [...] > LargeObjectManager lobj =3D pgdb.getLargeObjectAPI(); //pgdb is a > PGConnection > int loid =3D lobj.create(); > System.out.println("loid : " + loid); //this give 359648 > LargeObject image =3D lobj.open(loid); > int s, count =3D 0; > byte buf[] =3D new byte[2048]; > while ((s =3D affiche.read(buf, 0, buf.length)) > 0){ //affiche is an > InputStream > count +=3D s; > image.write(buf, 0, s); > } > BlobInputStream b =3D new BlobInputStream(image); > addDVD.setBinaryStream(4, b, count); //addDVD is an PreparedStatement > //addDVD.setNull(4, java.sql.Types.BINARY); // --> all work well if I > decomment this and comment the preceding > image.close(); > affiche.close(); > [...] > System.out.println("addDVD : " + addDVD.toString()); // bytes> for the fourth prm (bytea) > > int update =3D addDVD.executeUpdate(); // -->deadlocking here !!! > System.out.println("update =3D " + update); //never pass here > db.setAutoCommit(true); > [...] > > Am I setting the bytea in the rigth manner ? Else, how may I do that , > where are my mistakes ? > > Thx u all. > > andy > > ------=_Part_11253_21243021.1130287342751 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Oh, finally it seems rigth but my problem comes with the insertion in a function written in plpgsql... so how may I do to insert a bytea receive with an ROW ?

          CREATE  OR = ;     REPLACE FUNCTION
          rule_dvd  =       (FICHES.DVD)
          RETURNS INT
          AS   =    $Func$
          DECLARE
           fiche_dvd       ALIAS FO= R $1;

[...]

           INSERT INTO IN= FORMATIONS.FILMS
            &nb= sp;            =        (
            &nb= sp;            =             &nb= sp;  id,
            &nb= sp;            =             &nb= sp;  titre_o,
            &nb= sp;            =             &nb= sp;  titre_f,
            &nb= sp;            =             &nb= sp;  sortie,
            &nb= sp;            =             &nb= sp;  affiche,
            &nb= sp;            =             &nb= sp;  duree,
            &nb= sp;            =             &nb= sp;  genre,
            &nb= sp;            =             &nb= sp;  resume,
            &nb= sp;            =             &nb= sp;  visites,
            &nb= sp;            =             &nb= sp;  cote,
            &nb= sp;            =             &nb= sp;  imdb
            &nb= sp;            =        )
            &nb= sp;           VALUES
            &nb= sp;            =        (
            &nb= sp;            =             &nb= sp;  default,
            &nb= sp;            =             &nb= sp;  fiche_dvd.titre_o,
            &nb= sp;            =             &nb= sp;  fiche_dvd.titre_f,         &nb= sp;            =             &nb= sp;    
                                        fiche_dvd.sortie,
            &nb= sp;            =             &nb= sp;  fiche_dvd.affiche, //????????= ??????
            &nb= sp;            =             &nb= sp;  fiche_dvd.duree,
            &nb= sp;            =             &nb= sp;  fiche_dvd.genre,
            &nb= sp;            =             &nb= sp;  fiche_dvd.resume,
            &nb= sp;            =             &nb= sp;  1,
            &nb= sp;            =             &nb= sp;  0,
            &nb= sp;            =             &nb= sp;  fiche_dvd.imdb
            &nb= sp;            =        );            &= nbsp;           &nbs= p;

[...]

I think that's my problem... but how can I do else ?



Thx (and apologize my english...)

andy



2005/10/26, andy petrella <andy.petrella@gmail.com>:
HI all,

I have somme problem with largeobjects setting in a preparedstatement, here= is the code with the problem in comment // :

[...]
      &nb= sp;     db.setAutoCommit(false);
[...]     &nbs= p;    
      &nb= sp;     LargeObjectManager lobj =3D pgdb.getLargeObject= API(); //pgdb is a PGConnection
      &nb= sp;     int loid =3D lobj.create();
      &nb= sp;     System.out.println("loid : " + loid);= //this give 359648
      &nb= sp;     LargeObject image =3D lobj.open(loid); <= br style=3D"font-style: italic;">       &nb= sp;     int s, count =3D 0;
      &nb= sp;     byte buf[] =3D new byte[2048];
      &nb= sp;     while ((s =3D affiche.read(buf, 0, buf.length))= > 0){ //affiche is an InputStream
      &nb= sp;         count +=3D s;       &nb= sp;         image.write(buf, 0, s);=
      &nb= sp;     }
      &nb= sp;     BlobInputStream b =3D new BlobInputStream(image= );
      &nb= sp;     addDVD.setBinaryStream(4, b, count); //addDVD is an PreparedStatement
      &nb= sp;     //addDVD.setNull(4, java.sql.Types.BINARY); // = --> all wo= rk well if I decomment this and comment the preceding
      &nb= sp;     image.close();
      &nb= sp;     affiche.close();
[...]
   =          System.out.println("a= ddDVD : " + addDVD.toString()); // <stream of 6503 bytes> for the fourth prm (bytea)
      &nb= sp;    
      &nb= sp;     int update =3D addDVD.executeUpdate(); // -->deadlocking = here !!!
      &nb= sp;     System.out.println("update =3D " + up= date); //never pass here       &nb= sp;     db.setAutoCommit(true);
[...]

Am I setting the bytea in the rigth manner ? Else, how may I do that , wher= e are my mistakes ?

Thx u all.

andy




------=_Part_11253_21243021.1130287342751--