Closed (duplicate)
Project:
Drupal core
Version:
6.x-dev
Component:
base system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Apr 2005 at 19:12 UTC
Updated:
20 Feb 2007 at 02:45 UTC
Jump to comment: Most recent file
Comments
Comment #1
chx commentedHm , tostinni is this applicable for MyISAM tables? I thought select for update is for InnoDB.
Comment #2
tostinni commentedWell, MySQL doc doesn't specify that it's restricted to MyISAM tables type, in fact I try this in a DB I got at free.fr which restrict tables types to MyISAM and it worked.
So I guess it's fine ;)
Comment #3
dries commentedSELECT ... FOR UPDATEuses row-level locking which requires MySQL 4 as far as I know. The syntax is ANSI SQL though. Are you using MySQL 3 or MySQL 4?Comment #4
dries commentedI wrote a mail to drupal-devel about making MySQL 4 a requirement. If we agree to drop support for MySQL 3, the proposed patch might improve performance too (although it will not be noticable).
Comment #5
menesis commentedFrom MySQL Reference Manual,
SELECTSyntax:Meaning
FOR UPDATEclause is allowed on any engine, but it only works on InnoDB; MyISAM just ignores that, and no locking occurs.I found a useful tip in Locking Reads
SELECT ... FOR UPDATEpage:Tried to modify
db_next_id(), diff attached, but not sure how to test if that works. Just an idea.Comment #6
menesis commentedmisread my own quote, missed LAST_INSERT_ID in the query. Updated diff.
Comment #7
tostinni commentedOk, sorry, I thought that MySQL doc would be more explicit regarding ROW locks.
As I didn't encounter errors with MySQL 3, I thought lock just apply correctly.
BTW, I read the doc and had seen the
LAST_INSERT_IDthat menesis proposed, but as it didn't make any lock, I thought it wouldn't be an acceptable way to handle thedb_next_idintegrity.Comment #8
killes@www.drop.org commentedLAST_INSERT_ID only works with auto_incremented columns.
Comment #9
moshe weitzman commentedwell, as a separate task we might consider throwing out our sequqnces implementation and just using DB provided seqences. Both pgsql and mysql provide these. mssql does too in case we ever revive support for it. Further, PHP 5.1 brings us PDO (a native DB access layer) that handles sequences automatically: http://www.php.net/manual/en/ref.pdo.php
Comment #10
tostinni commentedThis look promising, I hope we can see a support for Oracle DB one day, and I will help to support this.
But let's focus on the main thread ;)
I wasn't at the birth of Drupal, and I wonder why we use db_next_id sequence for MySQL if it exists since version 3 ? (also see this thread).
So I agree about abandonning this, unless there's a big compatibility reason.
Comment #11
kbahey commentedI agree with Moshe that we should use the database's autoincrement feature, and not our own sequences.
As he said, the two engines we support already do it, as well as the potential third engine as well.
I disagree somewhat with the PDO thing, since it is PHP5 only, and hence not suitable for the time being. In the future, maybe, but not now.
Comment #12
allie mickaLOCK's don't play well with multi-master replication (which we're using). MySQL 5 has support for safe auto_increment.
I would be in support of having every table use its own auto_increment, but here's what we have done for now:
AND...
Comment #13
magico commentedComment #14
chx commented