install procedure fails to create table httpbl w/ postgresql db.
database query syntax only works w/ mysql.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

uffner’s picture

The following statements create approximately the same table in postgresql:

create table httpbl (hostname varchar(128) NOT NULL,
     status smallint NOT NULL default '0',
     expire integer NOT NULL default '0', 
     PRIMARY KEY (hostname));
create index expire_idx on table httpbl (expire);
uffner’s picture

I think the only problem query is the insert. PostgreSQL does not support the MySql
extension "INSERT IGNORE" which in addition to the standard SQL insert will also update existing rows. From a brief glance at the code, it does not appear to need the ignore semantics, because a select is done first. If the ignore keyword can indeed be dropped, the module should work with postgresql (assuming that table creation gets fixed of course).

praseodym’s picture

Assigned: Unassigned » praseodym

I'm going to take a look at this; to be honest I've never done any PostgreSQL compatibility myself before so I'll have to check how to create install files etc.

stormsweeper’s picture

I will try to roll a patch later today, but I just had to do this for myself. This is the changed install function for 1.2.2.4

/**
 * Implementation of hook_install().
 */
function httpbl_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {httpbl} (
        hostname varchar(128) NOT NULL,
        status tinyint(2) NOT NULL default '0',
        expire int(11) NOT NULL default '0',
        PRIMARY KEY (hostname),
        INDEX (expire)
      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {httpbl} (
        hostname varchar(128) NOT NULL PRIMARY KEY,
        status smallint NOT NULL default 0,
        expire int NOT NULL default 0
        );");
      db_query("CREATE INDEX {httpbl}_expire_index on {httpbl} (expire);");
      break;
  }
}

As mentioned above, the "ignore" keyword should also be dropped from the cache set query.

jaydub’s picture

Version: 5.x-0.9 » 5.x-1.x-dev
Status: Active » Needs review
FileSize
828 bytes
1.55 KB

here's the above code in patch form with a few small changes.

Also patch to httpbl.module for the one query that has issues
in PostgreSQL

praseodym’s picture

Status: Needs review » Fixed

This change has been committed. Expect a new release within a few days.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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