1
0
mirror of https://github.com/golang/go synced 2024-10-01 16:28:33 -06:00
Commit Graph

170 Commits

Author SHA1 Message Date
Daniel Theophanes
683ffe09f6 database/sql: add support for decimal interface
Add support for scanning decimal types into values. If the dest
supports the decimal composer interface and the src supports
the decimal decomposer, set the value of the decimal when Scanning.

Add support for sending decimal decomposer interface values
as parameters.

For #30870

Change-Id: Ic5dbf9069df8d56405852b17542a9188d55c2947
Reviewed-on: https://go-review.googlesource.com/c/go/+/174181
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-13 16:59:01 +00:00
Daniel Theophanes
dc63b59630 database/sql: add Conn.Raw to expose the driver Conn safely
Exposing the underlying driver conn will allow the use of the
standard connection pool while still able to run special function
directly on the driver.

Fixes #29835

Change-Id: Ib6d3b9535e730f008916805ae3bf76e4494c88f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/174182
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-13 16:49:52 +00:00
Daniel Theophanes
73abea300a database/sql/driver: document Valuer must not panic
While it is possible for the connection pool to guard against panics
on every valuer read, this seems like a high cost to be added,
in both code complexity and possible runtime performance.

Most uses of the Valuer will be trivial, like returning
a struct field. Optimize for that case. If sometime may panic the
valuer should itself use recover and return an error.

Fixes #26332

Change-Id: Iad18780b8028f669f5a7841b74a5384d62fb6a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/170700
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-13 02:49:03 +00:00
Brad Fitzpatrick
2637f1f950 database/sql: fix subject of unexported func comment
Change-Id: I5db429c86e01b55ec3abc6ab4ca11c221b27f189
Reviewed-on: https://go-review.googlesource.com/c/go/+/177039
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2019-05-14 15:51:48 +00:00
Shulhan
ed7f323c8f all: simplify code using "gofmt -s -w"
Most changes are removing redundant declaration of type when direct
instantiating value of map or slice, e.g. []T{T{}} become []T{{}}.

Small changes are removing the high order of subslice if its value
is the length of slice itself, e.g. T[:len(T)] become T[:].

The following file is excluded due to incompatibility with go1.4,

- src/cmd/compile/internal/gc/ssa.go

Change-Id: Id3abb09401795ce1e6da591a89749cba8502fb26
Reviewed-on: https://go-review.googlesource.com/c/go/+/166437
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-06 22:19:22 +00:00
Daniel Theophanes
2177bfb343 database/sql: add NullInt32
It is common for database integers to be represented as int32
internally. Although NullInt64 is already defined,
this should remove some type casts and make working with those eaiser.

For #31231

Change-Id: Ia0c37ecef035fee0734c1d1fb6f58aef6905cf5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/174178
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-26 21:54:41 +00:00
Daniel Theophanes
1805f425ad database/sql: check if src is nil before converting to string
A nil src (NULL database value) will result in a "nil" string,
which will never parse correctly in a ParseInt or similar
numeric conversion. The resulting error is confusing. Check
for a nil src prior to converting the value to string
if the resulting string will be parsed after that.

Closes #31274

Change-Id: I90f12cceff00fbbfdd3e343b04fa7e2596390e6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/174177
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-26 19:59:11 +00:00
Josh Bleecher Snyder
5781df421e all: s/cancelation/cancellation/
Though there is variation in the spelling of canceled,
cancellation is always spelled with a double l.

Reference: https://www.grammarly.com/blog/canceled-vs-cancelled/

Change-Id: I240f1a297776c8e27e74f3eca566d2bc4c856f2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/170060
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 20:27:15 +00:00
Daniel Theophanes
d47da9497f database/sql: add NullTime
This matches NullBool, NullFloat64, and NullInt64.

Fixes #30305

Change-Id: I79bfcf04a3d43b965d2a3159b0ac22f3e8084a53
Reviewed-on: https://go-review.googlesource.com/c/go/+/170699
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-05 18:03:45 +00:00
Hasan Ozgan
42cdc26665 database/sql: add example for DB.Prepare and Tx.Prepare
Change-Id: Ib9272a7713ed7aaf8ad54c4827be8c095763e648
Reviewed-on: https://go-review.googlesource.com/c/go/+/161677
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-25 15:51:17 +00:00
Andrei Matei
9e72e604a6 database/sql: fix comment grammar
Change-Id: I92d8c93967c5ec57f07151affd0041f00e405057
GitHub-Last-Rev: 2dea977d93
GitHub-Pull-Request: golang/go#30551
Reviewed-on: https://go-review.googlesource.com/c/go/+/164970
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-07 05:19:01 +00:00
Zhou Peng
4c89a10fb9 database/sql/driver: fix typo
Change-Id: I6e7035db4b3e2a09e5655eb7646eea9d99fb7118
Reviewed-on: https://go-review.googlesource.com/c/162917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-15 17:23:55 +00:00
Justin Li
d5a36531b2 database/sql: document Stmt lifetime
When prepared on a DB, prepared statement code in database/sql handles everything to keep the prepared statement alive as it moves across the connection pool. Understanding this is an important part of using this API correctly, but it was only documented indirectly via `(*Tx) Prepare*`.

Change-Id: Ic8757e0150d59e675d9f0252f6c15aef2cc2e831
GitHub-Last-Rev: 55dba87458
GitHub-Pull-Request: golang/go#29890
Reviewed-on: https://go-review.googlesource.com/c/159077
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2019-02-08 19:52:00 +00:00
Daniel Theophanes
70931c087b database/sql: fix logic for pulling a Conn from DB
The logic for pulling a database connection from the DB pool should
proceed as follows: attempt to pull either a cached connection or
new connection N times in a loop. If each connection results
in a bad connection, then create a new connection (no cache).

Previously pulling a Conn from the pool, the last step also
looked at the cache, rather then always creating a new connection.

Fixes #29684

Change-Id: I8f436fd9b96eb35502a620ebe8da4ab89fb06a2e
Reviewed-on: https://go-review.googlesource.com/c/157637
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-14 19:44:57 +00:00
Tobias Klauser
9e277f7d55 all: use "reports whether" consistently instead of "returns whether"
Follow-up for CL 147037 and after Brad noticed the "returns whether"
pattern during the review of CL 150621.

Go documentation style for boolean funcs is to say:

    // Foo reports whether ...
    func Foo() bool

(rather than "returns whether")

Created with:

    $ perl -i -npe 's/returns whether/reports whether/' $(git grep -l "returns whether" | grep -v vendor)

Change-Id: I15fe9ff99180ad97750cd05a10eceafdb12dc0b4
Reviewed-on: https://go-review.googlesource.com/c/150918
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-12-02 15:12:26 +00:00
Daniel Theophanes
8d335084cc database/sql: add examples for opening and testing a DB pool
Show two larger application examples. One example that
could be used in a CLI, the other in a long running
service. These demonstarates different strategies for
handling DB.Ping errors in context.

Fixes #23738

Change-Id: Id01213caf1f47917239a7506b01d30e37db74d31
Reviewed-on: https://go-review.googlesource.com/c/101216
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-16 17:17:09 +00:00
Daniel Theophanes
968742a824 database/sql: add support for returning cursors to client
This CL add support for converting a returned cursor (presented
to this package as a driver.Rows) and scanning it into a *Rows.

Fixes #28515

Change-Id: Id8191c568dc135af9e5e8555efcd01987708edcb
Reviewed-on: https://go-review.googlesource.com/c/145738
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-08 21:19:17 +00:00
Brad Fitzpatrick
3813edf26e all: use "reports whether" consistently in the few places that didn't
Go documentation style for boolean funcs is to say:

    // Foo reports whether ...
    func Foo() bool

(rather than "returns true if")

This CL also replaces 4 uses of "iff" with the same "reports whether"
wording, which doesn't lose any meaning, and will prevent people from
sending typo fixes when they don't realize it's "if and only if". In
the past I think we've had the typo CLs updated to just say "reports
whether". So do them all at once.

(Inspired by the addition of another "returns true if" in CL 146938
in fd_plan9.go)

Created with:

$ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true iff" | grep -v vendor)
$ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true if" | grep -v vendor)

Change-Id: Ided502237f5ab0d25cb625dbab12529c361a8b9f
Reviewed-on: https://go-review.googlesource.com/c/147037
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-02 22:47:58 +00:00
Vladimir Kovpak
d6e204e71f database/sql: add description to String method of IsolationLevel struct.
Add simple description to String method of IsolationLevel struct.

Change-Id: I8bdf829c81d4895b8542a3f21437bed61c6e925d
GitHub-Last-Rev: 7e16d6a93a
GitHub-Pull-Request: golang/go#28560
Reviewed-on: https://go-review.googlesource.com/c/147040
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-02 17:28:53 +00:00
Daniel Theophanes
cf6e4238b6 database/sql: prefer to return Rows.lasterr rather then a static error
Fixes #25829

Change-Id: I400fdaf0ef3a23bc0d61c4873ffa298e0cf0fc6a
Reviewed-on: https://go-review.googlesource.com/c/145204
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-29 16:11:22 +00:00
Umang Parmar
830f424c9b database/sql: remove commented debug prints
Fixes #28234

Change-Id: I89090ffb8285c4936b0c9b5c2475849c0643186a
GitHub-Last-Rev: 4dd0ec162d
GitHub-Pull-Request: golang/go#28246
Reviewed-on: https://go-review.googlesource.com/c/142877
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-17 22:58:50 +00:00
Igor Zhilianin
04dc1b2443 all: fix a bunch of misspellings
Change-Id: I94cebca86706e072fbe3be782d3edbe0e22b9432
GitHub-Last-Rev: 8e15a40545
GitHub-Pull-Request: golang/go#28067
Reviewed-on: https://go-review.googlesource.com/c/140437
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-08 03:12:03 +00:00
Igor Zhilianin
f90e89e675 all: fix a bunch of misspellings
Change-Id: If2954bdfc551515403706b2cd0dde94e45936e08
GitHub-Last-Rev: d4cfc41a55
GitHub-Pull-Request: golang/go#28049
Reviewed-on: https://go-review.googlesource.com/c/140299
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-06 15:40:03 +00:00
Tim
4559d58ced database/sql: improve unimplemented LastInsertId error message
The old one was rather confusing - it makes it sound like the user has done something wrong.

Change-Id: Ibc7411f4f1d5f6c66fbcaac64bb05b0743354418
GitHub-Last-Rev: 09290accdd
GitHub-Pull-Request: golang/go#27979
Reviewed-on: https://go-review.googlesource.com/c/139102
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-03 17:28:45 +00:00
Daniel Theophanes
7db509e682 database/sql: correctly report MaxIdleClosed stat
Previously the MaxIdleClosed counter was incremented when added
to the free connection list, rather then when it wasn't added
to the free connection list. Flip this logic to correct.

Fixes #27792

Change-Id: I405302c14fb985369dab48fbe845e5651afc4ccf
Reviewed-on: https://go-review.googlesource.com/c/138578
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-02 19:24:37 +00:00
Alexey Palazhchenko
5ed30d82b7 database/sql: fix Rows.Columns() documentation
Fixes #27202

Change-Id: I83620748a81500e433795c7b2b7f13399d17f777
GitHub-Last-Rev: 64457e12ce
GitHub-Pull-Request: golang/go#27472
Reviewed-on: https://go-review.googlesource.com/133057
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2018-09-03 16:28:42 +00:00
Frédéric Guillot
4cc09cd532 database/sql: fix driverStmt.Close() comment typo
Change-Id: I2256c850e071882b00c362da03abc8b021c1ec2a
Reviewed-on: https://go-review.googlesource.com/126015
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-03 03:58:03 +00:00
Eugene Kalinin
9e4c344c72 database/sql: update doc related to per-connection state
Fixes #25330

Change-Id: I41b5b3459ed7808d18112ec02d734e2268099a81
Reviewed-on: https://go-review.googlesource.com/116596
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2018-06-06 18:18:20 +00:00
Daniel Theophanes
94280237f4 database/sql: add note to Scanner that the database owns values
It was unclear that users must copy values out of the src value
for value types like []byte.

Fixes #24492

Change-Id: I99ad61e0ad0075b9efc5ee4e0d067f752f91b8fa
Reviewed-on: https://go-review.googlesource.com/108535
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-11 20:28:02 +00:00
Daniel Theophanes
d89ea41006 database/sql: add additional Stats to DBStats
Provide better statistics for the database pool. Add counters
for waiting on the pool and closes. Too much waiting or too many
connection closes could indicate a problem.

Fixes #24683
Fixes #22138

Change-Id: I9e1e32a0487edf41c566b8d9c07cb55e04078fec
Reviewed-on: https://go-review.googlesource.com/108536
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-11 14:52:58 +00:00
Daniel Theophanes
b98ffdf859 database/sql: check for nil connRequest.conn before use
The connRequest may return a nil conn value. However in a rare
case that is difficult to test for it was being passed to
DB.putConn without a nil check. This was an error as this
made no sense if the driverConn is nil. This also caused
a panic in putConn.

A test for this would be nice, but didn't find a sane
way to test for this condition.

Fixes #24445

Change-Id: I827316e856788a5a3ced913f129bb5869b7bcf68
Reviewed-on: https://go-review.googlesource.com/102477
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-10 19:41:08 +00:00
Daniel Theophanes
5cf3e34f96 database/sql: make error prefixes consistent
Ensure all error prefixes in the "database/sql" package start with
"sql: ". Do not prefix errors for type conversions because they
are always embedded in another error message with a specific
context.

Fixes #25251

Change-Id: I349d9804f3bfda4eeb755b32b508ec5992c28e07
Reviewed-on: https://go-review.googlesource.com/111637
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-05 16:27:20 +00:00
Alexey Palazhchenko
1129ec2ffe database/sql: trivial documentation fixes
Change-Id: I573172384eaf32daaca5021a9a1874bf0f3d340f
Reviewed-on: https://go-review.googlesource.com/110575
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-01 14:43:13 +00:00
weeellz
da24c95ce0 database/sql: remove unnecessary else conditions
Fixes golint warning about "if block ends with a return statement,
so drop this else and outdent its block".

Change-Id: Iac4fd324e04e3e3fe3e3933f5e59095041d292c5
Reviewed-on: https://go-review.googlesource.com/107115
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-19 18:57:52 +00:00
dchenk
90fee59287 database/sql: remove a couple redundancies
This commit includes efficiency improvements in two places in the
database/sql package where an "if err != nil" was redundant and
the error can be returned as-is (most of the code in the standard
library and even in the file I changed does it my suggested way).

Change-Id: Ib9dac69ed01ee846e570a776164cb87c2caee6ca
Reviewed-on: https://go-review.googlesource.com/106555
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-12 19:23:46 +00:00
Eric Rykwalder
16f32a0726 database/sql: return context errors from Rows.Scan
The previous implementation would return "sql: Rows are closed" for any
context errors, which can be confusing for context timeouts or
cancelations.

Fixes #24431

Change-Id: I884904ec43204c43f4e94e2335b2802aab77a888
Reviewed-on: https://go-review.googlesource.com/104276
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-11 19:45:16 +00:00
Daniel Theophanes
7a7b63f3e7 database/sql: clarify behavior of DB.Close
It wasn't clear for existing docs if DB.Close forcefully closed
connections or waited for them to finish.

Fixes #23753

Change-Id: Id7df31224c93181c8d01bab7b0b23da25b42a288
Reviewed-on: https://go-review.googlesource.com/103397
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-11 19:26:17 +00:00
Daniel Theophanes
6e59c73a9f database/sql: check to see if ctx is cancelable before await
Prevent queries from starting a goroutine if the context is
not able to be canceled.

Fixes #23879

Change-Id: I392047bd53d7f796219dd12ee11b07303658fdaf
Reviewed-on: https://go-review.googlesource.com/102478
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-27 18:40:46 +00:00
Andrew Bonventre
165ebe6558 database/sql: fix docs to correctly refer to time.RFC3339Nano
It mentions time.Format3339Nano, which isn’t defined. The
underlying code uses time.RFC3339Nano.

Updates golang/go#24542

Change-Id: Ia34ae8b66427139d9005f902c2eb60aac4bfa8c6
Reviewed-on: https://go-review.googlesource.com/102607
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-26 23:12:45 +00:00
Kevin Burke
6f08b9faf2 database/sql: add more examples
This aims to expand the coverage of examples showing how the sql
package works, as well as to address a number of issues I've observed
while explaining how the database package works:

- The best way to issue UPDATE or INSERT queries, that don't need
to scan anything in return. (Previously, we had no examples for any
Execute statement).

- How to use prepared statements and transactions.

- How to aggregate arguments from a Query/QueryContext query into
a slice.

Furthermore just having examples in more places should help, as users
click on e.g. the "Rows" return parameter and are treated with the
lack of any example about how Rows is used.

Switch package examples to use QueryContext/QueryRowContext; I think
it is a good practice to prepare users to issue queries with a timeout
attached, even if they are not using it immediately.

Change-Id: I4e63af91c7e4fff88b25f820906104ecefde4cc3
Reviewed-on: https://go-review.googlesource.com/91015
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-03-25 05:09:57 +00:00
Tobias Klauser
0657235660 database/sql: fix typo in comment
Change-Id: Ie2966bae1dc2e542c42fb32d8059a4b2d4690014
Reviewed-on: https://go-review.googlesource.com/99115
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-07 15:42:31 +00:00
Alexey Palazhchenko
ef3ab3f5e2 database/sql: add String method to IsolationLevel
Fixes #23632

Change-Id: I7197e13df6cf28400a6dd86c110f41129550abb6
Reviewed-on: https://go-review.googlesource.com/92235
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2018-02-22 15:17:52 +00:00
Shawn Smith
d3beea8c52 all: fix misspellings
GitHub-Last-Rev: 468df242d0
GitHub-Pull-Request: golang/go#23935
Change-Id: If751ce3ffa3a4d5e00a3138211383d12cb6b23fc
Reviewed-on: https://go-review.googlesource.com/95577
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-02-20 21:02:58 +00:00
Ryuma Yoshida
8fc25b531b all: remove duplicate word "the"
Change-Id: Ia5908e94a6bd362099ca3c63f6ffb7e94457131d
GitHub-Last-Rev: 545a40571a
GitHub-Pull-Request: golang/go#23942
Reviewed-on: https://go-review.googlesource.com/95435
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-20 16:45:55 +00:00
Tamir Duberstein
1091b50cc0 database/sql: remove duplicate validation
Since https://golang.org/cl/38533, this validation is performed in
driverArgs.

Change-Id: I13a3ca46a1aa3197370de1095fb46ab83ea4628c
Reviewed-on: https://go-review.googlesource.com/91115
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-13 21:25:13 +00:00
HaraldNordgren
8da7706bb4 database/sql: include SQL column name in Scan() error message
When 'convertAssign' gives an error, instead of giving just the index of
the failing column -- which is not always helpful, especially when there
are lots of columns in the query -- utilize 'rs.rowsi.Columns()' to
extract the underlying column name and include that in the error string:

    sql: Scan error on column index 0, name "some_column": ...

Fixes #23362

Change-Id: I0fe71ff3c25f4c0dd9fc6aa2c2da2360dd93e3e0
Reviewed-on: https://go-review.googlesource.com/86537
Reviewed-by: Harald Nordgren <haraldnordgren@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-13 21:24:53 +00:00
Daniel Theophanes
651ddbdb50 database/sql: buffers provided to Rows.Next should not be modified by drivers
Previously we allowed drivers to modify the row buffer used to scan
values when closing Rows. This is no longer acceptable and can lead
to data races.

Fixes #23519

Change-Id: I91820a6266ffe52f95f40bb47307d375727715af
Reviewed-on: https://go-review.googlesource.com/89936
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2018-01-25 19:14:14 +00:00
Daniel Theophanes
1b69d19a42 database/sql: fix TestConversions when count > 1
Provide a fresh conversion table for TestConversions as it gets
modified on each test.

Change-Id: I6e2240d0c3455451271a6879e994b82222c3d44c
Reviewed-on: https://go-review.googlesource.com/89595
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2018-01-25 03:39:24 +00:00
Daniel Theophanes
78583a125a database/sql: fix nil pointer use within withLock
During the refactor in 1126d1483f I
introduced a logical error within one withLock function that used
the result of the call before checking for the error. Change
the order so that the error is checked before the result is used.

None of the other withLock uses have similar issues.

Fixes #23208

Change-Id: I6c5dcf262e36bad4369c850f1e0131066360a82e
Reviewed-on: https://go-review.googlesource.com/85175
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Caleb Spare <cespare@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-01-03 18:18:40 +00:00
Daniel Theophanes
3aeb3950a9 database/sql/driver: update Value doc, can be driver supported type
The driver.Value type may be more then the documented 6 types if the
database driver supports it. Document that fact.

Updates #23077

Change-Id: If7e2112fa61a8cc4e155bb31e94e89b20c607242
Reviewed-on: https://go-review.googlesource.com/84636
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-12-18 20:24:12 +00:00