? modules/includes
? modules/modules
? modules/locale/.locale.test.swp
? sites/example.sites.php
? sites/default/files
? sites/default/settings.php
Index: includes/database/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/schema.inc,v
retrieving revision 1.36
diff -u -p -r1.36 schema.inc
--- includes/database/schema.inc	28 Jun 2010 19:57:34 -0000	1.36
+++ includes/database/schema.inc	12 Jul 2010 15:02:59 -0000
@@ -175,26 +175,32 @@ abstract class DatabaseSchema implements
    * @param
    *   Name of table to look prefix up for. Defaults to 'default' because thats
    *   default key for prefix.
+   * @param $add_prefix
+   *   Boolean that indicates whether the given table name should be prefixed.
+   *
    * @return
    *   A keyed array with information about the schema, table name and prefix.
    */
-  protected function getPrefixInfo($table = 'default') {
+  protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
     $info = array(
       'schema' => $this->defaultSchema,
       'prefix' => $this->connection->tablePrefix($table),
     );
+    if ($add_prefix) {
+      $table = $info['prefix'] . $table;
+    }
     // If the prefix contains a period in it, then that means the prefix also
     // contains a schema reference in which case we will change the schema key
     // to the value before the period in the prefix. Everything after the dot
     // will be prefixed onto the front of the table.
-    if ($pos = strpos($info['prefix'], '.') !== FALSE) {
+    if (($pos = strpos($table, '.')) !== FALSE) {
       // Grab everything before the period.
-      $info['schema'] = substr($info['prefix'], 0, $pos);
-      // Grab everything after the dot, and prefix on to the table.
-      $info['table'] = substr($info['prefix'], ++$pos) . $table;
+      $info['schema'] = substr($table, 0, $pos);
+      // Grab everything after the dot.
+      $info['table'] = substr($table, ++$pos);
     }
     else {
-      $info['table'] = $info['prefix'] . $table;
+      $info['table'] = $table;
     }
     return $info;
   }
@@ -230,15 +236,17 @@ abstract class DatabaseSchema implements
    *   The name of the table in question.
    * @param $operator
    *   The operator to apply on the 'table' part of the condition.
+   * @param $add_prefix
+   *   Boolean to indicate whether the table name needs to be prefixed.
    *
    * @return QueryConditionInterface
    *   A DatabaseCondition object.
    */
-  protected function buildTableNameCondition($table_name, $operator = '=') {
+  protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) {
     $info = $this->connection->getConnectionOptions();
 
     // Retrive the table name and schema
-    $table_info = $this->getPrefixInfo($table_name);
+    $table_info = $this->getPrefixInfo($table_name, $add_prefix);
 
     $condition = new DatabaseCondition('AND');
     $condition->condition('table_catalog', $info['database']);
@@ -278,7 +286,8 @@ abstract class DatabaseSchema implements
    *   Array, both the keys and the values are the matching tables.
    */
   public function findTables($table_expression) {
-    $condition = $this->buildTableNameCondition($table_expression, 'LIKE');
+    $condition = $this->buildTableNameCondition($table_expression, 'LIKE', FALSE);
+
     $condition->compile($this->connection, $this);
     // Normally, we would heartily discourage the use of string
     // concatenation for conditionals like this however, we
Index: includes/database/mysql/schema.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/mysql/schema.inc,v
retrieving revision 1.38
diff -u -p -r1.38 schema.inc
--- includes/database/mysql/schema.inc	28 Jun 2010 19:57:34 -0000	1.38
+++ includes/database/mysql/schema.inc	12 Jul 2010 15:02:59 -0000
@@ -30,16 +30,19 @@ class DatabaseSchema_mysql extends Datab
    * @return
    *   A keyed array with information about the database, table name and prefix.
    */
-  protected function getPrefixInfo($table = 'default') {
+  protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
     $info = array('prefix' => $this->connection->tablePrefix($table));
-    if (($pos = strpos($info['prefix'], '.')) !== FALSE) {
-      $info['database'] = substr($info['prefix'], 0, $pos);
-      $info['table'] = substr($info['prefix'], ++$pos) . $table;
+    if ($add_prefix) {
+      $table = $info['prefix'] . $table;
+    }
+    if (($pos = strpos($table, '.')) !== FALSE) {
+      $info['database'] = substr($table, 0, $pos);
+      $info['table'] = substr($table, ++$pos);
     }
     else {
       $db_info = Database::getConnectionInfo();
       $info['database'] = $db_info['default']['database'];
-      $info['table'] = $info['prefix'] . $table;
+      $info['table'] = $table;
     }
     return $info;
   }
@@ -52,10 +55,10 @@ class DatabaseSchema_mysql extends Datab
    * database as the schema unless specified otherwise, and exclude table_catalog
    * from the condition criteria.
    */
-  protected function buildTableNameCondition($table_name, $operator = '=') {
+  protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) {
     $info = $this->connection->getConnectionOptions();
 
-    $table_info = $this->getPrefixInfo($table_name);
+    $table_info = $this->getPrefixInfo($table_name, $add_prefix);
 
     $condition = new DatabaseCondition('AND');
     $condition->condition('table_schema', $table_info['database']);
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.132
diff -u -p -r1.132 system.test
--- modules/system/system.test	11 Jul 2010 01:01:11 -0000	1.132
+++ modules/system/system.test	12 Jul 2010 15:03:00 -0000
@@ -24,7 +24,7 @@ class ModuleTestCase extends DrupalWebTe
    *   specified base table. Defaults to TRUE.
    */
   function assertTableCount($base_table, $count = TRUE) {
-    $tables = db_find_tables($base_table . '%');
+    $tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
 
     if ($count) {
       return $this->assertTrue($tables, t('Tables matching "@base_table" found.', array('@base_table' => $base_table)));
