Re: last OID and connections?

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: johnny(at)halfahead(dot)dk, pgsql-php(at)postgresql(dot)org
Subject: Re: last OID and connections?
Date: 2001-10-17 15:51:39
Message-ID: web-149645@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Johnny,

> Once I get a current project to production state, I'm going to get a
> heap of users performing updates simultaneously through the same
> update.php, and that raises a few questions:
>
> 1. will pg_getlastoid() return the last oid inserted *by this user*,
> *on this page*, *on this connection*, or is there a possibility for
> them to get mixed up, because the database gets a connection from the
> same user (php), and reuses connections or something?

Use a more sophisticated scheme. I understand that the current OID
scheme is eventually being phased out of future Postgres releases (with
backwards compatibility, of course!) and replaced with something else
because of problems with very large/very old databases. Or so the rumor
mill goes.

I handle this issue by wrapping all adds and edits in functions; each
function returns the primary key of the record as its result. NEXTVAL
and CURVAL are your friends!

> 2. I find oid's pretty clever, but are they good for unique keys? It
> seems, foreign key constraints won't use oid's in the current
> release, should i use serials instead?

Yes, you should use SERIALs instead. OIDs are for system use only, and
will cause problems with backup/restore as well as databases with more
than 2 billion objects.

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

Attachment Content-Type Size
unknown_filename text/plain 2 bytes
unknown_filename text/plain 2 bytes
unknown_filename text/plain 2 bytes

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Adam Haberlach 2001-10-17 19:18:23 Re: last OID and connections?
Previous Message Johnny Jørgensen 2001-10-17 13:27:17 last OID and connections?