SphinxQL insert command with ending semicolon

I was having an issue with a C# MySqlConnector in a recent project because I was trying to insert into a real time index and the connector was automatically terminating the command it would send with a semicolon (if I added a semicolon the connector wouldn’t bother, but if I didn’t the connector would).

Both Sphinx and Manticore were returning a parsing error with the message:

sphinxql: syntax error, unexpected ‘;’, expecting $end near ‘;’

I found a way to rectify this issue with the Manticore source code by adding a single line into the source file “sphinxql.y”:

After the following section in “sphinxql.y”:

request:
    statement     { pParser->PushQuery(); }

I simply added the following line which resolved my issues:

    | statement ‘;’     { pParser->PushQuery(); }

With this addition Manticore still gives an error when trying to use multiple commands but no longer fails with an unexpected semicolon and doesn’t appear to cause any other issues (that I could find).

at mysql client you can change delimiter with
mysql>delimiter |

and then push multiple commands as multi-query
mysql>SELECT * FROM idx 1 GROUP BY add1; SELECT * FROM idx 1 GROUP BY add2 |

maybe there is a way at your connector to change command delimiter too?

I have been through the source code of the connector I am using and it automatically adds a semicolon without any possible configuration options.

I am using this MySql connector with the source code located here on GitHub.

The location where it adds the semicolon to the command automatically is located in the file src/MySqlConnector/Core/StatementPreparer.cs on line 99.

The command parser in the connector parses the command, sets a state flag saying either a semicolon needs to be added or not. The command is sent after parsing with the added semicolon that can not be removed.

I tried to use the oracle C# MySql connector with issues even trying to connect to Sphinx (I didn’t try with Manticore), with an error when sphinx sent the string UTF-8 as an integer and MySql connector was trying to parse it as an integer instead of as a string.

It actually took me a couple of days trying to get anything to connect to Sphinx at all, then when I succeeded I could send a SELECT statement to Sphinx/Manticore with the automatically added semicolon, but failed with an INSERT command (which is the reason for this topic).

then it might be better to create ticket at GitHub or PR there to be informed on progress

Do you mean ticket for Manticore or for the Connector?

What I suggested at the start of the topic is a solution that will ensure consistency within Manticore since it already allows a semicolon for several statements at the end, but not for INSERT.

It took me a day of pulling my hair out since the connector was automatically adding a semicolon for both SELECT statements and INSERT commands, but Manticore/Sphinx was rejecting it only for the INSERT command.

I know the solution for the connector would be check if this is the last/only command and remove the semicolon, but modifying manticore was easier for me to allow semicolons at the end and progress with my program.

I mean fix for Manticore.
We could check code and if ubertests pass well apply the change

Done: Posted here