[ 
https://issues.apache.org/jira/browse/CALCITE-3844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17052685#comment-17052685
 ] 

Francis Chuang commented on CALCITE-3844:
-----------------------------------------

Please see my comments
{code}
package main

import (
        "context"
        "database/sql"
        _ "github.com/apache/calcite-avatica-go/v4"
        "github.com/sirupsen/logrus"
)

const (
        JDBC_DRIVER = "avatica"

        PHOENIX_ADDR = "http://localhost:8765";
)

var db *sql.DB

func init() { // This runs when the program is executed
        db, err := sql.Open(JDBC_DRIVER, PHOENIX_ADDR)
        if err != nil {
                logrus.Error("error connecting: ", err.Error())
        }
        defer db.Close() // If you close the db here, it's no longer available
        return res // The res variable does not exist
}

func QueryContext(query string) (rows *sql.Rows) {
        rows, err := db.QueryContext(context.TODO(), query)
        if err != nil {
                logrus.Error("query: ", err)
        }
        defer db.Close() // I think this should be rows.Close()
        return rows
}

func main() {
        logrus.Info(QueryContext("SELECT * FROM TEST"))
}

{code}

> when i use the example calcite-avatica-go provided, it always reports “panic: 
> runtime error: invalid memory address or nil pointer dereference[signal 
> SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x4e6e01]”
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3844
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3844
>             Project: Calcite
>          Issue Type: Bug
>          Components: avatica-go
>            Reporter: yaruqi
>            Assignee: Francis Chuang
>            Priority: Blocker
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to