summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2001-12-13 10:48:39 +0000
committerBruce Momjian2001-12-13 10:48:39 +0000
commitcde5fae7c9125ae16cf29cb82e1640b762e99514 (patch)
tree79ef7e36324d566181bd2c8fc2e1daa9cd665f20
parentba578ae667161054871df049795a276170d6f8cd (diff)
>>I confirmed the UNION hack is no longer required. Thanks! Is it too late
>>to change the README in contrib/dblink? >> > > No, I don't think that's a problem. Send a patch. > Here's a (documentation only) patch for the contrib/dblink README. Joe Conway
-rw-r--r--contrib/dblink/README.dblink45
1 files changed, 9 insertions, 36 deletions
diff --git a/contrib/dblink/README.dblink b/contrib/dblink/README.dblink
index c56720d2fbe..0a2f87b0eed 100644
--- a/contrib/dblink/README.dblink
+++ b/contrib/dblink/README.dblink
@@ -82,7 +82,8 @@ Outputs
Example usage
- select dblink('hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd','select f1, f2 from mytable');
+ select dblink('hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd'
+ ,'select f1, f2 from mytable');
==================================================================
@@ -118,44 +119,16 @@ Example usage
==================================================================
-NOTE: If you need to provide selection criteria in a WHERE clause, it is necessary
-to 'fake' a UNION, e.g.
-
- select
- dblink_tok(t1.dblink_p,0) as f1
- ,dblink_tok(t1.dblink_p,1) as f2
- from
- (
- select dblink(
- 'hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd'
- ,'select f1, f2 from mytable'
- ) as dblink_p
- union all
- select null where false
- ) as t1
- where
- dblink_tok(t1.dblink_p,0) = 'mycriteria';
-
-in order to work around an issue with the query optimizer. A more convenient way to approach
-this problem is to create a view:
-
- create view myremotetable as
- select
- dblink_tok(t1.dblink_p,0) as f1
- ,dblink_tok(t1.dblink_p,1) as f2
- from
- (
- select dblink(
- 'hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd'
- ,'select f1, f2 from mytable'
- ) as dblink_p
- union all
- select null where false
- ) as t1;
+A more convenient way to use dblink may be to create a view:
+
+ create view myremotetable as
+ select dblink_tok(t1.dblink_p,0) as f1, dblink_tok(t1.dblink_p,1) as f2
+ from (select dblink('hostaddr=127.0.0.1 port=5432 dbname=template1 user=postgres password=postgres'
+ ,'select proname, prosrc from pg_proc') as dblink_p) as t1;
Then you can simply write:
- select f1,f2 from myremotetable where f1 = 'mycriteria';
+ select f1, f2 from myremotetable where f1 like 'bytea%';
==================================================================