Reply to Re: Race condition when inserting data / MySQL 4.0+, MyISAM tables

Your name:

Reply:


Posted by Markus on 07/15/07 17:46

petersprc schrieb:
> With MyISAM, you can do one of the methods you described or use LOCK
> TABLES.
>
> In your case I would do ON DUPLICATE KEY UPDATE or remove the unique
> constraint on the id.
>
> Finally, if you need to prevent more than one thread from executing
> the generate function, you can use a semaphore with the key being your
> id.

Thank you, I will remove the primary key then. As I never heard of
semaphores before, I read about them in Wikipedia; it is an interesting
concept. Before I realized I could remove the unique constraint (and not
aware of LOCK TABLES being available for MyISAM), I had even thought of
some kind of locking mechanism, adding a "locked" field to the items
table, that a thread could set to 1 in order to lock the item, and back
to 0 in order to unlock it. This would be kind of a binary semaphore
emulation for a non-OO environment such as PHP 4.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация