mirror of https://github.com/citusdata/citus.git
Replace int nodes with bool nodes where needed
In PG15, Boolean nodes are added. Pre PG15, internal Boolean values in Create Role commands were represented by Integer nodes. This commit replaces int nodes logic with bool nodes logic where needed. Mostly there are CREATE ROLE logic changes. Relevant PG commit: 941460fcf731a32e6a90691508d5cfa3d1f8eeafnaisila/failure_pg15
parent
2cd3ddb9f7
commit
b0b400b6e1
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "pg_version_compat.h"
|
||||
|
||||
#include "distributed/pg_version_constants.h"
|
||||
|
||||
#include "access/heapam.h"
|
||||
|
@ -59,6 +61,7 @@ static char * CreateCreateOrAlterRoleCommand(const char *roleName,
|
|||
CreateRoleStmt *createRoleStmt,
|
||||
AlterRoleStmt *alterRoleStmt);
|
||||
static DefElem * makeDefElemInt(char *name, int value);
|
||||
static DefElem * makeDefElemBool(char *name, bool value);
|
||||
static List * GenerateRoleOptionsList(HeapTuple tuple);
|
||||
static List * GenerateGrantRoleStmtsFromOptions(RoleSpec *roleSpec, List *options);
|
||||
static List * GenerateGrantRoleStmtsOfRole(Oid roleid);
|
||||
|
@ -454,13 +457,13 @@ GenerateRoleOptionsList(HeapTuple tuple)
|
|||
Form_pg_authid role = ((Form_pg_authid) GETSTRUCT(tuple));
|
||||
|
||||
List *options = NIL;
|
||||
options = lappend(options, makeDefElemInt("superuser", role->rolsuper));
|
||||
options = lappend(options, makeDefElemInt("createdb", role->rolcreatedb));
|
||||
options = lappend(options, makeDefElemInt("createrole", role->rolcreaterole));
|
||||
options = lappend(options, makeDefElemInt("inherit", role->rolinherit));
|
||||
options = lappend(options, makeDefElemInt("canlogin", role->rolcanlogin));
|
||||
options = lappend(options, makeDefElemInt("isreplication", role->rolreplication));
|
||||
options = lappend(options, makeDefElemInt("bypassrls", role->rolbypassrls));
|
||||
options = lappend(options, makeDefElemBool("superuser", role->rolsuper));
|
||||
options = lappend(options, makeDefElemBool("createdb", role->rolcreatedb));
|
||||
options = lappend(options, makeDefElemBool("createrole", role->rolcreaterole));
|
||||
options = lappend(options, makeDefElemBool("inherit", role->rolinherit));
|
||||
options = lappend(options, makeDefElemBool("canlogin", role->rolcanlogin));
|
||||
options = lappend(options, makeDefElemBool("isreplication", role->rolreplication));
|
||||
options = lappend(options, makeDefElemBool("bypassrls", role->rolbypassrls));
|
||||
options = lappend(options, makeDefElemInt("connectionlimit", role->rolconnlimit));
|
||||
|
||||
/* load password from heap tuple, use NULL if not set */
|
||||
|
@ -616,6 +619,16 @@ makeDefElemInt(char *name, int value)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* makeDefElemBool creates a DefElem with boolean typed value with -1 as location.
|
||||
*/
|
||||
static DefElem *
|
||||
makeDefElemBool(char *name, bool value)
|
||||
{
|
||||
return makeDefElem(name, (Node *) makeBoolean(value), -1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GetDatabaseNameFromDbRoleSetting performs a lookup, and finds the database name
|
||||
* associated DbRoleSetting Tuple
|
||||
|
|
|
@ -196,7 +196,7 @@ AppendDefElem(StringInfo buf, DefElem *def)
|
|||
static void
|
||||
AppendDefElemStrict(StringInfo buf, DefElem *def)
|
||||
{
|
||||
if (intVal(def->arg) == 1)
|
||||
if (boolVal(def->arg))
|
||||
{
|
||||
appendStringInfo(buf, " STRICT");
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ AppendDefElemVolatility(StringInfo buf, DefElem *def)
|
|||
static void
|
||||
AppendDefElemLeakproof(StringInfo buf, DefElem *def)
|
||||
{
|
||||
if (intVal(def->arg) == 0)
|
||||
if (!boolVal(def->arg))
|
||||
{
|
||||
appendStringInfo(buf, " NOT");
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ AppendDefElemLeakproof(StringInfo buf, DefElem *def)
|
|||
static void
|
||||
AppendDefElemSecurity(StringInfo buf, DefElem *def)
|
||||
{
|
||||
if (intVal(def->arg) == 0)
|
||||
if (!boolVal(def->arg))
|
||||
{
|
||||
appendStringInfo(buf, " SECURITY INVOKER");
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "pg_version_compat.h"
|
||||
|
||||
#include "distributed/citus_ruleutils.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "lib/stringinfo.h"
|
||||
|
@ -98,59 +100,59 @@ AppendRoleOption(StringInfo buf, ListCell *optionCell)
|
|||
{
|
||||
DefElem *option = (DefElem *) lfirst(optionCell);
|
||||
|
||||
if (strcmp(option->defname, "superuser") == 0 && intVal(option->arg))
|
||||
if (strcmp(option->defname, "superuser") == 0 && boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " SUPERUSER");
|
||||
}
|
||||
else if (strcmp(option->defname, "superuser") == 0 && !intVal(option->arg))
|
||||
else if (strcmp(option->defname, "superuser") == 0 && !boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " NOSUPERUSER");
|
||||
}
|
||||
else if (strcmp(option->defname, "createdb") == 0 && intVal(option->arg))
|
||||
else if (strcmp(option->defname, "createdb") == 0 && boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " CREATEDB");
|
||||
}
|
||||
else if (strcmp(option->defname, "createdb") == 0 && !intVal(option->arg))
|
||||
else if (strcmp(option->defname, "createdb") == 0 && !boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " NOCREATEDB");
|
||||
}
|
||||
else if (strcmp(option->defname, "createrole") == 0 && intVal(option->arg))
|
||||
else if (strcmp(option->defname, "createrole") == 0 && boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " CREATEROLE");
|
||||
}
|
||||
else if (strcmp(option->defname, "createrole") == 0 && !intVal(option->arg))
|
||||
else if (strcmp(option->defname, "createrole") == 0 && !boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " NOCREATEROLE");
|
||||
}
|
||||
else if (strcmp(option->defname, "inherit") == 0 && intVal(option->arg))
|
||||
else if (strcmp(option->defname, "inherit") == 0 && boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " INHERIT");
|
||||
}
|
||||
else if (strcmp(option->defname, "inherit") == 0 && !intVal(option->arg))
|
||||
else if (strcmp(option->defname, "inherit") == 0 && !boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " NOINHERIT");
|
||||
}
|
||||
else if (strcmp(option->defname, "canlogin") == 0 && intVal(option->arg))
|
||||
else if (strcmp(option->defname, "canlogin") == 0 && boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " LOGIN");
|
||||
}
|
||||
else if (strcmp(option->defname, "canlogin") == 0 && !intVal(option->arg))
|
||||
else if (strcmp(option->defname, "canlogin") == 0 && !boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " NOLOGIN");
|
||||
}
|
||||
else if (strcmp(option->defname, "isreplication") == 0 && intVal(option->arg))
|
||||
else if (strcmp(option->defname, "isreplication") == 0 && boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " REPLICATION");
|
||||
}
|
||||
else if (strcmp(option->defname, "isreplication") == 0 && !intVal(option->arg))
|
||||
else if (strcmp(option->defname, "isreplication") == 0 && !boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " NOREPLICATION");
|
||||
}
|
||||
else if (strcmp(option->defname, "bypassrls") == 0 && intVal(option->arg))
|
||||
else if (strcmp(option->defname, "bypassrls") == 0 && boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " BYPASSRLS");
|
||||
}
|
||||
else if (strcmp(option->defname, "bypassrls") == 0 && !intVal(option->arg))
|
||||
else if (strcmp(option->defname, "bypassrls") == 0 && !boolVal(option->arg))
|
||||
{
|
||||
appendStringInfo(buf, " NOBYPASSRLS");
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ typedef Value String;
|
|||
#define pgstat_init_relation(r) pgstat_initstats(r)
|
||||
#define pg_analyze_and_rewrite_fixedparams(a, b, c, d, e) pg_analyze_and_rewrite(a, b, c, \
|
||||
d, e)
|
||||
#define boolVal(v) intVal(v)
|
||||
#define makeBoolean(val) makeInteger(val)
|
||||
|
||||
static inline int64
|
||||
pg_strtoint64(char *s)
|
||||
|
|
Loading…
Reference in New Issue