Fix issue #1264
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index ff5eb3f..9b76392 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -72,6 +72,11 @@
 			return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
 		}
 
+		if ( ! empty($this->db->data_cache['db_names']))
+		{
+			$this->db->data_cache['db_names'][] = $db_name;
+		}
+
 		return TRUE;
 	}
 
@@ -99,6 +104,15 @@
 			return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
 		}
 
+		if ( ! empty($this->db->data_cache['db_names']))
+		{
+			$key = array_search(strtolower($db_name), array_map('strtolower', $this->db->data_cache['db_names']), TRUE);
+			if ($key !== FALSE)
+			{
+				unset($this->db->data_cache['db_names'][$key]);
+			}
+		}
+
 		return TRUE;
 	}
 
@@ -209,7 +223,18 @@
 
 		$sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists);
 		$this->_reset();
-		return is_bool($sql) ? $sql : $this->db->query($sql);
+
+		if (is_bool($sql))
+		{
+			return $sql;
+		}
+
+		if (($result = $this->db->query($sql)) !== FALSE && ! empty($this->db->data_cache['table_names']))
+		{
+			$this->db->data_cache['table_names'][] = $$this->db->dbprefix.$table;
+		}
+
+		return $result;
 	}
 
 	// --------------------------------------------------------------------
@@ -231,7 +256,19 @@
 			return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
 		}
 
-		return $this->db->query(sprintf($this->_drop_table, $this->db->escape_identifiers($this->db->dbprefix.$table_name)));
+		$result = $this->db->query(sprintf($this->_drop_table, $this->db->escape_identifiers($this->db->dbprefix.$table_name)));
+
+		// Update table list cache
+		if ($result && ! empty($this->db->data_cache['table_names']))
+		{
+			$key = array_search(strtolower($this->db->dbprefix.$table_name), array_map('strtolower', $this->db->data_cache['table_names']), TRUE);
+			if ($key !== FALSE)
+			{
+				unset($this->db->data_cache['table_names'][$key]);
+			}
+		}
+
+		return $result;
 	}
 
 	// --------------------------------------------------------------------
@@ -255,10 +292,21 @@
 			return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
 		}
 
-		return $this->db->query(sprintf($this->_rename_table,
+		$result = $this->db->query(sprintf($this->_rename_table,
 						$this->db->escape_identifiers($this->db->dbprefix.$table_name),
 						$this->db->escape_identifiers($this->db->dbprefix.$new_table_name))
 					);
+
+		if ($result && ! empty($this->db->data_cache['table_names']))
+		{
+			$key = array_search(strtolower($this->db->dbprefix.$table_name), array_map('strtolower', $this->db->data_cache['table_names']), TRUE);
+			if ($key !== FALSE)
+			{
+				$this->db->data_cache['table_names'][$key] = $this->db->dbprefix.$new_table_name;
+			}
+		}
+
+		return $result;
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 02c9218..6a3b407 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -35,7 +35,6 @@
 abstract class CI_DB_utility extends CI_DB_forge {
 
 	public $db;
-	public $data_cache		= array();
 
 	// Platform specific SQL strings
 	// Just setting those defaults to FALSE as they are mostly MySQL-specific
@@ -60,29 +59,29 @@
 	public function list_databases()
 	{
 		// Is there a cached result?
-		if (isset($this->data_cache['db_names']))
+		if (isset($this->db->data_cache['db_names']))
 		{
-			return $this->data_cache['db_names'];
+			return $this->db->data_cache['db_names'];
 		}
 		elseif ($this->_list_databases === FALSE)
 		{
 			return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
 		}
 
-		$this->data_cache['db_names'] = array();
+		$this->db->data_cache['db_names'] = array();
 
 		$query = $this->db->query($this->_list_databases);
 		if ($query === FALSE)
 		{
-			return $this->data_cache['db_names'];
+			return $this->db->data_cache['db_names'];
 		}
 
 		for ($i = 0, $c = count($query); $i < $c; $i++)
 		{
-			$this->data_cache['db_names'] = current($query[$i]);
+			$this->db->data_cache['db_names'] = current($query[$i]);
 		}
 
-		return $this->data_cache['db_names'];
+		return $this->db->data_cache['db_names'];
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php
index c8cee99..ea8feb4 100644
--- a/system/database/drivers/cubrid/cubrid_utility.php
+++ b/system/database/drivers/cubrid/cubrid_utility.php
@@ -41,12 +41,12 @@
 	 */
 	public function list_databases()
 	{
-		if (isset($this->data_cache['db_names']))
+		if (isset($this->db->data_cache['db_names']))
 		{
-			return $this->data_cache['db_names'];
+			return $this->db->data_cache['db_names'];
 		}
 
-		return $this->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id);
+		return $this->db->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php
index 3f9967f..d1b006e 100644
--- a/system/database/drivers/interbase/interbase_forge.php
+++ b/system/database/drivers/interbase/interbase_forge.php
@@ -67,6 +67,14 @@
 		{
 			return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
 		}
+		elseif ( ! empty($this->db->data_cache['db_names']))
+		{
+			$key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE);
+			if ($key !== FALSE)
+			{
+				unset($this->db->data_cache['db_names'][$key]);
+			}
+		}
 
 		return TRUE;
 	}
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index 71eed7d..e02e327 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -61,6 +61,14 @@
 		{
 			return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
 		}
+		elseif ( ! empty($this->db->data_cache['db_names']))
+		{
+			$key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE);
+			if ($key !== FALSE)
+			{
+				unset($this->db->data_cache['db_names'][$key]);
+			}
+		}
 
 		return TRUE;
 	}
diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php
index f8bd116..6a76ba9 100644
--- a/system/database/drivers/sqlite3/sqlite3_forge.php
+++ b/system/database/drivers/sqlite3/sqlite3_forge.php
@@ -66,6 +66,14 @@
 			{
 				return $this->db->db_debug ? $this->db->display_error('db_unable_to_drop') : FALSE;
 			}
+			elseif ( ! empty($this->db->data_cache['db_names']))
+			{
+				$key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE);
+				if ($key !== FALSE)
+				{
+					unset($this->db->data_cache['db_names'][$key]);
+				}
+			}
 
 			return TRUE;
 		}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 5627f02..fb137e4 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -249,6 +249,7 @@
 -  Fixed a bug where protect_identifiers() ignored it's extra arguments when the value passed to it is an array.
 -  Fixed a bug where _has_operator() didn't detect BETWEEN.
 -  Fixed a bug where :doc:`Query Builder <database/query_builder>`'s join failed with identifiers containing dashes.
+-  Fixed a bug (#1264) - :doc:`Database Forge <database/forge>` and :doc:`Database Utilities <database/utilities>` didn't update/reset the databases and tables list cache when a table or a database is created, dropped or renamed.
 
 Version 2.1.1
 =============