Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/postgres/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ var RESERVED_SCHEMA_NAMES = map[string]bool{
"public": true, // This is here for documentation; Postgres will reject a role named `public` as reserved
"pgbouncer": true,
"monitor": true,

// A "postgres" schema precedes "public" in the default search_path and
// would capture objects the superuser creates for "public", such as the
// "pg_stat_statements" view used by pgMonitor.
"postgres": true,
}

func sanitizeAlterRoleOptions(options string) string {
Expand Down
7 changes: 6 additions & 1 deletion internal/postgres/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,15 @@ func TestWriteUsersSchemasInPostgreSQL(t *testing.T) {
Name: "public",
Databases: []string{"db3"},
},
{
Name: "postgres",
Databases: []string{"postgres"},
},
},
))
// The spec.users has four elements, but two will be skipped:
// The spec.users has five elements, but three will be skipped:
// * the user with the reserved name `public`
// * the user with the reserved name `postgres`
// * the user with 0 databases
assert.Equal(t, calls, 2)
})
Expand Down