]> granicus.if.org Git - postgresql/commitdiff
Make regression tests safe for autocommit = 'off'.
authorBruce Momjian <bruce@momjian.us>
Sat, 19 Oct 2002 01:35:43 +0000 (01:35 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 19 Oct 2002 01:35:43 +0000 (01:35 +0000)
src/test/regress/expected/alter_table.out
src/test/regress/expected/copy2.out
src/test/regress/expected/domain.out
src/test/regress/expected/privileges.out
src/test/regress/expected/temp.out
src/test/regress/pg_regress.sh
src/test/regress/sql/alter_table.sql
src/test/regress/sql/copy2.sql
src/test/regress/sql/domain.sql
src/test/regress/sql/privileges.sql
src/test/regress/sql/temp.sql

index f604c1c0dd0ddac5dc29f882e7911d1763c81a46..4d61811045846ff63aecb296058e67f61d965ee3 100644 (file)
@@ -993,6 +993,7 @@ ERROR:  Relation "test" has no column "........pg.dropped.1........"
 copy test from stdin;
 ERROR:  copy: line 1, Extra data after last expected column
 lost synchronization with server, resetting connection
+SET autocommit TO 'on';
 select * from test;
  b | c 
 ---+---
index a0241313108068150c60aecd51cdbb5aeb36704b..cf28af8c198de5b26392bd50ce7e463df5eb3d75 100644 (file)
@@ -46,6 +46,7 @@ lost synchronization with server, resetting connection
 COPY x from stdin;
 ERROR:  copy: line 1, Extra data after last expected column
 lost synchronization with server, resetting connection
+SET autocommit TO 'on';
 -- various COPY options: delimiters, oids, NULL string
 COPY x (b, c, d, e) from stdin with oids delimiter ',' null 'x';
 -- check results of copy in
index 79953d472c53c9e5d773c242f010f21ef9116201..e82ce6fdf08ecf2a95cb92096130db68c95a7c5e 100644 (file)
@@ -41,6 +41,7 @@ INSERT INTO basictest values ('88', 'haha', 'short', '123.1212');    -- Truncate
 COPY basictest (testvarchar) FROM stdin; -- fail
 ERROR:  copy: line 1, value too long for type character varying(5)
 lost synchronization with server, resetting connection
+SET autocommit TO 'on';
 COPY basictest (testvarchar) FROM stdin;
 select * from basictest;
  testint4 | testtext | testvarchar | testnumeric 
@@ -122,6 +123,7 @@ INSERT INTO nulltest values ('a', 'b', 'c', NULL); -- Good
 COPY nulltest FROM stdin; --fail
 ERROR:  copy: line 1, CopyFrom: Fail to add null value in not null attribute col3
 lost synchronization with server, resetting connection
+SET autocommit TO 'on';
 COPY nulltest FROM stdin;
 select * from nulltest;
  col1 | col2 | col3 | col4 
index 092b8e2e77a74f2d4ca67d357368ce967a1aa295..c962879e40b64de636a44f685047c1df249cb635 100644 (file)
@@ -220,6 +220,7 @@ ERROR:  atest2: permission denied
 -- privileges on functions, languages
 -- switch to superuser
 \c -
+SET autocommit TO 'on';
 REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
 GRANT USAGE ON LANGUAGE sql TO regressuser1; -- ok
 GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
@@ -270,6 +271,7 @@ SELECT testfunc1(5); -- ok
 DROP FUNCTION testfunc1(int); -- fail
 ERROR:  testfunc1: must be owner
 \c -
+SET autocommit TO 'on';
 DROP FUNCTION testfunc1(int); -- ok
 -- restore to sanity
 GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
@@ -293,6 +295,7 @@ select has_table_privilege(1,'rule');
 ERROR:  pg_class_aclcheck: relation 1 not found
 -- superuser
 \c -
+SET autocommit TO 'on';
 select has_table_privilege(current_user,'pg_shadow','select');
  has_table_privilege 
 ---------------------
@@ -543,6 +546,7 @@ from (select oid from pg_class where relname = 'atest1') as t1;
 
 -- clean up
 \c regression
+SET autocommit TO 'on';
 DROP FUNCTION testfunc2(int);
 DROP FUNCTION testfunc4(boolean);
 DROP VIEW atestv1;
index a3a583ec624a71a6fd46e0c3bc14cbb33b78a85b..1800b9ebe561f77512614bb8d7027267a410e25b 100644 (file)
@@ -33,5 +33,6 @@ DROP TABLE temptest;
 CREATE TEMP TABLE temptest(col int);
 -- test temp table deletion
 \c regression
+SET autocommit TO 'on';
 SELECT * FROM temptest;
 ERROR:  Relation "temptest" does not exist
index c700791a544aa4b9020610fe6e59496517f752d5..cfc6275a3d1c71cd5d92dbda597e971b66b04f69 100644 (file)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.27 2002/09/04 18:04:57 petere Exp $
+# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.28 2002/10/19 01:35:43 momjian Exp $
 
 me=`basename $0`
 : ${TMPDIR=/tmp}
@@ -420,7 +420,7 @@ fi
 # Set up SQL shell for the test.
 # ----------
 
-PSQL="$bindir/psql -a -q -X $psql_options"
+PSQL="$bindir/psql -q -X $psql_options"
 
 
 # ----------
@@ -473,7 +473,7 @@ fi
 # ----------
 
 message "dropping regression test user accounts"
-"$bindir/psql" $psql_options -c 'drop group regressgroup1; drop group regressgroup2; drop user regressuser1, regressuser2, regressuser3, regressuser4;' $dbname 2>/dev/null
+"$bindir/psql" $psql_options -c 'SET autocommit TO on;DROP GROUP regressgroup1; DROP GROUP regressgroup2; DROP USER regressuser1, regressuser2, regressuser3, regressuser4;' $dbname 2>/dev/null
 if [ $? -eq 2 ]; then
     echo "$me: could not drop user accounts"
     (exit 2); exit
@@ -545,12 +545,17 @@ do
         formatted=`echo $1 | awk '{printf "%-20.20s", $1;}'`
         $ECHO_N "test $formatted ... $ECHO_C"
 
-        $PSQL -d "$dbname" <"$inputdir/sql/$1.sql" >"$outputdir/results/$1.out" 2>&1
+       # use awk to properly output backslashes
+        (echo "SET autocommit TO 'on';"; awk 'BEGIN {printf "\\set ECHO all\n"}'; cat "$inputdir/sql/$1.sql") |
+        $PSQL -d "$dbname" >"$outputdir/results/$1.out" 2>&1
     else
         # Start a parallel group
         $ECHO_N "parallel group ($# tests): $ECHO_C"
         for name do
-            ( $PSQL -d $dbname <"$inputdir/sql/$name.sql" >"$outputdir/results/$name.out" 2>&1
+            ( 
+             # use awk to properly output backslashes
+              (echo "SET autocommit TO 'on';"; awk 'BEGIN {printf "\\set ECHO all\n"}'; cat "$inputdir/sql/$name.sql") |
+             $PSQL -d $dbname >"$outputdir/results/$name.out" 2>&1
               $ECHO_N " $name$ECHO_C"
             ) &
         done
index b74df5a725681982ec94b532d9337ac52cb4c050..7fcfb09df2b4f2246ee7f9f954420c4d873fe4f8 100644 (file)
@@ -718,6 +718,7 @@ copy test("........pg.dropped.1........") to stdout;
 copy test from stdin;
 10     11      12
 \.
+SET autocommit TO 'on';
 select * from test;
 copy test from stdin;
 21     22
index 72c52dba11363f0a4cc6df255b24a03075be0855..b036cb1b7f947e5b4676f7323459956e9876ba3e 100644 (file)
@@ -71,6 +71,7 @@ COPY x from stdin;
 2002   232     40      50      60      70      80
 \.
 
+SET autocommit TO 'on';
 -- various COPY options: delimiters, oids, NULL string
 COPY x (b, c, d, e) from stdin with oids delimiter ',' null 'x';
 500000,x,45,80,90
index 98ed4248cc0b509a2d573345a631a3c6c712ead4..4d210cd4aa7fcbd2e9b83c0d0ebb8aaa57d4f612 100644 (file)
@@ -41,6 +41,8 @@ COPY basictest (testvarchar) FROM stdin; -- fail
 notsoshorttext
 \.
 
+SET autocommit TO 'on';
+
 COPY basictest (testvarchar) FROM stdin;
 short
 \.
@@ -100,6 +102,8 @@ COPY nulltest FROM stdin; --fail
 a      b       \N      d
 \.
 
+SET autocommit TO 'on';
+
 COPY nulltest FROM stdin;
 a      b       c       \N
 \.
index 95e5c14f1a9e8fe1834a707311072590749e74f2..1d1bde3bddc55487fdf6378d820205a2ab9bb370 100644 (file)
@@ -147,6 +147,8 @@ SELECT * FROM atestv2; -- fail (even though regressuser2 can access underlying a
 
 -- switch to superuser
 \c -
+SET autocommit TO 'on';
+
 REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
 GRANT USAGE ON LANGUAGE sql TO regressuser1; -- ok
 GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
@@ -182,6 +184,8 @@ SELECT testfunc1(5); -- ok
 DROP FUNCTION testfunc1(int); -- fail
 
 \c -
+SET autocommit TO 'on';
+
 DROP FUNCTION testfunc1(int); -- ok
 -- restore to sanity
 GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
@@ -199,6 +203,8 @@ select has_table_privilege(1,'rule');
 
 -- superuser
 \c -
+SET autocommit TO 'on';
+
 select has_table_privilege(current_user,'pg_shadow','select');
 select has_table_privilege(current_user,'pg_shadow','insert');
 
@@ -290,6 +296,8 @@ from (select oid from pg_class where relname = 'atest1') as t1;
 -- clean up
 
 \c regression
+SET autocommit TO 'on';
+
 DROP FUNCTION testfunc2(int);
 DROP FUNCTION testfunc4(boolean);
 
index 8033405ff982793d6d5bec6f174282b70dda7369..6f45b2eaac772eaa4d78e0e9c15121c9292712c6 100644 (file)
@@ -44,6 +44,7 @@ CREATE TEMP TABLE temptest(col int);
 -- test temp table deletion
 
 \c regression
+SET autocommit TO 'on';
 
 SELECT * FROM temptest;