Allow database dumps to be restored in test suite.

Primary fix is the search_path to ensure that the collection table
is in the search path so that the copy into dav_binding (and
possibly others) will work.

I also suppressed the warning about plpgsql.
This commit is contained in:
Andrew Ruthven 2018-11-12 18:00:30 +13:00
parent b0a1c9212d
commit 95ad5ec373
4 changed files with 25 additions and 4 deletions

View File

@ -140,7 +140,16 @@ restore_database() {
dump_database() {
TEST="Dump-Database"
pg_dump -Fp $PSQLOPTS ${DBNAME} > "${REGRESSION}/initial.dbdump" 2>&1
pg_dump -Fp $PSQLOPTS ${DBNAME} \
| grep -v -E '(CREATE\ EXTENSION|COMMENT\ ON)' \
> "${REGRESSION}/initial.dbdump" 2>&1
# This is ugly, for the COPY into dav_binding to work on Pg >= 9.6 (possibly earlier)
# we need to ensure that the schema that collection is in is within our search path
# since the function real_path_exists is called on each insert into dav_binding and
# it doesn't specify the schema for 'collection', therefore the copy fails.
schema=$(grep "CREATE TABLE .*.collection" "${REGRESSION}/initial.dbdump" | sed -r 's/CREATE TABLE (.*?)\.collection \(/\1/')
sed -i "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', '$schema', false);/" "${REGRESSION}/initial.dbdump"
}

View File

@ -1,4 +1,8 @@
psql:tests/binding/initial.dbdump:28: ERROR: must be owner of extension plpgsql
set_config
------------
public
(1 row)
setval
--------
1601

View File

@ -1,4 +1,8 @@
psql:tests/carddav/initial.dbdump:28: ERROR: must be owner of extension plpgsql
set_config
------------
public
(1 row)
setval
--------
1633

View File

@ -1,4 +1,8 @@
psql:tests/scheduling/initial.dbdump:28: ERROR: must be owner of extension plpgsql
set_config
------------
public
(1 row)
setval
--------
1648