mirror of https://github.com/apache/druid.git
fix #1701 - MySQL 5.7 defaults break database character set check
This commit is contained in:
parent
8fa34ee671
commit
ba41f37ce1
|
@ -30,6 +30,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.skife.jdbi.v2.DBI;
|
import org.skife.jdbi.v2.DBI;
|
||||||
import org.skife.jdbi.v2.Handle;
|
import org.skife.jdbi.v2.Handle;
|
||||||
import org.skife.jdbi.v2.tweak.HandleCallback;
|
import org.skife.jdbi.v2.tweak.HandleCallback;
|
||||||
|
import org.skife.jdbi.v2.util.BooleanMapper;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
@ -77,16 +78,14 @@ public class MySQLConnector extends SQLMetadataConnector
|
||||||
{
|
{
|
||||||
// ensure database defaults to utf8, otherwise bail
|
// ensure database defaults to utf8, otherwise bail
|
||||||
boolean isUtf8 = handle
|
boolean isUtf8 = handle
|
||||||
.createQuery("SHOW VARIABLES where variable_name = 'character_set_database' and value = 'utf8'")
|
.createQuery("SELECT @@character_set_database = 'utf8'")
|
||||||
.list()
|
.map(BooleanMapper.FIRST)
|
||||||
.size() == 1;
|
.first();
|
||||||
|
|
||||||
if (!isUtf8) {
|
if (!isUtf8) {
|
||||||
throw new ISE(
|
throw new ISE(
|
||||||
"Database default character set is not UTF-8." + System.lineSeparator()
|
"Database default character set is not UTF-8." + System.lineSeparator()
|
||||||
+ " Druid requires its MySQL database to be created using UTF-8 as default character set."
|
+ " Druid requires its MySQL database to be created using UTF-8 as default character set."
|
||||||
+ " If you are upgrading from Druid 0.6.x, please make all tables have been converted to utf8 and change the database default."
|
|
||||||
+ " For more information on how to convert and set the default, please refer to section on updating from 0.6.x in the Druid 0.7.1 release notes."
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue