@@ -17,12 +17,15 @@ try {
17
17
} catch ( e ) { }
18
18
19
19
//************************************************
20
- // COMMON CONFIGURATION
20
+ // COMMON CONFIGURATION.
21
+ // Mysql and Mysql2 doesn't use server collation, but fixed collation UTF8_GENERAL_CI.
22
+ // setting it to default utf8mb4 collation, to be fair
21
23
//************************************************
22
24
const conf = require ( '../test/conf' ) ;
23
25
const logUtility = require ( './log-utility' ) ;
24
26
const config = Object . assign ( { } , conf . baseConfig , { trace : false } ) ;
25
- console . log ( config ) ;
27
+
28
+ let configWithCharset = null ;
26
29
const minimumSamples = process . env . PERF_SAMPLES ? parseInt ( process . env . PERF_SAMPLES ) : 200 ;
27
30
28
31
//************************************************
@@ -90,22 +93,28 @@ const createBenchSuite = async (bench) => {
90
93
//************************************************
91
94
const loadsources = async ( requiresPool , requireExecute , mariadbOnly ) => {
92
95
const sources = { } ;
96
+ sources [ 'mariadb' ] = await mariadb . createConnection ( Object . assign ( { } , config ) ) ;
97
+ if ( ! configWithCharset && sources [ 'mariadb' ] . info . collation ) {
98
+ const collation = sources [ 'mariadb' ] . info . collation . name ;
99
+ configWithCharset = Object . assign ( { } , conf . baseConfig , { trace : false , charset : collation } ) ;
100
+ console . log ( configWithCharset ) ;
101
+ }
102
+
93
103
if ( requiresPool == undefined || requiresPool === false ) {
94
104
if ( mysql ) {
95
105
if ( ! mariadbOnly && ( requireExecute == undefined || requireExecute === false ) ) {
96
- sources [ 'mysql' ] = await mysql . createConnection ( Object . assign ( { } , config ) ) ;
106
+ sources [ 'mysql' ] = await mysql . createConnection ( Object . assign ( { } , configWithCharset ) ) ;
97
107
}
98
108
}
99
109
if ( mysql2 && ! mariadbOnly ) {
100
- sources [ 'mysql2' ] = await mysql2 . createConnection ( Object . assign ( { } , config ) ) ;
110
+ sources [ 'mysql2' ] = await mysql2 . createConnection ( Object . assign ( { } , configWithCharset ) ) ;
101
111
}
102
- sources [ 'mariadb' ] = await mariadb . createConnection ( Object . assign ( { } , config ) ) ;
103
112
} else {
104
113
if ( ! mariadbOnly && mysql ) {
105
- sources [ 'mysql' ] = await mysql . createPool ( Object . assign ( { connectionLimit : 1 } , config ) ) ;
114
+ sources [ 'mysql' ] = await mysql . createPool ( Object . assign ( { connectionLimit : 1 } , configWithCharset ) ) ;
106
115
}
107
116
if ( ! mariadbOnly && mysql2 ) {
108
- sources [ 'mysql2' ] = mysql2 . createPool ( Object . assign ( { connectionLimit : 1 } , config ) ) ;
117
+ sources [ 'mysql2' ] = mysql2 . createPool ( Object . assign ( { connectionLimit : 1 } , configWithCharset ) ) ;
109
118
}
110
119
}
111
120
0 commit comments