Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 2C4779FB283 for ; Wed, 18 Apr 2007 10:41:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 74710-07 for ; Wed, 18 Apr 2007 10:41:23 -0300 (ADT) X-Greylist: delayed 00:06:38.12499 by SQLgrey-1.7.4 Received: from web26607.mail.ukl.yahoo.com (web26607.mail.ukl.yahoo.com [217.146.176.57]) by postgresql.org (Postfix) with SMTP id F09A59FA617 for ; Wed, 18 Apr 2007 10:41:22 -0300 (ADT) Received: (qmail 39953 invoked by uid 60001); 18 Apr 2007 13:34:40 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.es; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=coePROo4U81Ola0Ce3dHiKZvq29HDo15Wgw12RpSotE7gEWyEzpvurgoyxfAEf6meQHjTTZNgJ4ssVPgP8TjrWKMQC4WY9zcxs0KEXmkJSr4oCfIdc6xHc08eq3r8qTcEh6DBGUkxmsXPytcFGX8PIKVRl1740hJEizwku7jF9s=; X-YMail-OSG: 0dfZesQVM1nLfSapoJ8rMlZG9i9Ghi6rBA3Rcdvx15QjuiVc1BX4BJhyPPKJNMv_XKSLv_xeY_RazC_PH_jZkCICo0D02xRP_NEdVijML.FCpKTTwx6VoddKmoQ- Received: from [158.42.168.142] by web26607.mail.ukl.yahoo.com via HTTP; Wed, 18 Apr 2007 13:34:40 GMT X-Mailer: YahooMailRC/478 YahooMailWebService/0.7.41.10 Date: Wed, 18 Apr 2007 13:34:40 +0000 (GMT) From: =?iso-8859-1?Q?Miguel_Garc=EDa?= Subject: lo_write and lo_import does not work! To: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1348835020-1176903280=:38834" Message-ID: <471146.38834.qm@web26607.mail.ukl.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.698 tagged_above=0 required=5 tests=BAYES_50=0.001, DNS_FROM_RFC_ABUSE=0.2, HTML_40_50=0.496, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200704/10 X-Sequence-Number: 6498 --0-1348835020-1176903280=:38834 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hello,=0A=0AI have a little trouble using large objects with libpq an postg= resql 8.2 in windows xp professional SP2.=0A=0AI want to save and load larg= e objects from/to database, but its fails.=0A=0AIf i try to use the lo_impo= rt() function=0A=0A#define FILE_IN "d:/question-icon.png"=0AOid file_oid = =3D lo_import (conn, FILE_IN);=0A=0Afile_oid always have 0 value, neverthel= ess the large object has been created in table=0Apg_largeobject, but has no= data.=0A=0AIf i try to create the large object by hand, read the file from= disk, and then write the binary data=0Ato the large object, the call to lo= _write() always fail (always returns -1):=0A=0A ifstream is;=0A is.op= en (FILE_IN, ios::binary );=0A=0A // get length of file:=0A is.seekg = (0, ios::end);=0A length =3D is.tellg(); =0A is.seekg (0, ios::beg= );=0A=0A // allocate memory:=0A buffer =3D new char [length];=0A=0A = // read data as a block:=0A is.read (buffer,length);=0A is.close();= =0A =0A /*=0A * create the large object=0A */ = =0A lobjId =3D lo_creat(conn, INV_WRITE);=0A if (lobjId =3D=3D 0) {= =0A fprintf(stderr, "no se pudo crear el objeto grande\n");=0A = exit_nicely (conn);=0A }=0A =0A lobj_fd =3D lo_open(conn, lobjId= , INV_WRITE);=0A=0A /*=0A * Write the content of the file to the larg= e object=0A */=0A tmp =3D lo_write(conn, lobj_fd, buffer, length);=0A= if (tmp < length) {=0A fprintf(stderr, "error al escribir el obj= eto grande: %d bytes escritos\n", tmp);=0A exit_nicely (conn);=0A = } =0A=0AIn this case, the call to lo_write() does not work, but i can s= ee the large object created in table=0Apg_largeobject.=0A=0AAny Idea?=0A=0A= =0A=0A=0A =0A________________________________________________________= ____________________________=0ALLama Gratis a cualquier PC del Mundo. =0ALl= amadas a fijos y m=F3viles desde 1 c=E9ntimo por minuto. =0Ahttp://es.voice= .yahoo.com --0-1348835020-1176903280=:38834 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hello,

I have a little trouble using large obje= cts with libpq an postgresql 8.2 in windows xp professional SP2.

I w= ant to save and load large objects from/to database, but its fails.

= If i try to use the lo_import() function

#define FILE_IN "d:/questio= n-icon.png"
Oid file_oid =3D lo_import (conn, FILE_IN);

file_oid = always have 0 value, nevertheless the large object has been created in tabl= e
pg_largeobject, but has no data.

If i try to create the large o= bject by hand, read the file from disk, and then write the binary data
t= o the large object, the call to lo_write() always fail (always returns -1):=

    ifstream is;
    is.open (FILE= _IN, ios::binary );

    // get length of file:
&nb= sp;   is.seekg (0, ios::end);
    length =3D is.tellg(); =  
    is.seekg (0, ios::beg);

  &= nbsp; // allocate memory:
    buffer =3D new char [length= ];

    // read data as a block:
   = is.read (buffer,length);
    is.close();
  =                 = ; 
    /*
    * create the large = object
    */  
    lobjId = =3D lo_creat(conn, INV_WRITE);
    if (lobjId =3D=3D 0) {=
        fprintf(stderr, "no se pudo crear= el objeto grande\n");
        exit_nicely= (conn);
    }
  
    lo= bj_fd =3D lo_open(conn, lobjId, INV_WRITE);

    /*    * Write the content of the file to the large object
    */=
    tmp =3D lo_write(conn, lobj_fd, buffer, length);
=     if (tmp < length) {
      = ;  fprintf(stderr, "error al escribir el objeto grande: %d bytes escri= tos\n", tmp);
        exit_nicely (conn);<= br>    }   

In this case, the call to= lo_write() does not work, but i can see the large object created in table<= br>pg_largeobject.

Any Idea?

=0A=0A=0A

LLama Gratis a cualquier PC = del Mundo.
Llamadas a fijos y m=F3viles desde 1 c=E9ntimo por minuto.http://es.voice.yahoo.com
--0-1348835020-1176903280=:38834--