Skip to content

Commit

Permalink
Move name of DB superuser to a macro
Browse files Browse the repository at this point in the history
To ensure the superuser role name ("dba") is used consistently, it is
now defined as the macro DB_SUPERUSER_ROLE.
  • Loading branch information
timopollmeier committed Apr 12, 2021
1 parent ce35ab2 commit d775241
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
*/
#define G_LOG_DOMAIN "md manage"

/**
* @brief Database superuser role
*/
#define DB_SUPERUSER_ROLE "dba"


/* Headers */
int
Expand Down Expand Up @@ -197,7 +202,7 @@ manage_create_sql_functions ()

/* Functions in C. */

sql ("SET role dba;");
sql ("SET ROLE \"%s\";", DB_SUPERUSER_ROLE);

sql ("CREATE OR REPLACE FUNCTION hosts_contains (text, text)"
" RETURNS boolean"
Expand Down Expand Up @@ -3076,7 +3081,7 @@ check_db_extensions ()
g_debug ("%s: All required extensions are available.", __func__);

// Switch to superuser role and try to install extensions.
sql ("SET ROLE dba;");
sql ("SET ROLE \"%s\";", DB_SUPERUSER_ROLE);

sql ("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"");
sql ("CREATE EXTENSION IF NOT EXISTS \"pgcrypto\"");
Expand Down

0 comments on commit d775241

Please sign in to comment.