Обсуждение: AW: Re: postgres TODO

Поиск
Список
Период
Сортировка

AW: Re: postgres TODO

От
Zeugswetter Andreas SB
Дата:
> Thus spake Alessio Bragadini
> > > >       * Add function to return primary key value on INSERT
> > > 
> > > I don't get the point of this. Don't you know what you 
> inserted? For
> > > sequences there's curval()
> > 
> > Mmmhhh... it means that we can assume no update to the 
> sequence value
> > between the insert and the curval selection?
> 
> We can within one connection so this is safe but there are 
> other problems
> which I am not sure would be solved by this anyway.  With 
> rules, triggers
> and defaults there are often changes to the row between the 
> insert and the
> values that hit the backing store.  This is a general problem of which
> the primary key is only one example.
> 
> In fact, the OID of the new row is returned so what stops one 
> from just
> using it to get any information required.  This is exactly 
> what PyGreSQL
> does in its insert method.  After returning, the dictionary 
> used to store
> the fields for the row have been updated with the actual 
> contents of the
> row in the database.  It simply does a "SELECT *" using the new OID to
> get the row back.

OID access is not indexed by default, only if the dba created a
corresponding 
index. Thus OID access is a seq scan in a default environment.

Andreas


Re: AW: Re: postgres TODO

От
Philip Warner
Дата:
At 15:58 10/07/00 +0200, Zeugswetter Andreas SB wrote:
>
>OID access is not indexed by default, only if the dba created a
>corresponding 
>index. Thus OID access is a seq scan in a default environment.
>

Sticking my head out even further, this seems like a good reason to use
'insert/update...returning' - isn't the tuple already on the heap, and
easily available at the end of the insert/update?


----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.C.N. 008 659 498)             |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|                                |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/