Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit 1757b11

Browse files
Robert Tomczakrobertomczak
authored andcommitted
Add missing defer rows.Close()
1 parent d19ecc1 commit 1757b11

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

redshift/resource_redshift_grant.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ func readSchemaGrants(db *DBConnection, d *schema.ResourceData) error {
292292
}
293293

294294
func readTableGrants(db *DBConnection, d *schema.ResourceData) error {
295+
log.Printf("[DEBUG] Reading table grants")
295296
var entityName, query string
296297
_, isUser := d.GetOk(grantUserAttr)
297298

@@ -344,6 +345,7 @@ func readTableGrants(db *DBConnection, d *schema.ResourceData) error {
344345
if err != nil {
345346
return err
346347
}
348+
defer rows.Close()
347349

348350
for rows.Next() {
349351
var objName string
@@ -388,11 +390,14 @@ func readTableGrants(db *DBConnection, d *schema.ResourceData) error {
388390
break
389391
}
390392
}
393+
log.Printf("[DEBUG] Collected table grants")
391394

392395
return nil
393396
}
394397

395398
func readCallableGrants(db *DBConnection, d *schema.ResourceData) error {
399+
log.Printf("[DEBUG] Reading callable grants")
400+
396401
var entityName, query string
397402

398403
_, isUser := d.GetOk(grantUserAttr)
@@ -444,6 +449,7 @@ func readCallableGrants(db *DBConnection, d *schema.ResourceData) error {
444449
}
445450
return false
446451
}
452+
defer rows.Close()
447453

448454
privilegesSet := schema.NewSet(schema.HashString, nil)
449455
for rows.Next() {
@@ -465,11 +471,13 @@ func readCallableGrants(db *DBConnection, d *schema.ResourceData) error {
465471
if !privilegesSet.Equal(d.Get(grantPrivilegesAttr).(*schema.Set)) {
466472
d.Set(grantPrivilegesAttr, privilegesSet)
467473
}
474+
log.Printf("[DEBUG] Reading callable grants - Done")
468475

469476
return nil
470477
}
471478

472479
func readLanguageGrants(db *DBConnection, d *schema.ResourceData) error {
480+
log.Printf("[DEBUG] Reading language grants")
473481

474482
var entityName, query string
475483

@@ -503,6 +511,7 @@ func readLanguageGrants(db *DBConnection, d *schema.ResourceData) error {
503511
}
504512

505513
objects := d.Get(grantObjectsAttr).(*schema.Set)
514+
defer rows.Close()
506515

507516
for rows.Next() {
508517
var objName string
@@ -526,6 +535,7 @@ func readLanguageGrants(db *DBConnection, d *schema.ResourceData) error {
526535
break
527536
}
528537
}
538+
log.Printf("[DEBUG] Reading language grants - Done")
529539

530540
return nil
531541
}

0 commit comments

Comments
 (0)