1- --
2- -- First, create a slave database and define the functions and test data
3- -- therein.
4- --
5- -- This initial hackery is to allow successive runs without failures.
6- --
7-
81-- Adjust this setting to control where the objects get created.
92SET search_path= public;
103
11- CREATE OR REPLACE FUNCTION conditional_drop ()
12- RETURNStext AS '
13- DECLARE
14- dbname text;
15- BEGIN
16- SELECT INTO dbname datname FROM pg_database WHERE datname =' ' regression_slave' ' ;
17- IF FOUND THEN
18- DROP DATABASE regression_slave;
19- END IF;
20- RETURN' ' OK' ' ;
21- END;
22- ' LANGUAGE' plpgsql' ;
23- SELECT conditional_drop();
24-
25- CREATE DATABASE regression_slave ;
26- \connect regression_slave
27-
4+ --
5+ -- Define the functions and test data
6+ -- therein.
7+ --
288-- Turn off echoing so that expected file does not depend on
299-- contents of dblink.sql.
3010\set ECHO none
@@ -64,20 +44,9 @@ SELECT dblink_build_sql_update('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}');
6444-- build a delete statement based on a local tuple,
6545SELECT dblink_build_sql_delete(' foo' ,' 1 2' ,2 ,' {"0", "a"}' );
6646
67- --
68- -- Connect back to the regression database and define the functions.
69- -- Turn off echoing so that expected file does not depend on
70- -- contents of dblink.sql.
71- --
72- \connect regression
73- \set ECHO none
74- SET autocommit TO' on' ;
75- \idblink .sql
76- \set ECHO all
77-
7847-- regular old dblink
7948SELECT *
80- FROM dblink(' dbname=regression_slave ' ,' SELECT * FROM foo' )AS t(aint , btext , ctext [])
49+ FROM dblink(' dbname=regression ' ,' SELECT * FROM foo' )AS t(aint , btext , ctext [])
8150WHERE t .a > 7 ;
8251
8352-- should generate "no connection available" error
@@ -86,7 +55,7 @@ FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
8655WHERE t .a > 7 ;
8756
8857-- create a persistent connection
89- SELECT dblink_connect(' dbname=regression_slave ' );
58+ SELECT dblink_connect(' dbname=regression ' );
9059
9160-- use the persistent connection
9261SELECT *
@@ -124,29 +93,29 @@ WHERE t.a > 7;
12493
12594-- put more data into our slave table, first using arbitrary connection syntax
12695-- but truncate the actual return value so we can use diff to check for success
127- SELECT substr(dblink_exec(' dbname=regression_slave ' ,' SET autocommit TO' ' on' ' ;INSERT INTO foo VALUES(10,' ' k' ' ,' ' {"a10","b10","c10"}' ' )' ),1 ,6 );
96+ SELECT substr(dblink_exec(' dbname=regression ' ,' SET autocommit TO' ' on' ' ;INSERT INTO foo VALUES(10,' ' k' ' ,' ' {"a10","b10","c10"}' ' )' ),1 ,6 );
12897
12998-- create a persistent connection
130- SELECT dblink_connect(' dbname=regression_slave ' );
99+ SELECT dblink_connect(' dbname=regression ' );
131100
132101-- put more data into our slave table, using persistent connection syntax
133102-- but truncate the actual return value so we can use diff to check for success
134- SELECT substr(dblink_exec(' INSERT INTO foo VALUES(11,' ' l' ' ,' ' {"a11","b11","c11"}' ' )' ),1 ,6 );
103+ SELECT substr(dblink_exec(' SET autocommit TO ' ' on ' ' ; INSERT INTO foo VALUES(11,' ' l' ' ,' ' {"a11","b11","c11"}' ' )' ),1 ,6 );
135104
136105-- let's see it
137106SELECT *
138107FROM dblink(' SELECT * FROM foo' )AS t(aint , btext , ctext []);
139108
140109-- change some data
141- SELECT dblink_exec(' UPDATE foo SET f3[2] =' ' b99' ' WHERE f1 = 11' );
110+ SELECT dblink_exec(' SET autocommit TO ' ' on ' ' ; UPDATE foo SET f3[2] =' ' b99' ' WHERE f1 = 11' );
142111
143112-- let's see it
144113SELECT *
145114FROM dblink(' SELECT * FROM foo' )AS t(aint , btext , ctext [])
146115WHERE a= 11 ;
147116
148117-- delete some data
149- SELECT dblink_exec(' DELETE FROM foo WHERE f1 = 11' );
118+ SELECT dblink_exec(' SET autocommit TO ' ' on ' ' ; DELETE FROM foo WHERE f1 = 11' );
150119
151120-- let's see it
152121SELECT *