Skip to content

Commit 81e66c3

Browse files
committed
remove proto 1 and 2 support
You can't find servers that support only proto 1 or 2. And there is no technical benefits to restrict proto to these versions. So, we can easily remove code that is taking care of these versions. Patch by dkropachev; reviewed by joao-r-reis for CASSGO-75
1 parent c0cefb0 commit 81e66c3

File tree

12 files changed

+389
-1101
lines changed

12 files changed

+389
-1101
lines changed

batch_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ func TestBatch_Errors(t *testing.T) {
4040
session := createSession(t)
4141
defer session.Close()
4242

43-
if session.cfg.ProtoVersion < protoVersion2 {
44-
t.Skip("atomic batches not supported. Please use Cassandra >= 2.0")
45-
}
46-
4743
if err := createTable(session, `CREATE TABLE gocql_test.batch_errors (id int primary key, val inet)`); err != nil {
4844
t.Fatal(err)
4945
}
@@ -59,10 +55,6 @@ func TestBatch_WithTimestamp(t *testing.T) {
5955
session := createSession(t)
6056
defer session.Close()
6157

62-
if session.cfg.ProtoVersion < protoVersion3 {
63-
t.Skip("Batch timestamps are only available on protocol >= 3")
64-
}
65-
6658
if err := createTable(session, `CREATE TABLE gocql_test.batch_ts (id int primary key, val text)`); err != nil {
6759
t.Fatal(err)
6860
}

cassandra_test.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,25 +2284,7 @@ func TestGetTableMetadata(t *testing.T) {
22842284
if testTable == nil {
22852285
t.Fatal("Expected table metadata for name 'test_table_metadata'")
22862286
}
2287-
if session.cfg.ProtoVersion == protoVersion1 {
2288-
if testTable.KeyValidator != "org.apache.cassandra.db.marshal.Int32Type" {
2289-
t.Errorf("Expected test_table_metadata key validator to be 'org.apache.cassandra.db.marshal.Int32Type' but was '%s'", testTable.KeyValidator)
2290-
}
2291-
if testTable.Comparator != "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.UTF8Type)" {
2292-
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)
2293-
}
2294-
if testTable.DefaultValidator != "org.apache.cassandra.db.marshal.BytesType" {
2295-
t.Errorf("Expected test_table_metadata key validator to be 'org.apache.cassandra.db.marshal.BytesType' but was '%s'", testTable.DefaultValidator)
2296-
}
2297-
expectedKeyAliases := []string{"first_id"}
2298-
if !reflect.DeepEqual(testTable.KeyAliases, expectedKeyAliases) {
2299-
t.Errorf("Expected key aliases %v but was %v", expectedKeyAliases, testTable.KeyAliases)
2300-
}
2301-
expectedColumnAliases := []string{"second_id"}
2302-
if !reflect.DeepEqual(testTable.ColumnAliases, expectedColumnAliases) {
2303-
t.Errorf("Expected key aliases %v but was %v", expectedColumnAliases, testTable.ColumnAliases)
2304-
}
2305-
}
2287+
23062288
if testTable.ValueAlias != "" {
23072289
t.Errorf("Expected value alias '' but was '%s'", testTable.ValueAlias)
23082290
}
@@ -3228,10 +3210,6 @@ func TestUnmarshallNestedTypes(t *testing.T) {
32283210
session := createSession(t)
32293211
defer session.Close()
32303212

3231-
if session.cfg.ProtoVersion < protoVersion3 {
3232-
t.Skip("can not have frozen types in cassandra < 2.1.3")
3233-
}
3234-
32353213
if err := createTable(session, `CREATE TABLE gocql_test.test_557 (
32363214
id text PRIMARY KEY,
32373215
val list<frozen<map<text, text> > >

conn.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ type Conn struct {
179179
frameObserver FrameHeaderObserver
180180
streamObserver StreamObserver
181181

182-
headerBuf [maxFrameHeaderSize]byte
182+
headerBuf [frameHeadSize]byte
183183

184184
streams *streams.IDGenerator
185185
mu sync.Mutex
@@ -784,12 +784,11 @@ func (c *Conn) recvSegment(ctx context.Context) error {
784784
return err
785785
}
786786

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

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

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

17401739
func (c *Conn) executeBatch(ctx context.Context, batch *Batch) *Iter {
1741-
if c.version == protoVersion1 {
1742-
return &Iter{err: ErrUnsupported}
1743-
}
1744-
17451740
n := len(batch.Entries)
17461741
req := &writeBatchFrame{
17471742
typ: batch.Type,

conn_test.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import (
5353
)
5454

5555
const (
56-
defaultProto = protoVersion2
56+
defaultProto = protoVersion4
5757
)
5858

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

1059-
headerSize := 8
1060-
if nts.protocol > protoVersion2 {
1061-
headerSize = 9
1062-
}
1063-
10641059
ctx, cancel := context.WithCancel(ctx)
10651060
srv := &TestServer{
10661061
Address: listen.Addr().String(),
10671062
listen: listen,
10681063
t: t,
10691064
protocol: nts.protocol,
1070-
headerSize: headerSize,
1065+
headerSize: 9,
10711066
ctx: ctx,
10721067
cancel: cancel,
10731068

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

1106-
headerSize := 8
1107-
if protocol > protoVersion2 {
1108-
headerSize = 9
1109-
}
1110-
11111101
ctx, cancel := context.WithCancel(ctx)
11121102
srv := &TestServer{
11131103
Address: listen.Addr().String(),
11141104
listen: listen,
11151105
t: t,
11161106
protocol: protocol,
1117-
headerSize: headerSize,
1107+
headerSize: 9,
11181108
ctx: ctx,
11191109
cancel: cancel,
11201110
}

0 commit comments

Comments
 (0)