Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
daviszhen committed Dec 11, 2024
1 parent 5d82985 commit 874bc41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/frontend/authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3615,7 +3615,7 @@ func doDropAccount(ctx context.Context, bh BackgroundExec, ses *Session, da *dro

dropAccountFunc := func() (rtnErr error) {
ses.Infof(ctx, "dropAccount %s sql: %s", da.Name, getAccountIdNamesSql)
_, nameInfoMap, rtnErr := getAccounts(ctx, bh, true)
_, nameInfoMap, rtnErr := getAccounts(ctx, bh, da.Name, true)
if rtnErr != nil {
return rtnErr
}
Expand Down Expand Up @@ -7675,7 +7675,7 @@ func createTablesInInformationSchemaOfGeneralTenant(ctx context.Context, bh Back
// createSubscription insert records into mo_subs of To-All-Publications
func createSubscription(ctx context.Context, bh BackgroundExec, newTenant *TenantInfo) (err error) {
// get all accounts
accIdInfoMap, accNameInfoMap, err := getAccounts(ctx, bh, false)
accIdInfoMap, accNameInfoMap, err := getAccounts(ctx, bh, "", false)
if err != nil {
return
}
Expand Down
14 changes: 9 additions & 5 deletions pkg/frontend/publication_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func createPublication(ctx context.Context, bh BackgroundExec, cp *tree.CreatePu
accountNamesStr string
)

accIdInfoMap, accNameInfoMap, err := getAccounts(ctx, bh, false)
accIdInfoMap, accNameInfoMap, err := getAccounts(ctx, bh, "", false)
if err != nil {
return
}
Expand Down Expand Up @@ -342,7 +342,7 @@ func doAlterPublication(ctx context.Context, ses *Session, ap *tree.AlterPublica
err = finishTxn(ctx, bh, err)
}()

accIdInfoMap, accNameInfoMap, err := getAccounts(ctx, bh, false)
accIdInfoMap, accNameInfoMap, err := getAccounts(ctx, bh, "", false)
if err != nil {
return
}
Expand Down Expand Up @@ -554,7 +554,7 @@ func doDropPublication(ctx context.Context, ses *Session, dp *tree.DropPublicati
func dropPublication(ctx context.Context, bh BackgroundExec, ifExists bool, pubName string) (err error) {
var sql string

accIdInfoMap, _, err := getAccounts(ctx, bh, false)
accIdInfoMap, _, err := getAccounts(ctx, bh, "", false)
if err != nil {
return
}
Expand Down Expand Up @@ -625,9 +625,13 @@ func dropPublication(ctx context.Context, bh BackgroundExec, ifExists bool, pubN
return
}

func getAccounts(ctx context.Context, bh BackgroundExec, forUpdate bool) (idInfoMap map[int32]*pubsub.AccountInfo, nameInfoMap map[string]*pubsub.AccountInfo, err error) {
func getAccounts(ctx context.Context, bh BackgroundExec, accName string, forUpdate bool) (idInfoMap map[int32]*pubsub.AccountInfo, nameInfoMap map[string]*pubsub.AccountInfo, err error) {
ctx = defines.AttachAccountId(ctx, catalog.System_Account)
sql := getAccountIdNamesSql
if len(accName) != 0 {
sql += fmt.Sprintf(` and account_name = "%s"`, accName)
}
sql += " order by account_id "
if forUpdate {
sql += " for update"
}
Expand Down Expand Up @@ -1040,7 +1044,7 @@ func doShowPublications(ctx context.Context, ses *Session, sp *tree.ShowPublicat
return
}

accIdInfoMap, _, err := getAccounts(ctx, bh, false)
accIdInfoMap, _, err := getAccounts(ctx, bh, "", false)
if err != nil {
return
}
Expand Down

0 comments on commit 874bc41

Please sign in to comment.