Re: OID Usage - Mailing list pgsql-general

From Bo Lorentsen
Subject Re: OID Usage
Date
Msg-id 41E81302.5060102@netgroup.dk
Whole thread Raw
In response to Re: OID Usage  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Responses Re: OID Usage
List pgsql-general
Alvaro Herrera wrote:

>You can create a function to get the sequence name attached to a table.
>Of course, you should take into account the fact that there could be
>more than one (two serial fields in a table are rare but not
>impossible), but if your tables have only one sequence you should be OK.
>
>
Are there a way to find and test if it is a primary key ?

>Something with
>
>select relname, relkind
>from pg_depend join pg_class on (oid = objid)
>where pg_depend.refobjid = 'foo'::regclass
>  and relkind = 'S';
>
>
Hmm, need to play more around using the "pg_" system tables.

Are they all well documentet, or need I some guessing ?

>(only lightly tested).  Then you can use that to construct your argument
>to the nextval() function.
>
>
:-)

>This doesn't happen with sequences on Postgres.  The value you get is
>guaranteed to be the one the sequence generated for you.
>
>
I know, and this is one of the reasons for not using MySQL :-)

/BL

pgsql-general by date:

Previous
From: Bo Lorentsen
Date:
Subject: Re: OID Usage
Next
From: "Frank D. Engel, Jr."
Date:
Subject: Re: [HACKERS] Much Ado About COUNT(*)