Project

General

Profile

1 10224 aaronmk
#!/bin/bash -e
2 4428 aaronmk
# Translates a MySQL data-only DB export to PostgreSQL
3
# The export must be created with:
4
# `--compatible=postgresql --add-locks=false --set-charset --no-create-info`
5
# Usage: self {input...|<input} >translated
6
7 10224 aaronmk
. "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/../lib/sh/util.sh
8 4428 aaronmk
9 5886 aaronmk
echo 'SET standard_conforming_strings = off;'
10 5887 aaronmk
echo 'SET escape_string_warning = off;'
11 4428 aaronmk
sed \
12 8002 aaronmk
-e 's/([^\\](\\\\)*)\\0/$10/g' \
13 4428 aaronmk
"$@"
14 8002 aaronmk
# \0 isn't allowed in UTF-8; note that \ is doubled for sed