Thread: pgsql: Implement IMPORT FOREIGN SCHEMA.

pgsql: Implement IMPORT FOREIGN SCHEMA.

From
Tom Lane
Date:
Implement IMPORT FOREIGN SCHEMA.

This command provides an automated way to create foreign table definitions
that match remote tables, thereby reducing tedium and chances for error.
In this patch, we provide the necessary core-server infrastructure and
implement the feature fully in the postgres_fdw foreign-data wrapper.
Other wrappers will throw a "feature not supported" error until/unless
they are updated.

Ronan Dunklau and Michael Paquier, additional work by me

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/59efda3e50ca4de6a9d5aa4491464e22b6329b1e

Modified Files
--------------
contrib/postgres_fdw/deparse.c                 |    3 +-
contrib/postgres_fdw/expected/postgres_fdw.out |  230 ++++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c            |  269 ++++++++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.h            |    1 +
contrib/postgres_fdw/sql/postgres_fdw.sql      |   57 +++++
doc/src/sgml/ddl.sgml                          |    5 +-
doc/src/sgml/event-trigger.sgml                |    6 +
doc/src/sgml/fdwhandler.sgml                   |   60 ++++++
doc/src/sgml/postgres-fdw.sgml                 |   75 ++++++-
doc/src/sgml/ref/allfiles.sgml                 |    1 +
doc/src/sgml/ref/create_foreign_table.sgml     |    1 +
doc/src/sgml/ref/import_foreign_schema.sgml    |  168 +++++++++++++++
doc/src/sgml/reference.sgml                    |    1 +
src/backend/commands/event_trigger.c           |    3 +-
src/backend/commands/foreigncmds.c             |  144 ++++++++++++-
src/backend/foreign/foreign.c                  |   41 ++++
src/backend/nodes/copyfuncs.c                  |   18 ++
src/backend/nodes/equalfuncs.c                 |   16 ++
src/backend/nodes/outfuncs.c                   |   16 ++
src/backend/parser/gram.y                      |   64 +++++-
src/backend/tcop/utility.c                     |   10 +
src/bin/psql/tab-complete.c                    |   12 +-
src/include/commands/defrem.h                  |    1 +
src/include/foreign/fdwapi.h                   |    8 +
src/include/nodes/nodes.h                      |    1 +
src/include/nodes/parsenodes.h                 |   25 ++-
src/include/parser/kwlist.h                    |    1 +
src/test/regress/expected/foreign_data.out     |   10 +
src/test/regress/sql/foreign_data.sql          |    7 +
29 files changed, 1239 insertions(+), 15 deletions(-)