Skip to content

Commit

Permalink
Merge 320ed79 into e0d2ce7
Browse files Browse the repository at this point in the history
  • Loading branch information
DoubleDi committed Apr 29, 2020
2 parents e0d2ce7 + 320ed79 commit 6277e09
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
8 changes: 6 additions & 2 deletions conn.go
Expand Up @@ -16,7 +16,7 @@ import (
"sync/atomic"
"time"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
)

type key int
Expand Down Expand Up @@ -313,7 +313,11 @@ func (c *conn) buildRequest(ctx context.Context, query string, params []driver.V
}

if c.killQueryOnErr && queryID == "" {
queryID = uuid.NewV4().String()
queryUUID, err := uuid.NewV4()
if err != nil {
return nil, err
}
queryID = queryUUID.String()
}

reqQuery := req.URL.Query()
Expand Down
12 changes: 7 additions & 5 deletions conn_test.go
Expand Up @@ -4,12 +4,11 @@ import (
"context"
"database/sql"
"database/sql/driver"
"fmt"
"net/http"
"testing"
"time"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
"github.com/stretchr/testify/suite"
)

Expand Down Expand Up @@ -177,11 +176,14 @@ func (s *connSuite) TestServerError() {
}

func (s *connSuite) TestServerKillQuery() {
queryID := uuid.NewV4().String()
_, err := s.connWithKillQuery.QueryContext(context.Background(), "SELECT sleep(2)")
queryUUID, err := uuid.NewV4()
s.Require().NoError(err)
queryID := queryUUID.String()
_, err = s.connWithKillQuery.QueryContext(context.WithValue(context.Background(), QueryID, queryID), "SELECT sleep(3)")
s.Error(err)
s.Contains(err.Error(), "net/http: timeout awaiting response headers")
rows := s.connWithKillQuery.QueryRow(fmt.Sprintf("SELECT count(query_id) FROM system.processes where query_id='%s'", queryID))

rows := s.connWithKillQuery.QueryRow("SELECT count(query_id) FROM system.processes where query_id=?", queryID)
var amount int
err = rows.Scan(&amount)
s.NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
@@ -1,7 +1,7 @@
module github.com/mailru/go-clickhouse

require (
github.com/satori/go.uuid v1.1.0
github.com/gofrs/uuid v3.2.0+incompatible
github.com/stretchr/testify v1.3.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
@@ -1,9 +1,9 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/satori/go.uuid v1.1.0 h1:B9KXyj+GzIpJbV7gmr873NsY6zpbxNy24CBtGrk7jHo=
github.com/satori/go.uuid v1.1.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
Expand Down

0 comments on commit 6277e09

Please sign in to comment.