Db Module fails to load dump.sql file that contains /* in data #3902

Open
michaeljem opened this Issue Jan 10, 2017 · 1 comment

Projects

None yet

2 participants

@michaeljem

We are trying to use Db to restore the database at the start of each test. Unfortunately we get an SQL error when Db tries to restore from the dump.sql file. When mysql client is used to restore the database using the same dump.sql file, it works.

After considerable investigation it appears that the two characters /* in our data caused the problem. Basically /* caused the information after it to be ignored (or treated as a comment). This obviously mangled the sql statement and caused the error.

In the following example the INSERT statement that does not contain /* works. The INSERT statement that contains /* fails.

CONTENTS of dump.sql:

-- MySQL dump 10.13  Distrib 5.5.52, for debian-linux-gnu (x86_64)
--
-- Host: db    Database: distro
-- ------------------------------------------------------
-- Server version	5.5.53-MariaDB-1~wheezy

/*!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 `variable`
--

DROP TABLE IF EXISTS `variable`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `variable` (
  `name` varchar(128) NOT NULL DEFAULT '' COMMENT 'The name of the variable.',
  `value` longblob NOT NULL COMMENT 'The value of the variable.',
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Named variable/value pairs created by Drupal core or any...';
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `variable`
--

LOCK TABLES `variable` WRITE;
/*!40000 ALTER TABLE `variable` DISABLE KEYS */;
INSERT INTO `variable` VALUES ('good','this works');
INSERT INTO `variable` VALUES ('bad','this fails /* with SQL error');
/*!40000 ALTER TABLE `variable` ENABLE KEYS */;
UNLOCK TABLES;
/*!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-01-05 21:44:51

TESTING OUTPUT:

Codeception PHP Testing Framework v2.2.6
Powered by PHPUnit 5.6.7 by Sebastian Bergmann and contributors.

                                                                               
  [Codeception\Exception\ModuleException]                                      
  Db: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an err  
  or in your SQL syntax; check the manual that corresponds to your MariaDB se  
  rver version for the right syntax to use near ''this fails' at line 1        
  SQL query being executed:                                                    
  INSERT INTO `variable` VALUES ('bad','this fails                                                                                    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment