Make pg_regress a tad simpler and more general-purpose by removing its

code to forcibly drop regressuser[1-4] and regressgroup[1-2].  Instead,
let the privileges.sql test do that for itself (this is made easy by
the recent addition of DROP ROLE IF EXISTS).  Per a recent patch proposed
by Joachim Wieland --- the rest of his patch is superseded by the
rewrite into C, but this is a good idea we should adopt.
This commit is contained in:
Tom Lane 2006-07-18 00:32:42 +00:00
parent 2256d299bb
commit 84e6042725
3 changed files with 29 additions and 13 deletions

View File

@ -1,6 +1,17 @@
--
-- Test access privileges
--
-- Clean up in case a prior regression run failed
-- Suppress NOTICE messages when users/groups don't exist
SET client_min_messages TO 'error';
DROP ROLE IF EXISTS regressgroup1;
DROP ROLE IF EXISTS regressgroup2;
DROP ROLE IF EXISTS regressuser1;
DROP ROLE IF EXISTS regressuser2;
DROP ROLE IF EXISTS regressuser3;
DROP ROLE IF EXISTS regressuser4;
RESET client_min_messages;
-- test proper begins here
CREATE USER regressuser1;
CREATE USER regressuser2;
CREATE USER regressuser3;

View File

@ -1,5 +1,5 @@
#! /bin/sh
# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.64 2006/01/05 03:01:38 momjian Exp $
# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.65 2006/07/18 00:32:41 tgl Exp $
me=`basename $0`
: ${TMPDIR=/tmp}
@ -555,18 +555,6 @@ if [ $? -ne 0 ]; then
fi
# ----------
# Remove regressuser* and regressgroup* user accounts.
# ----------
message "dropping regression test user accounts"
"$bindir/psql" -q -X $psql_options -c '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
fi
# ----------
# Install any requested PL languages
# ----------

View File

@ -2,6 +2,23 @@
-- Test access privileges
--
-- Clean up in case a prior regression run failed
-- Suppress NOTICE messages when users/groups don't exist
SET client_min_messages TO 'error';
DROP ROLE IF EXISTS regressgroup1;
DROP ROLE IF EXISTS regressgroup2;
DROP ROLE IF EXISTS regressuser1;
DROP ROLE IF EXISTS regressuser2;
DROP ROLE IF EXISTS regressuser3;
DROP ROLE IF EXISTS regressuser4;
RESET client_min_messages;
-- test proper begins here
CREATE USER regressuser1;
CREATE USER regressuser2;
CREATE USER regressuser3;