joomla/joomla-platform — pull request #691 by marcel-kanter (2012-01-01 13:25:31+00:00)
Title: Improper use of lock and unlock and racing condition in tablenested

This is a change according to trackers:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=27569
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=27562

Reason for the changes are the work of LOCK TABLES SQL statement. it works differnt then intented by the php code here. Lock has no "Incremental" behaviour instead it is "Release-If-Any and Set-New". So in tablenested the tables got unlocked after modifing the assets

Implemented for SQL Server too (was missing).

The lock has to be made in combination for the both tables. Is the same bebaviour on all databases. mysql here as an example: http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html is worth a reading.

Rules for Lock Release

When the table locks held by a session are released, they are all released at
the same time. A session can release its locks explicitly, or locks may be
released implicitly under certain conditions.

* A session can release its locks explicitly with UNLOCK TABLES.

* If a session issues a LOCK TABLES statement to acquire a lock while
already holding locks, its existing locks are released implicitly before the
new locks are granted.

* If a session begins a transaction (for example, with START TRANSACTION), an
implicit UNLOCK TABLES is performed, which causes existing locks to be released.
(For additional information about the interaction between table locking and
transactions, see Section 12.3.5.1, “Interaction of Table Locking and
Transactions”.)

So a change in the lock/unlock functions are needed too.