Re: Using oids

From: Bo Lorentsen <bl(at)netgroup(dot)dk>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: shridhar_daithankar(at)persistent(dot)co(dot)in, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Using oids
Date: 2003-09-03 11:47:01
Message-ID: 1062589621.7852.106.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Wed, 2003-09-03 at 13:19, Martijn van Oosterhout wrote:

> But your insert function needs to know something about the table it's
> inserting into. The sequences have quite predicatable names. Besides, you
> can set the name yourself (DCL does this IIRC).
No it don't know anything about the table it insert into. I simply do
the following :

1. INSERT data (comming from another layer)
2. Get the last oid
3. SELECT * FROM the same table where oid = what I just found.

I know absolutly nothing about the table, and I like it this way :-)

> The only thing you need to know is the name of the primary key field. This
> many be a problem in a generic layer. If you like you can make a UNIQUE
> INDEX on the oid column and retry inserts when they fail.
Hmm, it all end up putting alot of information to a lower layer, and
this is sad as PG already knows, but it may not tell me.

> In your code, do create an index on the OID column? If not, that's be a
> performance hit,
I'm not sure what you mean !

> Something called CTID usually (AFAIK). It's a (block,tuple) pair. It changes
> whenever you do an update. Or a vacuum.
So no id for a row, but only for a row instance ? Is this the reason for
the growing index files ?

> If I were doing it would extract the primary key of each table on startup
> and then change that one line of code to:
>
> os << "SELECT * FROM " << sTable << " WHERE "
> << prikey << " = currval('" << sTable << "_" << prikey << "_seq')";
Thanks, but I have to be aware of the "prikey" name, and demand a prikey
for all tables to insert row into :-(

> Hope this helps,

I know what you mean, but I don't like the impact of the solution.

/BL

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Larry Rosenman 2003-09-03 11:47:51 Re: Output from PLPGSQL
Previous Message Martijn van Oosterhout 2003-09-03 11:19:16 Re: Using oids

Browse pgsql-hackers by date

  From Date Subject
Next Message Oliver Elphick 2003-09-03 13:03:55 Re: Using oids
Previous Message Martijn van Oosterhout 2003-09-03 11:19:16 Re: Using oids