PostgreSQL Source Code  git master
foreign.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * foreign.h
4  * support for foreign-data wrappers, servers and user mappings.
5  *
6  *
7  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8  *
9  * src/include/foreign/foreign.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef FOREIGN_H
14 #define FOREIGN_H
15 
16 #include "nodes/parsenodes.h"
17 
18 
19 /* Helper for obtaining username for user mapping */
20 #define MappingUserName(userid) \
21  (OidIsValid(userid) ? GetUserNameFromId(userid, false) : "public")
22 
23 
24 typedef struct ForeignDataWrapper
25 {
26  Oid fdwid; /* FDW Oid */
27  Oid owner; /* FDW owner user Oid */
28  char *fdwname; /* Name of the FDW */
29  Oid fdwhandler; /* Oid of handler function, or 0 */
30  Oid fdwvalidator; /* Oid of validator function, or 0 */
31  List *options; /* fdwoptions as DefElem list */
33 
34 typedef struct ForeignServer
35 {
36  Oid serverid; /* server Oid */
37  Oid fdwid; /* foreign-data wrapper */
38  Oid owner; /* server owner user Oid */
39  char *servername; /* name of the server */
40  char *servertype; /* server type, optional */
41  char *serverversion; /* server version, optional */
42  List *options; /* srvoptions as DefElem list */
44 
45 typedef struct UserMapping
46 {
47  Oid umid; /* Oid of user mapping */
48  Oid userid; /* local user Oid */
49  Oid serverid; /* server Oid */
50  List *options; /* useoptions as DefElem list */
51 } UserMapping;
52 
53 typedef struct ForeignTable
54 {
55  Oid relid; /* relation Oid */
56  Oid serverid; /* server Oid */
57  List *options; /* ftoptions as DefElem list */
58 } ForeignTable;
59 
60 /* Flags for GetForeignServerExtended */
61 #define FSV_MISSING_OK 0x01
62 
63 /* Flags for GetForeignDataWrapperExtended */
64 #define FDW_MISSING_OK 0x01
65 
66 
67 extern ForeignServer *GetForeignServer(Oid serverid);
69  bits16 flags);
70 extern ForeignServer *GetForeignServerByName(const char *name, bool missing_ok);
71 extern UserMapping *GetUserMapping(Oid userid, Oid serverid);
74  bits16 flags);
76  bool missing_ok);
77 extern ForeignTable *GetForeignTable(Oid relid);
78 
80 
81 extern Oid get_foreign_data_wrapper_oid(const char *fdwname, bool missing_ok);
82 extern Oid get_foreign_server_oid(const char *servername, bool missing_ok);
83 
84 #endif /* FOREIGN_H */
ForeignTable * GetForeignTable(Oid relid)
Definition: foreign.c:248
Oid umid
Definition: foreign.h:47
ForeignDataWrapper * GetForeignDataWrapperExtended(Oid fdwid, bits16 flags)
Definition: foreign.c:47
uint16 bits16
Definition: c.h:367
char * fdwname
Definition: foreign.h:28
struct ForeignTable ForeignTable
char * serverversion
Definition: foreign.h:41
unsigned int Oid
Definition: postgres_ext.h:31
Oid userid
Definition: foreign.h:48
char * servertype
Definition: foreign.h:40
ForeignDataWrapper * GetForeignDataWrapperByName(const char *name, bool missing_ok)
Definition: foreign.c:94
ForeignServer * GetForeignServer(Oid serverid)
Definition: foreign.c:109
struct ForeignDataWrapper ForeignDataWrapper
ForeignServer * GetForeignServerExtended(Oid serverid, bits16 flags)
Definition: foreign.c:121
Oid relid
Definition: foreign.h:55
UserMapping * GetUserMapping(Oid userid, Oid serverid)
Definition: foreign.c:198
List * options
Definition: foreign.h:50
List * options
Definition: foreign.h:31
Oid get_foreign_data_wrapper_oid(const char *fdwname, bool missing_ok)
Definition: foreign.c:691
ForeignDataWrapper * GetForeignDataWrapper(Oid fdwid)
Definition: foreign.c:35
List * GetForeignColumnOptions(Oid relid, AttrNumber attnum)
Definition: foreign.c:286
ForeignServer * GetForeignServerByName(const char *name, bool missing_ok)
Definition: foreign.c:180
int16 attnum
Definition: pg_attribute.h:79
Oid get_foreign_server_oid(const char *servername, bool missing_ok)
Definition: foreign.c:714
Oid serverid
Definition: foreign.h:56
Oid serverid
Definition: foreign.h:49
const char * name
Definition: encode.c:521
List * options
Definition: foreign.h:57
char * servername
Definition: foreign.h:39
Definition: pg_list.h:50
List * options
Definition: foreign.h:42
struct ForeignServer ForeignServer
int16 AttrNumber
Definition: attnum.h:21
Oid serverid
Definition: foreign.h:36
struct UserMapping UserMapping