go-ora
go-ora copied to clipboard
network.(*Session).GetInt64 runtime error: slice bounds out of range
time="2022-09-10 01:39:35.632733" level=debug msg="the run sqlID: 1568293051590250496 [SELECT DISTINCT PRIVILEGE FROM ( SELECT PRIVILEGE FROM USER_SYS_PRIVS UNION ALL SELECT GRANTED_ROLE FROM USER_ROLE_PRIVS UNION ALL SELECT PRIVILEGE FROM ROLE_SYS_PRIVS a,USER_ROLE_PRIVS b WHERE b.GRANTED_ROLE = A.ROLE ) ORDER BY PRIVILEGE]" function=printSQL line=62 file="mtk/pkg/utils/log/log_sql.go" taskID=1568293051409895424 panic: runtime error: slice bounds out of range [-17:]
goroutine 1 [running]: github.com/sijms/go-ora/v2/network.(*Session).GetInt64(0xc000516ec8, 0x1396239, 0xd8, 0x0) github.com/sijms/go-ora/[email protected]/network/session.go:1036 +0x19a github.com/sijms/go-ora/v2/network.(*Session).GetInt(...) github.com/sijms/go-ora/[email protected]/network/session.go:1052 github.com/sijms/go-ora/v2/network.(*Session).GetDlc(0xc0000016c0) github.com/sijms/go-ora/[email protected]/network/session.go:1117 +0x2e github.com/sijms/go-ora/v2/network.NewSummary(0xc0000016c0) github.com/sijms/go-ora/[email protected]/network/summary_object.go:156 +0x589 github.com/sijms/go-ora/v2.(*defaultStmt).read(0xc0002e8c80, 0xc0004ac2d0) github.com/sijms/go-ora/[email protected]/command.go:483 +0x21b github.com/sijms/go-ora/v2.(*Stmt).Query(0xc0002e8c80, {0x32eadb0, 0x0, 0xc000f59380}) github.com/sijms/go-ora/[email protected]/command.go:1453 +0x406 github.com/sijms/go-ora/v2.(*Stmt).QueryContext(0xc0002e8c80, {0x209e278, 0xc000282340}, {0x32eadb0, 0x0, 0x1aa9d00}) github.com/sijms/go-ora/[email protected]/command.go:1425 +0x294 github.com/sijms/go-ora/v2.(*Connection).QueryContext(0x1ac, {0x209e278, 0xc000282340}, {0x1c7b947, 0x4000100}, {0x32eadb0, 0x0, 0x0}) github.com/sijms/go-ora/[email protected]/connection.go:1111 +0x6a database/sql.ctxDriverQuery({0x209e278, 0xc000282340}, {0x7f90b804f478, 0xc000e98200}, {0x0, 0x0}, {0x1c7b947, 0x1ac}, {0x32eadb0, 0x0, ...}) database/sql/ctxutil.go:48 +0x17d database/sql.(*DB).queryDC.func1() database/sql/sql.go:1722 +0x175 database/sql.withLock({0x208d9c0, 0xc0004ac090}, 0xc000517608) database/sql/sql.go:3396 +0x8c database/sql.(*DB).queryDC(0xf08401, {0x209e278, 0xc000282340}, {0x0, 0x0}, 0xc0004ac090, 0xc000f59340, {0x1c7b947, 0xf9}, {0x0, ...}) database/sql/sql.go:1717 +0x211 database/sql.(*DB).query(0xac24f4, {0x209e278, 0xc000282340}, {0x1c7b947, 0xf9}, {0x0, 0x0, 0x0}, 0x0) database/sql/sql.go:1700 +0xfd database/sql.(*DB).QueryContext(0x1c7b947, {0x209e278, 0xc000282340}, {0x1c7b947, 0xf9}, {0x0, 0x0, 0x0}) database/sql/sql.go:1674 +0xdf mtk/pkg/utils/query.SimpleQueryContext({0x209e278, 0xc000282340}, 0xc000e00b60, {0x1c7b947, 0xf9}, {0x20ae070, 0xc000291490}, {0x0, 0x0, 0x0}) mtk/pkg/utils/query/query.go:68 +0x13c mtk/pkg/utils/query.SimpleQueryWithArgs({0x209e278, 0xc000282340}, 0x100000001c04e25, 0xc000517980, {0x1c7b947, 0x20}, {0x20ae070, 0xc000291490}, {0x0, 0x0, ...}) mtk/pkg/utils/query/query.go:44 +0xa7 mtk/pkg/databases/oracle.(*oracle).CheckReadUserPrivilege(0xc00017c460, {0x209e278, 0xc000282340}) mtk/pkg/databases/oracle/oracle.go:342 +0xf7
I have faced same issue with v2.5.3 (see stack trace attached). As a temporary solution, I am forced to downgrade the version to v2.4.X.
I try the following code with latest version everything is ok
package main
import (
"database/sql"
"fmt"
_ "github.com/sijms/go-ora/v2"
)
func main() {
sqlText := `SELECT DISTINCT PRIVILEGE FROM
(
SELECT PRIVILEGE FROM USER_SYS_PRIVS
UNION ALL
SELECT GRANTED_ROLE FROM USER_ROLE_PRIVS
UNION ALL
SELECT PRIVILEGE FROM ROLE_SYS_PRIVS a,USER_ROLE_PRIVS b WHERE b.GRANTED_ROLE = A.ROLE
) ORDER BY PRIVILEGE`
conn, err := sql.Open("oracle", "oracle://user:pass@localhost:1521/service?TRACE FILE=trace.log")
if err != nil {
fmt.Println(err)
return
}
defer conn.Close()
rows, err := conn.Query(sqlText)
if err != nil {
fmt.Println(err)
return
}
var par1 string
for rows.Next() {
err = rows.Scan(&par1)
if err != nil {
fmt.Println(err)
}
fmt.Println(par1)
}
}
I try the following code with latest version everything is ok
package main import ( "database/sql" "fmt" _ "github.com/sijms/go-ora/v2" ) func main() { sqlText := `SELECT DISTINCT PRIVILEGE FROM ( SELECT PRIVILEGE FROM USER_SYS_PRIVS UNION ALL SELECT GRANTED_ROLE FROM USER_ROLE_PRIVS UNION ALL SELECT PRIVILEGE FROM ROLE_SYS_PRIVS a,USER_ROLE_PRIVS b WHERE b.GRANTED_ROLE = A.ROLE ) ORDER BY PRIVILEGE` conn, err := sql.Open("oracle", "oracle://user:pass@localhost:1521/service?TRACE FILE=trace.log") if err != nil { fmt.Println(err) return } defer conn.Close() rows, err := conn.Query(sqlText) if err != nil { fmt.Println(err) return } var par1 string for rows.Next() { err = rows.Scan(&par1) if err != nil { fmt.Println(err) } fmt.Println(par1) } }
2022-09-10T01:39:35.6284: Database Version: 11.2.0.4.0
your database version?
i test for 2 oracle versions 12.2 and 19.3
does error come every time or intermittent intermittent error means network problem you can return to issue #256 I make a long investigation about the issue using Mac OS, Linux mint and windows 10 and I find problem with linux mint when use localhost. but when change to real IP address the problem resolved
I think many issues here I cannot find because I use different oracle versions. this is 2nd issue I find it ok with me oracle 12.2 and 19.3 but when I test on oracle 11g I get the problem
is you oracle version is 11g?
Yes it is:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
final result as follow: the code tested for the following oracle version: 1- 12c and after on local machine => no error 2- 11.2.0.4 on local machine ==> no error 3- 11.2.0.2 XE on local machine ==> no error 4- 11.2.0.1 EE on remote machine ==> the program stuck at read (expected more bytes from the server)
so I will check the summary object reading operation (possible cause of the problem)
I find a bug related to oracle 11g Summary Object reading and fix it in version 2.5.11 pls test it and see if every thing is ok