Skip to content

Commit

Permalink
Merge #139193
Browse files Browse the repository at this point in the history
139193: sql: minor fixup of a recent change r=yuzefovich a=yuzefovich

This commit addresses comments identified during the review of a backport of 3fb9f91.

Epic: None
Release note: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
craig[bot] and yuzefovich committed Jan 16, 2025
2 parents cd0ea66 + 948f207 commit 470e512
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions pkg/sql/explain_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,12 @@ func (b *stmtBundleBuilder) addEnv(ctx context.Context) {
}
if mem.Metadata().HasUserDefinedRoutines() {
// Get all relevant user-defined routines.
//
// Note that we first populate fast int set so that we add routines in
// increasing order of Oids to the bundle. This should allow for easier
// recreation when we have dependencies between routines since _usually_
// smaller Oid would indicate an older routine which makes it less
// likely to depend on another routine.
var ids intsets.Fast
isProcedure := make(map[oid.Oid]bool)
mem.Metadata().ForEachUserDefinedRoutine(func(ol *tree.Overload) {
Expand Down
12 changes: 6 additions & 6 deletions pkg/sql/explain_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,15 @@ CREATE TABLE users(id UUID DEFAULT gen_random_uuid() PRIMARY KEY, promo_id INT R
checkBundle(
t, fmt.Sprint(rows), "s.foo", func(name, contents string) error {
if name == "schema.sql" {
reg := regexp.MustCompile("s.foo")
reg := regexp.MustCompile(`s\.foo`)
if reg.FindString(contents) == "" {
return errors.Errorf("could not find definition for 's.foo' function in schema.sql")
}
reg = regexp.MustCompile("^foo")
reg = regexp.MustCompile(`^CREATE FUNCTION public\.foo`)
if reg.FindString(contents) != "" {
return errors.Errorf("found irrelevant function 'foo' in schema.sql")
}
reg = regexp.MustCompile("s.a")
reg = regexp.MustCompile(`s\.a`)
if reg.FindString(contents) == "" {
return errors.Errorf("could not find definition for relation 's.a' in schema.sql")
}
Expand All @@ -473,15 +473,15 @@ CREATE TABLE users(id UUID DEFAULT gen_random_uuid() PRIMARY KEY, promo_id INT R
checkBundle(
t, fmt.Sprint(rows), "s.bar", func(name, contents string) error {
if name == "schema.sql" {
reg := regexp.MustCompile("s.bar")
reg := regexp.MustCompile(`s\.bar`)
if reg.FindString(contents) == "" {
return errors.Errorf("could not find definition for 's.bar' procedure in schema.sql")
}
reg = regexp.MustCompile("^bar")
reg = regexp.MustCompile(`^CREATE PROCEDURE public\.bar`)
if reg.FindString(contents) != "" {
return errors.Errorf("Found irrelevant procedure 'bar' in schema.sql")
}
reg = regexp.MustCompile("s.a")
reg = regexp.MustCompile(`s\.a`)
if reg.FindString(contents) == "" {
return errors.Errorf("could not find definition for relation 's.a' in schema.sql")
}
Expand Down

0 comments on commit 470e512

Please sign in to comment.