We recently installed CRM Core on a drupal site running PostgreSQL, and on activation we got the following:

PDOException: SQLSTATE[42701]: Duplicate column: 7 ERROR: column name "ctid" conflicts with a system column name: CREATE TABLE {crm_core_match_contact_types} ( ctid serial CHECK (ctid >= 0), contact_type varchar(32) NOT NULL, threshold int CHECK (threshold >= 0) NOT NULL default 0, status smallint NOT NULL default 0, strict smallint NOT NULL default 0, return_order varchar(32) NOT NULL, PRIMARY KEY (ctid) ); Array ( ) in db_create_table() (line 2720 of /home/site1/public_html/includes/database/database.inc).

The problem is that 'ctid' is a reserved field name in PostgreSQL, and the crm_core_match_contact_types table uses that for the id column. A quick grep seems to show that ctid isn't referenced anywhere in CRM Core code other than in the .install file. Anyone know if one of the extension modules uses it?

I'm inclined to change the field name to 'ct_id'. Any other suggestions? A patch will follow once I get a test site on MySQL set up to test the upgrade code.

Comments

ben coleman’s picture

Status: Active » Needs review
StatusFileSize
new1.89 KB

Attached is a patch that fixes the above problem. This changes the field name to ct_id, and includes .install file update code to rename the field on an update. I put up a test MySQL site and the update appears to work, but it wouldn't hurt if someone more familiar with MySQL tested it, too (we're exclusively a PostgreSQL shop).

  • RoSk0 committed 5b34a30 on 7.x-0.x authored by Ben Coleman
    Issue #2496619 by Ben Coleman: PostgreSQL compatibility problem on...
rosk0’s picture

Version: 7.x-0.980 » 7.x-1.x-dev
Component: Code » CRM Core Match
Status: Needs review » Fixed

Fixed.
Thanks!

Status: Fixed » Closed (fixed)

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