diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index dc0d78a91b0f55478b1d8d59b2d72a1e6d2068d1..41dca93ce1c8db09e3513a9a194c6383b55b620d 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -631,7 +631,7 @@ function drupal_is_denied($type, $mask) {
   // (allowed).
   // The use of ORDER BY / LIMIT is more efficient than "MAX(status) = 0"
   // in PostgreSQL <= 8.0.
-  return (bool) db_result(db_query_range("SELECT (status = 0) FROM {access} WHERE type = '%s' AND LOWER('%s') LIKE LOWER(mask) ORDER BY status DESC", $type, $mask, 0, 1));
+  return (bool) db_result(db_query_range("SELECT CASE WHEN status=1 THEN 0 ELSE 1 END FROM {access} WHERE type = '%s' AND LOWER('%s') LIKE LOWER(mask) ORDER BY status DESC", $type, $mask, 0, 1));
 }
 
 /**