Skip to content

Commit 8b1fa24

Browse files
author
Travis Fields
committed
(fix) - Fix an issue were we assume triggers work
- There are older versions of mysql that do not support the privilege TRIGGER and need to change default to not include http://dev.mysql.com/doc/refman/5.0/en/grant.html 'MySQL does not support the standard SQL UNDER privilege, and does not support the TRIGGER privilege until MySQL 5.1.6' - Updated tests to have both 5.1.6 and 5.0.11 tests for mysql_version fact
1 parent 3ce8ad3 commit 8b1fa24

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

manifests/backup/mysqldump.pp

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
require => Class['mysql::server::root_password'],
2727
}
2828

29-
30-
if $include_triggers {
29+
if $include_triggers and versioncmp($::mysql_version, '5.1.5') > 0 {
3130
$privs = [ 'SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS', 'TRIGGER' ]
3231
} else {
3332
$privs = [ 'SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS' ]

spec/classes/mysql_server_backup_spec.rb

+16-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms|
55
pe_platforms.each do |pe_platform,facts|
66
describe "on #{pe_version} #{pe_platform}" do
7-
let(:facts) { facts }
7+
let(:facts) { {'mysql_version' => '5.1.6'}.merge(facts) }
88

99
let(:default_params) {
1010
{ 'backupuser' => 'testuser',
@@ -26,7 +26,12 @@
2626
it { is_expected.to contain_mysql_grant('testuser@localhost/*.*').with(
2727
:privileges => ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS', 'TRIGGER']
2828
).that_requires('Mysql_user[testuser@localhost]') }
29-
29+
context 'mysql < 5.1.6' do
30+
let(:facts) { {'mysql_version' => '5.0.95'}.merge(facts) }
31+
it { is_expected.to contain_mysql_grant('testuser@localhost/*.*').with(
32+
:privileges => ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS']
33+
).that_requires('Mysql_user[testuser@localhost]') }
34+
end
3035
context 'with triggers excluded' do
3136
let(:params) do
3237
{ :include_triggers => false }.merge(default_params)
@@ -275,6 +280,15 @@
275280
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/
276281
)
277282
end
283+
describe 'mysql_version < 5.0.11' do
284+
let(:facts) { facts.merge({'mysql_version' => '5.0.10'}) }
285+
it 'should backup triggers when asked' do
286+
is_expected.to contain_file('mysqlbackup.sh').with_content(
287+
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/
288+
)
289+
end
290+
end
291+
278292
end
279293

280294
context 'with include_triggers set to false' do

0 commit comments

Comments
 (0)