diff --git a/go/bytes2/buffer.go b/go/bytes2/buffer.go index 48561c5e493..ba0b1ec2265 100644 --- a/go/bytes2/buffer.go +++ b/go/bytes2/buffer.go @@ -28,11 +28,6 @@ type Buffer struct { bytes []byte } -// NewBuffer is equivalent to bytes.NewBuffer. -func NewBuffer(b []byte) *Buffer { - return &Buffer{bytes: b} -} - // Write is equivalent to bytes.Buffer.Write. func (buf *Buffer) Write(b []byte) (int, error) { buf.bytes = append(buf.bytes, b...) diff --git a/go/bytes2/buffer_test.go b/go/bytes2/buffer_test.go index 1652f176df4..5171059d375 100644 --- a/go/bytes2/buffer_test.go +++ b/go/bytes2/buffer_test.go @@ -23,7 +23,7 @@ import ( ) func TestBuffer(t *testing.T) { - b := NewBuffer(nil) + var b Buffer // Test Write function b.Write([]byte("ab")) diff --git a/go/cache/theine/bf/bf.go b/go/cache/theine/bf/bf.go index 97b27a5c217..3549d709d97 100644 --- a/go/cache/theine/bf/bf.go +++ b/go/cache/theine/bf/bf.go @@ -19,16 +19,6 @@ func New(falsePositiveRate float64) *Bloomfilter { return d } -// create new bloomfilter with given size in bytes -func NewWithSize(size uint32) *Bloomfilter { - d := &Bloomfilter{} - bits := size * 8 - m := nextPowerOfTwo(uint32(bits)) - d.M = m - d.Filter = newbv(m) - return d -} - func (d *Bloomfilter) EnsureCapacity(capacity int) { if capacity <= d.Capacity { return diff --git a/go/cache/theine/bf/bf_test.go b/go/cache/theine/bf/bf_test.go index 135826195ac..12999cdcbc9 100644 --- a/go/cache/theine/bf/bf_test.go +++ b/go/cache/theine/bf/bf_test.go @@ -7,11 +7,8 @@ import ( ) func TestBloom(t *testing.T) { - bf := NewWithSize(5) - bf.FalsePositiveRate = 0.1 - bf.EnsureCapacity(5) + bf := New(0.1) bf.EnsureCapacity(500) - bf.EnsureCapacity(200) exist := bf.Insert(123) require.False(t, exist) diff --git a/go/cmd/vtctldclient/command/framework_test.go b/go/cmd/vtctldclient/command/framework_test.go index 3e4a6753411..351356ea3a0 100644 --- a/go/cmd/vtctldclient/command/framework_test.go +++ b/go/cmd/vtctldclient/command/framework_test.go @@ -101,14 +101,6 @@ func TabletKeyspaceShard(t *testing.T, keyspace, shard string) TabletOption { } } -// ForceInitTablet is the tablet option to set the 'force' flag during InitTablet -func ForceInitTablet() TabletOption { - return func(tablet *topodatapb.Tablet) { - // set the force_init field into the portmap as a hack - tablet.PortMap["force_init"] = 1 - } -} - // StartHTTPServer is the tablet option to start the HTTP server when // starting a tablet. func StartHTTPServer() TabletOption { diff --git a/go/sqltypes/value_test.go b/go/sqltypes/value_test.go index f6360c8b5c4..e71e866c9f5 100644 --- a/go/sqltypes/value_test.go +++ b/go/sqltypes/value_test.go @@ -20,7 +20,6 @@ import ( "math" "strings" "testing" - "time" "github.com/stretchr/testify/assert" @@ -612,16 +611,6 @@ func TestToUint32(t *testing.T) { } } -var randomLocation = time.FixedZone("Nowhere", 3*60*60) - -func DatetimeValue(str string) Value { - return TestValue(Datetime, str) -} - -func DateValue(str string) Value { - return TestValue(Date, str) -} - func TestEncodeSQLStringBuilder(t *testing.T) { testcases := []struct { in Value @@ -680,9 +669,9 @@ func TestEncodeSQLBytes2(t *testing.T) { outSQL: "\x89\x02\x011\x950\x03foo", }} for _, tcase := range testcases { - buf := bytes2.NewBuffer([]byte{}) + var buf bytes2.Buffer - tcase.in.EncodeSQLBytes2(buf) + tcase.in.EncodeSQLBytes2(&buf) assert.Equal(t, tcase.outSQL, buf.String()) } } diff --git a/go/test/vschemawrapper/vschema_wrapper.go b/go/test/vschemawrapper/vschema_wrapper.go index 02daa646bf8..b48d7f5d0b7 100644 --- a/go/test/vschemawrapper/vschema_wrapper.go +++ b/go/test/vschemawrapper/vschema_wrapper.go @@ -288,20 +288,6 @@ func (vw *VSchemaWrapper) FindTableOrVindex(tab sqlparser.TableName) (*vindexes. return vw.Vcursor.FindTableOrVindex(tab) } -func (vw *VSchemaWrapper) getActualKeyspace() string { - if vw.Keyspace == nil { - return "" - } - if !sqlparser.SystemSchema(vw.Keyspace.Name) { - return vw.Keyspace.Name - } - ks, err := vw.AnyKeyspace() - if err != nil { - return "" - } - return ks.Name -} - func (vw *VSchemaWrapper) SelectedKeyspace() (*vindexes.Keyspace, error) { return vw.AnyKeyspace() } diff --git a/go/vt/schemadiff/table.go b/go/vt/schemadiff/table.go index 88f8e7d4ce8..182aa9537e7 100644 --- a/go/vt/schemadiff/table.go +++ b/go/vt/schemadiff/table.go @@ -1099,16 +1099,6 @@ func (c *CreateTableEntity) TableDiff(other *CreateTableEntity, hints *DiffHints return parentAlterTableEntityDiff, nil } -func (c *CreateTableEntity) diffTableCharset( - t1cc *charsetCollate, - t2cc *charsetCollate, -) string { - if t1cc.charset != t2cc.charset { - return t2cc.charset - } - return "" -} - // isDefaultTableOptionValue sees if the value for a TableOption is also its default value func isDefaultTableOptionValue(option *sqlparser.TableOption) bool { var value string diff --git a/go/vt/sqlparser/rewriter_api.go b/go/vt/sqlparser/rewriter_api.go index e159987e8e1..5641681b447 100644 --- a/go/vt/sqlparser/rewriter_api.go +++ b/go/vt/sqlparser/rewriter_api.go @@ -126,15 +126,6 @@ func (c *Cursor) Replace(newNode SQLNode) { c.node = newNode } -// ReplacerF returns a replace func that will work even when the cursor has moved to a different node. -func (c *Cursor) ReplacerF() func(newNode SQLNode) { - replacer := c.replacer - parent := c.parent - return func(newNode SQLNode) { - replacer(newNode, parent) - } -} - // ReplaceAndRevisit replaces the current node in the parent field with this new object. // When used, this will abort the visitation of the current node - no post or children visited, // and the new node visited. diff --git a/go/vt/sqlparser/tracked_buffer.go b/go/vt/sqlparser/tracked_buffer.go index 9ef0cfd1f93..7fdb741aed6 100644 --- a/go/vt/sqlparser/tracked_buffer.go +++ b/go/vt/sqlparser/tracked_buffer.go @@ -430,12 +430,6 @@ func CanonicalString(node SQLNode) string { return buf.String() } -func FormatSlice[T SQLNode](buf *TrackedBuffer, valueExprs []T) { - for _, expr := range valueExprs { - buf.Myprintf("%v", expr) - } -} - func SliceString[T SQLNode](valueExprs []T) string { return SliceStringWithSep(valueExprs, ", ") } diff --git a/go/vt/vttablet/onlineddl/executor.go b/go/vt/vttablet/onlineddl/executor.go index ea6ea8732d2..3a3d1a9906e 100644 --- a/go/vt/vttablet/onlineddl/executor.go +++ b/go/vt/vttablet/onlineddl/executor.go @@ -25,7 +25,6 @@ import ( "errors" "fmt" "os" - "path" "strconv" "strings" "sync" @@ -425,10 +424,6 @@ func (e *Executor) isAnyConflictingMigrationRunning(onlineDDL *schema.OnlineDDL) return (conflictingMigration != nil), conflictingMigration } -func (e *Executor) ptPidFileName(uuid string) string { - return path.Join(os.TempDir(), fmt.Sprintf("pt-online-schema-change.%s.pid", uuid)) -} - // tableExists checks if a given table exists. func (e *Executor) tableExists(ctx context.Context, tableName string) (bool, error) { tableName = strings.ReplaceAll(tableName, `_`, `\_`) diff --git a/go/vt/vttablet/onlineddl/vrepl.go b/go/vt/vttablet/onlineddl/vrepl.go index 7423b05a574..52ac775adfe 100644 --- a/go/vt/vttablet/onlineddl/vrepl.go +++ b/go/vt/vttablet/onlineddl/vrepl.go @@ -226,19 +226,6 @@ func (v *VRepl) readTableStatus(ctx context.Context, conn *dbconnpool.DBConnecti return tableRows, err } -// formalizeColumns -func formalizeColumns(columnsLists ...*schemadiff.ColumnDefinitionEntityList) error { - for _, colList := range columnsLists { - for _, col := range colList.Entities { - col.SetExplicitDefaultAndNull() - if err := col.SetExplicitCharsetCollate(); err != nil { - return err - } - } - } - return nil -} - func (v *VRepl) analyzeAlter() error { if v.alterTableAnalysis.IsRenameTable { return fmt.Errorf("renaming the table is not supported in ALTER TABLE") diff --git a/go/vt/wrangler/testlib/fake_tablet.go b/go/vt/wrangler/testlib/fake_tablet.go index 97d74edf3f7..9649d717d73 100644 --- a/go/vt/wrangler/testlib/fake_tablet.go +++ b/go/vt/wrangler/testlib/fake_tablet.go @@ -102,14 +102,6 @@ func TabletKeyspaceShard(t *testing.T, keyspace, shard string) TabletOption { } } -// ForceInitTablet is the tablet option to set the 'force' flag during InitTablet -func ForceInitTablet() TabletOption { - return func(tablet *topodatapb.Tablet) { - // set the force_init field into the portmap as a hack - tablet.PortMap["force_init"] = 1 - } -} - // StartHTTPServer is the tablet option to start the HTTP server when // starting a tablet. func StartHTTPServer() TabletOption {