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

about use golang's client #537

Closed
mitiger opened this issue Mar 31, 2015 · 6 comments
Closed

about use golang's client #537

mitiger opened this issue Mar 31, 2015 · 6 comments

Comments

@mitiger
Copy link

mitiger commented Mar 31, 2015

hi ,sougou:

when i use golang's client about vitess to save my data , there is a question appeared.
In the vttablet, the log show as follows:

W0331 16:59:06.763275 12975 sqlquery.go:297] error: missing bind var v3: Sql: "insert into t_login_history(f_account_id, f_ip, f_createtime) values (?,?,?)", BindVars: {v0: 1, v1: "localhost", v2: 1427792377099, #maxLimit: 10001, }

i just only hava 3 params , why it show me , missing bind var v3?

if i use another sql like :
insert into t_login_history(f_account_id, f_ip, f_createtime) values (1, "localhost", 123456), it will be ok.

is there something wrong about my code ?

@mitiger
Copy link
Author

mitiger commented Mar 31, 2015

my code are as follows:

tx, err := db.Begin()
if err != nil {
return
}

    stmt, err := tx.Prepare("insert into t_login_history(f_account_id, f_ip, f_createtime) values (?,?,?)")
    if err != nil {
        fmt.Println("-----> stmt error:", err)
        return
    }

    _, err = stmt.Exec(1, "localhost", time.Now().UnixNano()/1000000)
    if err != nil {
        tx.Rollback()
        fmt.Println("---->> stmt exec error:", err)
        return
    }
    defer stmt.Close()
    tx.Commit()

@sougou
Copy link
Contributor

sougou commented Mar 31, 2015

This is most likely a bug on my go client. Let me confirm. If so, I'll have a fix out very soon.

@sougou
Copy link
Contributor

sougou commented Apr 1, 2015

I just submitted a fix. Can you try again?

@mitiger
Copy link
Author

mitiger commented Apr 2, 2015

should i rebuild vttablet , and restart it?

@sougou
Copy link
Contributor

sougou commented Apr 2, 2015

Yes. My fix went in #539

@mitiger
Copy link
Author

mitiger commented Apr 2, 2015

ok, i just test it . Error does not appear again.
thank you .

@sougou sougou closed this as completed Apr 2, 2015
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