617 lines
23 KiB
SQL
617 lines
23 KiB
SQL
CREATE DATABASE IF NOT EXISTS `util` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;
|
|
USE `util`;
|
|
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
|
|
--
|
|
-- Host: db.verdnatura.es Database: util
|
|
-- ------------------------------------------------------
|
|
-- Server version 5.6.25-4-log
|
|
|
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
|
/*!40101 SET NAMES utf8 */;
|
|
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
|
/*!40103 SET TIME_ZONE='+00:00' */;
|
|
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
|
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
|
|
|
--
|
|
-- Table structure for table `debug`
|
|
--
|
|
|
|
DROP TABLE IF EXISTS `debug`;
|
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
/*!40101 SET character_set_client = utf8 */;
|
|
CREATE TABLE `debug` (
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
`connectionId` int(10) unsigned DEFAULT NULL,
|
|
`user` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
|
`host` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
|
`variable` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
|
`value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Log de depuración';
|
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
|
|
--
|
|
-- Dumping events for database 'util'
|
|
--
|
|
|
|
--
|
|
-- Dumping routines for database 'util'
|
|
--
|
|
/*!50003 DROP FUNCTION IF EXISTS `capitalizeFirst` */;
|
|
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `capitalizeFirst`(vString VARCHAR(255)) RETURNS varchar(255) CHARSET utf8
|
|
NO SQL
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Pass the first letter of every word in a string to uppercase.
|
|
*
|
|
* @param vString String to tranform
|
|
* @return Transformed string
|
|
*/
|
|
DECLARE vNewString VARCHAR(255) DEFAULT '';
|
|
DECLARE vI INT DEFAULT 1;
|
|
DECLARE vSpaceIni, vWordIni INT;
|
|
DECLARE vLen INT DEFAULT CHAR_LENGTH(vString);
|
|
|
|
WHILE vI < vLen
|
|
DO
|
|
SET vSpaceIni = vI;
|
|
|
|
WHILE MID(vString, vI, 1) REGEXP '[[:space:]]' DO
|
|
SET vI = vI + 1;
|
|
END WHILE;
|
|
|
|
SET vWordIni = vI;
|
|
SET vI = vWordIni + 1;
|
|
|
|
WHILE vI <= vLen AND MID(vString, vI, 1) NOT REGEXP '[[:space:]]' DO
|
|
SET vI = vI + 1;
|
|
END WHILE;
|
|
|
|
SET vNewString = CONCAT(vNewString
|
|
,MID(vString, vSpaceIni, vWordIni - vSpaceIni)
|
|
,UPPER(MID(vString, vWordIni, 1))
|
|
,MID(vString, vWordIni + 1, vI - vWordIni - 1)
|
|
);
|
|
END WHILE;
|
|
|
|
RETURN vNewString;
|
|
END ;;
|
|
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 */ ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `dayEnd` */;
|
|
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `dayEnd`(vDated DATE) RETURNS datetime
|
|
NO SQL
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Formats a date to the end of the day.
|
|
*
|
|
* @param vDated The date to format
|
|
* @return The formatted date
|
|
*/
|
|
RETURN TIMESTAMP(vDated, '23:59:59');
|
|
END ;;
|
|
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 */ ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `firstDayOfMonth` */;
|
|
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `firstDayOfMonth`(vDate DATE) RETURNS date
|
|
NO SQL
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Returns the date formatted to the first day of month.
|
|
*
|
|
* @param vDate The date to format
|
|
* @return The formatted date
|
|
*/
|
|
RETURN DATE_FORMAT(vDate, '%Y-%m-01');
|
|
END ;;
|
|
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 */ ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `hmacSha2` */;
|
|
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `hmacSha2`(`vAlg` SMALLINT, `vMsg` MEDIUMBLOB, `vKey` MEDIUMBLOB) RETURNS varchar(128) CHARSET utf8
|
|
NO SQL
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* HMAC function based on SHA2 vAlgorythms.
|
|
*/
|
|
DECLARE vHashlen INT UNSIGNED;
|
|
DECLARE vOpad, vIpad TINYBLOB;
|
|
|
|
CASE vAlg
|
|
WHEN 224 THEN SET vHashlen = 64;
|
|
WHEN 256 THEN SET vHashlen = 64;
|
|
WHEN 384 THEN SET vHashlen = 128;
|
|
WHEN 512 THEN SET vHashlen = 128;
|
|
ELSE CALL throw ('WRONG_vALGORYTHM_IDENTIFICATOR_USED');
|
|
END CASE;
|
|
|
|
IF LENGTH(vKey) > vHashlen THEN
|
|
SET vKey = UNHEX(SHA2(vKey, vAlg));
|
|
END IF;
|
|
|
|
SET vKey = RPAD(vKey, vHashlen, 0x00);
|
|
|
|
SET vIpad = stringXor(vKey, 0x36);
|
|
SET vOpad = stringXor(vKey, 0x5C);
|
|
|
|
RETURN SHA2(CONCAT(vOpad, UNHEX(SHA2(CONCAT(vIpad, vMsg), vAlg))), vAlg);
|
|
END ;;
|
|
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 */ ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `lang` */;
|
|
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `lang`() RETURNS char(2) CHARSET utf8
|
|
NO SQL
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Returns the current language code.
|
|
*
|
|
* @return The language code
|
|
*/
|
|
RETURN IFNULL(@lang, SUBSTR(@@lc_messages, 1, 2));
|
|
END ;;
|
|
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 */ ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `nextWeek` */;
|
|
ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `nextWeek`(vYearWeek INT) RETURNS int(11)
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* A partir de un perido año/semana en formato AAAASS devuelve el siguiente
|
|
* periodo. Esta función trabaja de la misma forma que la función WEEK() en
|
|
* modo 3.
|
|
*/
|
|
DECLARE vYear INT DEFAULT FLOOR(vYearWeek / 100);
|
|
|
|
IF vYearWeek < YEARWEEK(CONCAT(vYear, '-12-31'), 3) THEN
|
|
RETURN vYearWeek + 1;
|
|
ELSE
|
|
RETURN ((vYear + 1) * 100) + 1;
|
|
END IF;
|
|
END ;;
|
|
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 `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `stringXor` */;
|
|
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `stringXor`(vString MEDIUMBLOB, vConst TINYINT UNSIGNED) RETURNS mediumblob
|
|
NO SQL
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Returns XOR of binary string and an 8-bit constant.
|
|
*/
|
|
DECLARE vLen, vPos INT UNSIGNED;
|
|
DECLARE vResult MEDIUMBLOB;
|
|
|
|
SET vLen = LENGTH(vString);
|
|
SET vPos = 1;
|
|
SET vResult = '';
|
|
|
|
WHILE vPos <= vLen DO
|
|
SET vResult = CONCAT(vResult, LPAD(HEX( ORD(SUBSTR(vString, vPos, 1)) ^ vConst), 2, '0'));
|
|
SET vPos = vPos + 1;
|
|
END WHILE;
|
|
|
|
RETURN UNHEX(vResult);
|
|
END ;;
|
|
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 */ ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `today` */;
|
|
ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `today`() RETURNS date
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Devuelve la fecha actual. Usar en lugar de la función nativa
|
|
* CURDATE() en aquellos que se necesite rendimiento ya que la
|
|
* la última no es determinista.
|
|
*
|
|
* @return La fecha actual
|
|
*/
|
|
RETURN CURDATE();
|
|
END ;;
|
|
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 `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `twoDaysAgo` */;
|
|
ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `twoDaysAgo`() RETURNS date
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Devuelve la fecha de antes de ayer.
|
|
*
|
|
* @return La fecha de antes de ayer
|
|
*/
|
|
RETURN TIMESTAMPADD(DAY, -2, CURDATE());
|
|
END ;;
|
|
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 `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `yearRelativePosition` */;
|
|
ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `yearRelativePosition`(vYear INT) RETURNS varchar(20) CHARSET utf8
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Devuelve la posicion del año relativa al año actual.
|
|
* Se utiliza como cabecera en informes de balances.
|
|
*
|
|
* @param vYear Año a evaluar
|
|
* @return La posicion relativa del año
|
|
*/
|
|
DECLARE vCurYear INT DEFAULT YEAR(CURDATE());
|
|
|
|
IF vYear = vCurYear THEN
|
|
RETURN 'curYear';
|
|
END IF;
|
|
|
|
IF vYear = vCurYear - 1 THEN
|
|
RETURN 'lastYear';
|
|
END IF;
|
|
|
|
IF vYear = vCurYear - 2 THEN
|
|
RETURN 'twoYearsAgo';
|
|
END IF;
|
|
|
|
RETURN 'other';
|
|
END ;;
|
|
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 `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
|
/*!50003 DROP FUNCTION IF EXISTS `yesterday` */;
|
|
ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` FUNCTION `yesterday`() RETURNS date
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Devuelve la fecha de ayer.
|
|
*
|
|
* @return La fecha de ayer
|
|
*/
|
|
RETURN TIMESTAMPADD(DAY, -1, CURDATE());
|
|
END ;;
|
|
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 `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
|
/*!50003 DROP PROCEDURE IF EXISTS `debugAdd` */;
|
|
ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` PROCEDURE `debugAdd`(vVariable VARCHAR(255), vValue VARCHAR(255))
|
|
MODIFIES SQL DATA
|
|
BEGIN
|
|
/**
|
|
* Añade una entrada de depuración en la tabla @debug.
|
|
*
|
|
* @param vVariable Nombre de variable
|
|
* @param vValue Valor de la variable
|
|
*/
|
|
DECLARE vIndex INT DEFAULT INSTR(USER(), '@');
|
|
|
|
INSERT INTO debug SET
|
|
`connectionId` = CONNECTION_ID(),
|
|
`user` = LEFT(USER(), vIndex - 1),
|
|
`host` = RIGHT(USER(), CHAR_LENGTH(USER()) - vIndex),
|
|
`variable` = vVariable,
|
|
`value` = vValue;
|
|
END ;;
|
|
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 `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
|
/*!50003 DROP PROCEDURE IF EXISTS `exec` */;
|
|
/*!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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` PROCEDURE `exec`(vSqlQuery TEXT)
|
|
BEGIN
|
|
/**
|
|
* Executes a string with an SQL query.
|
|
*
|
|
* @param vSqlQuery The SQL string
|
|
*/
|
|
SET @sqlQuery = vSqlQuery;
|
|
|
|
PREPARE stmt FROM @sqlQuery;
|
|
EXECUTE stmt;
|
|
DEALLOCATE PREPARE stmt;
|
|
|
|
SET @sqlQuery = NULL;
|
|
END ;;
|
|
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 */ ;
|
|
/*!50003 DROP PROCEDURE IF EXISTS `findObject` */;
|
|
ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` PROCEDURE `findObject`(vChain VARCHAR(45))
|
|
READS SQL DATA
|
|
BEGIN
|
|
/**
|
|
* Devuelve un listado de todos los procedimientos, funciones
|
|
* eventos, disparadores y vistas que inluyen una cadena dada.
|
|
*
|
|
* @param vChain Cadena a buscar
|
|
* @select Listado de objetos
|
|
*/
|
|
SET vChain = CONCAT('%', vChain, '%');
|
|
|
|
SELECT * FROM
|
|
(
|
|
SELECT
|
|
`db`,
|
|
`name`,
|
|
`type`,
|
|
`body`,
|
|
`created`,
|
|
`modified`
|
|
FROM `mysql`.`proc`
|
|
WHERE `body` LIKE vChain COLLATE utf8_general_ci
|
|
UNION ALL
|
|
SELECT
|
|
`db`,
|
|
`name`,
|
|
'EVENT',
|
|
`body_utf8`,
|
|
`created`,
|
|
`modified`
|
|
FROM `mysql`.`event`
|
|
WHERE `body_utf8` LIKE vChain COLLATE utf8_general_ci
|
|
UNION ALL
|
|
SELECT
|
|
`EVENT_OBJECT_SCHEMA`,
|
|
`TRIGGER_NAME`,
|
|
'TRIGGER',
|
|
`ACTION_STATEMENT`,
|
|
NULL,
|
|
NULL
|
|
FROM `information_schema`.`TRIGGERS`
|
|
WHERE `ACTION_STATEMENT` LIKE vChain COLLATE utf8_general_ci
|
|
UNION ALL
|
|
SELECT
|
|
`TABLE_SCHEMA`,
|
|
`TABLE_NAME`,
|
|
'VIEW',
|
|
`VIEW_DEFINITION`,
|
|
NULL,
|
|
NULL
|
|
FROM `information_schema`.`VIEWS`
|
|
WHERE `VIEW_DEFINITION` LIKE vChain COLLATE utf8_general_ci
|
|
) t
|
|
ORDER BY `db`, `name`;
|
|
END ;;
|
|
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 `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
|
/*!50003 DROP PROCEDURE IF EXISTS `throw` */;
|
|
ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`root`@`%` PROCEDURE `throw`(vCode CHAR(35))
|
|
BEGIN
|
|
/**
|
|
* Lanza una error de usuario.
|
|
*
|
|
* @param vCode Código de error
|
|
*/
|
|
SIGNAL SQLSTATE '45000'
|
|
SET MESSAGE_TEXT = vCode;
|
|
END ;;
|
|
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 `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
|
/*!50003 DROP PROCEDURE IF EXISTS `warn` */;
|
|
ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_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 = 'NO_ENGINE_SUBSTITUTION' */ ;
|
|
DELIMITER ;;
|
|
CREATE DEFINER=`z-developer`@`%` PROCEDURE `warn`(vCode CHAR(35))
|
|
BEGIN
|
|
DECLARE w VARCHAR(1) DEFAULT '__';
|
|
SET @warn = vCode;
|
|
END ;;
|
|
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 `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
|
|
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
|
|
|
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
|
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
|
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
|
|
|
-- Dump completed on 2017-12-29 7:39:15
|