updating blobs in Perl with DBD::Pg

Поиск
Список
Период
Сортировка
От Herbert Liechti
Тема updating blobs in Perl with DBD::Pg
Дата
Msg-id 39EEA286.16994C84@thinx.ch
обсуждение исходный текст
Ответы Re: updating blobs in Perl with DBD::Pg  (Maurizio Cimaschi <mcc@iol.it>)
Список pgsql-general
Hello

I'm trying to update blob fields with the $dbh->func interface
of the Postgres driver. These functions are encapsulating the
appropriate functions of the lipq library. I'm able to create a
new blob field. Content is written correctly.

When I try to update an existing blob (overwriting the whole
content of the blob) the content is mixed up with the previous
version of the blob field. Here ist a snipped of my code:

  my $lobjId = $self->getOid($_); # Returns the oid
  die "Sorry got no oid for updating" unless ( $lobjId  );

  my $lobj_fd = $dbh->func($lobjId, $dbh->{pg_INV_WRITE}, 'lo_open');
  my $len = length($self->{data}->{$field});  # new content
  my $pos = $dbh->func($lobj_fd, 0, 0, 'lo_lseek'); # Seek Position 0
  die "Error while positioning to 0 in oid $lobjId" unless ( defined( $pos ) );

  my $nbytes = $dbh->func($lobj_fd, $self->{data}->{$_}, $len, 'lo_write');
  die "Error on writing to oid" unless ( defined( $nbytes ) );

  print "WROTE $nbytes of $len\n"; # Debug

  die "Error while closing oid $!" unless ( $dbh->func($lobj_fd, 'lo_close'));

Does anybody know what is wrong here?
Thanks for helping

Best regards
Herbie

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herbert Liechti                     E-Mail: Herbert.Liechti@thinx.ch
ThinX networked business services        Stahlrain 10, CH-5200 Brugg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

В списке pgsql-general по дате отправления:

Предыдущее
От: Karel Zak
Дата:
Сообщение: Re: to_char function
Следующее
От: Joerg Hessdoerfer
Дата:
Сообщение: Weird effects using BLOBs from libpq