restauration : la section d'une base passe a psql par l'entree standard
postgres ne lit pas le repertoire jetable de root ; trouve en repetition sur data-sql-01 de Technolibre. Le test l'exige desormais. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8a9da0c31a
commit
515aac415a
3 changed files with 21 additions and 4 deletions
|
|
@ -127,11 +127,15 @@ esac
|
|||
""")
|
||||
# PostgreSQL : on journalise, on garde la section rejouee ; toute base est vierge.
|
||||
executable(bin_ / "runuser", '#!/bin/bash\nwhile [[ "$1" != "--" ]]; do shift; done; shift; exec "$@"\n')
|
||||
# Sans `-c`, psql lit la section sur son entree standard : c'est ainsi que l'outil
|
||||
# doit la lui passer (`postgres` ne lit pas le repertoire jetable de root).
|
||||
executable(bin_ / "psql", f"""#!/bin/bash
|
||||
echo "psql $*" >> "{log}/pg"
|
||||
avec_c=0
|
||||
while (( $# )); do
|
||||
case "$1" in -f) cp "$2" "{log}/section.sql"; shift 2;; -c) [[ "$2" == select* ]] && echo 0; shift 2;; *) shift;; esac
|
||||
case "$1" in -f) echo "psql -f INTERDIT" >> "{log}/pg"; shift 2;; -c) avec_c=1; [[ "$2" == select* ]] && echo 0; shift 2;; *) shift;; esac
|
||||
done
|
||||
if (( ! avec_c )); then cat > "{log}/section.sql"; fi
|
||||
""")
|
||||
executable(bin_ / "pg_dump", '#!/bin/bash\necho dump\n')
|
||||
executable(bin_ / "dropdb", f'#!/bin/bash\necho "dropdb $*" >> "{log}/pg"\n')
|
||||
|
|
@ -181,6 +185,7 @@ done
|
|||
"la section s'arrete avant le DROP DATABASE postgres, et ne deborde sur aucune autre base")
|
||||
pg = (log / "pg").read_text()
|
||||
verifier("--single-transaction" in pg, "la base est rejouee en une seule transaction")
|
||||
verifier("INTERDIT" not in pg, "la section passe par l'entree standard, jamais par `psql -f`")
|
||||
|
||||
r = lancer("base", "inexistante")
|
||||
verifier(r.returncode == 0 and "ABSENTE" in r.stdout, "une base absente de l'instantane est dite, pas inventee")
|
||||
|
|
|
|||
Loading…
Reference in a new issue