mirror of
https://github.com/postgres/postgres.git
synced 2025-08-12 15:23:02 +03:00
Update handling of backslashes, and pg_user dump.
This commit is contained in:
@@ -4,22 +4,29 @@
|
|||||||
# dumps all databases to standard output
|
# dumps all databases to standard output
|
||||||
# It also dumps the pg_user table
|
# It also dumps the pg_user table
|
||||||
#
|
#
|
||||||
|
# to adapt to System V vs. BSD 'echo'
|
||||||
|
set -x
|
||||||
|
if echo '\\' | grep '\\\\' >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
BS='\' # BSD
|
||||||
|
else
|
||||||
|
BS='\\' # System V
|
||||||
|
fi
|
||||||
psql -l -A -q -t|cut -d"|" -f1 | grep -v '^template1$' | \
|
psql -l -A -q -t|cut -d"|" -f1 | grep -v '^template1$' | \
|
||||||
while read DATABASE
|
while read DATABASE
|
||||||
do
|
do
|
||||||
/bin/echo '\connect template1'
|
echo "${BS}connect template1"
|
||||||
/bin/echo "create database $DATABASE;"
|
echo "create database $DATABASE;"
|
||||||
/bin/echo '\connect' "$DATABASE"
|
echo "${BS}connect $DATABASE"
|
||||||
pg_dump "$@" $DATABASE
|
pg_dump "$@" $DATABASE
|
||||||
done
|
done
|
||||||
/bin/echo '\connect template1'
|
echo "${BS}connect template1"
|
||||||
/bin/echo 'copy pg_user from stdin;'
|
echo "copy pg_user from stdin;"
|
||||||
#
|
#
|
||||||
# Dump everyone but the postgres user
|
# Dump everyone but the postgres user
|
||||||
# initdb creates him
|
# initdb creates him
|
||||||
#
|
#
|
||||||
POSTGRES_SUPER_USER_ID="`psql -q template1 <<END
|
POSTGRES_SUPER_USER_ID="`psql -A -q -t template1 <<END
|
||||||
\\t
|
|
||||||
select datdba
|
select datdba
|
||||||
from pg_database
|
from pg_database
|
||||||
where datname = 'template1';
|
where datname = 'template1';
|
||||||
@@ -31,4 +38,4 @@ where usesysid <> $POSTGRES_SUPER_USER_ID;
|
|||||||
copy tmp_pg_user to stdout;
|
copy tmp_pg_user to stdout;
|
||||||
drop table tmp_pg_user;
|
drop table tmp_pg_user;
|
||||||
END
|
END
|
||||||
/bin/echo '\.'
|
echo "${BS}."
|
||||||
|
Reference in New Issue
Block a user