diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-08-05 14:45:09 +0000 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-08-05 14:45:09 +0000 |
commit | 2a6ef3445c73473edb222abf108b323fb7f002dc (patch) | |
tree | ca6a6f51dcf5193303f466c4072b243e3f979227 /src/include | |
parent | 641459f26954b04f74d098a758b716297b6554ea (diff) | |
download | postgresql-2a6ef3445c73473edb222abf108b323fb7f002dc.tar.gz postgresql-2a6ef3445c73473edb222abf108b323fb7f002dc.zip |
Standardize get_whatever_oid functions for object types with
unqualified names.
- Add a missing_ok parameter to get_tablespace_oid.
- Avoid duplicating get_tablespace_od guts in objectNamesToOids.
- Add a missing_ok parameter to get_database_oid.
- Replace get_roleid and get_role_checked with get_role_oid.
- Add get_namespace_oid, get_language_oid, get_am_oid.
- Refactor existing code to use new interfaces.
Thanks to KaiGai Kohei for the review.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/namespace.h | 3 | ||||
-rw-r--r-- | src/include/commands/dbcommands.h | 4 | ||||
-rw-r--r-- | src/include/commands/defrem.h | 3 | ||||
-rw-r--r-- | src/include/commands/proclang.h | 3 | ||||
-rw-r--r-- | src/include/commands/tablespace.h | 4 | ||||
-rw-r--r-- | src/include/utils/acl.h | 3 | ||||
-rw-r--r-- | src/include/utils/lsyscache.h | 4 |
7 files changed, 13 insertions, 11 deletions
diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h index 277ea0171fb..ec4e45125b7 100644 --- a/src/include/catalog/namespace.h +++ b/src/include/catalog/namespace.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.62 2010/01/02 16:58:01 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.63 2010/08/05 14:45:06 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -91,6 +91,7 @@ extern void DeconstructQualifiedName(List *names, char **objname_p); extern Oid LookupNamespaceNoError(const char *nspname); extern Oid LookupExplicitNamespace(const char *nspname); +extern Oid get_namespace_oid(const char *nspname, bool missing_ok); extern Oid LookupCreationNamespace(const char *nspname); extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p); diff --git a/src/include/commands/dbcommands.h b/src/include/commands/dbcommands.h index f150da3fb76..7da6e14ada8 100644 --- a/src/include/commands/dbcommands.h +++ b/src/include/commands/dbcommands.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/dbcommands.h,v 1.50 2010/01/02 16:58:03 momjian Exp $ + * $PostgreSQL: pgsql/src/include/commands/dbcommands.h,v 1.51 2010/08/05 14:45:07 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -59,7 +59,7 @@ extern void AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel); extern void AlterDatabaseSet(AlterDatabaseSetStmt *stmt); extern void AlterDatabaseOwner(const char *dbname, Oid newOwnerId); -extern Oid get_database_oid(const char *dbname); +extern Oid get_database_oid(const char *dbname, bool missingok); extern char *get_database_name(Oid dbid); extern void dbase_redo(XLogRecPtr lsn, XLogRecord *rptr); diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index cd5be6e4fda..502ee749cde 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.102 2010/07/03 13:53:13 rhaas Exp $ + * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.103 2010/08/05 14:45:07 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -99,6 +99,7 @@ extern void AlterOpClassOwner(List *name, const char *access_method, Oid newOwne extern void AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId); extern void AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId); extern void AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId); +extern Oid get_am_oid(const char *amname, bool missing_ok); /* commands/tsearchcmds.c */ extern void DefineTSParser(List *names, List *parameters); diff --git a/src/include/commands/proclang.h b/src/include/commands/proclang.h index 255af9291e0..8cc72494f87 100644 --- a/src/include/commands/proclang.h +++ b/src/include/commands/proclang.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/src/include/commands/proclang.h,v 1.15 2009/06/11 14:49:11 momjian Exp $ + * $PostgreSQL: pgsql/src/include/commands/proclang.h,v 1.16 2010/08/05 14:45:08 rhaas Exp $ * *------------------------------------------------------------------------- * @@ -21,5 +21,6 @@ extern void RenameLanguage(const char *oldname, const char *newname); extern void AlterLanguageOwner(const char *name, Oid newOwnerId); extern void AlterLanguageOwner_oid(Oid oid, Oid newOwnerId); extern bool PLTemplateExists(const char *languageName); +extern Oid get_language_oid(const char *langname, bool missing_ok); #endif /* PROCLANG_H */ diff --git a/src/include/commands/tablespace.h b/src/include/commands/tablespace.h index 3d46eeb650e..44eed246a1f 100644 --- a/src/include/commands/tablespace.h +++ b/src/include/commands/tablespace.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.23 2010/01/07 03:53:08 rhaas Exp $ + * $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.24 2010/08/05 14:45:08 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -51,7 +51,7 @@ extern Oid GetDefaultTablespace(bool forTemp); extern void PrepareTempTablespaces(void); -extern Oid get_tablespace_oid(const char *tablespacename); +extern Oid get_tablespace_oid(const char *tablespacename, bool missing_ok); extern char *get_tablespace_name(Oid spc_oid); extern bool directory_is_empty(const char *path); diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h index 16a2202fdd1..1fa0a3df679 100644 --- a/src/include/utils/acl.h +++ b/src/include/utils/acl.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.113 2010/02/26 02:01:28 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.114 2010/08/05 14:45:09 rhaas Exp $ * * NOTES * An ACL array is simply an array of AclItems, representing the union @@ -223,6 +223,7 @@ extern bool is_member_of_role(Oid member, Oid role); extern bool is_member_of_role_nosuper(Oid member, Oid role); extern bool is_admin_of_role(Oid member, Oid role); extern void check_is_member_of_role(Oid member, Oid role); +extern Oid get_role_oid(const char *rolname, bool missing_ok); extern void select_best_grantor(Oid roleId, AclMode privileges, const Acl *acl, Oid ownerId, diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index b16ab8680a3..ef78aa8b7f9 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.133 2010/04/24 16:20:32 sriggs Exp $ + * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.134 2010/08/05 14:45:09 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -136,8 +136,6 @@ extern void free_attstatsslot(Oid atttype, Datum *values, int nvalues, float4 *numbers, int nnumbers); extern char *get_namespace_name(Oid nspid); -extern Oid get_roleid(const char *rolname); -extern Oid get_roleid_checked(const char *rolname); #define type_is_array(typid) (get_element_type(typid) != InvalidOid) |