Index: includes/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/Attic/database.inc,v
retrieving revision 1.92.2.5
diff -u -p -r1.92.2.5 database.inc
--- includes/database.inc	9 Jun 2009 10:42:02 -0000	1.92.2.5
+++ includes/database.inc	21 Jul 2009 19:39:17 -0000
@@ -208,7 +208,21 @@ function _db_query_callback($match, $ini
 
   switch ($match[1]) {
     case '%d': // We must use type casting to int to convert FALSE/NULL/(TRUE?)
-      return (int) array_shift($args); // We don't need db_escape_string as numbers are db-safe
+      $value = array_shift($args);
+      // Do we need special bigint handling?
+      if ($value > PHP_INT_MAX || $value < -(PHP_INT_MAX)) {
+        $precision = ini_get('precision');
+        @ini_set('precision', 16);
+        $value = sprintf('%.0f', $value);
+        @ini_set('precision', $precision);
+      }
+      else {
+        $value = (int) $value;
+      }
+      // We don't need db_escape_string as numbers are db-safe.
+      return $value;
+    case '%u':
+      return sprintf('%u', array_shift($args));
     case '%s':
       return db_escape_string(array_shift($args));
     case '%n':
@@ -244,7 +258,7 @@ function db_placeholders($arguments, $ty
 /**
  * Indicates the place holders that should be replaced in _db_query_callback().
  */
-define('DB_QUERY_REGEXP', '/(%d|%s|%%|%f|%b|%n)/');
+define('DB_QUERY_REGEXP', '/(%d|%u|%s|%%|%f|%b|%n)/');
 
 /**
  * Helper function for db_rewrite_sql.
@@ -572,6 +586,9 @@ function db_type_placeholder($type) {
     case 'int':
       return '%d';
 
+    case 'unsigned':
+      return '%u';
+
     case 'float':
       return '%f';
 
Index: includes/database.mysql-common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/Attic/database.mysql-common.inc,v
retrieving revision 1.17.2.1
diff -u -p -r1.17.2.1 database.mysql-common.inc
--- includes/database.mysql-common.inc	7 Feb 2008 10:17:26 -0000	1.17.2.1
+++ includes/database.mysql-common.inc	21 Jul 2009 19:26:38 -0000
@@ -20,7 +20,7 @@
  *   using printf() syntax. Instead of a variable number of query arguments,
  *   you may also pass a single array containing the query arguments.
  *
- *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
+ *   Valid %-modifiers are: %s, %d, %u, %f, %b (binary data, do not enclose
  *   in '') and %%.
  *
  *   NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
Index: includes/database.mysql.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/Attic/database.mysql.inc,v
retrieving revision 1.89.2.1
diff -u -p -r1.89.2.1 database.mysql.inc
--- includes/database.mysql.inc	21 Jul 2009 08:52:29 -0000	1.89.2.1
+++ includes/database.mysql.inc	21 Jul 2009 19:26:55 -0000
@@ -212,7 +212,7 @@ function db_affected_rows() {
  *   A variable number of arguments which are substituted into the query
  *   using printf() syntax. The query arguments can be enclosed in one
  *   array instead.
- *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
+ *   Valid %-modifiers are: %s, %d, %u, %f, %b (binary data, do not enclose
  *   in '') and %%.
  *
  *   NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
@@ -261,7 +261,7 @@ function db_query_range($query) {
  *   A variable number of arguments which are substituted into the query
  *   using printf() syntax. The query arguments can be enclosed in one
  *   array instead.
- *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
+ *   Valid %-modifiers are: %s, %d, %u, %f, %b (binary data, do not enclose
  *   in '') and %%.
  *
  *   NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
Index: includes/database.mysqli.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/Attic/database.mysqli.inc,v
retrieving revision 1.54.2.1
diff -u -p -r1.54.2.1 database.mysqli.inc
--- includes/database.mysqli.inc	21 Jul 2009 08:52:30 -0000	1.54.2.1
+++ includes/database.mysqli.inc	21 Jul 2009 19:27:07 -0000
@@ -214,7 +214,7 @@ function db_affected_rows() {
  *   A variable number of arguments which are substituted into the query
  *   using printf() syntax. The query arguments can be enclosed in one
  *   array instead.
- *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
+ *   Valid %-modifiers are: %s, %d, %u, %f, %b (binary data, do not enclose
  *   in '') and %%.
  *
  *   NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
@@ -263,7 +263,7 @@ function db_query_range($query) {
  *   A variable number of arguments which are substituted into the query
  *   using printf() syntax. The query arguments can be enclosed in one
  *   array instead.
- *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
+ *   Valid %-modifiers are: %s, %d, %u, %f, %b (binary data, do not enclose
  *   in '') and %%.
  *
  *   NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
Index: includes/database.pgsql.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/Attic/database.pgsql.inc,v
retrieving revision 1.68.2.5
diff -u -p -r1.68.2.5 database.pgsql.inc
--- includes/database.pgsql.inc	9 Jun 2009 10:53:52 -0000	1.68.2.5
+++ includes/database.pgsql.inc	21 Jul 2009 19:27:20 -0000
@@ -103,7 +103,7 @@ function db_connect($url) {
  *   using printf() syntax. Instead of a variable number of query arguments,
  *   you may also pass a single array containing the query arguments.
  *
- *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
+ *   Valid %-modifiers are: %s, %d, %u, %f, %b (binary data, do not enclose
  *   in '') and %%.
  *
  *   NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
@@ -255,7 +255,7 @@ function db_affected_rows() {
  *   A variable number of arguments which are substituted into the query
  *   using printf() syntax. Instead of a variable number of query arguments,
  *   you may also pass a single array containing the query arguments.
- *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
+ *   Valid %-modifiers are: %s, %d, %u, %f, %b (binary data, do not enclose
  *   in '') and %%.
  *
  *   NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
@@ -304,7 +304,7 @@ function db_query_range($query) {
  *   A variable number of arguments which are substituted into the query
  *   using printf() syntax. The query arguments can be enclosed in one
  *   array instead.
- *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
+ *   Valid %-modifiers are: %s, %d, %u, %f, %b (binary data, do not enclose
  *   in '') and %%.
  *
  *   NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.299.2.3
diff -u -p -r1.299.2.3 block.module
--- modules/block/block.module	24 Jun 2008 14:40:08 -0000	1.299.2.3
+++ modules/block/block.module	21 Jul 2009 20:33:45 -0000
@@ -357,7 +357,7 @@ function block_user($type, $edit, &$acco
     case 'form':
       if ($category == 'account') {
         $rids = array_keys($account->roles);
-        $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (". db_placeholders($rids) .") OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids);
+        $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (". db_placeholders($rids, 'unsigned') .") OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids);
         $form['block'] = array('#type' => 'fieldset', '#title' => t('Block configuration'), '#weight' => 3, '#collapsible' => TRUE, '#tree' => TRUE);
         while ($block = db_fetch_object($result)) {
           $data = module_invoke($block->module, 'block', 'list');
@@ -404,7 +404,7 @@ function block_list($region) {
 
   if (!count($blocks)) {
     $rids = array_keys($user->roles);
-    $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (". db_placeholders($rids) .") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids));
+    $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (". db_placeholders($rids, 'unsigned') .") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids));
     while ($block = db_fetch_object($result)) {
       if (!isset($blocks[$block->region])) {
         $blocks[$block->region] = array();
Index: modules/blogapi/blogapi.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.module,v
retrieving revision 1.115.2.5
diff -u -p -r1.115.2.5 blogapi.module
--- modules/blogapi/blogapi.module	8 Oct 2008 20:12:17 -0000	1.115.2.5
+++ modules/blogapi/blogapi.module	21 Jul 2009 20:34:18 -0000
@@ -572,7 +572,7 @@ function blogapi_mt_validate_terms($node
       $term_list = array_unique($node->taxonomy);
       $params = $term_list;
       $params[] = $node->type;
-      $result = db_query(db_rewrite_sql("SELECT t.tid, t.vid FROM {term_data} t INNER JOIN {vocabulary_node_types} n ON t.vid = n.vid WHERE t.tid IN (". db_placeholders($term_list) .") AND n.type = '%s'", 't', 'tid'), $params);
+      $result = db_query(db_rewrite_sql("SELECT t.tid, t.vid FROM {term_data} t INNER JOIN {vocabulary_node_types} n ON t.vid = n.vid WHERE t.tid IN (". db_placeholders($term_list, 'unsigned') .") AND n.type = '%s'", 't', 'tid'), $params);
       $found_terms = array();
       $found_count = 0;
       while ($term = db_fetch_object($result)) {
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.414.2.11
diff -u -p -r1.414.2.11 taxonomy.module
--- modules/taxonomy/taxonomy.module	13 May 2009 19:38:33 -0000	1.414.2.11
+++ modules/taxonomy/taxonomy.module	21 Jul 2009 20:35:47 -0000
@@ -1116,7 +1116,7 @@ function taxonomy_select_nodes($tids = a
 
     if ($operator == 'or') {
       $args = call_user_func_array('array_merge', $descendant_tids);
-      $placeholders = db_placeholders($args, 'int');
+      $placeholders = db_placeholders($args, 'unsigned');
       $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN ('. $placeholders .') AND n.status = 1 ORDER BY '. $order;
       $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN ('. $placeholders .') AND n.status = 1';
     }
@@ -1126,7 +1126,7 @@ function taxonomy_select_nodes($tids = a
       $args = array();
       foreach ($descendant_tids as $index => $tids) {
         $joins .= ' INNER JOIN {term_node} tn'. $index .' ON n.vid = tn'. $index .'.vid';
-        $wheres .= ' AND tn'. $index .'.tid IN ('. db_placeholders($tids, 'int') .')';
+        $wheres .= ' AND tn'. $index .'.tid IN ('. db_placeholders($tids, 'unsigned') .')';
         $args = array_merge($args, $tids);
       }
       $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres .' ORDER BY '. $order;
Index: modules/taxonomy/taxonomy.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v
retrieving revision 1.9.2.1
diff -u -p -r1.9.2.1 taxonomy.pages.inc
--- modules/taxonomy/taxonomy.pages.inc	27 Apr 2009 11:49:05 -0000	1.9.2.1
+++ modules/taxonomy/taxonomy.pages.inc	21 Jul 2009 20:34:51 -0000
@@ -16,7 +16,7 @@ function taxonomy_term_page($str_tids = 
   }
 
   if ($terms['tids']) {
-    $result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN ('. db_placeholders($terms['tids']) .')', 't', 'tid'), $terms['tids']);
+    $result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN ('. db_placeholders($terms['tids'], 'unsigned') .')', 't', 'tid'), $terms['tids']);
     $tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to.
     $names = array();
     while ($term = db_fetch_object($result)) {
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.892.2.14
diff -u -p -r1.892.2.14 user.module
--- modules/user/user.module	1 Jul 2009 20:51:56 -0000	1.892.2.14
+++ modules/user/user.module	21 Jul 2009 20:35:12 -0000
@@ -499,7 +499,7 @@ function user_access($string, $account =
   // To reduce the number of SQL queries, we cache the user's permissions
   // in a static variable.
   if (!isset($perm[$account->uid])) {
-    $result = db_query("SELECT p.perm FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (". db_placeholders($account->roles) .")", array_keys($account->roles));
+    $result = db_query("SELECT p.perm FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (". db_placeholders($account->roles, 'unsigned') .")", array_keys($account->roles));
 
     $perms = array();
     while ($row = db_fetch_object($result)) {
