From 592f723246e7bdf4453cdd3d1701f6d1f922bd04 Mon Sep 17 00:00:00 2001 From: Michael Turner Date: Sat, 9 Sep 2023 10:08:11 -0400 Subject: [PATCH] Use uint32 for OID to stop conversion errors with pguint32 (#324) Co-authored-by: michaelt Co-authored-by: Cyril Gaudin --- postgresql/helpers.go | 4 ++-- postgresql/resource_postgresql_grant.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/postgresql/helpers.go b/postgresql/helpers.go index a11103d2..e2281398 100644 --- a/postgresql/helpers.go +++ b/postgresql/helpers.go @@ -491,12 +491,12 @@ func isSuperuser(db QueryAble, role string) (bool, error) { const publicRole = "public" -func getRoleOID(db QueryAble, role string) (int, error) { +func getRoleOID(db QueryAble, role string) (uint32, error) { if role == publicRole { return 0, nil } - var oid int + var oid uint32 if err := db.QueryRow("SELECT oid FROM pg_roles WHERE rolname = $1", role).Scan(&oid); err != nil { return 0, fmt.Errorf("could not find oid for role %s: %w", role, err) } diff --git a/postgresql/resource_postgresql_grant.go b/postgresql/resource_postgresql_grant.go index e6cc5315..8e0b315f 100644 --- a/postgresql/resource_postgresql_grant.go +++ b/postgresql/resource_postgresql_grant.go @@ -255,7 +255,7 @@ func resourcePostgreSQLGrantDelete(db *DBConnection, d *schema.ResourceData) err return nil } -func readDatabaseRolePriviges(txn *sql.Tx, d *schema.ResourceData, roleOID int) error { +func readDatabaseRolePriviges(txn *sql.Tx, d *schema.ResourceData, roleOID uint32) error { dbName := d.Get("database").(string) query := ` SELECT array_agg(privilege_type) @@ -274,7 +274,7 @@ WHERE grantee = $2 return nil } -func readSchemaRolePriviges(txn *sql.Tx, d *schema.ResourceData, roleOID int) error { +func readSchemaRolePriviges(txn *sql.Tx, d *schema.ResourceData, roleOID uint32) error { dbName := d.Get("schema").(string) query := ` SELECT array_agg(privilege_type) @@ -293,7 +293,7 @@ WHERE grantee = $2 return nil } -func readForeignDataWrapperRolePrivileges(txn *sql.Tx, d *schema.ResourceData, roleOID int) error { +func readForeignDataWrapperRolePrivileges(txn *sql.Tx, d *schema.ResourceData, roleOID uint32) error { objects := d.Get("objects").(*schema.Set).List() fdwName := objects[0].(string) query := ` @@ -313,7 +313,7 @@ WHERE grantee = $2 return nil } -func readForeignServerRolePrivileges(txn *sql.Tx, d *schema.ResourceData, roleOID int) error { +func readForeignServerRolePrivileges(txn *sql.Tx, d *schema.ResourceData, roleOID uint32) error { objects := d.Get("objects").(*schema.Set).List() srvName := objects[0].(string) query := `