Large objects.

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Large objects.
Date: 2010-09-24 13:13:45
Message-ID: AANLkTi=UAXxCVaOPvBtQLQYji5ZJ30my8bO3-CdcM7Dx@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hey all,

Here is simple test case of LOB usage, please, note the comments:

#include <libpq-fe.h>
#include <libpq/libpq-fs.h>

int main(int argc, char* argv[])
{
PGconn* c = PQconnectdb("password=test");

PGresult* r = PQexec(c, "BEGIN");
PQclear(r);

const unsigned int id = lo_create(c, 0);

int fd1 = lo_open(c, id, INV_READ | INV_WRITE);
int nBytes = lo_write(c, fd1, "D", 1);
int fd1Pos = lo_lseek(c, fd1, 2147483647, SEEK_SET);
fd1Pos = lo_lseek(c, fd1, 1, SEEK_CUR);
nBytes = lo_write(c, fd1, "Dima", 4); // nBytes == 4 ! Should be 0, IMO.
// If not, where is
my name
// will be written?

r = PQexec(c, "COMMIT");
PQclear(r);

r = PQexec(c, "BEGIN");
PQclear(r);

fd1 = lo_open(c, id, INV_READ | INV_WRITE);
fd1Pos = lo_lseek(c, fd1, 0, SEEK_END); // fd1Pos == -2147483647 !

char buf[16];
nBytes = lo_read(c, fd1, buf, 4); // nBytes == 0 ! Correct, IMO.

r = PQexec(c, "COMMIT");
PQclear(r);

return 0;
}

Tell me please, why lo_write() returns me the number of bytes "actually
written"
when current write location is out of 2GB ? IMO, in this case it should
returns
at least zero.
lo_read() returns zero in this case, and it is correct, IMO.

--
Regards,
Dmitriy

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2010-09-24 13:23:32 Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Previous Message Aidan Van Dyk 2010-09-24 13:01:54 Re: Configuring synchronous replication