A PGLIB lo_export function for Win32

From: Scott Holmes <sholmes(at)pacificnet(dot)net>
To: pgsql-general(at)postgresql(dot)org (PG-General)
Cc: egk(at)egksystems(dot)com
Subject: A PGLIB lo_export function for Win32
Date: 2001-07-05 21:20:18
Message-ID: 200107052120.OAA07715@scotts.mynetwork.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Well, I'm making progress in my attempt to incorporate large objects in my NT
application. At this point I can export an object but the resulting file is
corrupt. The object within the database is not corrupt. I have checked by
using the normal lo_export function. Following is the section of code used to
create the file. I have removed the error checks for readability here. The
normal C function calls open(), write(), and close() as well as the single
call to lo_export() produce the corrupted file, the commented out Win32
calls cause a memory fault.

res = PQexec(conn, "begin");
PQclear(res);

lobj_fd = lo_open(conn, lobjId, INV_READ);

/* lo_export(conn, lobjId, filename); */

fd = open(filename, OF_CREATE | OF_WRITE, 0666);

/* fd = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE
| FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL); */

while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0)
{
tmp = write(fd, buf, nbytes);

/* tmp =WriteFile(fd, buf, nbytes, BUFSIZE, NULL); */

}

/* (void) lo_close(conn, lobj_fd); */

(void) close(fd);
(void) CloseHandle(fd);

res = PQexec(conn, "end");
PQclear(res);
PQfinish(conn);

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Holmes 2001-07-05 21:24:35 I Meant LIBPQ not PGLIB
Previous Message Allan Engelhardt 2001-07-05 20:20:14 Re: query optimizer questions