FAQ
Hi,
I'm trying to get lo size via libpq before starting reading it (postgres
server 8.3.5). lo_lseek always returns 4 (actual size is > 1M).
I query table with "select photo from employee where id='xxxx'". It returns
lo oid integer as expected. Then I use following code to obtain size of the
lo object:
int lobj_fd = lo_open(conn, lobjId, INV_READ); // returns valid fd, ok

lo_lseek(conn, lobj_fd, 0L, SEEK_END );
size = lo_tell(conn, lobj_fd); // always returns 4, error?

Is it possible to obtain lo object size before reading it?

Thank you
Konstantin

Search Discussions

  • Konstantin Izmailov at Jun 17, 2009 at 10:15 pm
    I found the reason - it was bug in my code when inserting lo object. It's
    size was actually 4.
    Please ignore or delete my post.

    On Wed, Jun 17, 2009 at 11:38 AM, Konstantin Izmailov
    wrote:
    Hi,
    I'm trying to get lo size via libpq before starting reading it (postgres
    server 8.3.5). lo_lseek always returns 4 (actual size is > 1M).
    I query table with "select photo from employee where id='xxxx'". It returns
    lo oid integer as expected. Then I use following code to obtain size of the
    lo object:
    int lobj_fd = lo_open(conn, lobjId, INV_READ); // returns valid fd, ok

    lo_lseek(conn, lobj_fd, 0L, SEEK_END );
    size = lo_tell(conn, lobj_fd); // always returns 4, error?

    Is it possible to obtain lo object size before reading it?

    Thank you
    Konstantin
  • Konstantin Izmailov at Jun 17, 2009 at 10:18 pm
    Out of curiosity, what if lo object has size > 4GB, how lo_tell return its
    size? Looks like this is an interface issue.

    I found a post dated back to 1998, when somebody pointed it out and a
    posgres developer promised to fix it.

    Thank you all
    On Wed, Jun 17, 2009 at 3:15 PM, Konstantin Izmailov wrote:

    I found the reason - it was bug in my code when inserting lo object. It's
    size was actually 4.
    Please ignore or delete my post.

    On Wed, Jun 17, 2009 at 11:38 AM, Konstantin Izmailov <
    kizmailov@gmail.com> wrote:
    Hi,
    I'm trying to get lo size via libpq before starting reading it (postgres
    server 8.3.5). lo_lseek always returns 4 (actual size is > 1M).
    I query table with "select photo from employee where id='xxxx'". It
    returns lo oid integer as expected. Then I use following code to obtain size
    of the lo object:
    int lobj_fd = lo_open(conn, lobjId, INV_READ); // returns valid fd,
    ok

    lo_lseek(conn, lobj_fd, 0L, SEEK_END );
    size = lo_tell(conn, lobj_fd); // always returns 4, error?

    Is it possible to obtain lo object size before reading it?

    Thank you
    Konstantin
  • Tom Lane at Jun 17, 2009 at 11:05 pm

    Konstantin Izmailov writes:
    Out of curiosity, what if lo object has size > 4GB, how lo_tell return its
    size? Looks like this is an interface issue.
    That's simple: it can't have such a size.

    Allowing LOs bigger than 2GB is on the TODO list, but don't hold your
    breath. Most people who are interested in objects that large are
    storing them out in the filesystem anyway.

    regards, tom lane
  • Konstantin Izmailov at Jun 18, 2009 at 12:30 am
    It would be great to remove the limitation. I can image various
    possibilities if Postgres can handle larger lo objects. For example, to
    stream HD content from DB to a multimedia device for displaying.

    Would that be technically hard to do? My impression is that lo has pretty
    scalable implementation already.
    On Wed, Jun 17, 2009 at 4:05 PM, Tom Lane wrote:

    Konstantin Izmailov <pgfizm@gmail.com> writes:
    Out of curiosity, what if lo object has size > 4GB, how lo_tell return its
    size? Looks like this is an interface issue.
    That's simple: it can't have such a size.

    Allowing LOs bigger than 2GB is on the TODO list, but don't hold your
    breath. Most people who are interested in objects that large are
    storing them out in the filesystem anyway.

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-general @
categoriespostgresql
postedJun 17, '09 at 6:38p
activeJun 18, '09 at 12:30a
posts5
users3
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase