Postgres Support

eleybourn - February 6, 2008 - 00:40
Project:Classified Ads
Version:5.x-1.5-8
Component:Code
Category:task
Priority:critical
Assigned:eleybourn
Status:needs review
Description

Here is the patch to the install file, and a small patch to the module file for the postgresql functionality.

ed_classified.install

--- ed_classified/ed_classified.install 2007-06-05 13:25:14.000000000 +1000
+++ ed_classified.new/ed_classified.install     2008-02-06 11:28:13.098440000 +1100
@@ -17,10 +17,18 @@
       break;
 
     case 'pgsql':
-     watchdog('classified', 'install does not support postgres (pgsql)', WATCHDOG_ERROR);
-     drupal_set_message(t('This module does not support postgres at this time.','error'));
-      $success = FALSE;
-     break;
+      drupal_set_message(t('Creating classified ads table'));
+      // the {tablename} syntax is so multisite installs can add a
+      // prefix to the table name as set in the settings.php file
+       $success = db_query("CREATE TABLE  {edi_classified_nodes} (
+          nid serial NOT NULL,
+          vid int NOT NULL default '0',
+          expires_on int NOT NULL default '0',
+          expiration_notify_last_sent int NOT NULL default '0',
+          PRIMARY KEY  (nid,vid));"
+          );
+
+      break;
   }

ed_classified.module

--- ed_classified/ed_classified.module  2007-08-06 03:30:05.000000000 +1000
+++ ed_classified.new/ed_classified.module      2008-02-06 11:35:28.596235000 +1100
@@ -659,7 +659,9 @@
     $tree = taxonomy_get_tree(_ed_classified_get_vid(), $cats[$i]->tid, -1);
     $descendant_tids = array_merge(array($cats[$i]->tid), array_map('_taxonomy_get_tid_from_term', $tree));
     $last = db_fetch_object(db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN (%s) AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), implode(',', $descendant_tids), 0, 1));
-    $cats[$i]->latest = node_load(array('nid' => $last->nid));
+    if ($last->nid) {
+      $cats[$i]->latest = node_load(array('nid' => $last->nid));
+    }
   }

   // TODO: order by created date, #views, what?

#1

grateful_drupal_user - August 4, 2008 - 18:15
Status:reviewed & tested by the community» needs work

Please re-roll this patch against the current dev branch, and submit a proper patch file as an attachment. Thank you

#2

milesgillham - September 2, 2009 - 04:56
Status:needs work» needs review

I've applied a hand-crafted version of this patch along with elements from #177789: Postgres support (removing double quotes was a good idea) into 5.x-dev branch pending next release.

I don't have Postgres myself, so reviewer assistance would be helpful.

Cheers,

Miles

#3

milesgillham - September 14, 2009 - 03:42

The 5.x dev branch is presently quite unstable, the is a lot of development churn going on to bring 5.x branch up to 6.x branch in terms of bug fixes and features. Postgres testing should wait until the next 5.x release which should be this week.

Cheers,

Miles

 
 

Drupal is a registered trademark of Dries Buytaert.