Cannot use LIMIT on DELETE query

mattconnolly - July 4, 2008 - 13:03
Project:Drupal
Version:6.2
Component:database system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

The function db_query_range steals the last two arguments to the function as LIMIT offset,count values. This is fine for SELECT queries, but DELETE queries use only LIMIT count.

Additionally, specifying a single parameter is valid in MySQL (ie: LIMIT count) but no provision is made for that by this function.

Effectively that means that the db_query_range function cannot be used to LIMIT DELETE queries or apply a LIMIT without an offset.

I suggest that the LIMIT count value be taken and the offset only applied if the argument is provided. This would make the command compatible with DELETE queries.

 
 

Drupal is a registered trademark of Dries Buytaert.