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: alter_role.go
    path of file: ./repos/cockroach/pkg/sql
    
    the code of the file until where you have to start completion: // Copyright 2017 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

import (
	"context"
	"fmt"
	"strings"

	"github.com/cockroachdb/cockroach/pkg/security/username"
	"github.com/cockroachdb/cockroach/pkg/settings"
	"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
	"github.com/cockroachdb/cockroach/pkg/sql/decodeusername"
	"github.com/cockroachdb/cockroach/pkg/sql/paramparse"
	"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
	"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
	"
    
func (p *planner) AlterRoleSet(ctx context.Context, n *tree.AlterRoleSet) (planNode, error) {
	// Note that for Postgres, only superuser can ALTER another superuser.
	// CockroachDB does not support the superuser role option right now.
	// However we make it so members of the ADMIN role can only be edited
	// by other ADMINs (done in startExec).
	// Also note that we diverge from Postgres by prohibiting users from
	// modifying their own defaults unless they have CREATEROLE. This is analogous
	// to our restriction that prevents a user from modifying their own password.
	if n.AllRoles {
		if hasAdmin, err := p.HasAdminRole(ctx); err != nil {
			return nil, err
		} else if !hasAdmin {
			return nil, pgerror.Newf(pgcode.InsufficientPrivilege,
				"only users with the admin role are allowed to ALTER ROLE ALL ... SET")
		}
	} else {
		canAlterRoleSet, err := p.HasGlobalPrivilegeOrRoleOption(ctx, privilege.CREATEROLE)
		if err != nil {
			return nil, err
		}
		if !canAlterRoleSet {
			canAlterRoleSet, err = p.HasGlobalPrivilegeOrRoleOption(ctx, privilege.MODIFYCLUSTERSETTING)
			if err != nil {
				return nil, err
			}
		}
		if !canAlterRoleSet {
			canAlterRoleSet, err = p.HasGlobalPrivilegeOrRoleOption(ctx, privilege.MODIFYSQLCLUSTERSETTING)
			if err != nil {
				return nil, err
			}
		}
		if !canAlterRoleSet {
			return nil, pgerror.Newf(pgcode.InsufficientPrivilege, "ALTER ROLE ... SET requires %s, %s or %s", privilege.MODIFYCLUSTERSETTING, privilege.MODIFYSQLCLUSTERSETTING, roleoption.CREATEROLE)
		}
	}

	var roleName username.SQLUsername
	if !n.AllRoles {
		var err error
		roleName, err = decodeusername.FromRoleSpec(
			p.SessionData(), username.PurposeValidation, n.RoleName,
		)
		if err != nil {
			return nil, err
		}
	}

	dbDescID := descpb.ID(0)
	if n.DatabaseName != "" {
		dbDesc, err := p.Descriptors().ByNameWithLeased(p.txn).Get().Database(ctx, string(n.DatabaseName))
		if err != nil {
			return nil, err
		}
		dbDescID = dbDesc.GetID()
	}

	setVarKind, varName, sVar, typedValues, err := p.processSetOrResetClause(ctx, n.SetOrReset)
	if err != nil {
		return nil, err
	}

	return &alterRoleSetNode{
		roleName:    roleName,
		ifExists:    n.IfExists,
		isRole:      n.IsRole,
		allRoles:    n.AllRoles,
		dbDescID:    dbDescID,
		setVarKind:  setVarKind,
		varName:     varName,
		sVar:        sVar,
		typedValues: typedValues,
	}, nil
}