Обсуждение: update to contrib/dblink
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
Вложения
Your patch has been added to the PostgreSQL unapplied patches list at:
http://207.106.42.251/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
---------------------------------------------------------------------------
Joe Conway wrote:
> 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
[ application/x-gzip is not supported, skipping... ]
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Your patch has been added to the PostgreSQL unapplied patches list at:
dblink is Joe's baby; there is no one else who will review it better
than he can. Same for contrib/tablefunc. Just apply 'em.
regards, tom lane
I am just filling the queue and will apply everything in an hour once I am done reading all the emails. --------------------------------------------------------------------------- Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > Your patch has been added to the PostgreSQL unapplied patches list at: > > dblink is Joe's baby; there is no one else who will review it better > than he can. Same for contrib/tablefunc. Just apply 'em. > > regards, tom lane > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Patch applied. Thanks. --------------------------------------------------------------------------- Joe Conway wrote: > 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 [ application/x-gzip is not supported, skipping... ] > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073