pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christian Niles <christian@unit12.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: LargeObject API and OIDs
Date: Sun, 24 Oct 2004 16:26:54 -0400
Message-ID: <17821.1098649614@sss.pgh.pa.us> (raw)
In-Reply-To: <ED2AAA08-25E2-11D9-AD96-000A9590B78E@unit12.net>
References: <ED2AAA08-25E2-11D9-AD96-000A9590B78E@unit12.net>

Christian Niles <christian@unit12.net> writes:
> However, since a versioning system will have a higher number of entries 
> compared to a normal storage system, I'm curious if there's any chance 
> for data corruption in the case that the DB runs out of OIDs. Ideally, 
> the database would raise an exception, and leave the existing data 
> untouched. From what I've read in the documentation, OIDs aren't 
> guaranteed to be unique, and may cycle. In this case, would the first 
> large object after the limit overwrite the first object?

No; instead you'd get a failure during lo_create:

	/* Check for duplicate (shouldn't happen) */
	if (LargeObjectExists(file_oid))
		elog(ERROR, "large object %u already exists", file_oid);

You could deal with this by retrying lo_create until it succeeds.
However, if you are expecting more than a few tens of millions of
objects, you probably don't want to go this route because the
probability of collision will be too high; you could spend a long time
iterating to find a free OID.  Something involving a bigint identifier
would work better.

> Also, would 
> the number of large objects available be limited by other database 
> objects that use OIDs?

No.  Although we use just a single OID sequence generator, each
different kind of system object has a separate unique index (or other
enforcement mechanism), so it doesn't really matter if, say, an OID in
use for a large object is also in use for a table.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <17821.1098649614@sss.pgh.pa.us>
Permalink:  ../17821.1098649614@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17821.1098649614@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: tgl@sss.pgh.pa.us, christian@unit12.net
  Subject: Re: LargeObject API and OIDs
  In-Reply-To: <17821.1098649614@sss.pgh.pa.us>
  References: <ED2AAA08-25E2-11D9-AD96-000A9590B78E@unit12.net> <17821.1098649614@sss.pgh.pa.us>

* 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