Closed nangcr closed 6 months ago
It's peculiar that the panic is only triggered when the number of rows selected by the select for update statement is three or more.
Environment to Reproduce:
Oracle: Oracle 19C and Oracle 12C Go: go1.20.2 darwin/arm64 Driver: github.com/sijms/go-ora/v2 v2.8.9
Steps to Reproduce:
CREATE TABLE "TESTTABLE" ( "EMP_ID" NUMBER, "EMP_NAME" VARCHAR2(255), PRIMARY KEY ("EMP_ID") );
INSERT INTO TESTTABLE VALUES(1,'a'); INSERT INTO TESTTABLE VALUES(2,'b'); INSERT INTO TESTTABLE VALUES(3,'c');
select t."EMP_ID",t."EMP_NAME" from "TESTTABLE" t;
2. Use the following code for testing ```Go package main import ( "context" "database/sql" "fmt" _ "github.com/sijms/go-ora/v2" go_ora "github.com/sijms/go-ora/v2" ) func main() { db, err := sql.Open("oracle", go_ora.BuildJDBC("SYSTEM", "oracle", "(DESCRIPTION=(connect_timeout=15)(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.155)(PORT=11521))(CONNECT_DATA=(SID=ORCLCDB)))", map[string]string{})) if db == nil { fmt.Println("open err:", err) return } ctx := context.Background() err = db.PingContext(ctx) if err != nil { fmt.Println("ping err:", err) return } c, err := db.Conn(ctx) if err != nil { fmt.Println("conn err:", err) return } rows, err := c.QueryContext(ctx, `select * from "TESTTABLE" for update`) if err != nil { fmt.Println("query err:", err) return } defer rows.Close() return }
panic: runtime error: index out of range [2] with length 2
goroutine 1 [running]: github.com/sijms/go-ora/v2.(DataSet).setBitVector(0x140001ac000?, {0x14000288240?, 0x18?, 0x1032b3060?}) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/data_set.go:91 +0xfc github.com/sijms/go-ora/v2.(DataSet).load(0x14000158a80, 0x1?) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/data_set.go:75 +0x1a0 github.com/sijms/go-ora/v2.(defaultStmt).read(0x14000180180, 0x14000158a80) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/command.go:777 +0x144 github.com/sijms/go-ora/v2.(Stmt).query(0x14000180180) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/command.go:2348 +0xd0 github.com/sijms/go-ora/v2.(*Stmt).Query(0x14000180180, {0x1034797b0, 0x0, 0x1400012a0d8?}) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/command.go:2241 +0x38c github.com/sijms/go-ora/v2.(Stmt).QueryContext(0x14000180180, {0x1032bbf88, 0x14000112000}, {0x1034797b0, 0x0, 0x0}) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/command.go:2316 +0x168 github.com/sijms/go-ora/v2.(Connection).QueryContext(0x140001899c8?, {0x1032bbf88, 0x14000112000}, {0x1025b7174?, 0x1034797b0?}, {0x1034797b0, 0x0, 0x0}) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/connection.go:1086 +0xdc database/sql.ctxDriverQuery({0x1032bbf88?, 0x14000112000?}, {0x12a990148?, 0x14000130f00?}, {0x0?, 0x0?}, {0x1025b7174?, 0x102378a00?}, {0x1034797b0?, 0x10324db10?, ...}) /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/ctxutil.go:48 +0xac database/sql.(DB).queryDC.func1() /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/sql.go:1748 +0x12c database/sql.withLock({0x1032badb8, 0x140000ae090}, 0x14000189c28) /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/sql.go:3405 +0x7c database/sql.(DB).queryDC(0x1400010ee10?, {0x1032bbf88, 0x14000112000}, {0x0, 0x0}, 0x140000ae090, 0x1400010ab40, {0x1025b7174, 0x24}, {0x0, ...}) /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/sql.go:1743 +0x168 database/sql.(*Conn).QueryContext(0x1400010ee10, {0x1032bbf88, 0x14000112000}, {0x1025b7174, 0x24}, {0x0, 0x0, 0x0}) /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/sql.go:1992 +0x94 main.main() /Users/nangcr/GolandProjects/kasumi/main.go:32 +0x274
fixed in next release
It's peculiar that the panic is only triggered when the number of rows selected by the select for update statement is three or more.
Environment to Reproduce:
Oracle: Oracle 19C and Oracle 12C Go: go1.20.2 darwin/arm64 Driver: github.com/sijms/go-ora/v2 v2.8.9
Steps to Reproduce:
INSERT INTO TESTTABLE VALUES(1,'a'); INSERT INTO TESTTABLE VALUES(2,'b'); INSERT INTO TESTTABLE VALUES(3,'c');
select t."EMP_ID",t."EMP_NAME" from "TESTTABLE" t;
goroutine 1 [running]: github.com/sijms/go-ora/v2.(DataSet).setBitVector(0x140001ac000?, {0x14000288240?, 0x18?, 0x1032b3060?}) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/data_set.go:91 +0xfc github.com/sijms/go-ora/v2.(DataSet).load(0x14000158a80, 0x1?) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/data_set.go:75 +0x1a0 github.com/sijms/go-ora/v2.(defaultStmt).read(0x14000180180, 0x14000158a80) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/command.go:777 +0x144 github.com/sijms/go-ora/v2.(Stmt).query(0x14000180180) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/command.go:2348 +0xd0 github.com/sijms/go-ora/v2.(*Stmt).Query(0x14000180180, {0x1034797b0, 0x0, 0x1400012a0d8?}) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/command.go:2241 +0x38c github.com/sijms/go-ora/v2.(Stmt).QueryContext(0x14000180180, {0x1032bbf88, 0x14000112000}, {0x1034797b0, 0x0, 0x0}) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/command.go:2316 +0x168 github.com/sijms/go-ora/v2.(Connection).QueryContext(0x140001899c8?, {0x1032bbf88, 0x14000112000}, {0x1025b7174?, 0x1034797b0?}, {0x1034797b0, 0x0, 0x0}) /Users/nangcr/go/pkg/mod/github.com/sijms/go-ora/v2@v2.8.9/connection.go:1086 +0xdc database/sql.ctxDriverQuery({0x1032bbf88?, 0x14000112000?}, {0x12a990148?, 0x14000130f00?}, {0x0?, 0x0?}, {0x1025b7174?, 0x102378a00?}, {0x1034797b0?, 0x10324db10?, ...}) /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/ctxutil.go:48 +0xac database/sql.(DB).queryDC.func1() /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/sql.go:1748 +0x12c database/sql.withLock({0x1032badb8, 0x140000ae090}, 0x14000189c28) /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/sql.go:3405 +0x7c database/sql.(DB).queryDC(0x1400010ee10?, {0x1032bbf88, 0x14000112000}, {0x0, 0x0}, 0x140000ae090, 0x1400010ab40, {0x1025b7174, 0x24}, {0x0, ...}) /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/sql.go:1743 +0x168 database/sql.(*Conn).QueryContext(0x1400010ee10, {0x1032bbf88, 0x14000112000}, {0x1025b7174, 0x24}, {0x0, 0x0, 0x0}) /opt/homebrew/Cellar/go/1.20.2/libexec/src/database/sql/sql.go:1992 +0x94 main.main() /Users/nangcr/GolandProjects/kasumi/main.go:32 +0x274