I've been testing modules on my postgresql based drupal setup, and I have this error when adding the table in location.pgsql (I created this, attached below).

psql:location.pgsql:15: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "location_pkey" for table "location"

psql:location.pgsql:15: ERROR: column name "oid" conflicts with a system column name

Comments

sammys’s picture

Title: oid is a postgresql system table name, dont use it! » No PostgreSQL support for location module
Version: 6.x-3.x-dev » 4.7.x-1.x-dev
Assigned: Unassigned » sammys
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new9.54 KB

As already mentioned in this thread, the oid field name is invalid in PostgreSQL and need to be changed or the module will be unusable. Here is a patch for location 4.7 including the update code for the field rename. Please test it on MySQL so we can get this issue dealt with. I'm tired of having to patch the module when I use it.

Cheers,

Sammy Spets
Synerger
http://www.synerger.com

redsky’s picture

Yes, it would be fantastic if this patch was applied!

sammys’s picture

Priority: Normal » Critical

since it doesn't work, this bug is critical. redsky: please see if the patch works on your system and post a response so I can get this issue set to 'ready to be committed'.

redsky’s picture

Hi, Sorry but I don't know how to apply a patch. I have the location module working using Drupal 4.7.3 and Postgres 8.0 by manually applying the changes outlined in the patch but I'm not sure I'd trust that as a good test of the patch. Sorry I know applying a patch is probably pretty basic, I'd be willing to help if you could point me in the right direction. I'm familiar with Subversion but not patches in it or CVS.

sammys’s picture

ok.. get the original files for location back again and put the patch file in your drupal site directory. i.e the one with sites and modules directories in it. Then run:
patch -p0 < patchfile.txt

This command doesn't work for every patch because of the -p argument needing variation when patch files are created differently or the directory from which you execute the patch command. Let me know how you go and thanks for pushing your boundaries! :)

bkieser’s picture

Thank you for this patch. I started doing the same work myself, then came across this post. Saved me a lot of time and effort!

Brad

bkieser’s picture

The patch creates a problem:
PHP Fatal error: Cannot redeclare location_update_2() (previously declared in /home/drupal/html/modules/location/location.install:98) in /home/drupal/html/modules/location/location.install on line 114

File has this after running the patch:

function location_update_2() {
$configured_countries = variable_get('location_configured_countries', array());
if ($configured_countries['us']) {
$configured_countries['us'] = 'us';
variable_set('location_configured_countries', $configured_countries);
}
}

function location_update_2() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("ALTER TABLE {location} CHANGE oid lid int(10) unsigned NOT NULL default '0'");
break;
case 'pgsql':
break;
}
}

I amended this to be:

function location_update_2() {
$configured_countries = variable_get('location_configured_countries', array());
if ($configured_countries['us']) {
$configured_countries['us'] = 'us';
variable_set('location_configured_countries', $configured_countries);
}
}

function location_update_2() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("ALTER TABLE {location} CHANGE oid lid int(10) unsigned NOT NULL default '0'");
break;
case 'pgsql':
break;
}
}

and it worked perfectly.

sammys’s picture

Seems the maintainer doesn't like the idea of changing the oid field to lid. Ah well. A new patch needs to be rolled up with the update_2 (supplied by this patch) changed to update_3 and the functions ordered properly. I don't have the time to do this just yet.

sammys’s picture

Status: Needs review » Needs work

setting it to code needs work

sammys’s picture

Status: Needs work » Needs review
StatusFileSize
new10.37 KB

Here is the updated patch for PostgreSQL support. I've changed the oid field to eid as requested by ankur (module maintainer). I've also torn out the (N) additions to integer types in the MySQL schema since they are not needed.

This code needs review by both PostgreSQL and MySQL parties before it's committed. I'll have a look at PostgreSQL after this post is done.

sammys’s picture

StatusFileSize
new10.53 KB

I've added a comment into the location.install file to notify everyone that all updates below the comment must include PostgreSQL support. Patch works in PostgreSQL and is RTBC on my side. Waiting on the MySQL side to be confirmed as working before this will be committed.

ankur’s picture

Status: Needs review » Reviewed & tested by the community

I have reviewed this patch and am going to commit it. The only hitch now is that I want to coordinate the column name change with maintainers of a couple of modules that refer to the location schema (and, specifically, the 'oid' column). Once I hear back from them, this will be committed.

ankur’s picture

Status: Reviewed & tested by the community » Fixed

This patch has been committed to DRUPAL-4-7 and HEAD branches.

Anonymous’s picture

Status: Fixed » Closed (fixed)