My Drupal 6.22 site runs on PostgreSQL 8.x database and httpbl module gives these errors:

Warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "REPLACE" LINE 1: REPLACE httpbl (hostname, status, expire) VALUES ('213.164.1... ^ in [.....]/httpdocs/includes/database.pgsql.inc on line 139

The line 677 in httbl.module is causing this problem, since in PostgreSQL there is not "Replace" command:

  db_query("REPLACE {httpbl} (hostname, status, expire) VALUES ('%s', %d, %d)", $ip, $status, time() + $offset);

Comments

praseodym’s picture

Problem is that fixing this bug by using two queries instead causes a conflict with #723358: PHP Warning: Duplicate entry <snip> for key 1\nquery: INSERT INTO httpbl (hostname, status, expire) VALUES <snip>. If you can come up with a solution that works on both PostgreSQL and MySQL, it'd be very helpful.

alpapan’s picture

Assigned: Unassigned » alpapan
Status: Active » Needs review
StatusFileSize
new1.04 KB

use db_lock_table

a

praseodym’s picture

Thanks for the patch. Have you tested this in production? I'm afraid that table locking for common operations like this one will have a severe performance impact.

alpapan’s picture

Might be a bit better to be a bit slow than not working at all?

praseodym’s picture

Since this code is executed on every page view, we simply cannot afford waiting for locks. That's simply killing for performance.

bendiy’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
StatusFileSize
new1.33 KB

Attached is a new patch that should address this issue for both PostgreSQL and MySQL. It is based on this approach for a PostgreSQL REPLACE:
http://stackoverflow.com/questions/1109061/insert-on-duplicate-update-po...

I see no reason why this would be any slower as a REPLACE is basically doing the same thing.

ben coleman’s picture

Status: Needs review » Reviewed & tested by the community

I tested the patch from #6 on both MySQL 5 and PostgreSQL 9.1, and it works on both.

  • bendiy authored 5b76a13 on 6.x-2.x
    Issue #807696 by bendiy, Ben Coleman: Module broken when using...
bryrock’s picture

Assigned: alpapan » Unassigned
Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

This has been committed. Should appear in next 6.x-2.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.