Browse Source

Only read result column meta data for v2 of the protocol

Ben Hood 11 years ago
parent
commit
b38f2d96fd
2 changed files with 10 additions and 2 deletions
  1. 7 2
      cassandra_test.go
  2. 3 0
      conn.go

+ 7 - 2
cassandra_test.go

@@ -615,10 +615,15 @@ func TestQueryInfo(t *testing.T) {
 		t.Fatalf("Failed to execute query for preparing statement: %v", err)
 	}
 
-	if len(info.rval) != 2 {
-		t.Fatalf("Was not expecting meta data for %d result columns, but got %d\n", 2, len(info.rval))
+	if len(info.args) != 1 {
+		t.Fatalf("Was not expecting meta data for %d query arguments, but got %d\n", 1, len(info.args))
 	}
 
+	if *flagProto > 1 {
+		if len(info.rval) != 2 {
+			t.Fatalf("Was not expecting meta data for %d result columns, but got %d\n", 2, len(info.rval))
+		}
+	}
 }
 
 //TestPreparedCacheEviction will make sure that the cache size is maintained

+ 3 - 0
conn.go

@@ -586,6 +586,9 @@ func (c *Conn) decodeFrame(f frame, trace Tracer) (rval interface{}, err error)
 		case resultKindPrepared:
 			id := f.readShortBytes()
 			args, _ := f.readMetaData()
+			if c.version < 2 {
+				return resultPreparedFrame{PreparedId: id, Arguments: args}, nil
+			}
 			rvals, _ := f.readMetaData()
 			return resultPreparedFrame{PreparedId: id, Arguments: args, ReturnValues: rvals}, nil
 		case resultKindSchemaChanged: