Fix #808 Postgresql DBForge Driver errors.
- _process_fields() was missing and add_column(), drop_column() was producing malformed queries.
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index f86ba2d..7368b94 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -63,32 +63,13 @@
 	}
 
 	// --------------------------------------------------------------------
-
+	
 	/**
-	 * Create Table
-	 *
-	 * @access	private
-	 * @param	string	the table name
-	 * @param	array	the fields
-	 * @param	mixed	primary key(s)
-	 * @param	mixed	key(s)
-	 * @param	boolean	should 'IF NOT EXISTS' be added to the SQL
-	 * @return	bool
+	 * Process Fields
 	 */
-	function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+	function _process_fields($fields, $primary_keys=array())
 	{
-		$sql = 'CREATE TABLE ';
-
-		if ($if_not_exists === TRUE)
-		{
-			// PostgreSQL doesn't support IF NOT EXISTS syntax so we check if table exists manually
-			if ($this->db->table_exists($table))
-			{
-				return TRUE;
-			}
-		}
-
-		$sql .= $this->db->_escape_identifiers($table)." (";
+		$sql = '';
 		$current_field_count = 0;
 
 		foreach ($fields as $field=>$attributes)
@@ -184,6 +165,38 @@
 				$sql .= ',';
 			}
 		}
+		
+		return $sql;
+	}
+
+	// --------------------------------------------------------------------
+
+	/**
+	 * Create Table
+	 *
+	 * @access	private
+	 * @param	string	the table name
+	 * @param	array	the fields
+	 * @param	mixed	primary key(s)
+	 * @param	mixed	key(s)
+	 * @param	boolean	should 'IF NOT EXISTS' be added to the SQL
+	 * @return	bool
+	 */
+	function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+	{
+		$sql = 'CREATE TABLE ';
+
+		if ($if_not_exists === TRUE)
+		{
+			// PostgreSQL doesn't support IF NOT EXISTS syntax so we check if table exists manually
+			if ($this->db->table_exists($table))
+			{
+				return TRUE;
+			}
+		}
+
+		$sql .= $this->db->_escape_identifiers($table)." (";
+		$sql .= $this->_process_fields($fields, $primary_keys);
 
 		if (count($primary_keys) > 0)
 		{
@@ -249,40 +262,25 @@
 	 * @param	string	the field after which we should add the new field
 	 * @return	object
 	 */
-	function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
-	{
-		$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
+ 	function _alter_table($alter_type, $table, $fields, $after_field = '')
+ 	{
+ 		$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
 
-		// DROP has everything it needs now.
-		if ($alter_type == 'DROP')
-		{
-			return $sql;
-		}
+ 		// DROP has everything it needs now.
+ 		if ($alter_type == 'DROP')
+ 		{
+ 			return $sql.$this->db->_protect_identifiers($fields);
+ 		}
 
-		$sql .= " $column_definition";
+ 		$sql .= $this->_process_fields($fields);
 
-		if ($default_value != '')
-		{
-			$sql .= " DEFAULT \"$default_value\"";
-		}
+ 		if ($after_field != '')
+ 		{
+ 			$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ 		}
 
-		if ($null === NULL)
-		{
-			$sql .= ' NULL';
-		}
-		else
-		{
-			$sql .= ' NOT NULL';
-		}
-
-		if ($after_field != '')
-		{
-			$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
-		}
-
-		return $sql;
-
-	}
+ 		return $sql;
+ 	}
 
 	// --------------------------------------------------------------------
 
@@ -301,8 +299,6 @@
 		$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
 		return $sql;
 	}
-
-
 }
 
 /* End of file postgre_forge.php */