A PGLIB lo_export function for Win32
От | Scott Holmes |
---|---|
Тема | A PGLIB lo_export function for Win32 |
Дата | |
Msg-id | 200107052120.OAA07715@scotts.mynetwork.net обсуждение исходный текст |
Ответы |
Re: A PGLIB lo_export function for Win32
|
Список | 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);
В списке pgsql-general по дате отправления: