Skip site navigation (1) Skip section navigation (2)

update to contrib/dblink

From: Joe Conway <mail(at)joeconway(dot)com>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: update to contrib/dblink
Date: 2002-08-30 19:05:34
Message-ID: 3D6FC1FE.9000308@joeconway.com (view raw or flat)
Thread:
Lists: pgsql-patches
Attached is a fairly sizeable update to contrib/dblink. I'd love to get 
review/feedback if anyone is interested and can spend the time. But I'd 
also love to get this committed and address changes as incremental 
patches ;-), so if there are no objections, please apply.

Below I'll give a synopsis of the changes. More detailed descriptions 
are now in a new doc directory under contrib/dblink. There is also a new 
dblink.test.sql file which will give a pretty good overview of the 
functions and their use.

Thanks,

Joe

 From README.dblink
=========================
Release Notes:
Version 0.5
- dblink now supports use directly as a table function; this is the new
   preferred usage going forward
- Use of dblink_tok is now deprecated; original form of dblink is also
   deprecated. They _will_ be removed in the next version.
- dblink_last_oid is also deprecated; use dblink_exec() which returns
   the command status as a single row, single column result.
- Original dblink, dblink_tok, and dblink_last_oid are commented out in
   dblink.sql; remove the comments to use the deprecated functions.
- dblink_strtok() and dblink_replace() functions were removed. Use
   split() and replace() respectively (new backend functions in
   PostgreSQL 7.3) instead.
- New functions: dblink_exec() for non-SELECT queries; dblink_connect()
   opens connection that persists for duration of a backend;
   dblink_disconnect() closes a persistent connection; dblink_open()
   opens a cursor; dblink_fetch() fetches results from an open cursor.
   dblink_close() closes a cursor.
- New test suite: dblink_check.sh, dblink.test.sql,
   dblink.test.expected.out. Execute dblink_check.sh from the same
   directory as the other two files. Output is dblink.test.out and
   dblink.test.diff. Note that dblink.test.sql is a good source
   of example usage.

dblink.sql installs following functions into a database:

connection
------------
dblink_connect(text) RETURNS text
   - opens a connection that will persist for duration of current
     backend or until it is disconnected
dblink_disconnect() RETURNS text
   - disconnects a persistent connection

cursor
------------
dblink_open(text,text) RETURNS text
   - opens a cursor using connection already opened with dblink_connect()
     that will persist for duration of current backend or until it is
     closed
dblink_fetch(text, int) RETURNS setof record
   - fetches data from an already opened cursor
dblink_close(text) RETURNS text
   - closes a cursor

query
------------
dblink(text,text) RETURNS setof record
   - returns a set of results from remote SELECT query
     (Note: comment out in dblink.sql to use deprecated version)
dblink(text) RETURNS setof record
   - returns a set of results from remote SELECT query, using connection
     already opened with dblink_connect()

execute
------------
dblink_exec(text, text) RETURNS text
   - executes an INSERT/UPDATE/DELETE query remotely
dblink_exec(text) RETURNS text
   - executes an INSERT/UPDATE/DELETE query remotely, using connection
     already opened with dblink_connect()

misc
------------
dblink_current_query() RETURNS text
   - returns the current query string
dblink_get_pkey(text) RETURNS setof text
   - returns the field names of a relation's primary key fields
dblink_build_sql_insert(text,int2vector,int2,_text,_text) RETURNS text
   - builds an insert statement using a local tuple, replacing the
     selection key field values with alternate supplied values
dblink_build_sql_delete(text,int2vector,int2,_text) RETURNS text
   - builds a delete statement using supplied values for selection
     key field values
dblink_build_sql_update(text,int2vector,int2,_text,_text) RETURNS text
   - builds an update statement using a local tuple, replacing the
     selection key field values with alternate supplied values

Not installed by default:
deprecated
------------
dblink(text,text) RETURNS setof int
   - *DEPRECATED* returns a resource id for results from remote query
     (Note: must uncomment in dblink.sql to use)
dblink_tok(int,int) RETURNS text
   - *DEPRECATED* extracts and returns individual field results; used
     only in conjunction with the *DEPRECATED* form of dblink
     (Note: must uncomment in dblink.sql to use)
dblink_last_oid(int) RETURNS oid
   - *DEPRECATED* returns the last inserted oid

Documentation:
See the following files:
      doc/connection
      doc/cursor
      doc/query
      doc/execute
      doc/misc
      doc/deprecated

Attachment: dblink.srf.9.patch.gz
Description: application/x-gzip (17.2 KB)

Responses

pgsql-patches by date

Next:From: Tom LaneDate: 2002-08-30 19:29:45
Subject: Re: [HACKERS] pg_attribute.attisinherited ?
Previous:From: Joe ConwayDate: 2002-08-30 18:51:43
Subject: Re: SRF memory mgmt patch (was [HACKERS] Concern about

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group