manticoresearch icon indicating copy to clipboard operation
manticoresearch copied to clipboard

Bug CREATE TABLE starting with an empty line

Open webigorkiev opened this issue 2 years ago • 4 comments

Hello Manticore 5.0.3 cff178311@220703 dev (columnar 1.16.1 637ddc6@220727) (secondary 1.16.1 637ddc6@220727)

If the CREATE TABLE statement starts with an empty string, no index is created

Steps to reproduce:

  1. Run script $db = new PDO('mysql:host=127.0.0.1;port=9306', '', ''); $response = $db->query(" CREATE TABLE test_index(test_field text); ");

  2. mysql -P9306

  3. SHOW TABLES;

No test_index index!

Works correctly without an empty line

In some cases the error is: conn=183209, no: 1064, SQLState: 42000) sphinxql: syntax error, unexpected CREATE near 'CREATE TABLE...

webigorkiev avatar Jul 30 '22 10:07 webigorkiev

Try to remove the semicolon after the query.

Here's what I'm getting if you try your script:

snikolaev@dev:~$ cat test_844.php
<?php
$db = new PDO('mysql:host=127.0.0.1;port=9315', '', '');
$response = $db->query("
CREATE TABLE test_index(test_field text);
");
print_r($db->errorInfo());

snikolaev@dev:~$ mysql -P9315 -h0 -e "drop table test_index"
ERROR 1064 (42000) at line 1: DROP TABLE failed: unknown index 'test_index'

snikolaev@dev:~$ php test_844.php
Array
(
    [0] => 42000
    [1] => 1064
    [2] => sphinxql: syntax error, unexpected $undefined, expecting $end near ';
'
)

If I remove the semicolon it works fine:

snikolaev@dev:~$ cat test_844.php
<?php
$db = new PDO('mysql:host=127.0.0.1;port=9315', '', '');
$response = $db->query("
CREATE TABLE test_index(test_field text)
");
print_r($db->errorInfo());

snikolaev@dev:~$ mysql -P9315 -h0 -e "drop table test_index"
ERROR 1064 (42000) at line 1: DROP TABLE failed: unknown index 'test_index'

snikolaev@dev:~$ php test_844.php
Array
(
    [0] => 00000
    [1] =>
    [2] =>
)

snikolaev@dev:~$ php test_844.php
Array
(
    [0] => 42000
    [1] => 1064
    [2] => index 'test_index': CREATE TABLE failed: index 'test_index' already exists
)

snikolaev@dev:~$ mysql -P9315 -h0 -e "drop table test_index"

snikolaev@dev:~$ php test_844.php
Array
(
    [0] => 00000
    [1] =>
    [2] =>
)

snikolaev@dev:~$ mysql -P9315 -h0 -e "drop table test_index"

snikolaev@dev:~$ php test_844.php
Array
(
    [0] => 00000
    [1] =>
    [2] =>
)

snikolaev@dev:~$ mysql -P9315 -h0 -e "show tables"
+------------+------+
| Index      | Type |
+------------+------+
| t          | rt   |
| t2         | rt   |
| t3         | rt   |
| test_index | rt   |
+------------+------+

sanikolaev avatar Aug 01 '22 06:08 sanikolaev

In my case, without a semicolon - does not work. But it works if you remove the empty line before and after CREATE TABLE.

In any case, this is somewhat incorrect.

webigorkiev avatar Aug 01 '22 06:08 webigorkiev

➤ Sergey Nikolaev commented:

In my case, without a semicolon - does not work

Hm. Can you wrap it all into a docker, so I can reproduce it on my side? Sorry I don't have a better idea. In my case it works fine with PDO, mysqlnd and Linux mysql client.

githubmanticore avatar Aug 01 '22 07:08 githubmanticore

Rebuilt manticore + updated boost Behavior is like yours.

If everything is correct and should work only without a semicolon, then the issue can be closed (I specifically checked in Mysql - it works with and without a semicolon)

Thanks

webigorkiev avatar Aug 01 '22 08:08 webigorkiev