Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5c6a5fe

Browse files
committed
Make regression tests safe for autocommit = 'off'.
1 parent5a0a79d commit5c6a5fe

File tree

11 files changed

+34
-5
lines changed

11 files changed

+34
-5
lines changed

‎src/test/regress/expected/alter_table.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ ERROR: Relation "test" has no column "........pg.dropped.1........"
993993
copy test from stdin;
994994
ERROR: copy: line 1, Extra data after last expected column
995995
lost synchronization with server, resetting connection
996+
SET autocommit TO 'on';
996997
select * from test;
997998
b | c
998999
---+---

‎src/test/regress/expected/copy2.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ lost synchronization with server, resetting connection
4646
COPY x from stdin;
4747
ERROR: copy: line 1, Extra data after last expected column
4848
lost synchronization with server, resetting connection
49+
SET autocommit TO 'on';
4950
-- various COPY options: delimiters, oids, NULL string
5051
COPY x (b, c, d, e) from stdin with oids delimiter ',' null 'x';
5152
-- check results of copy in

‎src/test/regress/expected/domain.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ INSERT INTO basictest values ('88', 'haha', 'short', '123.1212'); -- Truncate
4141
COPY basictest (testvarchar) FROM stdin; -- fail
4242
ERROR: copy: line 1, value too long for type character varying(5)
4343
lost synchronization with server, resetting connection
44+
SET autocommit TO 'on';
4445
COPY basictest (testvarchar) FROM stdin;
4546
select * from basictest;
4647
testint4 | testtext | testvarchar | testnumeric
@@ -122,6 +123,7 @@ INSERT INTO nulltest values ('a', 'b', 'c', NULL); -- Good
122123
COPY nulltest FROM stdin; --fail
123124
ERROR: copy: line 1, CopyFrom: Fail to add null value in not null attribute col3
124125
lost synchronization with server, resetting connection
126+
SET autocommit TO 'on';
125127
COPY nulltest FROM stdin;
126128
select * from nulltest;
127129
col1 | col2 | col3 | col4

‎src/test/regress/expected/privileges.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ ERROR: atest2: permission denied
220220
-- privileges on functions, languages
221221
-- switch to superuser
222222
\c -
223+
SET autocommit TO 'on';
223224
REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
224225
GRANT USAGE ON LANGUAGE sql TO regressuser1; -- ok
225226
GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
@@ -270,6 +271,7 @@ SELECT testfunc1(5); -- ok
270271
DROP FUNCTION testfunc1(int); -- fail
271272
ERROR: testfunc1: must be owner
272273
\c -
274+
SET autocommit TO 'on';
273275
DROP FUNCTION testfunc1(int); -- ok
274276
-- restore to sanity
275277
GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
@@ -293,6 +295,7 @@ select has_table_privilege(1,'rule');
293295
ERROR: pg_class_aclcheck: relation 1 not found
294296
-- superuser
295297
\c -
298+
SET autocommit TO 'on';
296299
select has_table_privilege(current_user,'pg_shadow','select');
297300
has_table_privilege
298301
---------------------
@@ -543,6 +546,7 @@ from (select oid from pg_class where relname = 'atest1') as t1;
543546

544547
-- clean up
545548
\c regression
549+
SET autocommit TO 'on';
546550
DROP FUNCTION testfunc2(int);
547551
DROP FUNCTION testfunc4(boolean);
548552
DROP VIEW atestv1;

‎src/test/regress/expected/temp.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ DROP TABLE temptest;
3333
CREATE TEMP TABLE temptest(col int);
3434
-- test temp table deletion
3535
\c regression
36+
SET autocommit TO 'on';
3637
SELECT * FROM temptest;
3738
ERROR: Relation "temptest" does not exist

‎src/test/regress/pg_regress.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.27 2002/09/04 18:04:57 petere Exp $
2+
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.28 2002/10/19 01:35:43 momjian Exp $
33

44
me=`basename$0`
55
:${TMPDIR=/tmp}
@@ -420,7 +420,7 @@ fi
420420
# Set up SQL shell for the test.
421421
# ----------
422422

423-
PSQL="$bindir/psql -a -q -X$psql_options"
423+
PSQL="$bindir/psql -q -X$psql_options"
424424

425425

426426
# ----------
@@ -473,7 +473,7 @@ fi
473473
# ----------
474474

475475
message"dropping regression test user accounts"
476-
"$bindir/psql"$psql_options -c'drop groupregressgroup1;drop group regressgroup2;drop user regressuser1, regressuser2, regressuser3, regressuser4;'$dbname2>/dev/null
476+
"$bindir/psql"$psql_options -c'SET autocommit TO on;DROP GROUPregressgroup1;DROP GROUP regressgroup2;DROP USER regressuser1, regressuser2, regressuser3, regressuser4;'$dbname2>/dev/null
477477
if [$?-eq 2 ];then
478478
echo"$me: could not drop user accounts"
479479
(exit 2);exit
@@ -545,12 +545,17 @@ do
545545
formatted=`echo$1| awk'{printf "%-20.20s", $1;}'`
546546
$ECHO_N"test$formatted ...$ECHO_C"
547547

548-
$PSQL -d"$dbname"<"$inputdir/sql/$1.sql">"$outputdir/results/$1.out"2>&1
548+
# use awk to properly output backslashes
549+
(echo"SET autocommit TO 'on';"; awk'BEGIN {printf "\\set ECHO all\n"}'; cat"$inputdir/sql/$1.sql")|
550+
$PSQL -d"$dbname">"$outputdir/results/$1.out"2>&1
549551
else
550552
# Start a parallel group
551553
$ECHO_N"parallel group ($# tests):$ECHO_C"
552554
for namedo
553-
($PSQL -d$dbname<"$inputdir/sql/$name.sql">"$outputdir/results/$name.out"2>&1
555+
(
556+
# use awk to properly output backslashes
557+
(echo"SET autocommit TO 'on';"; awk'BEGIN {printf "\\set ECHO all\n"}'; cat"$inputdir/sql/$name.sql")|
558+
$PSQL -d$dbname>"$outputdir/results/$name.out"2>&1
554559
$ECHO_N"$name$ECHO_C"
555560
)&
556561
done

‎src/test/regress/sql/alter_table.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ copy test("........pg.dropped.1........") to stdout;
718718
copy testfrom stdin;
719719
101112
720720
\.
721+
SET autocommit TO'on';
721722
select*from test;
722723
copy testfrom stdin;
723724
2122

‎src/test/regress/sql/copy2.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ COPY x from stdin;
7171
20022324050607080
7272
\.
7373

74+
SET autocommit TO'on';
7475
-- various COPY options: delimiters, oids, NULL string
7576
COPY x (b, c, d, e)from stdin with oids delimiter','null'x';
7677
500000,x,45,80,90

‎src/test/regress/sql/domain.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ COPY basictest (testvarchar) FROM stdin; -- fail
4141
notsoshorttext
4242
\.
4343

44+
SET autocommit TO'on';
45+
4446
COPY basictest (testvarchar)FROM stdin;
4547
short
4648
\.
@@ -100,6 +102,8 @@ COPY nulltest FROM stdin; --fail
100102
ab\Nd
101103
\.
102104

105+
SET autocommit TO'on';
106+
103107
COPY nulltestFROM stdin;
104108
abc\N
105109
\.

‎src/test/regress/sql/privileges.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ SELECT * FROM atestv2; -- fail (even though regressuser2 can access underlying a
147147

148148
-- switch to superuser
149149
\c-
150+
SET autocommit TO'on';
151+
150152
REVOKE ALL PRIVILEGESON LANGUAGE sqlFROM PUBLIC;
151153
GRANT USAGEON LANGUAGE sql TO regressuser1;-- ok
152154
GRANT USAGEON LANGUAGE c TO PUBLIC;-- fail
@@ -182,6 +184,8 @@ SELECT testfunc1(5); -- ok
182184
DROPFUNCTION testfunc1(int);-- fail
183185

184186
\c-
187+
SET autocommit TO'on';
188+
185189
DROPFUNCTION testfunc1(int);-- ok
186190
-- restore to sanity
187191
GRANT ALL PRIVILEGESON LANGUAGE sql TO PUBLIC;
@@ -199,6 +203,8 @@ select has_table_privilege(1,'rule');
199203

200204
-- superuser
201205
\c-
206+
SET autocommit TO'on';
207+
202208
select has_table_privilege(current_user,'pg_shadow','select');
203209
select has_table_privilege(current_user,'pg_shadow','insert');
204210

@@ -290,6 +296,8 @@ from (select oid from pg_class where relname = 'atest1') as t1;
290296
-- clean up
291297

292298
\c regression
299+
SET autocommit TO'on';
300+
293301
DROPFUNCTION testfunc2(int);
294302
DROPFUNCTION testfunc4(boolean);
295303

‎src/test/regress/sql/temp.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ CREATE TEMP TABLE temptest(col int);
4444
-- test temp table deletion
4545

4646
\c regression
47+
SET autocommit TO'on';
4748

4849
SELECT*FROM temptest;
4950

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp