diff --git a/lib/puppet/provider/mysql.rb b/lib/puppet/provider/mysql.rb index 62453be1e..c2e70382b 100644 --- a/lib/puppet/provider/mysql.rb +++ b/lib/puppet/provider/mysql.rb @@ -79,9 +79,9 @@ def self.cmd_table(table) # We can't escape *.* so special case this. table_string << if table == '*.*' '*.*' - # Special case also for PROCEDURES - elsif table.start_with?('PROCEDURE ') - table.sub(%r{^PROCEDURE (.*)(\..*)}, 'PROCEDURE `\1`\2') + # Special case also for FUNCTIONs and PROCEDUREs + elsif table.start_with?('FUNCTION ', 'PROCEDURE ') + table.sub(%r{^(FUNCTION|PROCEDURE) (.*)(\..*)}, '\1 `\2`\3') else table.sub(%r{^(.*)(\..*)}, '`\1`\2') end diff --git a/spec/acceptance/types/mysql_grant_spec.rb b/spec/acceptance/types/mysql_grant_spec.rb index 87dbfd239..081d3c160 100644 --- a/spec/acceptance/types/mysql_grant_spec.rb +++ b/spec/acceptance/types/mysql_grant_spec.rb @@ -422,6 +422,38 @@ class { 'mysql::server': end end + describe 'adding function privileges' do + it 'works without errors' do + pp = <<-EOS + exec { 'simplefunc-create': + command => '/usr/bin/mysql --user="root" --password="password" --database=mysql -NBe "CREATE FUNCTION simplefunc (s CHAR(20)) RETURNS CHAR(50) DETERMINISTIC RETURN CONCAT(\\'Hello, \\', s, \\'!\\')"', + before => Mysql_user['test3@tester'], + } + + mysql_user { 'test3@tester': + ensure => 'present', + } + + mysql_grant { 'test3@tester/FUNCTION mysql.simplefunc': + ensure => 'present', + table => 'FUNCTION mysql.simplefunc', + user => 'test3@tester', + privileges => ['EXECUTE'], + require => Mysql_user['test3@tester'], + } + EOS + + apply_manifest(pp, catch_failures: true) + end + + it 'finds the user' do + shell('mysql -NBe "SHOW GRANTS FOR test3@tester"') do |r| + expect(r.stdout).to match(%r{GRANT EXECUTE ON FUNCTION `mysql`.`simplefunc` TO 'test3'@'tester'}) + expect(r.stderr).to be_empty + end + end + end + describe 'proxy privilieges' do pre_run