Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select instances aka databases with one query #1657

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions lib/puppet/provider/mysql_database/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
commands mysql_raw: 'mysql'

def self.instances
mysql_caller('show databases', 'regular').split("\n").map do |name|
attributes = {}
mysql_caller(["show variables like '%_database'", name], 'regular').split("\n").each do |line|
k, v = line.split(%r{\s})
attributes[k] = v
end
mysql_caller('SELECT SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA', 'regular').split("\n").map do |line|
name, charset, collate = line.split(%r{\s})
new(name: name,
ensure: :present,
charset: attributes['character_set_database'],
collate: attributes['collation_database'])
charset: charset,
collate: collate)
end
end

Expand Down