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

Reply is not completely read error after running the query SELECT 1 #129

Open
arianitu opened this issue Jul 22, 2016 · 4 comments
Open

Comments

@arianitu
Copy link

arianitu commented Jul 22, 2016

When I run the query:

create database test

I get the error:

reply is not completely read

I also get the same error when doing a drop database.

Database:
mysql Ver 15.1 Distrib 10.1.14-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Go version:
go version go1.6.2 darwin/amd64

OS:
OS X Yosemite: 10.10.5

I'm also using _ "github.com/ziutek/mymysql/godrv" and opened the connection with sql.Open()

@arianitu
Copy link
Author

arianitu commented Jul 22, 2016

Here is the minimum program to reproduce this:

package main

import (
    "fmt"
    "database/sql"
    _"github.com/ziutek/mymysql/godrv"

)

func main() {
    db, err := sql.Open("mymysql", "tcp:localhost:3306*/root/password")
    if err != nil {
        fmt.Println(err)
        return
    }

    _, err = db.Exec("SELECT 1")
    if err != nil {
        fmt.Println(err)
        return
    }

    _, err = db.Exec("CREATE DATABASE test")
    if err != nil {
        fmt.Println(err)
        return
    }

}

@arianitu
Copy link
Author

It appears SELECT 1 is the issue here actually, if I remove that, it works fine. I guess it fails on the 2nd query after execting a SELECT 1 query.

@arianitu arianitu changed the title Reply is not completely read Reply is not completely read error after running the query SELECT 1 Jul 22, 2016
@ziutek
Copy link
Owner

ziutek commented Jul 25, 2016

You need to read result of "SELECT 1" query from server before send next query to it.

@arianitu
Copy link
Author

So you can't use Exec to ignore results? I need to use QueryRow? I guess if it's expected behaviour of https://golang.org/pkg/database/sql/, you can close this.

I think the error is non obvious to a person using the driver regardless and should probably be changed.

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

No branches or pull requests

2 participants