diff --git a/cassandra_test.go b/cassandra_test.go index 691d25cdd..30e213e76 100644 --- a/cassandra_test.go +++ b/cassandra_test.go @@ -20,7 +20,7 @@ import ( "time" "unicode" - inf "gopkg.in/inf.v0" + "gopkg.in/inf.v0" ) func TestEmptyHosts(t *testing.T) { @@ -2199,45 +2199,6 @@ func TestGetColumnMetadata(t *testing.T) { } } -func TestViewMetadata(t *testing.T) { - session := createSession(t) - defer session.Close() - createViews(t, session) - - views, err := getViewsMetadata(session, "gocql_test") - if err != nil { - t.Fatalf("failed to query view metadata with err: %v", err) - } - if views == nil { - t.Fatal("failed to query view metadata, nil returned") - } - - if len(views) != 1 { - t.Fatal("expected one view") - } - - textType := TypeText - if flagCassVersion.Before(3, 0, 0) { - textType = TypeVarchar - } - - expectedView := ViewMetadata{ - Keyspace: "gocql_test", - Name: "basicview", - FieldNames: []string{"birthday", "nationality", "weight", "height"}, - FieldTypes: []TypeInfo{ - NativeType{typ: TypeTimestamp}, - NativeType{typ: textType}, - NativeType{typ: textType}, - NativeType{typ: textType}, - }, - } - - if !reflect.DeepEqual(views[0], expectedView) { - t.Fatalf("view is %+v, but expected %+v", views[0], expectedView) - } -} - func TestMaterializedViewMetadata(t *testing.T) { if flagCassVersion.Before(3, 0, 0) { return @@ -2520,11 +2481,6 @@ func TestKeyspaceMetadata(t *testing.T) { if aggregate.StateFunc.Name != "avgstate" { t.Fatalf("expected state function %s, but got %s", "avgstate", aggregate.StateFunc.Name) } - - _, found = keyspaceMetadata.Views["basicview"] - if !found { - t.Fatal("failed to find the view in metadata") - } _, found = keyspaceMetadata.UserTypes["basicview"] if !found { t.Fatal("failed to find the types in metadata") diff --git a/conn.go b/conn.go index d780bcd97..e063e861d 100644 --- a/conn.go +++ b/conn.go @@ -154,14 +154,6 @@ func (fn connErrorHandlerFn) HandleError(conn *Conn, err error, closed bool) { fn(conn, err, closed) } -// If not zero, how many timeouts we will allow to occur before the connection is closed -// and restarted. This is to prevent a single query timeout from killing a connection -// which may be serving more queries just fine. -// Default is 0, should not be changed concurrently with queries. -// -// Deprecated. -var TimeoutLimit int64 = 0 - // Conn is a single connection to a Cassandra node. It can be used to execute // queries, but users are usually advised to use a more reliable, higher // level API. @@ -752,7 +744,7 @@ func (c *Conn) releaseStream(call *callReq) { } func (c *Conn) handleTimeout() { - if TimeoutLimit > 0 && atomic.AddInt64(&c.timeouts, 1) > TimeoutLimit { + if atomic.AddInt64(&c.timeouts, 1) > 0 { c.closeWithError(ErrTooManyTimeouts) } } diff --git a/frame.go b/frame.go index 44be7879d..b419c0aab 100644 --- a/frame.go +++ b/frame.go @@ -255,17 +255,6 @@ func ParseConsistencyWrapper(s string) (consistency Consistency, err error) { return } -// MustParseConsistency is the same as ParseConsistency except it returns -// an error (never). It is kept here since breaking changes are not good. -// DEPRECATED: use ParseConsistency if you want a panic on parse error. -func MustParseConsistency(s string) (Consistency, error) { - c, err := ParseConsistencyWrapper(s) - if err != nil { - panic(err) - } - return c, nil -} - type SerialConsistency uint16 const ( diff --git a/marshal.go b/marshal.go index b887b3f2b..c68de832f 100644 --- a/marshal.go +++ b/marshal.go @@ -2435,14 +2435,6 @@ type TypeInfo interface { Version() byte Custom() string - // New creates a pointer to an empty version of whatever type - // is referenced by the TypeInfo receiver. - // - // If there is no corresponding Go type for the CQL type, New panics. - // - // Deprecated: Use NewWithError instead. - New() interface{} - // NewWithError creates a pointer to an empty version of whatever type // is referenced by the TypeInfo receiver. // @@ -2468,14 +2460,6 @@ func (t NativeType) NewWithError() (interface{}, error) { return reflect.New(typ).Interface(), nil } -func (t NativeType) New() interface{} { - val, err := t.NewWithError() - if err != nil { - panic(err.Error()) - } - return val -} - func (s NativeType) Type() Type { return s.typ } @@ -2511,14 +2495,6 @@ func (t CollectionType) NewWithError() (interface{}, error) { return reflect.New(typ).Interface(), nil } -func (t CollectionType) New() interface{} { - val, err := t.NewWithError() - if err != nil { - panic(err.Error()) - } - return val -} - func (c CollectionType) String() string { switch c.typ { case TypeMap: @@ -2556,14 +2532,6 @@ func (t TupleTypeInfo) NewWithError() (interface{}, error) { return reflect.New(typ).Interface(), nil } -func (t TupleTypeInfo) New() interface{} { - val, err := t.NewWithError() - if err != nil { - panic(err.Error()) - } - return val -} - type UDTField struct { Name string Type TypeInfo @@ -2584,14 +2552,6 @@ func (u UDTTypeInfo) NewWithError() (interface{}, error) { return reflect.New(typ).Interface(), nil } -func (u UDTTypeInfo) New() interface{} { - val, err := u.NewWithError() - if err != nil { - panic(err.Error()) - } - return val -} - func (u UDTTypeInfo) String() string { buf := &bytes.Buffer{} diff --git a/metadata.go b/metadata.go index 13345d937..09221483a 100644 --- a/metadata.go +++ b/metadata.go @@ -15,15 +15,13 @@ import ( // schema metadata for a keyspace type KeyspaceMetadata struct { - Name string - DurableWrites bool - StrategyClass string - StrategyOptions map[string]interface{} - Tables map[string]*TableMetadata - Functions map[string]*FunctionMetadata - Aggregates map[string]*AggregateMetadata - // Deprecated: use the MaterializedViews field for views and UserTypes field for udts instead. - Views map[string]*ViewMetadata + Name string + DurableWrites bool + StrategyClass string + StrategyOptions map[string]interface{} + Tables map[string]*TableMetadata + Functions map[string]*FunctionMetadata + Aggregates map[string]*AggregateMetadata MaterializedViews map[string]*MaterializedViewMetadata UserTypes map[string]*UserTypeMetadata } @@ -85,15 +83,6 @@ type AggregateMetadata struct { finalFunc string } -// ViewMetadata holds the metadata for views. -// Deprecated: this is kept for backwards compatibility issues. Use MaterializedViewMetadata. -type ViewMetadata struct { - Keyspace string - Name string - FieldNames []string - FieldTypes []TypeInfo -} - // MaterializedViewMetadata holds the metadata for materialized views. type MaterializedViewMetadata struct { Keyspace string @@ -280,7 +269,7 @@ func (s *schemaDescriber) refreshSchema(keyspaceName string) error { if err != nil { return err } - views, err := getViewsMetadata(s.session, keyspaceName) + userTypes, err := getUserTypeMetadata(s.session, keyspaceName) if err != nil { return err } @@ -290,7 +279,7 @@ func (s *schemaDescriber) refreshSchema(keyspaceName string) error { } // organize the schema data - compileMetadata(s.session.cfg.ProtoVersion, keyspace, tables, columns, functions, aggregates, views, + compileMetadata(s.session.cfg.ProtoVersion, keyspace, tables, columns, functions, aggregates, userTypes, materializedViews, s.session.logger) // update the cache @@ -311,7 +300,7 @@ func compileMetadata( columns []ColumnMetadata, functions []FunctionMetadata, aggregates []AggregateMetadata, - views []ViewMetadata, + uTypes []UserTypeMetadata, materializedViews []MaterializedViewMetadata, logger StdLogger, ) { @@ -331,22 +320,9 @@ func compileMetadata( aggregates[i].StateFunc = *keyspace.Functions[aggregates[i].stateFunc] keyspace.Aggregates[aggregates[i].Name] = &aggregates[i] } - keyspace.Views = make(map[string]*ViewMetadata, len(views)) - for i := range views { - keyspace.Views[views[i].Name] = &views[i] - } - // Views currently holds the types and hasn't been deleted for backward compatibility issues. - // That's why it's ok to copy Views into Types in this case. For the real Views use MaterializedViews. - types := make([]UserTypeMetadata, len(views)) - for i := range views { - types[i].Keyspace = views[i].Keyspace - types[i].Name = views[i].Name - types[i].FieldNames = views[i].FieldNames - types[i].FieldTypes = views[i].FieldTypes - } - keyspace.UserTypes = make(map[string]*UserTypeMetadata, len(views)) - for i := range types { - keyspace.UserTypes[types[i].Name] = &types[i] + keyspace.UserTypes = make(map[string]*UserTypeMetadata, len(uTypes)) + for i := range uTypes { + keyspace.UserTypes[uTypes[i].Name] = &uTypes[i] } keyspace.MaterializedViews = make(map[string]*MaterializedViewMetadata, len(materializedViews)) for i, _ := range materializedViews { @@ -930,7 +906,7 @@ func getTypeInfo(t string, logger StdLogger) TypeInfo { return getCassandraType(t, logger) } -func getViewsMetadata(session *Session, keyspaceName string) ([]ViewMetadata, error) { +func getUserTypeMetadata(session *Session, keyspaceName string) ([]UserTypeMetadata, error) { if session.cfg.ProtoVersion == protoVersion1 { return nil, nil } @@ -948,31 +924,31 @@ func getViewsMetadata(session *Session, keyspaceName string) ([]ViewMetadata, er FROM %s WHERE keyspace_name = ?`, tableName) - var views []ViewMetadata + var uTypes []UserTypeMetadata rows := session.control.query(stmt, keyspaceName).Scanner() for rows.Next() { - view := ViewMetadata{Keyspace: keyspaceName} + uType := UserTypeMetadata{Keyspace: keyspaceName} var argumentTypes []string - err := rows.Scan(&view.Name, - &view.FieldNames, + err := rows.Scan(&uType.Name, + &uType.FieldNames, &argumentTypes, ) if err != nil { return nil, err } - view.FieldTypes = make([]TypeInfo, len(argumentTypes)) + uType.FieldTypes = make([]TypeInfo, len(argumentTypes)) for i, argumentType := range argumentTypes { - view.FieldTypes[i] = getTypeInfo(argumentType, session.logger) + uType.FieldTypes[i] = getTypeInfo(argumentType, session.logger) } - views = append(views, view) + uTypes = append(uTypes, uType) } if err := rows.Err(); err != nil { return nil, err } - return views, nil + return uTypes, nil } func getMaterializedViewsMetadata(session *Session, keyspaceName string) ([]MaterializedViewMetadata, error) {