Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Removed

- Drop support for old CQL protocol versions: 1 and 2 (CASSGO-75)

### Added

- Support vector type [CASSGO-11](https://issues.apache.org/jira/browse/CASSGO-11)
Expand Down
8 changes: 0 additions & 8 deletions batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ func TestBatch_Errors(t *testing.T) {
session := createSession(t)
defer session.Close()

if session.cfg.ProtoVersion < protoVersion2 {
t.Skip("atomic batches not supported. Please use Cassandra >= 2.0")
}

if err := createTable(session, `CREATE TABLE gocql_test.batch_errors (id int primary key, val inet)`); err != nil {
t.Fatal(err)
}
Expand All @@ -59,10 +55,6 @@ func TestBatch_WithTimestamp(t *testing.T) {
session := createSession(t)
defer session.Close()

if session.cfg.ProtoVersion < protoVersion3 {
t.Skip("Batch timestamps are only available on protocol >= 3")
}

if err := createTable(session, `CREATE TABLE gocql_test.batch_ts (id int primary key, val text)`); err != nil {
t.Fatal(err)
}
Expand Down
24 changes: 1 addition & 23 deletions cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2284,25 +2284,7 @@ func TestGetTableMetadata(t *testing.T) {
if testTable == nil {
t.Fatal("Expected table metadata for name 'test_table_metadata'")
}
if session.cfg.ProtoVersion == protoVersion1 {
if testTable.KeyValidator != "org.apache.cassandra.db.marshal.Int32Type" {
t.Errorf("Expected test_table_metadata key validator to be 'org.apache.cassandra.db.marshal.Int32Type' but was '%s'", testTable.KeyValidator)
}
if testTable.Comparator != "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type)" {
t.Errorf("Expected test_table_metadata key validator to be 'org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type)' but was '%s'", testTable.Comparator)
}
if testTable.DefaultValidator != "org.apache.cassandra.db.marshal.BytesType" {
t.Errorf("Expected test_table_metadata key validator to be 'org.apache.cassandra.db.marshal.BytesType' but was '%s'", testTable.DefaultValidator)
}
expectedKeyAliases := []string{"first_id"}
if !reflect.DeepEqual(testTable.KeyAliases, expectedKeyAliases) {
t.Errorf("Expected key aliases %v but was %v", expectedKeyAliases, testTable.KeyAliases)
}
expectedColumnAliases := []string{"second_id"}
if !reflect.DeepEqual(testTable.ColumnAliases, expectedColumnAliases) {
t.Errorf("Expected key aliases %v but was %v", expectedColumnAliases, testTable.ColumnAliases)
}
}

if testTable.ValueAlias != "" {
t.Errorf("Expected value alias '' but was '%s'", testTable.ValueAlias)
}
Expand Down Expand Up @@ -3228,10 +3210,6 @@ func TestUnmarshallNestedTypes(t *testing.T) {
session := createSession(t)
defer session.Close()

if session.cfg.ProtoVersion < protoVersion3 {
t.Skip("can not have frozen types in cassandra < 2.1.3")
}

if err := createTable(session, `CREATE TABLE gocql_test.test_557 (
id text PRIMARY KEY,
val list<frozen<map<text, text> > >
Expand Down
11 changes: 3 additions & 8 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ type Conn struct {
frameObserver FrameHeaderObserver
streamObserver StreamObserver

headerBuf [maxFrameHeaderSize]byte
headerBuf [frameHeadSize]byte

streams *streams.IDGenerator
mu sync.Mutex
Expand Down Expand Up @@ -784,12 +784,11 @@ func (c *Conn) recvSegment(ctx context.Context) error {
return err
}

const frameHeaderLength = 9
buf := bytes.NewBuffer(make([]byte, 0, head.length+frameHeaderLength))
buf := bytes.NewBuffer(make([]byte, 0, head.length+frameHeadSize))
buf.Write(frame)

// Computing how many bytes of message left to read
bytesToRead := head.length - len(frame) + frameHeaderLength
bytesToRead := head.length - len(frame) + frameHeadSize

err = c.recvPartialFrames(buf, bytesToRead)
if err != nil {
Expand Down Expand Up @@ -1738,10 +1737,6 @@ func (c *Conn) UseKeyspace(keyspace string) error {
}

func (c *Conn) executeBatch(ctx context.Context, batch *Batch) *Iter {
if c.version == protoVersion1 {
return &Iter{err: ErrUnsupported}
}

n := len(batch.Entries)
req := &writeBatchFrame{
typ: batch.Type,
Expand Down
16 changes: 3 additions & 13 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import (
)

const (
defaultProto = protoVersion2
defaultProto = protoVersion4
)

func TestApprove(t *testing.T) {
Expand Down Expand Up @@ -1056,18 +1056,13 @@ func (nts newTestServerOpts) newServer(t testing.TB, ctx context.Context) *TestS
t.Fatal(err)
}

headerSize := 8
if nts.protocol > protoVersion2 {
headerSize = 9
}

ctx, cancel := context.WithCancel(ctx)
srv := &TestServer{
Address: listen.Addr().String(),
listen: listen,
t: t,
protocol: nts.protocol,
headerSize: headerSize,
headerSize: 9,
ctx: ctx,
cancel: cancel,

Expand Down Expand Up @@ -1103,18 +1098,13 @@ func NewSSLTestServer(t testing.TB, protocol uint8, ctx context.Context) *TestSe
t.Fatal(err)
}

headerSize := 8
if protocol > protoVersion2 {
headerSize = 9
}

ctx, cancel := context.WithCancel(ctx)
srv := &TestServer{
Address: listen.Addr().String(),
listen: listen,
t: t,
protocol: protocol,
headerSize: headerSize,
headerSize: 9,
ctx: ctx,
cancel: cancel,
}
Expand Down
Loading