Menu

#4528 (ok 4.3) Can't import dump via SQL field

Latest_Git
fixed
None
1
2014-12-05
2014-09-10
No

I tried to import a totally valid dump by pasting in the SQL textfield, and it throws this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) NOT NULL,
  `test` text NOT N' at line 12 

Importing from file works. Also tested on http://demo.phpmyadmin.net/master/

-- phpMyAdmin SQL Dump
-- version 4.3.0-dev
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Erstellungszeit: 10. Sep 2014 um 15:01
-- Server Version: 5.5.38-0ubuntu0.14.04.1
-- PHP-Version: 5.5.9-1ubuntu4.4

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

--
-- Datenbank: `test`
--

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `test`
--

DROP TABLE IF EXISTS `test`;
CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) NOT NULL,
  `test` text NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Daten für Tabelle `test`
--

INSERT INTO `test` (`id`, `test`) VALUES
(1, 'asdasdasdas\r\nasdasdasd''adsadadsa\r\nIt''s broken');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `test`
--
ALTER TABLE `test`
 ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `test`
--
ALTER TABLE `test`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;

Discussion

  • Hugues Peccatte

    Hugues Peccatte - 2014-09-11

    It seems that the "ü" are causing some troubles.
    I removed the following line and the error was thrown later in the script:
    -- Tabellenstruktur für Tabelle test

    This might be caused by use (or not use) of mb_* functions.

     
  • Hugues Peccatte

    Hugues Peccatte - 2014-09-13

    With "git bisect", I determined that the first bad commit is 9b77d746aba.

     
  • Hugues Peccatte

    Hugues Peccatte - 2014-09-13
    • assigned_to: Hugues Peccatte
     
  • Marc Delisle

    Marc Delisle - 2014-09-14

    Fix merged, thanks. Raimund, please confirm, possibly with other, bigger German dumps.

    And, Raimund, thanks for testing master!

     
  • Hugues Peccatte

    Hugues Peccatte - 2014-09-14
    • summary: Can't import dump via SQL field --> (ok 4.3) Can't import dump via SQL field
    • status: open --> resolved
    • Priority: 7 --> 1
     
  • Raimund Meyer

    Raimund Meyer - 2014-09-15

    Thanks for the fix, the dump above is working now. Unfortunately I still have problems with the exmaple below. Apparently there's a problem if and only if these conditions meet:

    DROP TABLE IF EXISTS test;
    CREATE TABLE IF NOT EXISTS test (
    id int(11) NOT NULL,
    test  varchar(255) 
    )ENGINE=InnoDB ;
    
    --
    -- Daten für Tabelle test
    --
    
    INSERT INTO test (`id`, `test`) VALUES
    (1, 'test;test');
    
    • a ü in the comment
    • columns names in backticks
    • a semicolon in a string in the data
     
  • Marc Delisle

    Marc Delisle - 2014-09-15
    • summary: (ok 4.3) Can't import dump via SQL field --> Can't import dump via SQL field
    • status: resolved --> open
    • Priority: 1 --> 5
     
  • Hugues Peccatte

    Hugues Peccatte - 2014-09-15

    Thanks for this tricky bug…
    I kept only the minimum to have the error:

    -- Daten für Tabelle test
    INSERT INTO test (`id`, `test`) VALUES
    (1, 'test;test');
    
     
  • Hugues Peccatte

    Hugues Peccatte - 2014-09-15

    I think I found why, but currently, I don't know how to solve it…
    Let's try to explain: to be sure that the ";" (the delimiter) isn't into a string, the query is parsed to find each quoted string. But the preg_match doesn't seem to support an UTF8 subject. In fact, he can search into it, but he will return a wrong position… Because of this, the position is shifted and so, we don't find the last string ('test;test').

    So I need to find a way to get the correct position of a match. I hope I won't need to develop a way to look for a pattern…
    I'll keep you informed.

     
  • Hugues Peccatte

    Hugues Peccatte - 2014-09-17
    • summary: Can't import dump via SQL field --> (ok 4.3) Can't import dump via SQL field
    • status: open --> resolved
    • Priority: 5 --> 1
     
  • Raimund Meyer

    Raimund Meyer - 2014-09-19

    Thanks, it's now working

     
  • Marc Delisle

    Marc Delisle - 2014-12-05
    • Status: resolved --> fixed