--- includes/database.pgsql.inc	2005-08-14 05:58:26.000000000 -0400
+++ ../../Patches/database.pgsql.inc	2005-11-25 16:16:58.000000000 -0500
@@ -25,7 +25,7 @@
 
   $conn_string = ' user='. $url['user'] .' dbname='. substr($url['path'], 1) .' password='. $url['pass'] . ' host=' . $url['host'];
   $conn_string .= isset($url['port']) ? ' port=' . $url['port'] : '';
-  $connection = pg_connect($conn_string) or die(pg_last_error());
+  $connection = pg_connect($conn_string) or die(pg_last_error($connection));
 
   return $connection;
 }
@@ -52,14 +52,14 @@
   }
 
   if ($debug) {
-    print '<p>query: '. $query .'<br />error:'. pg_last_error() .'</p>';
+    print '<p>query: '. $query .'<br />error:'. pg_last_error($active_db) .'</p>';
   }
 
   if ($last_result !== FALSE) {
     return $last_result;
   }
   else {
-    trigger_error(pg_last_error() ."\nquery: ". htmlspecialchars($query), E_USER_ERROR);
+    trigger_error(pg_last_error($active_db) ."\nquery: ". htmlspecialchars($query), E_USER_ERROR);
     return FALSE;
   }
 }
@@ -134,7 +134,8 @@
  * Determine whether the previous query caused an error.
  */
 function db_error() {
-  return pg_last_error();
+  global $active_db;
+  return pg_last_error($active_db);
 }
 
 /**
