db.SetMaxIdleConns(1)
db.SetMaxOpenConns(3)
ctx, cancel := context.WithCancel(testContext("OpenClose"))
defer cancel()
const module = "godror.v2.test-OpenClose "
const countQry = "SELECT COUNT(0) FROM v$session WHERE module LIKE '" + module + "%'"
stmt, err := db.PrepareContext(ctx, countQry)
if err != nil {
t.Fatal(err)
}
defer stmt.Close()
sessCount := func() (int, error) {
var n int
qErr := stmt.QueryRowContext(ctx).Scan(&n)
return n, qErr
}
n, err := sessCount() // <--- here panics in NumInput
$ go version
go version go1.14.2 linux/amd64
$ go test -parallel=4 -run=OpenClose
Client: 19.3.0.0.0 Timezone: Local
Server: 11.2.0.4.0 [Oracle Database 11g Release 11.2.0.4.0 - 64bit Production] Timezone: Local
--- FAIL: TestOpenClose (0.14s)
z_test.go:1164: oracle://bruno:SECRET-MsTEvpLDUq8=@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=cig_tst.unosoft.local)))?connectionClass=POOLED&enableEvents=1&heterogeneousPool=0&poolIncrement=0&poolMaxSessions=5&poolMinSessions=1&poolSessionMaxLifetime=5m0s&poolSessionTimeout=10s&poolWaitTimeout=5s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone=local
panic: ORA-00000: DPI-1039: statement was already closed [recovered]
panic: ORA-00000: DPI-1039: statement was already closed
goroutine 19 [running]:
testing.tRunner.func1.1(0x741460, 0xc000090900)
/usr/local/go/src/testing/testing.go:940 +0x2f5
testing.tRunner.func1(0xc00009e360)
/usr/local/go/src/testing/testing.go:943 +0x3f9
panic(0x741460, 0xc000090900)
/usr/local/go/src/runtime/panic.go:969 +0x166
github.com/godror/godror.(*statement).NumInput(0xc0000ae3c0, 0x0)
/home/tgulacsi/src/github.com/godror/godror/stmt.go:622 +0x407
database/sql.driverArgsConnLocked(0x7e9e20, 0xc0000e2000, 0xc000098940, 0x0, 0x0, 0x0, 0xc000098940, 0xc000185978, 0x56647c, 0x0, ...)
/usr/local/go/src/database/sql/convert.go:119 +0x890
database/sql.rowsiFromStatement(0x7eb7a0, 0xc000098740, 0x7e9e20, 0xc0000e2000, 0xc000098940, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/usr/local/go/src/database/sql/sql.go:2600 +0xc8
database/sql.(*Stmt).QueryContext(0xc0000921b0, 0x7eb7a0, 0xc000098740, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/database/sql/sql.go:2556 +0x210
database/sql.(*Stmt).QueryRowContext(0xc0000921b0, 0x7eb7a0, 0xc000098740, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/database/sql/sql.go:2614 +0x6d
github.com/godror/godror_test.TestOpenClose.func2(0xc0000a40c0, 0x7eb7a0, 0xc000098740)
/home/tgulacsi/src/github.com/godror/godror/z_test.go:1191 +0x82
github.com/godror/godror_test.TestOpenClose(0xc00009e360)
/home/tgulacsi/src/github.com/godror/godror/z_test.go:1194 +0x530
testing.tRunner(0xc00009e360, 0x7834c8)
/usr/local/go/src/testing/testing.go:991 +0xdc
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:1042 +0x357
exit status 2
FAIL github.com/godror/godror 1.866s
! gotip version
go version devel +ac211c0 Tue Apr 28 02:36:39 2020 +0000 linux/amd64
:tgulacsi@tgulacsi-dell: ~/src/github.com/godror/godror
$ gotip test -parallel=4 -run=OpenClose
Client: 19.3.0.0.0 Timezone: Local
Server: 11.2.0.4.0 [Oracle Database 11g Release 11.2.0.4.0 - 64bit Production] Timezone: Local
--- FAIL: TestOpenClose (0.22s)
z_test.go:1164: oracle://bruno:SECRET-MsTEvpLDUq8=@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=cig_tst.unosoft.local)))?connectionClass=POOLED&enableEvents=1&heterogeneousPool=0&poolIncrement=0&poolMaxSessions=5&poolMinSessions=1&poolSessionMaxLifetime=5m0s&poolSessionTimeout=10s&poolWaitTimeout=5s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone=local
panic: ORA-00000: DPI-1039: statement was already closed [recovered]
panic: ORA-00000: DPI-1039: statement was already closed
goroutine 19 [running]:
testing.tRunner.func1.1(0x7411a0, 0xc000202720)
/home/tgulacsi/sdk/gotip/src/testing/testing.go:984 +0x2e0
testing.tRunner.func1(0xc00021c3c0)
/home/tgulacsi/sdk/gotip/src/testing/testing.go:987 +0x3f9
panic(0x7411a0, 0xc000202720)
/home/tgulacsi/sdk/gotip/src/runtime/panic.go:969 +0x166
github.com/godror/godror.(*statement).NumInput(0xc00021c640, 0x0)
/home/tgulacsi/src/github.com/godror/godror/stmt.go:622 +0x3fe
database/sql.driverArgsConnLocked(0x7ed3c0, 0xc000262000, 0xc000208940, 0x0, 0x0, 0x0, 0xc000208940, 0xc000183978, 0x569d4c, 0x0, ...)
/home/tgulacsi/sdk/gotip/src/database/sql/convert.go:119 +0x85e
database/sql.rowsiFromStatement(0x7eec40, 0xc000208740, 0x7ed3c0, 0xc000262000, 0xc000208940, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/home/tgulacsi/sdk/gotip/src/database/sql/sql.go:2684 +0xc8
database/sql.(*Stmt).QueryContext(0xc0002003f0, 0x7eec40, 0xc000208740, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/tgulacsi/sdk/gotip/src/database/sql/sql.go:2640 +0x20e
database/sql.(*Stmt).QueryRowContext(0xc0002003f0, 0x7eec40, 0xc000208740, 0x0, 0x0, 0x0, 0x0)
/home/tgulacsi/sdk/gotip/src/database/sql/sql.go:2698 +0x6d
github.com/godror/godror_test.TestOpenClose.func2(0xc000218820, 0x7eec40, 0xc000208740)
/home/tgulacsi/src/github.com/godror/godror/z_test.go:1191 +0x82
github.com/godror/godror_test.TestOpenClose(0xc00021c3c0)
/home/tgulacsi/src/github.com/godror/godror/z_test.go:1194 +0x530
testing.tRunner(0xc00021c3c0, 0x783e38)
/home/tgulacsi/sdk/gotip/src/testing/testing.go:1035 +0xdc
created by testing.(*T).Run
/home/tgulacsi/sdk/gotip/src/testing/testing.go:1086 +0x355
exit status 2
FAIL github.com/godror/godror 1.304s
--
You received this message because you are subscribed to the Google Groups "golang-sql" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-sql+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-sql/301e22d2-bf7a-4526-b599-e82a6289a965%40googlegroups.com.
Ah, database/sql "stmts", my least favorite part. I may have misunderstood your question, so let me know if I'm missing something.In database/sql, a Stmt doesn't actually store an individual prepared statement reference. It stores a Stmt Pool of references. The Tx Prepare and Conn Prepare use the same conn that you already have. So probably no sweat. Oh, also we don't actually put the driver.Conn back in the pool for Tx or Conn, so it doesn't get reset (that would defeat the point in both cases). Does reset session (however you implement it) also close any prepared statement on the connection?
--
You received this message because you are subscribed to the Google Groups "golang-sql" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-sql+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-sql/1020e923-379f-4e2b-bb30-56e9789e2dcc%40googlegroups.com.
There isn't a way to list the prepared statements that are within the pool, from the driver. You would need to keep track of the prepared statements within the your driver with every prepare you see.To handle sql.Out, You need to ensure you have implemented the NamedValueChecker, see mssql: https://github.com/denisenkom/go-mssqldb/blob/master/mssql_go19.go#L68
--
You received this message because you are subscribed to the Google Groups "golang-sql" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-sql+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-sql/09aba011-79ac-4f09-a4c7-176e78da0981%40googlegroups.com.