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