Re: pqlib large object error
От | Edward Amsden |
---|---|
Тема | Re: pqlib large object error |
Дата | |
Msg-id | 1213134401.17568.0.camel@dad-desktop2 обсуждение исходный текст |
Ответ на | Re: pqlib large object error (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-interfaces |
On Tue, 2008-06-10 at 16:49 -0400, Tom Lane wrote: > Edward Amsden <amsden_linux@embarqmail.com> writes: > > On Tue, 2008-06-10 at 14:29 -0400, Tom Lane wrote: > >> Edward Amsden <amsden_linux@embarqmail.com> writes: > >>> I cannot seem to figure this error message out: > >>> > >>> ERROR: duplicate key value violates unique constraint "pg_largeobject_loid_pn_index" > >> > >> Huh, that shouldn't happen. Is it repeatable? > > > Yes. It happens every time the program runs, no matter what db or user, > > tried unix socket and tcp connect > > >> What PG version > >> is your server? > > > 8.3.1, running on Ubuntu Linux > > Hmph. The only thing I can think of is that that index is corrupt, > but it seems unlikely that it would be so in all databases. What > happens if you REINDEX pg_largeobject? The error has disappeared. Now it can't write to the object. lo_open seems to be successful, but lo_write is failing with: > ERROR: invalid large-object descriptor: 0 0 is a valid value (I checked) but it appears it cannot write to the object. lo_open should return a negative value if itcannot create the handle Here is my code: if (PQstatus(connect1) == CONNECTION_OK) { lo_1 = lo_creat(connect1, INV_READ|INV_WRITE); if (lo_1 > 0) { lo_1_fd= lo_open(connect1, lo_1, INV_READ|INV_WRITE); written = lo_write(connect1, lo_1_fd, filedata, (size_t) filelen); if (written == filelen) { printf ("Write successful, %d bytes written.\n", written); }else if (written < 0) { printf ("Write unsuccessful: %s\n", PQerrorMessage(connect1)); } else { printf ("Write partially successful. %d of %d bytes written.\n", written, filelen); } } else { fprintf (stderr, "Unable to create large object: %s\n", PQerrorMessage(connect1)); }} else { fprintf (stderr, "Unable to open connection: %s\n", PQerrorMessage(connect1));} Let me know if it's unreadable, my mail client can do funny things with indents. > regards, tom lane
В списке pgsql-interfaces по дате отправления: