summaryrefslogtreecommitdiff
path: root/src/backend/commands/user.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2022-01-14 10:46:49 +0100
committerPeter Eisentraut <peter@eisentraut.org>2022-01-17 10:38:23 +0100
commit941460fcf731a32e6a90691508d5cfa3d1f8eeaf (patch)
tree2de0be4abcf7db131607ce9ba590a8040c16d6e3 /src/backend/commands/user.c
parentca86a63d207aca1f52ff13a1ce13854681d1bbf9 (diff)
Add Boolean node
Before, SQL-level boolean constants were represented by a string with a cast, and internal Boolean values in DDL commands were usually represented by Integer nodes. This takes the place of both of these uses, making the intent clearer and having some amount of type safety. Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/8c1a2e37-c68d-703c-5a83-7a6077f4f997@enterprisedb.com
Diffstat (limited to 'src/backend/commands/user.c')
-rw-r--r--src/backend/commands/user.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 5f6e94949b1..f9d3c1246bb 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -217,17 +217,17 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
if (dpassword && dpassword->arg)
password = strVal(dpassword->arg);
if (dissuper)
- issuper = intVal(dissuper->arg) != 0;
+ issuper = boolVal(dissuper->arg);
if (dinherit)
- inherit = intVal(dinherit->arg) != 0;
+ inherit = boolVal(dinherit->arg);
if (dcreaterole)
- createrole = intVal(dcreaterole->arg) != 0;
+ createrole = boolVal(dcreaterole->arg);
if (dcreatedb)
- createdb = intVal(dcreatedb->arg) != 0;
+ createdb = boolVal(dcreatedb->arg);
if (dcanlogin)
- canlogin = intVal(dcanlogin->arg) != 0;
+ canlogin = boolVal(dcanlogin->arg);
if (disreplication)
- isreplication = intVal(disreplication->arg) != 0;
+ isreplication = boolVal(disreplication->arg);
if (dconnlimit)
{
connlimit = intVal(dconnlimit->arg);
@@ -245,7 +245,7 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
if (dvalidUntil)
validUntil = strVal(dvalidUntil->arg);
if (dbypassRLS)
- bypassrls = intVal(dbypassRLS->arg) != 0;
+ bypassrls = boolVal(dbypassRLS->arg);
/* Check some permissions first */
if (issuper)
@@ -700,37 +700,37 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
*/
if (dissuper)
{
- new_record[Anum_pg_authid_rolsuper - 1] = BoolGetDatum(intVal(dissuper->arg));
+ new_record[Anum_pg_authid_rolsuper - 1] = BoolGetDatum(boolVal(dissuper->arg));
new_record_repl[Anum_pg_authid_rolsuper - 1] = true;
}
if (dinherit)
{
- new_record[Anum_pg_authid_rolinherit - 1] = BoolGetDatum(intVal(dinherit->arg));
+ new_record[Anum_pg_authid_rolinherit - 1] = BoolGetDatum(boolVal(dinherit->arg));
new_record_repl[Anum_pg_authid_rolinherit - 1] = true;
}
if (dcreaterole)
{
- new_record[Anum_pg_authid_rolcreaterole - 1] = BoolGetDatum(intVal(dcreaterole->arg));
+ new_record[Anum_pg_authid_rolcreaterole - 1] = BoolGetDatum(boolVal(dcreaterole->arg));
new_record_repl[Anum_pg_authid_rolcreaterole - 1] = true;
}
if (dcreatedb)
{
- new_record[Anum_pg_authid_rolcreatedb - 1] = BoolGetDatum(intVal(dcreatedb->arg));
+ new_record[Anum_pg_authid_rolcreatedb - 1] = BoolGetDatum(boolVal(dcreatedb->arg));
new_record_repl[Anum_pg_authid_rolcreatedb - 1] = true;
}
if (dcanlogin)
{
- new_record[Anum_pg_authid_rolcanlogin - 1] = BoolGetDatum(intVal(dcanlogin->arg));
+ new_record[Anum_pg_authid_rolcanlogin - 1] = BoolGetDatum(boolVal(dcanlogin->arg));
new_record_repl[Anum_pg_authid_rolcanlogin - 1] = true;
}
if (disreplication)
{
- new_record[Anum_pg_authid_rolreplication - 1] = BoolGetDatum(intVal(disreplication->arg));
+ new_record[Anum_pg_authid_rolreplication - 1] = BoolGetDatum(boolVal(disreplication->arg));
new_record_repl[Anum_pg_authid_rolreplication - 1] = true;
}
@@ -779,7 +779,7 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
if (dbypassRLS)
{
- new_record[Anum_pg_authid_rolbypassrls - 1] = BoolGetDatum(intVal(dbypassRLS->arg));
+ new_record[Anum_pg_authid_rolbypassrls - 1] = BoolGetDatum(boolVal(dbypassRLS->arg));
new_record_repl[Anum_pg_authid_rolbypassrls - 1] = true;
}