static AclResult pg_role_aclcheck(Oid role_oid, Oid roleid, AclMode mode);
static void RoleMembershipCacheCallback(Datum arg, int cacheid, ItemPointer tuplePtr);
+static Oid get_role_oid_or_public(const char *rolname);
/*
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*rolename), false);
+ roleid = get_role_oid_or_public(NameStr(*rolename));
tableoid = convert_table_name(tablename);
mode = convert_table_priv_string(priv_type_text);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_table_priv_string(priv_type_text);
if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(tableoid)))
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*rolename), false);
+ roleid = get_role_oid_or_public(NameStr(*rolename));
mode = convert_sequence_priv_string(priv_type_text);
sequenceoid = convert_table_name(sequencename);
if (get_rel_relkind(sequenceoid) != RELKIND_SEQUENCE)
AclResult aclresult;
char relkind;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_sequence_priv_string(priv_type_text);
relkind = get_rel_relkind(sequenceoid);
if (relkind == '\0')
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*rolename), false);
+ roleid = get_role_oid_or_public(NameStr(*rolename));
tableoid = convert_table_name(tablename);
mode = convert_column_priv_string(priv_type_text);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_column_priv_string(priv_type_text);
if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(tableoid)))
AclMode mode;
int privresult;
- roleid = get_role_oid(NameStr(*rolename), false);
+ roleid = get_role_oid_or_public(NameStr(*rolename));
tableoid = convert_table_name(tablename);
colattnum = convert_column_name(tableoid, column);
mode = convert_column_priv_string(priv_type_text);
AclMode mode;
int privresult;
- roleid = get_role_oid(NameStr(*rolename), false);
+ roleid = get_role_oid_or_public(NameStr(*rolename));
tableoid = convert_table_name(tablename);
mode = convert_column_priv_string(priv_type_text);
AclMode mode;
int privresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
colattnum = convert_column_name(tableoid, column);
mode = convert_column_priv_string(priv_type_text);
AclMode mode;
int privresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_column_priv_string(priv_type_text);
privresult = column_privilege_check(tableoid, colattnum, roleid, mode);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
databaseoid = convert_database_name(databasename);
mode = convert_database_priv_string(priv_type_text);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_database_priv_string(priv_type_text);
if (!SearchSysCacheExists1(DATABASEOID, ObjectIdGetDatum(databaseoid)))
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
fdwid = convert_foreign_data_wrapper_name(fdwname);
mode = convert_foreign_data_wrapper_priv_string(priv_type_text);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_foreign_data_wrapper_priv_string(priv_type_text);
aclresult = pg_foreign_data_wrapper_aclcheck(fdwid, roleid, mode);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
functionoid = convert_function_name(functionname);
mode = convert_function_priv_string(priv_type_text);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_function_priv_string(priv_type_text);
if (!SearchSysCacheExists1(PROCOID, ObjectIdGetDatum(functionoid)))
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
languageoid = convert_language_name(languagename);
mode = convert_language_priv_string(priv_type_text);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_language_priv_string(priv_type_text);
if (!SearchSysCacheExists1(LANGOID, ObjectIdGetDatum(languageoid)))
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
schemaoid = convert_schema_name(schemaname);
mode = convert_schema_priv_string(priv_type_text);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_schema_priv_string(priv_type_text);
if (!SearchSysCacheExists1(NAMESPACEOID, ObjectIdGetDatum(schemaoid)))
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
serverid = convert_server_name(servername);
mode = convert_server_priv_string(priv_type_text);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_server_priv_string(priv_type_text);
aclresult = pg_foreign_server_aclcheck(serverid, roleid, mode);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
tablespaceoid = convert_tablespace_name(tablespacename);
mode = convert_tablespace_priv_string(priv_type_text);
AclMode mode;
AclResult aclresult;
- roleid = get_role_oid(NameStr(*username), false);
+ roleid = get_role_oid_or_public(NameStr(*username));
mode = convert_tablespace_priv_string(priv_type_text);
aclresult = pg_tablespace_aclcheck(tablespaceoid, roleid, mode);
errmsg("role \"%s\" does not exist", rolname)));
return oid;
}
+
+/*
+ * get_role_oid_or_public - As above, but return ACL_ID_PUBLIC if the
+ * role name is "public".
+ */
+static Oid
+get_role_oid_or_public(const char *rolname)
+{
+ if (strcmp(rolname, "public") == 0)
+ return ACL_ID_PUBLIC;
+
+ return get_role_oid(rolname, false);
+}