diff -Nru schema/engines/pgsql.inc schema_patched//engines/pgsql.inc
--- schema/engines/pgsql.inc	2012-02-28 20:52:23.000000000 -0800
+++ schema_patched//engines/pgsql.inc	2012-02-28 20:49:13.000000000 -0800
@@ -44,12 +44,14 @@
     //
     $sql = ('SELECT * FROM information_schema.COLUMNS ' .
             'WHERE table_catalog=:database AND table_schema=current_schema()');
+    $tokens = array(':database' => $database);
     if (isset($tbl_name)) {
       $sql .= 'AND table_name = :table ';
+      $tokens[':table'] = $tblname;
     }
     $sql .= 'ORDER BY table_name, ordinal_position';
 
-    $res = db_query($sql, array(':database' => $database, ':table' => $tbl_name));
+    $res = db_query($sql, $tokens);
 
     //
     // Add an entry to $tables[<tablename>]['fields'] for each column.  $r
@@ -59,42 +61,42 @@
     foreach ($res as $r) {
       $col = array();
 
-      $r['new_table_name'] = schema_unprefix_table($r['table_name']);
+      $r->new_table_name = schema_unprefix_table($r->table_name);
 
       // We treat numeric columns slightly differently and identify them
       // because they have a 'numeric_precision_radix' property.
-      $numeric = !is_null($r['numeric_precision_radix']);
+      $numeric = !is_null($r->numeric_precision_radix);
 
       // Determine the Schema type and size from the database data_type.
-      list($col['type'], $col['size']) = schema_schema_type($r['data_type'], $r['table_name'], $r['column_name'], 'pgsql');
+      list($col['type'], $col['size']) = schema_schema_type($r->data_type, $r->table_name, $r->column_name, 'pgsql');
 
       // Non-numeric columns (e.g. varchar) can have a 'length'.
-      if (! $numeric && $r['character_maximum_length']) {
-        $col['length'] = $r['character_maximum_length'];
+      if (! $numeric && $r->character_maximum_length) {
+        $col['length'] = $r->character_maximum_length;
       }
 
       // Type 'numeric' columns have precision and scale
       if ($col['type'] == 'numeric') {
-        $col['precision'] = (int) $r['numeric_precision'];
-        $col['scale'] = (int) $r['numeric_scale'];
+        $col['precision'] = (int) $r->numeric_precision;
+        $col['scale'] = (int) $r->numeric_scale;
       }
 
       // Any column can have NOT NULL.
-      $col['not null'] = ($r['is_nullable'] == 'YES' ? FALSE : TRUE);
+      $col['not null'] = ($r->is_nullable == 'YES' ? FALSE : TRUE);
 
       // Any column might have a default value.  We have to set
       // $col['default'] to the correct type of data.  Remember that '',
       // 0, and '0' are all different types.
-      if (! is_null($r['column_default'])) {
+      if (! is_null($r->column_default)) {
 
         // pgsql's column_default can have ::typename appended,
         // nextval('<sequence_name>') if it is serial, etc.  Here, we're
         // just splitting out the actual default value.
-        if (strpos($r['column_default'], '::') !== FALSE) {
-          list($col['default'], $def_type) = explode('::', $r['column_default']);
+        if (strpos($r->column_default, '::') !== FALSE) {
+          list($col['default'], $def_type) = explode('::', $r->column_default);
         }
         else {
-          $col['default'] = $r['column_default'];
+          $col['default'] = $r->column_default;
           $def_type = '';
         }
 
@@ -121,7 +123,7 @@
         }
         else {
           // The column is not numeric, so $col['default'] should remain
-          // a string.  However, pgsql returns $r['column_default']
+          // a string.  However, pgsql returns $r->column_default
           // wrapped in single-quotes.  We just want the string value,
           // so strip off the quotes.
           $col['default'] = substr($col['default'], 1, -1);
@@ -132,22 +134,22 @@
       // Set $col['unsigned'] if the column is unsigned.  These
       // domains are currently defined in system.install (they should
       // probably eventually be moved into database.pgsql.inc).
-      switch ($r['domain_name']) {
+      switch ($r->domain_name) {
         case 'int_unsigned':
         case 'smallint_unsigned':
         case 'bigint_unsigned':
           $col['unsigned'] = 1;
           break;
       }
-      if (isset($r['check_clause']) && $r['check_clause'] == '((' . $r['column_name'] . ' => 0))') {
+      if (isset($r->check_clause) && $r->check_clause == '((' . $r->column_name . ' => 0))') {
         $col['unsigned'] = 1;
       }
 
       // Save the column definition we just derived from $r.
-      $tables[$r['table_name']]['fields'][$r['column_name']] = $col;
+      $tables[$r->table_name]['fields'][$r->column_name] = $col;
       // At this point, $tables is indexed by the raw db table name - save the unprefixed
       // name for later use
-      $tables[$r['table_name']]['name'] = $r['new_table_name'];
+      $tables[$r->table_name]['name'] = $r->new_table_name;
     }
 
     //
@@ -159,11 +161,11 @@
                      INNER JOIN information_schema.check_constraints cc ON ccu.constraint_name=cc.constraint_name
                      WHERE table_schema=current_schema()');
     foreach ($res as $r) {
-      $r['table_name'] = schema_unprefix_table($r['table_name']);
+      $r->table_name = schema_unprefix_table($r->table_name);
 
-      if ($r['check_clause'] == '((' . $r['column_name'] . ' >= 0))' ||
-          $r['check_clause'] == '((' . $r['column_name'] . ' >= (0)::numeric))') {
-        $tables[$r['table_name']]['fields'][$r['column_name']]['unsigned'] = TRUE;
+      if ($r->check_clause == '((' . $r->column_name . ' >= 0))' ||
+          $r->check_clause == '((' . $r->column_name . ' >= (0)::numeric))') {
+        $tables[$r->table_name]['fields'][$r->column_name]['unsigned'] = TRUE;
       }
     }
 
@@ -182,14 +184,14 @@
       '      c.relnamespace=n.oid AND n.nspname=current_schema() ' .
       'ORDER BY c2.relname');
     foreach ($res as $r) {
-      $r['tblname'] = schema_unprefix_table($r['tblname']);
-      $r['indname'] = schema_unprefix_table($r['indname']);
+      $r->tblname = schema_unprefix_table($r->tblname);
+      $r->indname = schema_unprefix_table($r->indname);
 
-      if (preg_match('@CREATE(?: UNIQUE)? INDEX \w+ ON "?(\w+)"?(?: USING \w+)? \((.*)\)@', $r['inddef'], $m)) {
+      if (preg_match('@CREATE(?: UNIQUE)? INDEX \w+ ON "?(\w+)"?(?: USING \w+)? \((.*)\)@', $r->inddef, $m)) {
         list($all, $table, $keys) = $m;
 
-        $name = $r['indname'];
-        if (preg_match('@^' . $r['tblname'] . '_(.*)_(?:idx|key)$@', $name, $m)) {
+        $name = $r->indname;
+        if (preg_match('@^' . $r->tblname . '_(.*)_(?:idx|key)$@', $name, $m)) {
           $name = $m[1];
         }
 
@@ -201,20 +203,20 @@
           else {
             $key = str_replace('"', '', $colname);
           }
-          if ($r['indisprimary'] == 't') {
-            $tables[$r['tblname']]['primary key'][] = $key;
+          if ($r->indisprimary == 't') {
+            $tables[$r->tblname]['primary key'][] = $key;
           }
-          elseif ($r['indisunique'] == 't') {
-            $tables[$r['tblname']]['unique keys'][$name][] = $key;
+          elseif ($r->indisunique == 't') {
+            $tables[$r->tblname]['unique keys'][$name][] = $key;
           }
           else {
-            $tables[$r['tblname']]['indexes'][$name][] = $key;
+            $tables[$r->tblname]['indexes'][$name][] = $key;
           }
         }
       }
       else {
         watchdog('schema', 'unrecognized pgsql index definition: @stmt',
-          array('@stmt' => $r['inddef']));
+          array('@stmt' => $r->inddef));
       }
     }
 
