2007-07-09 09:32:30 +08:00
|
|
|
$PostgreSQL: pgsql/contrib/dblink/doc/connection,v 1.4.2.1 2007/07/09 01:32:30 joe Exp $
|
2002-09-02 14:32:41 +08:00
|
|
|
==================================================================
|
|
|
|
Name
|
|
|
|
|
|
|
|
dblink_connect -- Opens a persistent connection to a remote database
|
|
|
|
|
|
|
|
Synopsis
|
|
|
|
|
|
|
|
dblink_connect(text connstr)
|
2003-06-25 09:10:15 +08:00
|
|
|
dblink_connect(text connname, text connstr)
|
2002-09-02 14:32:41 +08:00
|
|
|
|
|
|
|
Inputs
|
|
|
|
|
2003-06-25 09:10:15 +08:00
|
|
|
connname
|
|
|
|
if 2 arguments are given, the first is used as a name for a persistent
|
|
|
|
connection
|
|
|
|
|
2002-09-02 14:32:41 +08:00
|
|
|
connstr
|
|
|
|
|
|
|
|
standard libpq format connection string,
|
|
|
|
e.g. "hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd"
|
|
|
|
|
2003-06-25 09:10:15 +08:00
|
|
|
if only one argument is given, the connection is unnamed; only one unnamed
|
|
|
|
connection can exist at a time
|
|
|
|
|
2002-09-02 14:32:41 +08:00
|
|
|
Outputs
|
|
|
|
|
|
|
|
Returns status = "OK"
|
|
|
|
|
2007-07-09 09:32:30 +08:00
|
|
|
Notes
|
|
|
|
|
|
|
|
Only superusers may use dblink_connect to create non-password
|
|
|
|
authenticated connections. If non-superusers need this capability,
|
|
|
|
use dblink_connect_u instead.
|
|
|
|
|
2002-09-02 14:32:41 +08:00
|
|
|
Example usage
|
|
|
|
|
2005-06-21 12:02:34 +08:00
|
|
|
select dblink_connect('dbname=postgres');
|
2003-06-25 09:10:15 +08:00
|
|
|
dblink_connect
|
|
|
|
----------------
|
|
|
|
OK
|
|
|
|
(1 row)
|
|
|
|
|
2005-06-21 12:02:34 +08:00
|
|
|
select dblink_connect('myconn','dbname=postgres');
|
2002-09-02 14:32:41 +08:00
|
|
|
dblink_connect
|
|
|
|
----------------
|
|
|
|
OK
|
|
|
|
(1 row)
|
|
|
|
|
2007-07-09 09:32:30 +08:00
|
|
|
==================================================================
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2002-09-02 14:32:41 +08:00
|
|
|
==================================================================
|
|
|
|
Name
|
|
|
|
|
2003-06-25 09:10:15 +08:00
|
|
|
dblink_disconnect -- Closes a persistent connection to a remote database
|
2002-09-02 14:32:41 +08:00
|
|
|
|
|
|
|
Synopsis
|
|
|
|
|
|
|
|
dblink_disconnect()
|
2003-06-25 09:10:15 +08:00
|
|
|
dblink_disconnect(text connname)
|
2002-09-02 14:32:41 +08:00
|
|
|
|
|
|
|
Inputs
|
|
|
|
|
2003-06-25 09:10:15 +08:00
|
|
|
connname
|
|
|
|
if an argument is given, it is used as a name for a persistent
|
|
|
|
connection to close; otherwiase the unnamed connection is closed
|
2002-09-02 14:32:41 +08:00
|
|
|
|
|
|
|
Outputs
|
|
|
|
|
|
|
|
Returns status = "OK"
|
|
|
|
|
|
|
|
Example usage
|
|
|
|
|
|
|
|
test=# select dblink_disconnect();
|
|
|
|
dblink_disconnect
|
|
|
|
-------------------
|
|
|
|
OK
|
|
|
|
(1 row)
|
|
|
|
|
2003-06-25 09:10:15 +08:00
|
|
|
select dblink_disconnect('myconn');
|
|
|
|
dblink_disconnect
|
|
|
|
-------------------
|
|
|
|
OK
|
|
|
|
(1 row)
|