1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
==================================================================
Name
dblink_connect -- Opens a persistent connection to a remote database
Synopsis
dblink_connect(text connstr)
dblink_connect(text connname, text connstr)
Inputs
connname
if 2 arguments are given, the first is used as a name for a persistent
connection
connstr
standard libpq format connection string,
e.g. "hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd"
if only one argument is given, the connection is unnamed; only one unnamed
connection can exist at a time
Outputs
Returns status = "OK"
Notes
Only superusers may use dblink_connect to create non-password
authenticated connections. If non-superusers need this capability,
use dblink_connect_u instead.
Example usage
select dblink_connect('dbname=template1');
dblink_connect
----------------
OK
(1 row)
select dblink_connect('myconn','dbname=template1');
dblink_connect
----------------
OK
(1 row)
==================================================================
Name
dblink_connect_u -- Opens a persistent connection to a remote database
Synopsis
dblink_connect_u(text connstr)
dblink_connect_u(text connname, text connstr)
Inputs
connname
if 2 arguments are given, the first is used as a name for a persistent
connection
connstr
standard libpq format connection string,
e.g. "hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd"
if only one argument is given, the connection is unnamed; only one unnamed
connection can exist at a time
Outputs
Returns status = "OK"
Notes
With dblink_connect_u, a non-superuser may connect to any database server
using any authentication method. If the authentication method specified
for a particular user does not require a password, impersonation and
therefore escalation of privileges may occur. For this reason,
dblink_connect_u is initially installed with all privileges revoked from
public. Privilege to these functions should be granted with care.
Example usage
==================================================================
Name
dblink_disconnect -- Closes a persistent connection to a remote database
Synopsis
dblink_disconnect()
dblink_disconnect(text connname)
Inputs
connname
if an argument is given, it is used as a name for a persistent
connection to close; otherwiase the unnamed connection is closed
Outputs
Returns status = "OK"
Example usage
test=# select dblink_disconnect();
dblink_disconnect
-------------------
OK
(1 row)
select dblink_disconnect('myconn');
dblink_disconnect
-------------------
OK
(1 row)
|