Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(986)

Issue 5706047: code review 5706047: database/sql/driver: add a argument to sql.Open and Dri... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 8 months ago by mikespook
Modified:
12 years, 6 months ago
Reviewers:
ziutek, rsc, MC.Spring, vcc, bradfitz
CC:
golang-china_googlegroups.com, golang-dev
Visibility:
Public.

Description

database/sql/driver: add a argument to sql.Open and Driver.Open. There is a requirement that executing something after database connected. Eg. 'SET NAMES utf8' for mysql. Currently, there is no use to execute this. Because "database/sql uses multiple simultaneous connections to database"(mymysql, Ziutek) Option 1: Db.PostConn set the things, that will be executed after Db.driver.Open was called. db, err := sql.Open("mymysql", "test/testuser/TestPasswd9") db.PostConn("set names utf8") // without this statment, the Chinese characters will be displayed as '0x3F' rows, err := db.Query("SELECT * FROM go") Option 2: Let Driver.Open accept arguments: []Value. We colud pass the arguments to the drivers, then let the drivers determine what should be done.

Patch Set 1 : diff -r 1c2e5d6d7660 https://go.googlecode.com/hg/ #

Patch Set 2 : diff -r 7ff2bf9b131a https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+9 lines, -8 lines) Patch
M src/pkg/database/sql/driver/driver.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/database/sql/fakedb_test.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/database/sql/sql.go View 1 3 chunks +7 lines, -6 lines 0 comments Download

Messages

Total messages: 15
mikespook
database/sql: added the Db.PostConn for executive something after connected. There is a requirement that executing ...
12 years, 8 months ago (2012-02-28 16:38:26 UTC) #1
mikespook
Hello golang-dev@googlegroups.com (cc: golang-china@googlegroups.com, golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 8 months ago (2012-02-28 16:41:04 UTC) #2
mikespook
Hello golang-dev@googlegroups.com (cc: golang-china@googlegroups.com, golang-dev@googlegroups.com), Please take another look.
12 years, 8 months ago (2012-02-28 16:44:09 UTC) #3
mikespook
Why the review didn't display in the group of golang-dev? Let me try again. database/sql: ...
12 years, 8 months ago (2012-02-28 16:56:32 UTC) #4
vcc
在 2012年2月29日星期三, 写道: > Reviewers: golang-dev_googlegroups.com, > > Message: > database/sql: added the Db.PostConn for ...
12 years, 8 months ago (2012-02-28 17:01:57 UTC) #5
mikespook
It means that we must change the interface in the database/sql/driver/driver.go:36, from: Driver.Open(name string) (Conn, ...
12 years, 8 months ago (2012-02-28 17:18:11 UTC) #6
rsc
R+=bradfitz This is an API change.
12 years, 8 months ago (2012-02-28 18:04:05 UTC) #7
bradfitz
I think this is something drivers should provide. You can pack any form of arguments ...
12 years, 8 months ago (2012-02-28 22:39:04 UTC) #8
mikespook
Hello bradfitz@golang.org, vcc.163@gmail.com, rsc@golang.org (cc: golang-china@googlegroups.com, golang-dev@googlegroups.com), Please take another look.
12 years, 8 months ago (2012-02-29 01:45:51 UTC) #9
mikespook
Hello bradfitz@golang.org, vcc.163@gmail.com, rsc@golang.org (cc: golang-china@googlegroups.com, golang-dev@googlegroups.com), Please take another look.
12 years, 8 months ago (2012-02-29 01:50:08 UTC) #10
mikespook
于 Tue, 28 Feb 2012 14:39:04 -0800 Brad Fitzpatrick <bradfitz@golang.org> 写道: > I think this ...
12 years, 8 months ago (2012-02-29 01:51:50 UTC) #11
MC.Spring
I would prefer to use Query String model, suck as: db, err := sql.Open('mymysql', 'user=Username&passwd=Password&charset=UTF8') ...
12 years, 8 months ago (2012-02-29 02:50:16 UTC) #12
mikespook
On 2012/02/29 02:50:16, MC.Spring wrote: > I would prefer to use Query String model, suck ...
12 years, 8 months ago (2012-02-29 03:18:05 UTC) #13
ziutek
On 2012/02/28 22:39:04, bradfitz wrote: > I think this is something drivers should provide. You ...
12 years, 8 months ago (2012-02-29 10:17:06 UTC) #14
ziutek
12 years, 8 months ago (2012-02-29 10:36:20 UTC) #15
On 2012/02/29 02:50:16, MC.Spring wrote:
> I would prefer to use Query String model, suck as: 
> 
> db, err := sql.Open('mymysql', 'user=Username&passwd=Password&charset=UTF8')

Passwords can contain any char (=?/& 写 to) so with your model you need some
escape function for it. In mymysql model password is last part of name string so
it can be any string.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b