Skip to content

Commit

Permalink
sql: remove usage of GetBuiltinProperties from GetSequenceFromFunc
Browse files Browse the repository at this point in the history
In `GetSequenceFromFunc` we resolve a function and then use the
name to get builtin properties. This seems unnecessary because
we may just get function properties from the resolved function
definition. With this change, we are eleminating a good amount of
usage cases of "GetBuiltinProperties", which seems to be the
majority of the usages of "GetBuiltinProperties".

Release note: None
  • Loading branch information
chengxiong-ruan committed Jul 29, 2022
1 parent 6da18dc commit 5409013
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 69 deletions.
1 change: 0 additions & 1 deletion pkg/sql/catalog/seqexpr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ go_test(
"//pkg/sql/catalog/descpb",
"//pkg/sql/parser",
"//pkg/sql/sem/builtins",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/tree",
"//pkg/sql/types",
"@com_github_stretchr_testify//require",
Expand Down
32 changes: 10 additions & 22 deletions pkg/sql/catalog/seqexpr/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ func (si *SeqIdentifier) IsByID() bool {
// Returns the identifier of the sequence or nil if no sequence was found.
//
// `getBuiltinProperties` argument is commonly builtinsregistry.GetBuiltinProperties.
func GetSequenceFromFunc(
funcExpr *tree.FuncExpr,
getBuiltinProperties func(name string) (*tree.FunctionProperties, []tree.Overload),
) (*SeqIdentifier, error) {
func GetSequenceFromFunc(funcExpr *tree.FuncExpr) (*SeqIdentifier, error) {

// Resolve doesn't use the searchPath for resolving FunctionDefinitions
// so we can pass in an empty SearchPath.
Expand Down Expand Up @@ -143,17 +140,14 @@ func getSequenceIdentifier(expr tree.Expr) *SeqIdentifier {
// e.g. nextval('foo') => "foo"; nextval(123::regclass) => 123; <some other expression> => nil
//
// `getBuiltinProperties` argument is commonly builtinsregistry.GetBuiltinProperties.
func GetUsedSequences(
defaultExpr tree.Expr,
getBuiltinProperties func(name string) (*tree.FunctionProperties, []tree.Overload),
) ([]SeqIdentifier, error) {
func GetUsedSequences(defaultExpr tree.Expr) ([]SeqIdentifier, error) {
var seqIdentifiers []SeqIdentifier
_, err := tree.SimpleVisit(
defaultExpr,
func(expr tree.Expr) (recurse bool, newExpr tree.Expr, err error) {
switch t := expr.(type) {
case *tree.FuncExpr:
identifier, err := GetSequenceFromFunc(t, getBuiltinProperties)
identifier, err := GetSequenceFromFunc(t)
if err != nil {
return false, nil, err
}
Expand All @@ -176,14 +170,12 @@ func GetUsedSequences(
//
// `getBuiltinProperties` argument is commonly builtinsregistry.GetBuiltinProperties.
func ReplaceSequenceNamesWithIDs(
defaultExpr tree.Expr,
nameToID map[string]descpb.ID,
getBuiltinProperties func(name string) (*tree.FunctionProperties, []tree.Overload),
defaultExpr tree.Expr, nameToID map[string]descpb.ID,
) (tree.Expr, error) {
replaceFn := func(expr tree.Expr) (recurse bool, newExpr tree.Expr, err error) {
switch t := expr.(type) {
case *tree.FuncExpr:
identifier, err := GetSequenceFromFunc(t, getBuiltinProperties)
identifier, err := GetSequenceFromFunc(t)
if err != nil {
return false, nil, err
}
Expand Down Expand Up @@ -225,13 +217,11 @@ func ReplaceSequenceNamesWithIDs(
//
// `getBuiltinProperties` argument is commonly builtinsregistry.GetBuiltinProperties.
func UpgradeSequenceReferenceInExpr(
expr *string,
usedSequenceIDsToNames map[descpb.ID]*tree.TableName,
getBuiltinProperties func(name string) (*tree.FunctionProperties, []tree.Overload),
expr *string, usedSequenceIDsToNames map[descpb.ID]*tree.TableName,
) (hasUpgraded bool, err error) {
// Find the "reverse" mapping from sequence name to their IDs for those
// sequences referenced by-name in `expr`.
usedSequenceNamesToIDs, err := seqNameToIDMappingInExpr(*expr, usedSequenceIDsToNames, getBuiltinProperties)
usedSequenceNamesToIDs, err := seqNameToIDMappingInExpr(*expr, usedSequenceIDsToNames)
if err != nil {
return false, err
}
Expand All @@ -243,7 +233,7 @@ func UpgradeSequenceReferenceInExpr(
return false, err
}

newExpr, err := ReplaceSequenceNamesWithIDs(parsedExpr, usedSequenceNamesToIDs, getBuiltinProperties)
newExpr, err := ReplaceSequenceNamesWithIDs(parsedExpr, usedSequenceNamesToIDs)
if err != nil {
return false, err
}
Expand Down Expand Up @@ -271,15 +261,13 @@ func UpgradeSequenceReferenceInExpr(
//
// See its unit test for some examples.
func seqNameToIDMappingInExpr(
expr string,
seqIDToNameMapping map[descpb.ID]*tree.TableName,
getBuiltinProperties func(name string) (*tree.FunctionProperties, []tree.Overload),
expr string, seqIDToNameMapping map[descpb.ID]*tree.TableName,
) (map[string]descpb.ID, error) {
parsedExpr, err := parser.ParseExpr(expr)
if err != nil {
return nil, err
}
seqRefs, err := GetUsedSequences(parsedExpr, getBuiltinProperties)
seqRefs, err := GetUsedSequences(parsedExpr)
if err != nil {
return nil, err
}
Expand Down
23 changes: 11 additions & 12 deletions pkg/sql/catalog/seqexpr/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/catalog/seqexpr"
"github.com/cockroachdb/cockroach/pkg/sql/parser"
_ "github.com/cockroachdb/cockroach/pkg/sql/sem/builtins" // register all builtins in builtins:init() for seqexpr package
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -53,7 +52,7 @@ func TestGetSequenceFromFunc(t *testing.T) {
if !ok {
t.Fatal("Expr is not a FuncExpr")
}
identifier, err := seqexpr.GetSequenceFromFunc(funcExpr, builtinsregistry.GetBuiltinProperties)
identifier, err := seqexpr.GetSequenceFromFunc(funcExpr)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -99,7 +98,7 @@ func TestGetUsedSequences(t *testing.T) {
if err != nil {
t.Fatal(err)
}
identifiers, err := seqexpr.GetUsedSequences(typedExpr, builtinsregistry.GetBuiltinProperties)
identifiers, err := seqexpr.GetUsedSequences(typedExpr)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -150,7 +149,7 @@ func TestReplaceSequenceNamesWithIDs(t *testing.T) {
if err != nil {
t.Fatal(err)
}
newExpr, err := seqexpr.ReplaceSequenceNamesWithIDs(typedExpr, namesToID, builtinsregistry.GetBuiltinProperties)
newExpr, err := seqexpr.ReplaceSequenceNamesWithIDs(typedExpr, namesToID)
if err != nil {
t.Fatal(err)
}
Expand All @@ -169,7 +168,7 @@ func TestUpgradeSequenceReferenceInExpr(t *testing.T) {
usedSequenceIDsToNames[1] = &tbl1
usedSequenceIDsToNames[2] = &tbl2
expr := "nextval('testdb.sc1.t') + nextval('sc1.t')"
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames, builtinsregistry.GetBuiltinProperties)
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames)
require.NoError(t, err)
require.True(t, hasUpgraded)
require.Equal(t,
Expand All @@ -184,7 +183,7 @@ func TestUpgradeSequenceReferenceInExpr(t *testing.T) {
usedSequenceIDsToNames[1] = &tbl1
usedSequenceIDsToNames[2] = &tbl2
expr := "nextval('testdb.sc1.t') + nextval('sc1.t')"
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames, builtinsregistry.GetBuiltinProperties)
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames)
require.NoError(t, err)
require.True(t, hasUpgraded)
require.Equal(t,
Expand All @@ -200,7 +199,7 @@ func TestUpgradeSequenceReferenceInExpr(t *testing.T) {
usedSequenceIDsToNames[1] = &tbl1
usedSequenceIDsToNames[2] = &tbl2
expr := "nextval('testdb.public.t') + nextval('testdb.t')"
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames, builtinsregistry.GetBuiltinProperties)
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames)
require.NoError(t, err)
require.True(t, hasUpgraded)
require.Equal(t,
Expand All @@ -215,7 +214,7 @@ func TestUpgradeSequenceReferenceInExpr(t *testing.T) {
usedSequenceIDsToNames[1] = &tbl1
usedSequenceIDsToNames[2] = &tbl2
expr := "nextval('t')"
_, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames, builtinsregistry.GetBuiltinProperties)
_, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames)
require.Error(t, err, "ambiguous name matching for 't'; both 'sc1.t' and 'sc2.t' match it.")
require.Equal(t, "more than 1 matches found for \"t\"", err.Error())
})
Expand All @@ -227,7 +226,7 @@ func TestUpgradeSequenceReferenceInExpr(t *testing.T) {
usedSequenceIDsToNames[1] = &tbl1
usedSequenceIDsToNames[2] = &tbl2
expr := "nextval('t2')"
_, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames, builtinsregistry.GetBuiltinProperties)
_, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames)
require.Error(t, err, "no matching name for 't2'; neither 'sc1.t' nor 'sc2.t' match it.")
require.Equal(t, "no table name found to match input \"t2\"", err.Error())
})
Expand All @@ -241,7 +240,7 @@ func TestUpgradeSequenceReferenceInExpr(t *testing.T) {
usedSequenceIDsToNames[2] = &tbl2
usedSequenceIDsToNames[3] = &tbl3
expr := "((nextval(1::REGCLASS) + nextval(2::REGCLASS)) + currval(3::REGCLASS)) + nextval(3::REGCLASS)"
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames, builtinsregistry.GetBuiltinProperties)
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames)
require.NoError(t, err)
require.False(t, hasUpgraded)
require.Equal(t,
Expand All @@ -258,7 +257,7 @@ func TestUpgradeSequenceReferenceInExpr(t *testing.T) {
usedSequenceIDsToNames[2] = &tbl2
usedSequenceIDsToNames[3] = &tbl3
expr := "nextval('testdb.public.s1') + nextval('testdb.public.s2') + currval('testdb.sc1.s3') + nextval('testdb.sc1.s3')"
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames, builtinsregistry.GetBuiltinProperties)
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames)
require.NoError(t, err)
require.True(t, hasUpgraded)
require.Equal(t,
Expand All @@ -275,7 +274,7 @@ func TestUpgradeSequenceReferenceInExpr(t *testing.T) {
usedSequenceIDsToNames[2] = &tbl2
usedSequenceIDsToNames[3] = &tbl3
expr := "nextval('testdb.public.s1') + nextval(2::REGCLASS) + currval('testdb.sc1.s3') + nextval('testdb.sc1.s3')"
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames, builtinsregistry.GetBuiltinProperties)
hasUpgraded, err := seqexpr.UpgradeSequenceReferenceInExpr(&expr, usedSequenceIDsToNames)
require.NoError(t, err)
require.True(t, hasUpgraded)
require.Equal(t,
Expand Down
1 change: 0 additions & 1 deletion pkg/sql/catalog/tabledesc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ go_library(
"//pkg/sql/privilege",
"//pkg/sql/rowenc",
"//pkg/sql/schemachanger/scpb",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/catconstants",
"//pkg/sql/sem/catid",
"//pkg/sql/sem/eval",
Expand Down
7 changes: 3 additions & 4 deletions pkg/sql/catalog/tabledesc/table_desc_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/catalog/seqexpr"
"github.com/cockroachdb/cockroach/pkg/sql/parser"
"github.com/cockroachdb/cockroach/pkg/sql/privilege"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
Expand Down Expand Up @@ -843,7 +842,7 @@ func maybeUpgradeSequenceReferenceForTable(

// Upgrade sequence reference in DEFAULT expression, if any.
if col.HasDefault() {
hasUpgradedInDefault, err := seqexpr.UpgradeSequenceReferenceInExpr(col.DefaultExpr, usedSequenceIDToNames, builtinsregistry.GetBuiltinProperties)
hasUpgradedInDefault, err := seqexpr.UpgradeSequenceReferenceInExpr(col.DefaultExpr, usedSequenceIDToNames)
if err != nil {
return hasUpgraded, err
}
Expand All @@ -852,7 +851,7 @@ func maybeUpgradeSequenceReferenceForTable(

// Upgrade sequence reference in ON UPDATE expression, if any.
if col.HasOnUpdate() {
hasUpgradedInOnUpdate, err := seqexpr.UpgradeSequenceReferenceInExpr(col.OnUpdateExpr, usedSequenceIDToNames, builtinsregistry.GetBuiltinProperties)
hasUpgradedInOnUpdate, err := seqexpr.UpgradeSequenceReferenceInExpr(col.OnUpdateExpr, usedSequenceIDToNames)
if err != nil {
return hasUpgraded, err
}
Expand Down Expand Up @@ -882,7 +881,7 @@ func maybeUpgradeSequenceReferenceForView(
// by-ID reference. It, of course, also append replaced sequence IDs to `upgradedSeqIDs`.
replaceSeqFunc := func(expr tree.Expr) (recurse bool, newExpr tree.Expr, err error) {
newExprStr := expr.String()
hasUpgradedInExpr, err := seqexpr.UpgradeSequenceReferenceInExpr(&newExprStr, usedSequenceIDToNames, builtinsregistry.GetBuiltinProperties)
hasUpgradedInExpr, err := seqexpr.UpgradeSequenceReferenceInExpr(&newExprStr, usedSequenceIDToNames)
if err != nil {
return false, expr, err
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/sql/create_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgnotice"
"github.com/cockroachdb/cockroach/pkg/sql/privilege"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sqlerrors"
Expand Down Expand Up @@ -436,7 +435,7 @@ func replaceSeqNamesWithIDs(
ctx context.Context, sc resolver.SchemaResolver, queryStr string, multiStmt bool,
) (string, error) {
replaceSeqFunc := func(expr tree.Expr) (recurse bool, newExpr tree.Expr, err error) {
seqIdentifiers, err := seqexpr.GetUsedSequences(expr, builtinsregistry.GetBuiltinProperties)
seqIdentifiers, err := seqexpr.GetUsedSequences(expr)
if err != nil {
return false, expr, err
}
Expand All @@ -448,7 +447,7 @@ func replaceSeqNamesWithIDs(
}
seqNameToID[seqIdentifier.SeqName] = seqDesc.ID
}
newExpr, err = seqexpr.ReplaceSequenceNamesWithIDs(expr, seqNameToID, builtinsregistry.GetBuiltinProperties)
newExpr, err = seqexpr.ReplaceSequenceNamesWithIDs(expr, seqNameToID)
if err != nil {
return false, expr, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/sql/opt/optbuilder/scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/privilege"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree/treebin"
Expand Down Expand Up @@ -567,7 +566,7 @@ func (b *Builder) buildFunction(

// Add a dependency on sequences that are used as a string argument.
if b.trackSchemaDeps {
seqIdentifier, err := seqexpr.GetSequenceFromFunc(f, builtinsregistry.GetBuiltinProperties)
seqIdentifier, err := seqexpr.GetSequenceFromFunc(f)
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/sql/rename_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/privilege"
"github.com/cockroachdb/cockroach/pkg/sql/roleoption"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sqlerrors"
"github.com/cockroachdb/cockroach/pkg/util"
Expand Down Expand Up @@ -298,7 +297,7 @@ func isAllowedDependentDescInRenameDatabase(
if err != nil {
return false, "", err
}
seqIdentifiers, err := seqexpr.GetUsedSequences(typedExpr, builtinsregistry.GetBuiltinProperties)
seqIdentifiers, err := seqexpr.GetUsedSequences(typedExpr)
if err != nil {
return false, "", err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/sql/row/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ go_library(
"//pkg/sql/rowinfra",
"//pkg/sql/scrub",
"//pkg/sql/sem/builtins/builtinconstants",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/eval",
"//pkg/sql/sem/transform",
"//pkg/sql/sem/tree",
Expand Down
3 changes: 1 addition & 2 deletions pkg/sql/row/expr_walker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinconstants"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sem/volatility"
Expand Down Expand Up @@ -629,7 +628,7 @@ var supportedImportFuncOverrides = map[string]*customFunc{
visitorSideEffect: func(annot *tree.Annotations, fn *tree.FuncExpr) error {
// Get sequence name so that we can update the annotation with the number
// of nextval calls to this sequence in a row.
seqIdentifier, err := seqexpr.GetSequenceFromFunc(fn, builtinsregistry.GetBuiltinProperties)
seqIdentifier, err := seqexpr.GetSequenceFromFunc(fn)
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/sql/schemachanger/scbuild/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ go_library(
"//pkg/sql/schemachanger/scerrors",
"//pkg/sql/schemachanger/scpb",
"//pkg/sql/schemachanger/screl",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/catconstants",
"//pkg/sql/sem/catid",
"//pkg/sql/sem/eval",
Expand Down
5 changes: 2 additions & 3 deletions pkg/sql/schemachanger/scbuild/builder_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scerrors"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
"github.com/cockroachdb/cockroach/pkg/sql/sem/catid"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
Expand Down Expand Up @@ -412,7 +411,7 @@ func (b *builderState) WrapExpression(parentID catid.DescID, expr tree.Expr) *sc
// Collect sequence IDs.
var seqIDs catalog.DescriptorIDSet
{
seqIdentifiers, err := seqexpr.GetUsedSequences(expr, builtinsregistry.GetBuiltinProperties)
seqIdentifiers, err := seqexpr.GetUsedSequences(expr)
if err != nil {
panic(err)
}
Expand All @@ -435,7 +434,7 @@ func (b *builderState) WrapExpression(parentID catid.DescID, expr tree.Expr) *sc
seqIDs.Add(seq.SequenceID)
}
if len(seqNameToID) > 0 {
expr, err = seqexpr.ReplaceSequenceNamesWithIDs(expr, seqNameToID, builtinsregistry.GetBuiltinProperties)
expr, err = seqexpr.ReplaceSequenceNamesWithIDs(expr, seqNameToID)
if err != nil {
panic(err)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/sql/schemachanger/scdecomp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ go_library(
"//pkg/sql/parser",
"//pkg/sql/schemachanger/scerrors",
"//pkg/sql/schemachanger/scpb",
"//pkg/sql/sem/builtins/builtinsregistry",
"//pkg/sql/sem/catconstants",
"//pkg/sql/sem/catid",
"//pkg/sql/sem/tree",
Expand Down
3 changes: 1 addition & 2 deletions pkg/sql/schemachanger/scdecomp/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/parser"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scerrors"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb"
"github.com/cockroachdb/cockroach/pkg/sql/sem/builtins/builtinsregistry"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/lib/pq/oid"
Expand Down Expand Up @@ -68,7 +67,7 @@ func (w *walkCtx) newExpression(expr string) (*scpb.Expression, error) {
}
var seqIDs catalog.DescriptorIDSet
{
seqIdents, err := seqexpr.GetUsedSequences(e, builtinsregistry.GetBuiltinProperties)
seqIdents, err := seqexpr.GetUsedSequences(e)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 5409013

Please sign in to comment.