Merge pull request #735 from tomasz154/develop
Made an "innocuous SQL statement" more innocuous
SELECT * FROM was running in the PostgreSQL drivers just for the sake of returning valid SQL, which could of course be insanely slow on large tables.
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 1aa2334..78bf77a 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -205,6 +205,12 @@
$sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists);
$this->_reset();
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
+
return $this->db->query($sql);
}
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index 166cc4e..df0338e 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -81,9 +81,10 @@
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 "SELECT * FROM $table"; // Needs to return innocous but valid SQL statement
+ return TRUE;
}
}