Skip to content

Instantly share code, notes, and snippets.

@programble programble/repro.sh
Created Feb 20, 2015

Embed
What would you like to do?
Postgres dump view defined with VALUES drops column names (PostgreSQL 9.4.1 on Mac OS X 10.10.1 installed via Homebrew)
set -v
dropdb --if-exists repro
dropdb --if-exists repro-restore
createdb repro
createdb repro-restore
# Create a view with named columns defined with VALUES
psql repro -c "CREATE VIEW repro_view (my_column) AS VALUES (1);"
# Shows "my_column"
psql repro -c "SELECT * FROM repro_view;"
# Dumped CREATE VIEW statement is missing column names
pg_dump repro -t repro_view
# Restore dump to a new database
pg_dump repro | psql -X repro-restore
# Shows "column1"
psql repro-restore -c "SELECT * FROM repro_view;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.