From: Edward Amsden <amsden_linux@embarqmail.com>
To: pgsql-interfaces@postgresql.org
Subject: Re: pqlib large object error
Date: Tue, 10 Jun 2008 17:46:41 -0400
Message-ID: <1213134401.17568.0.camel@dad-desktop2> (raw)
In-Reply-To: <24396.1213130996@sss.pgh.pa.us>
References: <1213118594.9123.11.camel@dad-desktop2>
<21991.1213122593@sss.pgh.pa.us>
<1213130242.15557.3.camel@dad-desktop2>
<24396.1213130996@sss.pgh.pa.us>
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 it cannot 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: amsden_linux@embarqmail.com
Subject: Re: pqlib large object error
In-Reply-To: <1213134401.17568.0.camel@dad-desktop2>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox