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: 941460fcf731a32e6a90691508d5cfa3d1f8eeafversion-15-socket
parent
173c518320
commit
571417a133
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
|
#include "pg_version_compat.h"
|
||||||
|
|
||||||
#include "distributed/pg_version_constants.h"
|
#include "distributed/pg_version_constants.h"
|
||||||
|
|
||||||
#include "access/heapam.h"
|
#include "access/heapam.h"
|
||||||
|
@ -59,6 +61,7 @@ static char * CreateCreateOrAlterRoleCommand(const char *roleName,
|
||||||
CreateRoleStmt *createRoleStmt,
|
CreateRoleStmt *createRoleStmt,
|
||||||
AlterRoleStmt *alterRoleStmt);
|
AlterRoleStmt *alterRoleStmt);
|
||||||
static DefElem * makeDefElemInt(char *name, int value);
|
static DefElem * makeDefElemInt(char *name, int value);
|
||||||
|
static DefElem * makeDefElemBool(char *name, bool value);
|
||||||
static List * GenerateRoleOptionsList(HeapTuple tuple);
|
static List * GenerateRoleOptionsList(HeapTuple tuple);
|
||||||
static List * GenerateGrantRoleStmtsFromOptions(RoleSpec *roleSpec, List *options);
|
static List * GenerateGrantRoleStmtsFromOptions(RoleSpec *roleSpec, List *options);
|
||||||
static List * GenerateGrantRoleStmtsOfRole(Oid roleid);
|
static List * GenerateGrantRoleStmtsOfRole(Oid roleid);
|
||||||
|
@ -454,13 +457,13 @@ GenerateRoleOptionsList(HeapTuple tuple)
|
||||||
Form_pg_authid role = ((Form_pg_authid) GETSTRUCT(tuple));
|
Form_pg_authid role = ((Form_pg_authid) GETSTRUCT(tuple));
|
||||||
|
|
||||||
List *options = NIL;
|
List *options = NIL;
|
||||||
options = lappend(options, makeDefElemInt("superuser", role->rolsuper));
|
options = lappend(options, makeDefElemBool("superuser", role->rolsuper));
|
||||||
options = lappend(options, makeDefElemInt("createdb", role->rolcreatedb));
|
options = lappend(options, makeDefElemBool("createdb", role->rolcreatedb));
|
||||||
options = lappend(options, makeDefElemInt("createrole", role->rolcreaterole));
|
options = lappend(options, makeDefElemBool("createrole", role->rolcreaterole));
|
||||||
options = lappend(options, makeDefElemInt("inherit", role->rolinherit));
|
options = lappend(options, makeDefElemBool("inherit", role->rolinherit));
|
||||||
options = lappend(options, makeDefElemInt("canlogin", role->rolcanlogin));
|
options = lappend(options, makeDefElemBool("canlogin", role->rolcanlogin));
|
||||||
options = lappend(options, makeDefElemInt("isreplication", role->rolreplication));
|
options = lappend(options, makeDefElemBool("isreplication", role->rolreplication));
|
||||||
options = lappend(options, makeDefElemInt("bypassrls", role->rolbypassrls));
|
options = lappend(options, makeDefElemBool("bypassrls", role->rolbypassrls));
|
||||||
options = lappend(options, makeDefElemInt("connectionlimit", role->rolconnlimit));
|
options = lappend(options, makeDefElemInt("connectionlimit", role->rolconnlimit));
|
||||||
|
|
||||||
/* load password from heap tuple, use NULL if not set */
|
/* 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
|
* GetDatabaseNameFromDbRoleSetting performs a lookup, and finds the database name
|
||||||
* associated DbRoleSetting Tuple
|
* associated DbRoleSetting Tuple
|
||||||
|
|
|
@ -196,7 +196,7 @@ AppendDefElem(StringInfo buf, DefElem *def)
|
||||||
static void
|
static void
|
||||||
AppendDefElemStrict(StringInfo buf, DefElem *def)
|
AppendDefElemStrict(StringInfo buf, DefElem *def)
|
||||||
{
|
{
|
||||||
if (intVal(def->arg) == 1)
|
if (boolVal(def->arg))
|
||||||
{
|
{
|
||||||
appendStringInfo(buf, " STRICT");
|
appendStringInfo(buf, " STRICT");
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ AppendDefElemVolatility(StringInfo buf, DefElem *def)
|
||||||
static void
|
static void
|
||||||
AppendDefElemLeakproof(StringInfo buf, DefElem *def)
|
AppendDefElemLeakproof(StringInfo buf, DefElem *def)
|
||||||
{
|
{
|
||||||
if (intVal(def->arg) == 0)
|
if (!boolVal(def->arg))
|
||||||
{
|
{
|
||||||
appendStringInfo(buf, " NOT");
|
appendStringInfo(buf, " NOT");
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ AppendDefElemLeakproof(StringInfo buf, DefElem *def)
|
||||||
static void
|
static void
|
||||||
AppendDefElemSecurity(StringInfo buf, DefElem *def)
|
AppendDefElemSecurity(StringInfo buf, DefElem *def)
|
||||||
{
|
{
|
||||||
if (intVal(def->arg) == 0)
|
if (!boolVal(def->arg))
|
||||||
{
|
{
|
||||||
appendStringInfo(buf, " SECURITY INVOKER");
|
appendStringInfo(buf, " SECURITY INVOKER");
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
|
#include "pg_version_compat.h"
|
||||||
|
|
||||||
#include "distributed/citus_ruleutils.h"
|
#include "distributed/citus_ruleutils.h"
|
||||||
#include "distributed/deparser.h"
|
#include "distributed/deparser.h"
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
|
@ -98,59 +100,59 @@ AppendRoleOption(StringInfo buf, ListCell *optionCell)
|
||||||
{
|
{
|
||||||
DefElem *option = (DefElem *) lfirst(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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
appendStringInfo(buf, " NOBYPASSRLS");
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ typedef Value String;
|
||||||
#define pgstat_init_relation(r) pgstat_initstats(r)
|
#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, \
|
#define pg_analyze_and_rewrite_fixedparams(a, b, c, d, e) pg_analyze_and_rewrite(a, b, c, \
|
||||||
d, e)
|
d, e)
|
||||||
|
#define boolVal(v) intVal(v)
|
||||||
|
#define makeBoolean(val) makeInteger(val)
|
||||||
|
|
||||||
static inline int64
|
static inline int64
|
||||||
pg_strtoint64(char *s)
|
pg_strtoint64(char *s)
|
||||||
|
|
Loading…
Reference in New Issue