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

SERVER_MORE_RESULTS_EXISTS support #45

Open
t-ae opened this issue Jun 7, 2018 · 2 comments
Open

SERVER_MORE_RESULTS_EXISTS support #45

t-ae opened this issue Jun 7, 2018 · 2 comments
Assignees
Labels
enhancement New feature or request
Projects

Comments

@t-ae
Copy link

t-ae commented Jun 7, 2018

Recently I made PR to make MySQLCapabilities available (#170).

Now we can use CLIENT_MULTI_STATEMENTS. However I found MySQLPacketDecoder doesn't support results of such queries.

The result packet of multi statements query contains the status flag SERVER_MORE_RESULTS_EXISTS, but the decoder doesn't read more.
So if we execute next query, it'll recieves invalid bytes previous query left.

Reproduction code.

let config = MySQLDatabaseConfig(hostname: "localhost",
                                 port: 3306,
                                 username: "root",
                                 password: "PASSWORD",
                                 database: "DATABASE",
                                 capabilities: MySQLCapabilities.default.union([.CLIENT_MULTI_STATEMENTS]))
let mysql = MySQLDatabase(config: config)
let eventLoop = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let conn = try! mysql.newConnection(on: eventLoop).wait()

let query = """
set time_zone = "+00:00";
select CURRENT_TIMESTAMP;
"""
let res1 = try! conn.simpleQuery(query).wait()
print("res1: ", res1)

// Second query doesn't work well.
let res2 = try! conn.simpleQuery("select * from fluent where id = 0").wait()
print("res2: ", res2)

simpleQuery returns only one result, so we need multiQuery if the decoder supports SERVER_MORE_RESULTS_EXISTS.

I don't know if there's someone who really needs multiple statements (We can split query with ; and execute one by one). So simply forbid using CLIENT_MULTI_STATEMENTS is an option.

@tanner0101 tanner0101 self-assigned this Jun 14, 2018
@tanner0101
Copy link
Member

I think this package should support SERVER_MORE_RESULTS_EXISTS in a future update.

@tanner0101
Copy link
Member

This issue is related to vapor/mysql-kit#189. When the packet coder state is cleaned up, we should also add support for the more results query type.

@tanner0101 tanner0101 changed the title Decoder doesn't handle multiple results SERVER_MORE_RESULTS_EXISTS support Jul 23, 2020
@tanner0101 tanner0101 transferred this issue from vapor/mysql-kit Jul 23, 2020
@tanner0101 tanner0101 added the enhancement New feature or request label Jul 23, 2020
@tanner0101 tanner0101 moved this from To Do to Backlog in Vapor 4 Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Vapor 4
  
Backlog
Development

No branches or pull requests

2 participants