namespace.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*-------------------------------------------------------------------------
  2. *
  3. * namespace.h
  4. * prototypes for functions in backend/catalog/namespace.c
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/include/catalog/namespace.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef NAMESPACE_H
  15. #define NAMESPACE_H
  16. #include "nodes/primnodes.h"
  17. #include "storage/lock.h"
  18. /*
  19. * This structure holds a list of possible functions or operators
  20. * found by namespace lookup. Each function/operator is identified
  21. * by OID and by argument types; the list must be pruned by type
  22. * resolution rules that are embodied in the parser, not here.
  23. * See FuncnameGetCandidates's comments for more info.
  24. */
  25. typedef struct _FuncCandidateList
  26. {
  27. struct _FuncCandidateList *next;
  28. int pathpos; /* for internal use of namespace lookup */
  29. Oid oid; /* the function or operator's OID */
  30. int nominalnargs; /* either pronargs or length(proallargtypes) */
  31. int nargs; /* number of arg types returned */
  32. int nvargs; /* number of args to become variadic array */
  33. int ndargs; /* number of defaulted args */
  34. int *argnumbers; /* args' positional indexes, if named call */
  35. Oid args[FLEXIBLE_ARRAY_MEMBER]; /* arg types */
  36. } *FuncCandidateList;
  37. /*
  38. * Result of checkTempNamespaceStatus
  39. */
  40. typedef enum TempNamespaceStatus
  41. {
  42. TEMP_NAMESPACE_NOT_TEMP, /* nonexistent, or non-temp namespace */
  43. TEMP_NAMESPACE_IDLE, /* exists, belongs to no active session */
  44. TEMP_NAMESPACE_IN_USE /* belongs to some active session */
  45. } TempNamespaceStatus;
  46. /*
  47. * Structure for xxxOverrideSearchPath functions
  48. *
  49. * The generation counter is private to namespace.c and shouldn't be touched
  50. * by other code. It can be initialized to zero if necessary (that means
  51. * "not known equal to the current active path").
  52. */
  53. typedef struct OverrideSearchPath
  54. {
  55. List *schemas; /* OIDs of explicitly named schemas */
  56. bool addCatalog; /* implicitly prepend pg_catalog? */
  57. bool addTemp; /* implicitly prepend temp schema? */
  58. uint64 generation; /* for quick detection of equality to active */
  59. } OverrideSearchPath;
  60. /*
  61. * Option flag bits for RangeVarGetRelidExtended().
  62. */
  63. typedef enum RVROption
  64. {
  65. RVR_MISSING_OK = 1 << 0, /* don't error if relation doesn't exist */
  66. RVR_NOWAIT = 1 << 1, /* error if relation cannot be locked */
  67. RVR_SKIP_LOCKED = 1 << 2 /* skip if relation cannot be locked */
  68. } RVROption;
  69. typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId,
  70. Oid oldRelId, void *callback_arg);
  71. #define RangeVarGetRelid(relation, lockmode, missing_ok) \
  72. RangeVarGetRelidExtended(relation, lockmode, \
  73. (missing_ok) ? RVR_MISSING_OK : 0, NULL, NULL)
  74. extern Oid RangeVarGetRelidExtended(const RangeVar *relation,
  75. LOCKMODE lockmode, uint32 flags,
  76. RangeVarGetRelidCallback callback,
  77. void *callback_arg);
  78. extern Oid RangeVarGetCreationNamespace(const RangeVar *newRelation);
  79. extern Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation,
  80. LOCKMODE lockmode,
  81. Oid *existing_relation_id);
  82. extern void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid);
  83. extern Oid RelnameGetRelid(const char *relname);
  84. extern bool RelationIsVisible(Oid relid);
  85. extern Oid TypenameGetTypid(const char *typname);
  86. extern Oid TypenameGetTypidExtended(const char *typname, bool temp_ok);
  87. extern bool TypeIsVisible(Oid typid);
  88. extern FuncCandidateList FuncnameGetCandidates(List *names,
  89. int nargs, List *argnames,
  90. bool expand_variadic,
  91. bool expand_defaults,
  92. bool include_out_arguments,
  93. bool missing_ok);
  94. extern bool FunctionIsVisible(Oid funcid);
  95. extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright);
  96. extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind,
  97. bool missing_schema_ok);
  98. extern bool OperatorIsVisible(Oid oprid);
  99. extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname);
  100. extern bool OpclassIsVisible(Oid opcid);
  101. extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname);
  102. extern bool OpfamilyIsVisible(Oid opfid);
  103. extern Oid CollationGetCollid(const char *collname);
  104. extern bool CollationIsVisible(Oid collid);
  105. extern Oid ConversionGetConid(const char *conname);
  106. extern bool ConversionIsVisible(Oid conid);
  107. extern Oid get_statistics_object_oid(List *names, bool missing_ok);
  108. extern bool StatisticsObjIsVisible(Oid relid);
  109. extern Oid get_ts_parser_oid(List *names, bool missing_ok);
  110. extern bool TSParserIsVisible(Oid prsId);
  111. extern Oid get_ts_dict_oid(List *names, bool missing_ok);
  112. extern bool TSDictionaryIsVisible(Oid dictId);
  113. extern Oid get_ts_template_oid(List *names, bool missing_ok);
  114. extern bool TSTemplateIsVisible(Oid tmplId);
  115. extern Oid get_ts_config_oid(List *names, bool missing_ok);
  116. extern bool TSConfigIsVisible(Oid cfgid);
  117. extern void DeconstructQualifiedName(List *names,
  118. char **nspname_p,
  119. char **objname_p);
  120. extern Oid LookupNamespaceNoError(const char *nspname);
  121. extern Oid LookupExplicitNamespace(const char *nspname, bool missing_ok);
  122. extern Oid get_namespace_oid(const char *nspname, bool missing_ok);
  123. extern Oid LookupCreationNamespace(const char *nspname);
  124. extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
  125. extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p);
  126. extern RangeVar *makeRangeVarFromNameList(List *names);
  127. extern char *NameListToString(List *names);
  128. extern char *NameListToQuotedString(List *names);
  129. extern bool isTempNamespace(Oid namespaceId);
  130. extern bool isTempToastNamespace(Oid namespaceId);
  131. extern bool isTempOrTempToastNamespace(Oid namespaceId);
  132. extern bool isAnyTempNamespace(Oid namespaceId);
  133. extern bool isOtherTempNamespace(Oid namespaceId);
  134. extern TempNamespaceStatus checkTempNamespaceStatus(Oid namespaceId);
  135. extern int GetTempNamespaceBackendId(Oid namespaceId);
  136. extern Oid GetTempToastNamespace(void);
  137. extern void GetTempNamespaceState(Oid *tempNamespaceId,
  138. Oid *tempToastNamespaceId);
  139. extern void SetTempNamespaceState(Oid tempNamespaceId,
  140. Oid tempToastNamespaceId);
  141. extern void ResetTempTableNamespace(void);
  142. extern OverrideSearchPath *GetOverrideSearchPath(MemoryContext context);
  143. extern OverrideSearchPath *CopyOverrideSearchPath(OverrideSearchPath *path);
  144. extern bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path);
  145. extern void PushOverrideSearchPath(OverrideSearchPath *newpath);
  146. extern void PopOverrideSearchPath(void);
  147. extern Oid get_collation_oid(List *collname, bool missing_ok);
  148. extern Oid get_conversion_oid(List *conname, bool missing_ok);
  149. extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
  150. /* initialization & transaction cleanup code */
  151. extern void InitializeSearchPath(void);
  152. extern void AtEOXact_Namespace(bool isCommit, bool parallel);
  153. extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
  154. SubTransactionId parentSubid);
  155. /* stuff for search_path GUC variable */
  156. extern PGDLLIMPORT char *namespace_search_path;
  157. extern List *fetch_search_path(bool includeImplicit);
  158. extern int fetch_search_path_array(Oid *sarray, int sarray_len);
  159. #endif /* NAMESPACE_H */