Re: ISOLATION LEVEL SERIALIZABLE
От | Stephan Szabo |
---|---|
Тема | Re: ISOLATION LEVEL SERIALIZABLE |
Дата | |
Msg-id | 20020326120824.Y13230-100000@megazone23.bigpanda.com обсуждение исходный текст |
Ответ на | Re: ISOLATION LEVEL SERIALIZABLE (power2themacs <power2themacs@yahoo.com>) |
Список | pgsql-general |
On Tue, 26 Mar 2002, power2themacs wrote: > >In table two you would not create a serial instead you would create an > >INTEGER because serial is a counter and the values in table 2 may not be > >in table 1. > > > >Use a transaction like as follows > > > >BEGIN; > >INSERT INTO TABLE1 VALUES (Whatever values); > >var = SELECT CURRVAL('sequence_name'); > >INSERT INTO TABLE2 VALUES (var,whatever else); > >COMMIT; > > > > But this is the race condition I am trying to avoid. Someone can > insert before I get the currval and it will beincremented and this > will result in invalid data. Right now, I'm doing exactly that but I That will only happen if another insert occurs *in your session*. Currval is defined to give the last value from your session, so whatever happens in other sessions will not affect the value returned from currval.
В списке pgsql-general по дате отправления: