@@ -47,7 +47,12 @@ class Mysql extends \Magento\TestFramework\Db\AbstractDb
47
47
/**
48
48
* @var bool
49
49
*/
50
- private $ mysqlDumpVersionIs8 ;
50
+ private $ isMysqldumpVersion8 ;
51
+
52
+ /**
53
+ * @var bool
54
+ */
55
+ private $ isUsingAuroraDb ;
51
56
52
57
/**
53
58
* {@inheritdoc}
@@ -116,17 +121,21 @@ public function isDbDumpExists()
116
121
public function storeDbDump ()
117
122
{
118
123
$ this ->ensureDefaultsExtraFile ();
119
- $ additionalArguments = '' ;
124
+ $ additionalArguments = [] ;
120
125
121
126
if ($ this ->isMysqlDumpVersion8 ()) {
122
- $ additionalArguments = '--column-statistics=0 ' ;
127
+ $ additionalArguments [] = '--column-statistics=0 ' ;
128
+ }
129
+
130
+ if ($ this ->isUsingAuroraDb ()) {
131
+ $ additionalArguments [] = '--set-gtid-purged=OFF ' ;
123
132
}
124
133
125
134
$ format = sprintf (
126
135
'%s %s %s %s ' ,
127
136
'mysqldump --defaults-file=%s --host=%s --port=%s ' ,
128
137
'--no-tablespaces ' ,
129
- $ additionalArguments ,
138
+ implode ( ' ' , $ additionalArguments) ,
130
139
'%s > %s '
131
140
);
132
141
@@ -194,14 +203,42 @@ private function ensureDefaultsExtraFile()
194
203
*/
195
204
private function isMysqlDumpVersion8 (): bool
196
205
{
197
- if (!$ this ->mysqlDumpVersionIs8 ) {
206
+ if (!$ this ->isMysqldumpVersion8 ) {
198
207
$ version = $ this ->_shell ->execute (
199
208
'mysqldump --version '
200
209
);
201
210
202
- $ this ->mysqlDumpVersionIs8 = (bool ) preg_match ('/8\.0\./ ' , $ version );
211
+ $ this ->isMysqldumpVersion8 = (bool ) preg_match ('/8\.0\./ ' , $ version );
212
+ }
213
+
214
+ return $ this ->isMysqldumpVersion8 ;
215
+ }
216
+
217
+ /**
218
+ * Is the DB connection Aurora RDS?
219
+ *
220
+ * @return bool
221
+ */
222
+ private function isUsingAuroraDb (): bool
223
+ {
224
+ if (!isset ($ this ->isUsingAuroraDb )) {
225
+ try {
226
+ $ this ->_shell ->execute (
227
+ 'mysql --defaults-file=%s --host=%s --port=%s %s --execute="SELECT AURORA_VERSION()" ' ,
228
+ [
229
+ $ this ->_defaultsExtraFile ,
230
+ $ this ->_host ,
231
+ $ this ->_port ,
232
+ $ this ->_schema
233
+ ]
234
+ );
235
+
236
+ $ this ->isUsingAuroraDb = true ;
237
+ } catch (LocalizedException $ e ) {
238
+ $ this ->isUsingAuroraDb = false ;
239
+ }
203
240
}
204
241
205
- return $ this ->mysqlDumpVersionIs8 ;
242
+ return $ this ->isUsingAuroraDb ;
206
243
}
207
244
}
0 commit comments