Skip to content

Query has unexpected behavior on linux_amd64 #37

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

Closed
peterbourgon opened this issue Mar 11, 2013 · 6 comments
Closed

Query has unexpected behavior on linux_amd64 #37

peterbourgon opened this issue Mar 11, 2013 · 6 comments
Assignees

Comments

@peterbourgon
Copy link

Steps:

db, err := sql.Open(
    "mysql",
    fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", user, pass, host, port, name),
)
if err != nil { panic(err) }

var i int
err = db.QueryRow("SELECT 1 FROM DUAL").Scan(&i)
if err != nil { panic(err) }

Everything works great here. Then I try to actually use it for a different query.

var thing string
err = db.QueryRow("SELECT thing FROM place WHERE id = ?", id).Scan(&thing)
if err != nil { panic(err) }

This reliably panics with one of the two "Commands out of sync" errors, but ONLY on linux_amd64. It works fine on darwin_amd64.

Any insight appreciated.

@ghost ghost assigned julienschmidt Mar 11, 2013
@julienschmidt
Copy link
Member

Does this only occur if you run this two queries in that order?
Is the driver on both machines up to date? ( run go get -u github.com/Go-SQL-Driver/MySQL to be sure )
Which server version are you running on your Linux machine?

@peterbourgon
Copy link
Author

I tried to get some answers to your question. But the problem becomes even more bizarre. Again, on my laptop darwin_amd64, everything works as expected. When I ssh to any linux_amd64 server and run the mysql CLI manually, my manual queries work as expected. But when I run the exact same Go program, now every Query[Row] reports 0 rows returned.

I'm trying to bundle this into a single reproducible test case. Please stay tuned. Do you test this driver on linux_amd64 against MySQL 5.1.63-rel13.4?

@peterbourgon
Copy link
Author

Create a database on MySQL 5.1.63-rel13.4 with one table:

CREATE TABLE `live` (
  `user_id` int(11) NOT NULL,
  `list` text NOT NULL,
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Insert one record:

INSERT INTO live (user_id, list) VALUES (2, "999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999,999999999");

edit: make the list longer, because the real data is bigger than "1,2,3,4,5", and I think it might be the same bug as #38

Save this program as dbtest.go and run with go run dbtest.go -dsn="user:pass@tcp(1.2.3.4:3306)/database_name".

On my laptop (darwin_amd64) it works as expected, printing the list. On my Linux server (linux_amd64) it errors with sql: no rows in result set. Running the latest version of your driver, as retrieved by go get -u -d github.com/Go-SQL-Driver/MySQL in both cases.

@peterbourgon
Copy link
Author

This is definitely a bug in the Go-SQL-Driver. This code is exactly the same, but uses the mymysql driver (and a different DSN syntax). Running it yields the expected behavior.

julienschmidt added a commit that referenced this issue Mar 12, 2013
@julienschmidt
Copy link
Member

Can you confirm, that the it works now?

@peterbourgon
Copy link
Author

Test case confirmed working.

Thanks!

julienschmidt added a commit that referenced this issue Mar 12, 2013
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