Project

General

Profile

« Previous | Next » 

Revision 2617

db_dump_localize: Use new pg_version

View differences:

bin/db_dump_localize
2 2
# Translates a PostgreSQL DB dump for the local server's version
3 3
# Usage: self {input...|<input} >translated
4 4

  
5
sedEreFlag="$(test "$(uname)" = Darwin && echo E || echo r)"
5
selfDir="$(dirname -- "$0")"
6 6

  
7
sed () { "$(which sed)" -"$sedEreFlag" "$@";}
8

  
9
pg_version="$(pg_dump --version|sed -n 's/^.* ([0-9]+).*$/\1/p')"
10 7
# PostgreSQL 9.x started putting plpgsql into template0, screwing everything up.
11 8
# We solve this by putting plpgsql in the dump so that versions before 9.x get
12 9
# it, and removing it when restoring to a 9.x server.
13
if test "$pg_version" -ge 9; then
10
if test "$("$selfDir/pg_version")" -ge 9; then
14 11
    grep -v -F 'CREATE PROCEDURAL LANGUAGE plpgsql;' "$@"
15 12
else cat "$@" # pass through
16 13
fi

Also available in: Unified diff