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 30 Jul 2009 06:37:52 -0000 @@ -207,8 +207,23 @@ 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 + case '%d': + $value = array_shift($args); + // Do we need special bigint handling? This solution works for 53 bits. + 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 { + // We must use type casting to int to convert FALSE/NULL/TRUE + $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 +259,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 +587,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,