diff --git a/engines/mysql.inc b/engines/mysql.inc
index 545423c..f1beaaf 100644
--- a/engines/mysql.inc
+++ b/engines/mysql.inc
@@ -38,6 +38,15 @@ class SchemaDatabaseSchema_mysql extends DatabaseSchema_mysql {
     $info = $this->connection->getConnectionOptions();
     $database = $info['database'];
 
+    // Apply table prefixes.
+    if (isset($table_name)) {
+      $table_info = $this->connection->schema()->getPrefixInfo($table_name);
+      if (!empty($table_info['database'])) {
+        $database = $table_info['database'];
+      }
+      $table_name = $table_info['table'];
+    }
+
     $tables = array();
     $args = array(':database' => $database);
     $sql = 'SELECT table_name, table_comment
diff --git a/engines/pgsql.inc b/engines/pgsql.inc
index 4b702b5..06eb374 100644
--- a/engines/pgsql.inc
+++ b/engines/pgsql.inc
@@ -40,6 +40,13 @@ class SchemaDatabaseSchema_pgsql extends DatabaseSchema_pgsql {
     $info = $this->connection->getConnectionOptions();
     $database = $info['database'];
 
+    // Apply table prefixes.
+    if (isset($table_name)) {
+      $table_info = $this->connection->schema()->getPrefixInfo($table_name);
+      // @todo What do we do with $table_info['schema']?
+      $table_name = $table_info['table'];
+    }
+
     //
     // Retrieve information about all columns in the database from the
     // 'columns' table of 'information_schema'.  In pgsql, TABLE_CATALOG
diff --git a/tests/schema_regression.test b/tests/schema_regression.test
index 8f7aed3..c855c1b 100644
--- a/tests/schema_regression.test
+++ b/tests/schema_regression.test
@@ -15,28 +15,16 @@ class SchemaRegressionTest extends DrupalWebTestCase {
   }
 
   function setUp() {
-    parent::setUp('schema');
-  }
-
-  function tearDown() {
-    db_query("DROP TABLE schema_testtbl");
-    db_drop_table('schema_testtbl');
-    parent::tearDown();
+    parent::setUp('schema', 'schema_test');
   }
 
   /**
    * Test API for adding tables
    */
   function testInspectionConflict518210() {
-    // Create an unprefixed table...
-    $tablename = "schema_testtbl";
-    $sql = "CREATE TABLE $tablename (
-              fid INT NOT NULL,
-              destid INT NOT NULL
-            )";
-    db_query($sql);
-
-    // ...and a prefixed table, with a different column list
+    // Drop the test table and re-create it with different columns.
+    $table = 'schema_test_1';
+    db_drop_table($table);
     $schema = array(
       'fields' => array(
         'sourceid' => array(
@@ -49,11 +37,11 @@ class SchemaRegressionTest extends DrupalWebTestCase {
         ),
       ),
     );
-    db_create_table($tablename, $schema);
+    db_create_table($table, $schema);
 
     // Do the full inspection, and get our specified tablename
     $inspect = schema_dbobject()->inspect();
-    $fields = $inspect[$tablename]['fields'];
+    $fields = $inspect[$table]['fields'];
 
     // We should see only the columns from the prefixed version
     $this->assertFalse(isset($fields['fid']), 'Column fid does not exist');
@@ -61,7 +49,8 @@ class SchemaRegressionTest extends DrupalWebTestCase {
     $this->assertTrue(isset($fields['destid']), 'Column destid exists.');
 
     // Inspect the table by using schema_compare().
-    $comparison = schema_compare_table($inspect[$tablename]);
+    $schema = drupal_get_schema('schema_test_1');
+    $comparison = schema_compare_table($schema);
     $this->assertEqual($comparison['status'], 'different', 'Table does not match its schema.');
   }
 }
diff --git a/tests/schema_test/schema_test.info b/tests/schema_test/schema_test.info
new file mode 100644
index 0000000..eaa10ec
--- /dev/null
+++ b/tests/schema_test/schema_test.info
@@ -0,0 +1,3 @@
+name = Schema test
+core = 7.x
+hidden = TRUE
diff --git a/tests/schema_test/schema_test.install b/tests/schema_test/schema_test.install
new file mode 100644
index 0000000..1a20e1c
--- /dev/null
+++ b/tests/schema_test/schema_test.install
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * Implements hook_schema().
+ */
+function schema_test_schema() {
+  $schema['schema_test_1'] = array(
+    'fields' => array(
+      'fid' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'destid' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+    ),
+  );
+
+  return $schema;
+}
+
+/**
+ * Implements hook_schema_alter().
+ */
+function schema_test_schema_alter(&$schema) {
+  $alter = variable_get('schema_test_schema_alter', array());
+  $schema = drupal_array_merge_deep($schema, $alter);
+}
diff --git a/tests/schema_test/schema_test.module b/tests/schema_test/schema_test.module
new file mode 100644
index 0000000..a4abe2d
--- /dev/null
+++ b/tests/schema_test/schema_test.module
@@ -0,0 +1,2 @@
+<?php
+
