You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: drop_function_test.go
    path of file: ./repos/cockroach/pkg/sql
    
    the code of the file until where you have to start completion: // Copyright 2022 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package sql_test

import (
	"context"
	"regexp"
	"sort"
	"strconv"
	"testing"

	"github.com/cockroachdb/cockroach/pkg/base"
	"github.com/cockroachdb/cockroach/pkg/sql"
	"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
	"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
	"github.com/cockroachdb/cockroach/pkg/sql/isql"
	"github.com/cockroachdb/cockroach/pkg/sql/sem/catid"
	"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
	"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
	"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
	"github.com/cockroachdb/cockroach/pkg/util/leaktest"
	"github.com/cockroachdb/cockroach/pkg/util/log"
	"github.com/stretchr/testify/require"
)

func TestDropFunction(t *testing.T) {
	defer leaktest.AfterTest(t)()
	defer log.Scope(t).Close(t)

	ctx := context.Background()
	s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{
		DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(107322),
	})
	defer s.Stopper().Stop(ctx)
	tDB := sqlutils.MakeSQLRunner(sqlDB)

	tDB.Exec(t, `
CREATE TABLE t(
  a INT PRIMARY KEY,
  b INT,
  C INT,
  INDEX t_idx_b(b),
  INDEX t_idx_c(c)
);
CREATE SEQUENCE sq1;

    
func TestDropCascadeRemoveFunction(t *testing.T) {
	defer leaktest.AfterTest(t)()
	defer log.Scope(t).Close(t)

	setupQuery := `
CREATE DATABASE test_db;
USE test_db;
CREATE TABLE t(
  a INT PRIMARY KEY,
  b INT,
  C INT,
  d INT,
  INDEX t_idx_b(b),
  INDEX t_idx_c(c)
);
CREATE SEQUENCE sq1;
CREATE TABLE t2(a INT PRIMARY KEY);
CREATE VIEW v AS SELECT a FROM t2;
CREATE TYPE notmyworkday AS ENUM ('Monday', 'Tuesday');
CREATE SCHEMA test_sc;
CREATE FUNCTION test_sc.f(a notmyworkday) RETURNS INT VOLATILE LANGUAGE SQL AS $$
  SELECT a FROM t;
  SELECT b FROM t@t_idx_b;
  SELECT c FROM t@t_idx_c;
  SELECT d FROM t;
  SELECT a FROM v;
  SELECT nextval('sq1');
$$;
`

	testCases := []struct {
		testName string
		stmt     string
	}{
		{
			testName: "drop sequence",
			stmt:     "DROP SEQUENCE sq1 CASCADE",
		},
		{
			testName: "drop table",
			stmt:     "DROP TABLE t CASCADE",
		},
		{
			testName: "drop view",
			stmt:     "DROP VIEW v CASCADE",
		},
		{
			testName: "drop column",
			stmt:     "ALTER TABLE t DROP COLUMN d CASCADE",
		},
		{
			testName: "drop index",
			stmt:     "DROP INDEX t@t_idx_b CASCADE",
		},
		{
			testName: "drop database",
			stmt:     "DROP DATABASE test_db CASCADE",
		},
		{
			testName: "drop schema",
			stmt:     "DROP SCHEMA test_sc CASCADE",
		},
	}

	for _, tc := range testCases {
		t.Run(tc.testName, func(t *testing.T) {
			ctx := context.Background()
			s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{})
			defer s.Stopper().Stop(ctx)
			tDB := sqlutils.MakeSQLRunner(sqlDB)
			tDB.Exec(t, setupQuery)
			// Test drop/rename behavior in legacy schema changer.
			tDB.Exec(t, "SET use_declarative_schema_changer = off;")

			err := sql.TestingDescsTxn(ctx, s, func(ctx context.Context, txn isql.Txn, col *descs.Collection) error {
				fnDesc, err := col.ByIDWithLeased(txn.KV()).WithoutNonPublic().Get().Function(ctx, 113)
				require.NoError(t, err)
				require.Equal(t, "f", fnDesc.GetName())
				require.True(t, fnDesc.Public())
				return nil
			})
			require.NoError(t, err)

			tDB.Exec(t, tc.stmt)

			err = sql.TestingDescsTxn(ctx, s, func(ctx context.Context, txn isql.Txn, col *descs.Collection) error {
				_, err := col.ByIDWithLeased(txn.KV()).WithoutNonPublic().Get().Function(ctx, 113)
				require.Error(t, err)
				require.Regexp(t, regexp.MustCompile(`function \d+ does not exist`), err.Error())
				return nil
			})
			require.NoError(t, err)
		})
	}

	// Make sure declarative schema changer falls back to legacy schema changer to
	// drop the function.
	for _, tc := range testCases {
		t.Run(tc.testName, func(t *testing.T) {
			ctx := context.Background()
			s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{})
			defer s.Stopper().Stop(ctx)
			tDB := sqlutils.MakeSQLRunner(sqlDB)
			tDB.Exec(t, setupQuery)
			// Test drop/rename behavior in legacy schema changer.
			tDB.Exec(t, "SET use_declarative_schema_changer = on;")

			err := sql.TestingDescsTxn(ctx, s, func(ctx context.Context, txn isql.Txn, col *descs.Collection) error {
				fnDesc, err := col.ByIDWithLeased(txn.KV()).WithoutNonPublic().Get().Function(ctx, 113)
				require.NoError(t, err)
				require.Equal(t, "f", fnDesc.GetName())
				require.True(t, fnDesc.Public())
				return nil
			})
			require.NoError(t, err)

			tDB.Exec(t, tc.stmt)

			err = sql.TestingDescsTxn(ctx, s, func(ctx context.Context, txn isql.Txn, col *descs.Collection) error {
				_, err := col.ByIDWithLeased(txn.KV()).WithoutNonPublic().Get().Function(ctx, 113)
				require.Error(t, err)
				require.Regexp(t, regexp.MustCompile(`function \d+ does not exist`), err.Error())
				return nil
			})
			require.NoError(t, err)
		})
	}

}