Skip to content

Commit

Permalink
Merge branch 'cyrilgdn:main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
librucha authored Oct 20, 2024
2 parents 6472ad1 + cdcab17 commit 35408d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions postgresql/resource_postgresql_user_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ func resourcePostgreSQLUserMappingReadImpl(db *DBConnection, d *schema.ResourceD
var userMappingOptions []string
query := "SELECT umoptions FROM information_schema._pg_user_mappings WHERE authorization_identifier = $1 and foreign_server_name = $2"
err = txn.QueryRow(query, username, serverName).Scan(pq.Array(&userMappingOptions))

if err != sql.ErrNoRows && err != nil {
// Fallback to pg_user_mappings table if information_schema._pg_user_mappings is not available
query := "SELECT umoptions FROM pg_user_mappings WHERE usename = $1 and srvname = $2"
err = txn.QueryRow(query, username, serverName).Scan(pq.Array(&userMappingOptions))
}

switch {
case err == sql.ErrNoRows:
log.Printf("[WARN] PostgreSQL user mapping (%s) for server (%s) not found", username, serverName)
Expand Down

0 comments on commit 35408d2

Please sign in to comment.