RE: User locks code
От | Mikheev, Vadim |
---|---|
Тема | RE: User locks code |
Дата | |
Msg-id | 3705826352029646A3E91C53F7189E32016743@sectorbase2.sectorbase.com обсуждение исходный текст |
Ответ на | User locks code ("Mikheev, Vadim" <vmikheev@SECTORBASE.COM>) |
Список | pgsql-hackers |
> Would your suggested implementation allow locking on an > arbitrary string? Well, placing string in LOCKTAG is not good so we could create auxilary hash table in shmem to keep such strings and use string' address as part of LOCKTAG. New function (LockRelationKey?) in lmgr.c would first find/place key in that table, than construct LOCKTAG and call LockAcquire. Possible syntax: LOCK TABLE relation IN {SHARE | EXCLUSIVE} MODEON KEY user-string [FOR TRANSACTION | FOR SESSION]; UNLOCK (RELEASE?) TABLE relation {SHARE | EXCLUSIVE} LOCKON KEY user-string; (or just some built-in functions). > If it does then one of the things I'd use it for is to insert > unique data without having to lock the table or rollback on > failed insert (unique index still kept as a guarantee). (Classic example how could be used SAVEPOINTs -:)) So, in your application you would first lock a key in excl mode (for duration of transaction), than try to select and insert unless found? (Note that this will not work with serializable isolevel.) Comments? Vadim
В списке pgsql-hackers по дате отправления: