1 |
1934
|
aaronmk
|
#!/bin/sh
|
2 |
|
|
# Translates a PostgreSQL DB dump for the local server's version
|
3 |
|
|
# Usage: self {input...|<input} >translated
|
4 |
|
|
|
5 |
2617
|
aaronmk
|
selfDir="$(dirname -- "$0")"
|
6 |
1934
|
aaronmk
|
|
7 |
|
|
# PostgreSQL 9.x started putting plpgsql into template0, screwing everything up.
|
8 |
|
|
# We solve this by putting plpgsql in the dump so that versions before 9.x get
|
9 |
|
|
# it, and removing it when restoring to a 9.x server.
|
10 |
2617
|
aaronmk
|
if test "$("$selfDir/pg_version")" -ge 9; then
|
11 |
1934
|
aaronmk
|
grep -v -F 'CREATE PROCEDURAL LANGUAGE plpgsql;' "$@"
|
12 |
|
|
else cat "$@" # pass through
|
13 |
1935
|
aaronmk
|
fi
|