public function resolveCharacterSetAndCollation(Connection $connection)
    {
        $characterSet = $this->getCharacterSet();
        $collation = $this->getCollation();
        if ($collation !== '') {
            $collations = $connection->getSupportedCollations();
            if (!isset($collations[$collation])) {
                throw new Exception\UnsupportedCollationException($collation);
            }
            if ($characterSet === '') {
                $characterSet = $collations[$collation];
            } elseif ($characterSet !== $collations[$collation]) {
                throw new Exception\InvalidCharacterSetCollationCombination($characterSet, $collation, $collations[$characterSet]);
            }
        } elseif ($characterSet !== '') {
            $characterSets = $connection->getSupportedCharsets();
            if (!isset($characterSets[$characterSet])) {
                throw new Exception\UnsupportedCharacterSetException($characterSet);
            }
            $collation = $characterSets[$characterSet];
        } else {
            throw new Exception\NoCharacterSetCollationDefinedException();
        }
        if (!$connection->isCollationSupportedForKeys($collation, $this->getMaximumStringKeyLength())) {
            throw new Exception\LongKeysUnsupportedByCollation($collation, $this->getMaximumStringKeyLength());
        }

        return [$characterSet, $collation];
    }