cloudfoundry/cf-mysql-broker — pull request #11 by corlettb (2014-10-14 12:58:28+00:00)
Title: The query used to remove and re-add privilleges if a user goes over

their plan space is flawed.

If only a single user is bound to an instance (like in the previous
test cases) the query would be correct. If mulitple users were bound
it would multiply the actual usage by the number of users.
(e.g. 5mb space used with 5 users would report as 25mb space used).

This is due to including the mysql.db table in the query which could
end up with mulitple entries for multiple users.

The "SUM(tables.data_length + tables.index_length)" then
keeps counting the same rows repeatedly.

I have replaced joining with the dbs.Db table with a temporary
distinct table and added a second bound user to the test cases.