Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panicking at Prepare #10

Closed
simulot opened this issue Oct 31, 2020 · 3 comments
Closed

Panicking at Prepare #10

simulot opened this issue Oct 31, 2020 · 3 comments

Comments

@simulot
Copy link
Contributor

simulot commented Oct 31, 2020

Hi,

I'm very happy to see your package. Get ride of oci DLL will simplify compilation. Thank you!

I'm testing you package against a basic dockerized oracle server (https://hub.docker.com/r/oracleinanutshell/oracle-xe-11g). I'm able to run the query below using sql developer.

The program works fine under linux, but panics at Prepare under windows.
Unfortunately, enterprise system is not linux :-<

package main

import (
   "database/sql"
   "fmt"
   "os"

   _ "github.com/sijms/go-ora"
)

func OKorDie(err error) {
   if err != nil {
   	fmt.Println(err)
   	os.Exit(-1)
   }
}

func main() {
   conn, err := sql.Open("oracle", "oracle://system:oracle@192.168.10.10/xe")
   OKorDie(err)
   defer conn.Close()

   stmt, err := conn.Prepare("SELECT distinct(TOPIC)  FROM help")
   OKorDie(err)
   defer stmt.Close()

   rows, err := stmt.Query()
   OKorDie(err)
   defer rows.Close()

   for rows.Next() {
   	var topic string
   	err = rows.Scan(&topic)
   	OKorDie(err)
   	fmt.Println("Topics: ", topic)
   }
}
go version go1.15.3 windows/amd64
github.com/sijms/go-ora/network.newRefusePacketFromData(0xc000092110, 0xc, 0x10, 0x0)
	C:/Users/me/go/src/github.com/sijms/go-ora/network/refuse_packet.go:43 +0x285
github.com/sijms/go-ora/network.(*Session).readPacket(0xc0000a4000, 0x0, 0x0, 0x0, 0x0)
	C:/Users/me/go/src/github.com/sijms/go-ora/network/session.go:270 +0x2a5
github.com/sijms/go-ora/network.(*Session).Connect(0xc0000a4000, 0x0, 0x0)
	C:/Users/me/go/src/github.com/sijms/go-ora/network/session.go:76 +0x411
github.com/sijms/go-ora.(*Connection).Open(0xc0000a0000, 0x0, 0x0)
	C:/Users/me/go/src/github.com/sijms/go-ora/connection.go:234 +0x14a
github.com/sijms/go-ora.(*oracleDriver).Open(0xd94588, 0xb48cf6, 0x27, 0x0, 0x0, 0x0, 0x0)
	C:/Users/me/go/src/github.com/sijms/go-ora/connection.go:79 +0xf4
database/sql.dsnConnector.Connect(0xb48cf6, 0x27, 0xb6ab40, 0xd94588, 0xb6c380, 0xc000012028, 0x0, 0x0, 0x0, 0x0)
	c:/go/src/database/sql/sql.go:707 +0x84
database/sql.(*DB).conn(0xc000048ea0, 0xb6c380, 0xc000012028, 0xc00007db01, 0x0, 0x0, 0x0)
	c:/go/src/database/sql/sql.go:1294 +0xdc4
database/sql.(*DB).prepare(0xc000048ea0, 0xb6c380, 0xc000012028, 0xb4761d, 0x21, 0x1000000000001, 0x0, 0x0, 0x0)
	c:/go/src/database/sql/sql.go:1482 +0x9b
database/sql.(*DB).PrepareContext(0xc000048ea0, 0xb6c380, 0xc000012028, 0xb4761d, 0x21, 0x0, 0x0, 0x0)
	c:/go/src/database/sql/sql.go:1455 +0xd4
database/sql.(*DB).Prepare(0xc000048ea0, 0xb4761d, 0x21, 0x0, 0x0, 0x0)
	c:/go/src/database/sql/sql.go:1472 +0xb5
main.main()
	C:/Users/me/go/src/github.com/simulot/go-ora/main.go:26 +0x17f
Process exiting with code: 0
@sijms
Copy link
Owner

sijms commented Oct 31, 2020

actually I didn't test the code in windows environment
no problem I will test and see the source of problem and fix

@sijms
Copy link
Owner

sijms commented Oct 31, 2020

I test code in windows working properly
I think the problem in the following
SELECT distinct(TOPIC) FROM help

should be
SELECT distinct TOPIC FROM help

@simulot
Copy link
Contributor Author

simulot commented Nov 1, 2020

Amazing, it works!
Anyway there is something that causes the server rejection when using the unusual but valid query.
The panic occurs when trying to get the reason message from the packet.
I propose to rename the issue as
"Some queries are leading to panic" or so.

@sijms sijms closed this as completed Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants