Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix drop account #20726

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/frontend/authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3624,7 +3624,7 @@ func doDropAccount(ctx context.Context, ses *Session, da *dropAccount) (err erro
return rtnErr
}
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 @@ -7743,7 +7743,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
6 changes: 3 additions & 3 deletions pkg/frontend/authenticate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7126,7 +7126,7 @@ func Test_doDropAccount(t *testing.T) {
bh.sql2result["commit;"] = nil
bh.sql2result["rollback;"] = nil

sql := getAccountIdNamesSql + " for update"
sql := getAccountIdNamesSql + ` order by account_id for update`
mrs := newMrsForGetAllAccounts([][]interface{}{
{uint64(0), "sys", "open", uint64(1), nil},
{uint64(1), "acc", "open", uint64(1), nil},
Expand Down Expand Up @@ -7187,7 +7187,7 @@ func Test_doDropAccount(t *testing.T) {
bh.sql2result["commit;"] = nil
bh.sql2result["rollback;"] = nil

sql := getAccountIdNamesSql + " for update"
sql := getAccountIdNamesSql + ` order by account_id for update`
bh.sql2result[sql] = newMrsForGetAllAccounts([][]interface{}{})

sql, _ = getSqlForDeleteAccountFromMoAccount(context.TODO(), mustUnboxExprStr(stmt.Name))
Expand Down Expand Up @@ -7234,7 +7234,7 @@ func Test_doDropAccount(t *testing.T) {
bh.sql2result["commit;"] = nil
bh.sql2result["rollback;"] = nil

sql := getAccountIdNamesSql + " for update"
sql := getAccountIdNamesSql + ` order by account_id for update`
bh.sql2result[sql] = newMrsForGetAllAccounts([][]interface{}{})

sql, _ = getSqlForDeleteAccountFromMoAccount(context.TODO(), mustUnboxExprStr(stmt.Name))
Expand Down
11 changes: 6 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,10 @@ 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
sql += " order by account_id "
if forUpdate {
sql += " for update"
}
Expand Down Expand Up @@ -1040,7 +1041,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
Loading