pg.ddx.io pgsql-php@postgresql.org mailing list archivehelp / color / mirror / Atom feed
last OID and connections? 3+ messages / 3 participants [nested] [flat]
* last OID and connections? @ 2001-10-17 13:27 "Johnny Jørgensen" <johnny@halfahead.dk> 2001-10-17 15:51 ` Re: last OID and connections? Josh Berkus <josh@agliodbs.com> 2001-10-17 19:18 ` Re: last OID and connections? Adam Haberlach <adam@newsnipple.com> 0 siblings, 2 replies; 3+ messages in thread From: "Johnny Jørgensen" @ 2001-10-17 13:27 UTC (permalink / raw) To: pgsql-php 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? e.g. If a user changes his profile, and an administrator changes some other row at the same time? 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? thanks, Mvh, Johnny Jørgensen johnny@halfahead.dk +45 6315 7328 ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: last OID and connections? 2001-10-17 13:27 last OID and connections? "Johnny Jørgensen" <johnny@halfahead.dk> @ 2001-10-17 15:51 ` Josh Berkus <josh@agliodbs.com> 1 sibling, 0 replies; 3+ messages in thread From: Josh Berkus @ 2001-10-17 15:51 UTC (permalink / raw) To: johnny@halfahead.dk; 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@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: last OID and connections? 2001-10-17 13:27 last OID and connections? "Johnny Jørgensen" <johnny@halfahead.dk> @ 2001-10-17 19:18 ` Adam Haberlach <adam@newsnipple.com> 1 sibling, 0 replies; 3+ messages in thread From: Adam Haberlach @ 2001-10-17 19:18 UTC (permalink / raw) To: Johnny Jørgensen <johnny@halfahead.dk>; +Cc: pgsql-php On Wed, Oct 17, 2001 at 03:27:17PM +0200, "Johnny Jørgensen" wrote: > 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? If you pass it the result object from your last insert, it should give an oid unique to that insert. I usually do the insert, the immediately read the row back with a select for the pg_lastoid() in order to get the pkey. A little wanky, but it seems to be the way to do it. > e.g. If a user changes his profile, and an administrator changes some other row at the same time? If they are through seperate connections, they should be completely different. > 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? Don't use them for anything persistent except for large objects. Use serials as primary keys. -- Adam Haberlach | Computer science has the unfortunate characteristic adam@newsnipple.com| that many of the pioneers of the field are still | alive and doing research. | -- Adam Rifkin ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-10-17 19:18 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2001-10-17 13:27 last OID and connections? "Johnny Jørgensen" <johnny@halfahead.dk> 2001-10-17 15:51 ` Josh Berkus <josh@agliodbs.com> 2001-10-17 19:18 ` Adam Haberlach <adam@newsnipple.com>
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