Let's solve both. pgsql patch is untested and quite frankly I do not care, but I still have added %u support and I hope it works.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Priority: Critical » Normal
FileSize
4.77 KB

Downgrading and adding %u tothe regexp too.

Dries’s picture

Care to provide a bit more background/context? How does this relate to ip2long?

chx’s picture

s integers > 2147483647 overflow with %d, see also http://drupal.org/node/134292

Dries’s picture

Ah, right! :-)

catch’s picture

Status: Needs review » Needs work

no longer applies.

chx’s picture

Assigned: chx » Unassigned
Status: Needs work » Needs review
FileSize
5.52 KB

OK, rerolled. The patch adds %u to the useable placeholders.

agentrickard’s picture

FileSize
164.96 KB

The patch creates multiple issues with the menu system -- causing all pages to return NOT FOUND. Trying to decipher exactly what.

Screenshot is of testsite home page after applying the patch. Using HEAD and pgSQL 8.2.3.

agentrickard’s picture

Initial finding: db_query_load_values() fails to return a value, but I still have odd behavior. Investigating.

Changes line 474.

#  $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
  return preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
bdragon’s picture

Um... db_query_load_values is not returning $query.

agentrickard’s picture

For reference, here's the similar function from database-mysql-common.inc:

function db_query_load_values($query, $args) {
  $args = array_map('db_escape_string', $args);
  array_unshift($args, str_replace('%b', "'%s'", $query));
  return call_user_func_array('sprintf', $args);
}
agentrickard’s picture

Fixing the return value for db_query_load_values allows this statement to work correctly.

db_query('INSERT INTO {test} (foo) VALUES (%u)', ip2long('255.255.255.255'));

Where {test} is defined as:

foo 	bigint 	

pgSQL 8.2.3

Changes in database_pgsql.inc:

function db_query_load_values($query, $args) {
  _db_query_callback($args, TRUE);
  return preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
}
bdragon’s picture

FileSize
6.41 KB

Patch and an additional comment because I had to scratch my head for a second to figure out what was going on.

agentrickard’s picture

Status: Needs review » Reviewed & tested by the community

Patch works as desired; %u syntax functions correctly in pgSQL. RTBC.

Gábor Hojtsy’s picture

Being an API change, I hand this over to Dries for consideration.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

This issue combines two things: it adds support for longs _and_ it rewrite part of the database API for performance's sake. This should be split in two issues.

dpearcefl’s picture

Does this issue exist in current D6?

dpearcefl’s picture

Status: Needs work » Postponed (maintainer needs more info)
dpearcefl’s picture

Status: Postponed (maintainer needs more info) » Needs work

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.