puppetlabs/puppetlabs-mysql — pull request #30 by ccaum (2011-12-29 19:46:58+00:00)
Title: (#11620 ) Use mysql gem as backend

Purpose of mysql gem backend
-----------------------------------

Previous to this pull request, the mysql system command was used for the
backend functionality for all the providers included in this module.
This pull changes the providers to use the mysql gem instead of the
system commands.

The reasons for this change are mostly in the interest of speed. Things
are sped up nicely since a subshell doesn't have to be created for each
and every query. Changes are also sped up since a single connection can
be used to make several queries.

Also in the interest of speed. This commit gives each provider the
ability to prefetch data. At the beginning of each puppet run, all
database, database_grant, and database_user instances are prefetched
over a single connection for each type.

To implement prefetching and give better introspection, the
self.instances method has been implemented. This means that `puppet
resource database`, for example, will return all databases in puppet
code.

Authentication
--------------

Since the mysql gem requires authentication tokens to be passed during
the initialization of a *Mysql* object, this request uses the
*Puppet::Util::IniConfig::File* class to parse the */root/.my.cnf* file
managed by the *mysql::server* class. If the *mysql::server* class was
not given a password to assign to the root mysql user, the
*/root/.my.cnf* file will not be managed and so no authentication tokens
are needed