Index: includes/database/query.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/query.inc,v
retrieving revision 1.37
diff -u -9 -p -r1.37 query.inc
--- includes/database/query.inc	13 Dec 2009 18:10:42 -0000	1.37
+++ includes/database/query.inc	13 Jan 2010 19:12:53 -0000
@@ -1326,18 +1326,19 @@ class DatabaseCondition implements Query
     // $specials does not use drupal_static as its value never changes.
     static $specials = array(
       'BETWEEN' => array('delimiter' => ' AND '),
       'IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
       'NOT IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
       'IS NULL' => array('use_value' => FALSE),
       'IS NOT NULL' => array('use_value' => FALSE),
       // Use backslash for escaping wildcard characters.
       'LIKE' => array('postfix' => " ESCAPE '\\\\'"),
+      'NOT LIKE' => array('postfix' => " ESCAPE '\\\\'"),
       // These ones are here for performance reasons.
       '=' => array(),
       '<' => array(),
       '>' => array(),
       '>=' => array(),
       '<=' => array(),
     );
     if (isset($specials[$operator])) {
       $return = $specials[$operator];
Index: includes/database/pgsql/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/pgsql/database.inc,v
retrieving revision 1.32
diff -u -9 -p -r1.32 database.inc
--- includes/database/pgsql/database.inc	7 Jan 2010 04:51:26 -0000	1.32
+++ includes/database/pgsql/database.inc	13 Jan 2010 19:12:53 -0000
@@ -122,18 +122,19 @@ class DatabaseConnection_pgsql extends D
     return 'pgsql';
   }
 
   public function mapConditionOperator($operator) {
     static $specials = array(
       // In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE
       // statements, we need to use ILIKE instead. Use backslash for escaping
       // wildcard characters.
       'LIKE' => array('operator' => 'ILIKE', 'postfix' => " ESCAPE '\\\\'"),
+      'NOT LIKE' => array('operator' => 'NOT ILIKE', 'postfix' => " ESCAPE '\\\\'"),
     );
 
     return isset($specials[$operator]) ? $specials[$operator] : NULL;
   }
 
   /**
    * Retrive a the next id in a sequence.
    *
    * PostgreSQL has built in sequences. We'll use these instead of inserting
Index: includes/database/sqlite/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/sqlite/database.inc,v
retrieving revision 1.22
diff -u -9 -p -r1.22 database.inc
--- includes/database/sqlite/database.inc	7 Jan 2010 04:51:26 -0000	1.22
+++ includes/database/sqlite/database.inc	13 Jan 2010 19:12:53 -0000
@@ -151,18 +151,19 @@ class DatabaseConnection_sqlite extends 
 
   public function databaseType() {
     return 'sqlite';
   }
 
   public function mapConditionOperator($operator) {
     // We don't want to override any of the defaults.
     static $specials = array(
       'LIKE' => array('postfix' => " ESCAPE '\\'"),
+      'NOT LIKE' => array('postfix' => " ESCAPE '\\'"),
     );
     return isset($specials[$operator]) ? $specials[$operator] : NULL;
   }
 
   public function prepareQuery($query, $cache = TRUE) {
     // It makes no sense to use the static prepared statement cache here,
     // because all the work in our implementation is done in
     // DatabaseStatement_sqlite::execute() and cannot be cached.
     return $this->prepare($this->prefixTables($query));
Index: modules/statistics/statistics.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.admin.inc,v
retrieving revision 1.37
diff -u -9 -p -r1.37 statistics.admin.inc
--- modules/statistics/statistics.admin.inc	20 Dec 2009 19:41:57 -0000	1.37
+++ modules/statistics/statistics.admin.inc	13 Jan 2010 19:12:53 -0000
@@ -152,28 +152,28 @@ function statistics_top_referrers() {
     array('data' => t('Url'), 'field' => 'url'),
     array('data' => t('Last visit'), 'field' => 'last'),
   );
   $query = db_select('accesslog', 'a')->extend('PagerDefault')->extend('TableSort');
 
   $query->addExpression('COUNT(url)', 'hits');
   $query->addExpression('MAX(timestamp)', 'last');
   $query
     ->fields('a', array('url'))
-    ->where('LOWER(url) NOT LIKE :host', array(':host' => '%' . $_SERVER['HTTP_HOST'] . '%'))
+    ->condition('url', '%' . $_SERVER['HTTP_HOST'] . '%', 'NOT LIKE')
     ->condition('url', '', '<>')
     ->groupBy('url')
     ->limit(30)
     ->orderByHeader($header);
 
   $count_query = db_select('accesslog', 'a', array('target' => 'slave'));
   $count_query->addExpression('COUNT(DISTINCT url)');
   $count_query
-    ->where('LOWER(url) NOT LIKE :host', array(':host' => '%' . $_SERVER['HTTP_HOST'] . '%'))
+    ->condition('url', '%' . $_SERVER['HTTP_HOST'] . '%', 'NOT LIKE')
     ->condition('url', '', '<>');
   $query->setCountQuery($count_query);
 
   $result = $query->execute();
   $rows = array();
   foreach ($result as $referrer) {
     $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(REQUEST_TIME - $referrer->last))));
   }
 
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.442
diff -u -9 -p -r1.442 system.install
--- modules/system/system.install	13 Jan 2010 06:15:39 -0000	1.442
+++ modules/system/system.install	13 Jan 2010 19:12:53 -0000
@@ -1715,19 +1715,19 @@ function system_update_7003() {
   }
   // Make sure not to block any IP addresses that were specifically allowed by access rules.
   if (!empty($result)) {
     $result = db_query("SELECT mask FROM {access} WHERE status = :status AND type = :type", array(
       ':status' => 1,
       ':type' => $type,
     ));
     $or = db_condition('or');
     foreach ($result as $allowed) {
-      $or->where('LOWER(ip) LIKE LOWER(:mask)', array(':mask' => $allowed->mask));
+      $or->condition('ip', $allowed->mask, 'LIKE');
     }
     if (count($or)) {
       db_delete('blocked_ips')
         ->condition($or)
         ->execute();
     }
   }
 }
 
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1108
diff -u -9 -p -r1.1108 user.module
--- modules/user/user.module	13 Jan 2010 14:25:59 -0000	1.1108
+++ modules/user/user.module	13 Jan 2010 19:12:53 -0000
@@ -844,23 +844,23 @@ function user_search_access() {
 function user_search_execute($keys = NULL) {
   $find = array();
   // Replace wildcards with MySQL/PostgreSQL wildcards.
   $keys = preg_replace('!\*+!', '%', $keys);
   $query = db_select('users')->extend('PagerDefault');
   $query->fields('users', array('name', 'uid', 'mail'));
   if (user_access('administer users')) {
     // Administrators can also search in the otherwise private email field.
     $query->condition(db_or()->
-      where('LOWER(name) LIKE LOWER(:name)', array(':name' => "%$keys%"))->
-      where('LOWER(mail) LIKE LOWER(:mail)', array(':mail' => "%$keys%")));
+      condition('name', '%' . db_like($keys) . '%', 'LIKE')->
+      condition('mail', '%' . db_like($keys) . '%', 'LIKE'));
   }
   else {
-    $query->where('LOWER(name) LIKE LOWER(:name)', array(':name' => "%$keys%"));
+    $query->condition('name', '%' . db_like($keys) . '%', 'LIKE');
   }
   $result = $query
     ->limit(15)
     ->execute();
   foreach ($result as $account) {
     $find[] = array('title' => $account->name . ' (' . $account->mail . ')', 'link' => url('user/' . $account->uid, array('absolute' => TRUE)));
   }
   return $find;
 }
@@ -1059,19 +1059,19 @@ function user_account_form_validate($for
       elseif ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('name', db_like($form_state['values']['name']), 'LIKE')->range(0, 1)->execute()->fetchField()) {
         form_set_error('name', t('The name %name is already taken.', array('%name' => $form_state['values']['name'])));
       }
     }
 
     // Validate the e-mail address, and check if it is taken by an existing user.
     if ($error = user_validate_mail($form_state['values']['mail'])) {
       form_set_error('mail', $error);
     }
-    elseif ((bool) db_query_range("SELECT 1 FROM {users} WHERE uid <> :uid AND LOWER(mail) = LOWER(:mail)", 0, 1, array(':uid' => $account->uid, ':mail' => $form_state['values']['mail']))->fetchField()) {
+    elseif ((bool) db_select('users')->fields('users', array('uid'))->condition('uid', $account->uid, '<>')->condition('mail', db_like($form_state['values']['mail']), 'LIKE')->range(0, 1)->execute()->fetchField()) {
       // Format error message dependent on whether the user is logged in or not.
       if ($GLOBALS['user']->uid) {
         form_set_error('mail', t('The e-mail address %email is already taken.', array('%email' => $form_state['values']['mail'])));
       }
       else {
         form_set_error('mail', t('The e-mail address %email is already registered. <a href="@password">Have you forgotten your password?</a>', array('%email' => $form_state['values']['mail'], '@password' => url('user/password'))));
       }
     }
 
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.64
diff -u -9 -p -r1.64 user.pages.inc
--- modules/user/user.pages.inc	11 Jan 2010 16:25:16 -0000	1.64
+++ modules/user/user.pages.inc	13 Jan 2010 19:12:53 -0000
@@ -6,19 +6,19 @@
  * User page callback file for the user module.
  */
 
 /**
  * Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.
  */
 function user_autocomplete($string = '') {
   $matches = array();
   if ($string) {
-    $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER(:name)", 0, 10, array(':name' => $string . '%'));
+    $result = db_select('users')->fields('users', array('name'))->condition('name', db_like($string) . '%', 'LIKE')->range(0, 10)->execute();
     foreach ($result as $user) {
       $matches[$user->name] = check_plain($user->name);
     }
   }
 
   drupal_json_output($matches);
 }
 
 /**
