Git Product home page Git Product logo

dump_fdw's Introduction

Postgres Dump Foreign Data Wrapper

This extension implements a foreign data wrapper for PostgreSQL capable of querying data directly from files in PostgreSQL's custom dump format. This can be used to restore row-specific data.

Note. This has only been tested with PostgreSQL 9.1/9.2/9.3/9.4 and is currently a prototype. DO NOT RUN IT ON A PRODUCTION SERVER.

Introduction

This extension uses the PostgreSQL Custom Dump Format and brings the following benefits:

  • Analytics - Perform queries directly from your backups.
  • Selective Restore - Restore only the rows you need directly from your backups.

Building

Use the following commands to compile and install dump_fdw:

# To compile
USE_PGXS=1 make
USE_PGXS=1 make install

# To run the test
USE_PGXS=1 make installcheck

Example

As an example, we demonstrate querying data from the BookTown database (provided by Command Prompt, Inc.):

Log into Postgres, and run the following commands to install the FDW:

-- load extension first time after install
CREATE EXTENSION dump_fdw;

-- create server object
CREATE SERVER dump_server FOREIGN DATA WRAPPER dump_fdw;

Next, we create our foreign tables mapped to the pg_dump file:

-- create foreign table(s)
CREATE FOREIGN TABLE authors (
  id            INTEGER,
  last_name     TEXT,
  first_name    TEXT
) SERVER dump_server
  OPTIONS (
    file_name '/home/jharris/data/booktown.dmp',
    schema_name 'public',
    relation_name 'authors'
  )
;

CREATE FOREIGN TABLE books (
  id            INTEGER,
  title         TEXT,
  author_id     INTEGER,
  subject_id    INTEGER
) SERVER dump_server
  OPTIONS (
    file_name '/home/jharris/data/booktown.dmp',
    schema_name 'public',
    relation_name 'books'
  )
;

Finally, let's run an example SQL query on the dumped tables:

-- query the data
SELECT *
 FROM books b
 JOIN ONLY authors a
      ON (a.id = b.author_id)
ORDER BY b.id;

Uninstalling dump_fdw

Then you can drop the extension:

postgres=# DROP EXTENSION dump_fdw CASCADE;

Finally, to uninstall the extension you can run the following command in the extension's source code directory. This will clean up all the files copied during the installation:

$ USE_PGXS=1 make uninstall

Copyright

Foreign Data Wrapper

  • Copyright (c) 2015 MeetMe, Inc.

CSV Parser

License

The New BSD License. See LICENSE

dump_fdw's People

Contributors

jonahharris avatar theory avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.