A
A
AllSafe2018-02-25 18:32:40
MySQL
AllSafe, 2018-02-25 18:32:40

How to set stored procedure encoding?

I have several MySQL dumps that contain stored procedure creation statements:

Dump
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
ALTER DATABASE `DB` CHARACTER SET utf8 COLLATE utf8_general_ci ;
/*!50003 DROP PROCEDURE IF EXISTS `GetInfo` */;
ALTER DATABASE `DB` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`dba`@`%` PROCEDURE `GetInfo`( 
    __id BIGINT,
    )
BEGIN
    SELECT *
  FROM Test
  WHERE id = __id
END ;;
DELIMITER ;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
ALTER DATABASE `DB` CHARACTER SET utf8 COLLATE utf8_general_ci ;
/*!50003 DROP PROCEDURE IF EXISTS `GetPrice` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`dba`@`%` PROCEDURE `GetPrice`(__id BIGINT)
BEGIN
  SELECT * FROM Prices WHERE id = __id;
END ;;
DELIMITER ;

The problem is that some of them are forced to be encoded before:
ALTER DATABASE `DB` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;

Is it possible to somehow force MySQL to set the base encoding to utf8_general_ci, regardless of what is written before creating the store? At the very beginning of the dump, it is already set, but MySQL does not use this when creating storages:
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `DB` /*!40100 DEFAULT CHARACTER SET utf8 */;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question