Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sphinxql: syntax error, unexpected ';', expecting $end near ';' #1133

Closed
Andyyy777 opened this issue Feb 10, 2022 · 8 comments
Closed

sphinxql: syntax error, unexpected ';', expecting $end near ';' #1133

Andyyy777 opened this issue Feb 10, 2022 · 8 comments

Comments

@Andyyy777
Copy link

Andyyy777 commented Feb 10, 2022

Software versions
MySqlConnector version: MySqlConnector v2.1.5
Server type (MySQL, MariaDB, Aurora, etc.) and version: MySQ 5.7.3
.NET version: .NET framework 4.5

Describe the bug
Hi there, I'm trying to execute a simple insertion sphinxql query "INSERT into rt_table1 (id) VALUES (1700111)" by using mysqlcommand.ExecuteNonQuery(). However, it always shows the error

"sphinxql: syntax error, unexpected ';', expecting $end near ';'"

for every time the ExecuteNonQuery() is called, and adding a ";" at the end of the query does not bring any changes. Moreover, when I typed the same command text in cmd, the command text was able to be successfully executed. Thank you so much for the help!

Exception

Exception while inserting:    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
   at MySqlConnector.Core.ResultSet.<ReadResultSetHeaderAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken)
   at MySqlConnector.MySqlDataReader.<CreateAsync>d__106.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at MySqlConnector.Core.CommandExecutor.<ExecuteReaderAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySqlConnector.MySqlCommand.<ExecuteNonQueryAsync>d__78.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySqlConnector.MySqlCommand.ExecuteNonQuery()
   at TestSphinxRTIndexer.Main.VB$StateMachine_8_InsertBatchIntoIndex.MoveNext() in C:\Users\User\Desktop\New_folder

Code sample

Private Async Function InsertBatchIntoIndex(Index As Index, strRowDataToBeInserted As String, ByVal comDB As MySqlCommand) As Task

        Try
            Dim conDB As New MySqlConnection(connectionstring)
            Await conDB.OpenAsync()

            comDB.Connection = conDB

            Dim attribs As New ArrayList(Index.GetAttributes())
            'Insert and name the primary key column identified as 'id' in sphinx, as the first column
            attribs.Insert(0, "id")

            Dim strOfAttribs As String() = attribs.ToArray(GetType(String))

            comDB.CommandText = "INSERT into rt_posts_big_chunk_part1 (id) VALUES (1704996)"

            Console.WriteLine(comDB.CommandText)
            If (conDB.State = ConnectionState.Open) Then
                Console.WriteLine("keeps open")
                Dim result As Integer = comDB.ExecuteNonQuery()
            End If

            TryCloseDBCon_MySQL(conDB)
        Catch ex As Exception
        ...
        End Try

    End Function

Expected behavior
The insertion query can be successfully executed by using executeNonQuery(), and the corrected row can be added.

@bgrainger
Copy link
Member

Server type (MySQL, MariaDB, Aurora, etc.) and version: MySQ 5.7.3

How are you getting a "sphinxql" error message from MySQL? Is your server software actually Sphinx? Some kind of plugin?

@Andyyy777
Copy link
Author

Andyyy777 commented Feb 10, 2022

Yep, the actual server is sphinx but I use MySQL to connect with it.

@Andyyy777
Copy link
Author

And I just saw an another post about this issue as well: manticoresoftware/manticoresearch#314
Hope it could help.

@bgrainger
Copy link
Member

This is likely a problem introduced in 378c4b8 for batching, and might be fixed as a side-effect of #946.

@bgrainger
Copy link
Member

It's very odd that SphinxQL claims to be compatible with MySQL, but doesn't accept semicolons, even though the example documentation shows them: https://sphinxsearch.com/docs/sphinx3.html#running-queries-via-mysql-shell

Perhaps MySQL CLI treats them as a statement delimiter and doesn't send them on the wire, even when entered manually by a user?

@Andyyy777
Copy link
Author

Thank you @bgrainger !!! Definitely will try that :)

@bgrainger
Copy link
Member

Fixed in 2.1.7.

okramarenko added a commit to memsql/SingleStoreNETConnector that referenced this issue Mar 27, 2023
Summary:
This diff grabs changes from original connector that were made in 2.1.7 and 2.1.8 releases:
- Only insert a semicolon when concatenating SQL. Fixes mysql-net#1133
- Parse multiple TLS versions correctly. Fixes mysql-net#1138
- Document return value of ExecuteNonQuery. Fixes mysql-net#1136
- Enable all .NET analyzers
- Add support for new types to SingleStoreBulkCopy. Fixes mysql-net#1143
- Update SingleStoreParameter types documentation
- Update StyleCop to 1.2.0-beta.406
- Reset LastInsertedId to 0 between commands, not -1. Fixes mysql-net#1147
- Fix BulkCopy for DateOnly and TimeOnly. Fixes mysql-net#1146

Test Plan: https://app.circleci.com/pipelines/github/memsql/SingleStoreNETConnector/249/workflows/3100503c-8a0f-48e6-99a3-635efe59384f

Reviewers: pmishchenko-ua

Reviewed By: pmishchenko-ua

Subscribers: engineering-list

JIRA Issues: PLAT-6408

Differential Revision: https://grizzly.internal.memcompute.com/D61685
@winghang1992

This comment was marked as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants