Index: modules/simpletest/tests/database_test.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/database_test.test,v
retrieving revision 1.57
diff -u -p -r1.57 database_test.test
--- modules/simpletest/tests/database_test.test	5 Jun 2009 16:55:45 -0000	1.57
+++ modules/simpletest/tests/database_test.test	6 Jun 2009 13:31:35 -0000
@@ -518,7 +518,9 @@ class DatabaseInsertTestCase extends Dat
    * Test that the INSERT INTO ... SELECT ... syntax works.
    */
   function testInsertSelect() {
-    $query = db_select('test_people', 'tp')->fields('tp', array('name', 'age', 'job'));
+    $query = db_select('test_people', 'tp')
+      ->fields('tp', array('name', 'age', 'job'))
+      ->condition('tp.name', 'Meredith');
 
     db_insert('test')
       ->fields(array('name', 'age', 'job'))
Index: includes/database/query.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/query.inc,v
retrieving revision 1.24
diff -u -p -r1.24 query.inc
--- includes/database/query.inc	5 Jun 2009 16:55:45 -0000	1.24
+++ includes/database/query.inc	6 Jun 2009 13:31:35 -0000
@@ -439,7 +439,7 @@ class InsertQuery extends Query {
 
     // Check if a SelectQuery is passed in and use that.
     if (!empty($this->fromQuery)) {
-      return $this->connection->query((string) $this, array(), $this->queryOptions);
+      return $this->connection->query((string)$this, $this->fromQuery->getArguments(), $this->queryOptions);
     }
 
     // Confirm that the user did not try to specify an identical
Index: includes/database/mysql/query.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/mysql/query.inc,v
retrieving revision 1.12
diff -u -p -r1.12 query.inc
--- includes/database/mysql/query.inc	5 Jun 2009 16:55:45 -0000	1.12
+++ includes/database/mysql/query.inc	6 Jun 2009 13:31:36 -0000
@@ -41,6 +41,10 @@ class InsertQuery_mysql extends InsertQu
       }
     }
 
+    if (!empty($this->fromQuery)) {
+      $values += $this->fromQuery->getArguments();
+    }
+
     $last_insert_id = $this->connection->query((string)$this, $values, $this->queryOptions);
 
     // Re-initialize the values array so that we can re-use this query.
Index: includes/database/pgsql/query.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/pgsql/query.inc,v
retrieving revision 1.13
diff -u -p -r1.13 query.inc
--- includes/database/pgsql/query.inc	5 Jun 2009 16:55:45 -0000	1.13
+++ includes/database/pgsql/query.inc	6 Jun 2009 13:31:36 -0000
@@ -56,6 +56,11 @@ class InsertQuery_pgsql extends InsertQu
         }
       }
     }
+    if (!empty($this->fromQuery)) {
+      foreach ($this->fromQuery->getArguments() as $key => $value) {
+        $stmt->bindParam($key, $value);
+      }
+    }
 
     // PostgreSQL requires the table name to be specified explicitly
     // when requesting the last insert ID, so we pass that in via
