changeConnection from hook_query_alter

in

If you have multiple Drupal installations that share common data, it would be nice to redirect queries any database server without much work. db_prefix only works with different databases or tables on the same server. This issue is to allow multiple servers.
hook_query_alter is powerful, but it doesn't allow us to change the connection. Since the connection isn't actually used until after preExecute(), it could be changed. The problem is that hook_query_alter only allows one to call methods on the query, but not to return an entirely new query. So the solution is to either add a method to the query for changing the connection, or allow hook_query_alter to return a different query object (one presumably that was extended from the original object).
The attached patch is pretty simple change.
You would use this in a hook_query_alter as in the following code snippet:
function example_query_alter(QueryAlterableInterface $query) {  if ($query->hasTag('user_load_multiple')) {    $query->changeConnection(Database::getConnection('default', 'secondary'));  }}