aboutsummaryrefslogtreecommitdiff
path: root/src/bin/scripts/createuser.c
diff options
context:
space:
mode:
authorDaniel Gustafsson <dgustafsson@postgresql.org>2023-03-06 14:16:32 +0100
committerDaniel Gustafsson <dgustafsson@postgresql.org>2023-03-06 14:16:32 +0100
commitd3406d80360776bbcafa05d8b966806012f9594e (patch)
treedfd4dd751d869857ffc8309265699709751c4f3c /src/bin/scripts/createuser.c
parent4211fbd8413b26e0abedbe4338aa7cda2cd469b4 (diff)
downloadpostgresql-d3406d80360776bbcafa05d8b966806012f9594e.tar.gz
postgresql-d3406d80360776bbcafa05d8b966806012f9594e.zip
Fix handling of default option values in createuser
Add description of which one is the default between two complementary options of --bypassrls and --replication in the help text and docs. In correspondence let the command always include the tokens corresponding to every options of that kind in the SQL command sent to server. Tests are updated accordingly. Also fix the checks of some trivalue vars which were using literal zero for checking default value instead of the enum label TRI_DEFAULT. While not a bug, since TRI_DEFAULT is defined as zero, fixing improves read- ability improved readability (and avoid bugs if the enum is changed). Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Discussion: https://postgr.es/m/20220810.151243.1073197628358749087.horikyota.ntt@gmail.com
Diffstat (limited to 'src/bin/scripts/createuser.c')
-rw-r--r--src/bin/scripts/createuser.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c
index 3a1825e61fe..3f58759aa2c 100644
--- a/src/bin/scripts/createuser.c
+++ b/src/bin/scripts/createuser.c
@@ -239,7 +239,7 @@ main(int argc, char *argv[])
free(pw2);
}
- if (superuser == 0)
+ if (superuser == TRI_DEFAULT)
{
if (interactive && yesno_prompt("Shall the new role be a superuser?"))
superuser = TRI_YES;
@@ -254,7 +254,7 @@ main(int argc, char *argv[])
createrole = TRI_YES;
}
- if (createdb == 0)
+ if (createdb == TRI_DEFAULT)
{
if (interactive && yesno_prompt("Shall the new role be allowed to create databases?"))
createdb = TRI_YES;
@@ -262,7 +262,7 @@ main(int argc, char *argv[])
createdb = TRI_NO;
}
- if (createrole == 0)
+ if (createrole == TRI_DEFAULT)
{
if (interactive && yesno_prompt("Shall the new role be allowed to create more new roles?"))
createrole = TRI_YES;
@@ -270,10 +270,16 @@ main(int argc, char *argv[])
createrole = TRI_NO;
}
- if (inherit == 0)
+ if (bypassrls == TRI_DEFAULT)
+ bypassrls = TRI_NO;
+
+ if (replication == TRI_DEFAULT)
+ replication = TRI_NO;
+
+ if (inherit == TRI_DEFAULT)
inherit = TRI_YES;
- if (login == 0)
+ if (login == TRI_DEFAULT)
login = TRI_YES;
cparams.dbname = NULL; /* this program lacks any dbname option... */
@@ -432,9 +438,10 @@ help(const char *progname)
printf(_(" --interactive prompt for missing role name and attributes rather\n"
" than using defaults\n"));
printf(_(" --bypassrls role can bypass row-level security (RLS) policy\n"));
- printf(_(" --no-bypassrls role cannot bypass row-level security (RLS) policy\n"));
+ printf(_(" --no-bypassrls role cannot bypass row-level security (RLS) policy\n"
+ " (default)\n"));
printf(_(" --replication role can initiate replication\n"));
- printf(_(" --no-replication role cannot initiate replication\n"));
+ printf(_(" --no-replication role cannot initiate replication (default)\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\nConnection options:\n"));
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));