@@ -1001,7 +1001,7 @@ type logicTest struct {
10011001 clients map [string ]map [int ]* gosql.DB
10021002 // client currently in use. This can change during processing
10031003 // of a test input file when encountering the "user" directive.
1004- // see setUser () for details.
1004+ // see setSessionUser () for details.
10051005 user string
10061006 db * gosql.DB
10071007 // clusterCleanupFuncs contains the cleanup methods that are specific to a
@@ -1169,9 +1169,9 @@ func (t *logicTest) outf(format string, args ...interface{}) {
11691169 fmt .Printf ("[%s] %s\n " , now , msg )
11701170}
11711171
1172- // setUser sets the DB client to the specified user and connects
1172+ // setSessionUser sets the DB client to the specified user and connects
11731173// to the node in the cluster at index nodeIdx.
1174- func (t * logicTest ) setUser (user string , nodeIdx int ) {
1174+ func (t * logicTest ) setSessionUser (user string , nodeIdx int ) {
11751175 db := t .getOrOpenClient (user , nodeIdx )
11761176 t .db = db
11771177 t .user = user
@@ -1309,7 +1309,7 @@ func (t *logicTest) newTestServerCluster(bootstrapBinaryPath, upgradeBinaryPath
13091309 t .testserverCluster = ts
13101310 t .clusterCleanupFuncs = append (t .clusterCleanupFuncs , ts .Stop , cleanupLogsDir )
13111311
1312- t .setUser (username .RootUser , 0 /* nodeIdx */ )
1312+ t .setSessionUser (username .RootUser , 0 /* nodeIdx */ )
13131313}
13141314
13151315// newCluster creates a new cluster. It should be called after the logic tests's
@@ -1753,7 +1753,7 @@ func (t *logicTest) newCluster(
17531753 )
17541754 }
17551755
1756- t .setUser (username .RootUser , 0 /* nodeIdx */ )
1756+ t .setSessionUser (username .RootUser , 0 /* nodeIdx */ )
17571757}
17581758
17591759// waitForTenantReadOnlyClusterSettingToTakeEffectOrFatal waits until all tenant
@@ -2245,7 +2245,7 @@ func (t *logicTest) maybeBackupRestore(
22452245 oldUser := t .user
22462246 oldNodeIdx := t .nodeIdx
22472247 defer func () {
2248- t .setUser (oldUser , oldNodeIdx )
2248+ t .setSessionUser (oldUser , oldNodeIdx )
22492249 }()
22502250
22512251 log .Info (context .Background (), "Running cluster backup and restore" )
@@ -2265,7 +2265,7 @@ func (t *logicTest) maybeBackupRestore(
22652265 userToSessionVars [user ] = make (map [int ]map [string ]string )
22662266 for nodeIdx := range userClients {
22672267 users [user ] = append (users [user ], nodeIdx )
2268- t .setUser (user , nodeIdx )
2268+ t .setSessionUser (user , nodeIdx )
22692269
22702270 // Serialize session variables.
22712271 var userSession string
@@ -2307,7 +2307,7 @@ func (t *logicTest) maybeBackupRestore(
23072307 bucket , strconv .FormatInt (timeutil .Now ().UnixNano (), 10 ))
23082308
23092309 // Perform the backup and restore as root.
2310- t .setUser (username .RootUser , 0 /* nodeIdx */ )
2310+ t .setSessionUser (username .RootUser , 0 /* nodeIdx */ )
23112311
23122312 if _ , err := t .db .Exec (fmt .Sprintf ("BACKUP INTO '%s'" , backupLocation )); err != nil {
23132313 return errors .Wrap (err , "backing up cluster" )
@@ -2318,7 +2318,7 @@ func (t *logicTest) maybeBackupRestore(
23182318 t .resetCluster ()
23192319
23202320 // Run the restore as root.
2321- t .setUser (username .RootUser , 0 /* nodeIdx */ )
2321+ t .setSessionUser (username .RootUser , 0 /* nodeIdx */ )
23222322 if _ , err := t .db .Exec (fmt .Sprintf ("RESTORE FROM LATEST IN '%s'" , backupLocation )); err != nil {
23232323 return errors .Wrap (err , "restoring cluster" )
23242324 }
@@ -2330,7 +2330,7 @@ func (t *logicTest) maybeBackupRestore(
23302330 for user , userNodeIdxs := range users {
23312331 for _ , nodeIdx := range userNodeIdxs {
23322332 // Call setUser for every user to create the connection for that user.
2333- t .setUser (user , nodeIdx )
2333+ t .setSessionUser (user , nodeIdx )
23342334
23352335 if userSession , ok := userToHexSession [user ][nodeIdx ]; ok {
23362336 if _ , err := t .db .Exec (fmt .Sprintf (`SELECT crdb_internal.deserialize_session(decode('%s', 'hex'))` , userSession )); err != nil {
@@ -2977,7 +2977,7 @@ func (t *logicTest) processSubtest(
29772977 nodeIdx = int (idx )
29782978 }
29792979 }
2980- t .setUser (fields [1 ], nodeIdx )
2980+ t .setSessionUser (fields [1 ], nodeIdx )
29812981 // In multi-tenant tests, we may need to also create database test when
29822982 // we switch to a different tenant.
29832983 //
@@ -3107,7 +3107,7 @@ func (t *logicTest) processSubtest(
31073107 // If we upgraded the node we are currently on, we need to open a new
31083108 // connection since the previous one might now be invalid.
31093109 if t .nodeIdx == nodeIdx {
3110- t .setUser (t .user , nodeIdx )
3110+ t .setSessionUser (t .user , nodeIdx )
31113111 }
31123112 default :
31133113 return errors .Errorf ("%s:%d: unknown command: %s" ,
@@ -3806,17 +3806,19 @@ func (t *logicTest) validateAfterTestCompletion() error {
38063806 }
38073807 delete (t .clients , user )
38083808 }
3809- t .setUser (username .RootUser , 0 /* nodeIdx */ )
3809+ t .setSessionUser (username .RootUser , 0 /* nodeIdx */ )
38103810
38113811 // Some cleanup to make sure the following validation queries can run
38123812 // successfully. First we rollback in case the logic test had an uncommitted
38133813 // txn and second we reset vectorize mode in case it was switched to
38143814 // `experimental_always`.
38153815 _ , _ = t .db .Exec ("ROLLBACK" )
3816- _ , err := t .db .Exec ("RESET vectorize" )
3817- if err != nil {
3816+ if _ , err := t .db .Exec ("RESET vectorize" ); err != nil {
38183817 t .Fatal (errors .Wrap (err , "could not reset vectorize mode" ))
38193818 }
3819+ if _ , err := t .db .Exec ("RESET ROLE" ); err != nil {
3820+ t .Fatal (errors .Wrap (err , "could not reset role" ))
3821+ }
38203822
38213823 validate := func () (string , error ) {
38223824 rows , err := t .db .Query (`SELECT * FROM "".crdb_internal.invalid_objects ORDER BY id` )
0 commit comments