diff options
| author | Peter Eisentraut <peter_e@gmx.net> | 2009-02-24 10:06:36 +0000 |
|---|---|---|
| committer | Peter Eisentraut <peter_e@gmx.net> | 2009-02-24 10:06:36 +0000 |
| commit | 7babccb91504fd4a958ff778547af1a8cbc1f8f2 (patch) | |
| tree | ce41105b1add6e2c61ae7acc8e3ee6c2175a41af /src/bin | |
| parent | f73bed308a8ccaea9082634f417966f7beb71614 (diff) | |
| download | postgresql-7babccb91504fd4a958ff778547af1a8cbc1f8f2.tar.gz | |
Add the possibility to specify an explicit validator function for foreign-data
wrappers (similar to procedural languages). This way we don't need to retain
the nearly empty libraries, and we are more free in how to implement the
wrapper API in the future.
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/pg_dump/pg_dump.c | 19 | ||||
| -rw-r--r-- | src/bin/pg_dump/pg_dump.h | 4 | ||||
| -rw-r--r-- | src/bin/psql/describe.c | 6 | ||||
| -rw-r--r-- | src/bin/psql/tab-complete.c | 11 |
4 files changed, 20 insertions, 20 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 824f2fb090..1e971bc37c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -12,7 +12,7 @@ * by PostgreSQL * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.524 2009/02/18 12:07:07 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.525 2009/02/24 10:06:33 petere Exp $ * *------------------------------------------------------------------------- */ @@ -5394,7 +5394,7 @@ getForeignDataWrappers(int *numForeignDataWrappers) int i_oid; int i_fdwname; int i_rolname; - int i_fdwlibrary; + int i_fdwvalidator; int i_fdwacl; int i_fdwoptions; @@ -5409,7 +5409,7 @@ getForeignDataWrappers(int *numForeignDataWrappers) selectSourceSchema("pg_catalog"); appendPQExpBuffer(query, "SELECT oid, fdwname, " - "(%s fdwowner) AS rolname, fdwlibrary, fdwacl," + "(%s fdwowner) AS rolname, fdwvalidator::pg_catalog.regproc, fdwacl," "array_to_string(ARRAY(" " SELECT option_name || ' ' || quote_literal(option_value) " " FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions " @@ -5427,7 +5427,7 @@ getForeignDataWrappers(int *numForeignDataWrappers) i_oid = PQfnumber(res, "oid"); i_fdwname = PQfnumber(res, "fdwname"); i_rolname = PQfnumber(res, "rolname"); - i_fdwlibrary = PQfnumber(res, "fdwlibrary"); + i_fdwvalidator = PQfnumber(res, "fdwvalidator"); i_fdwacl = PQfnumber(res, "fdwacl"); i_fdwoptions = PQfnumber(res, "fdwoptions"); @@ -5439,7 +5439,7 @@ getForeignDataWrappers(int *numForeignDataWrappers) fdwinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_fdwname)); fdwinfo[i].dobj.namespace = NULL; fdwinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); - fdwinfo[i].fdwlibrary = strdup(PQgetvalue(res, i, i_fdwlibrary)); + fdwinfo[i].fdwvalidator = strdup(PQgetvalue(res, i, i_fdwvalidator)); fdwinfo[i].fdwoptions = strdup(PQgetvalue(res, i, i_fdwoptions)); fdwinfo[i].fdwacl = strdup(PQgetvalue(res, i, i_fdwacl)); @@ -9308,8 +9308,13 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) q = createPQExpBuffer(); delq = createPQExpBuffer(); - appendPQExpBuffer(q, "CREATE FOREIGN DATA WRAPPER %s LIBRARY '%s' LANGUAGE C", - fmtId(fdwinfo->dobj.name), fdwinfo->fdwlibrary); + appendPQExpBuffer(q, "CREATE FOREIGN DATA WRAPPER %s", + fmtId(fdwinfo->dobj.name)); + + if (fdwinfo->fdwvalidator && strcmp(fdwinfo->fdwvalidator, "-") != 0) + appendPQExpBuffer(q, " VALIDATOR %s", + fdwinfo->fdwvalidator); + if (fdwinfo->fdwoptions && strlen(fdwinfo->fdwoptions) > 0) appendPQExpBuffer(q, " OPTIONS (%s)", fdwinfo->fdwoptions); diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 9a38645fd5..6c5e48f273 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.152 2009/02/18 12:07:07 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.153 2009/02/24 10:06:34 petere Exp $ * *------------------------------------------------------------------------- */ @@ -409,7 +409,7 @@ typedef struct _fdwInfo { DumpableObject dobj; char *rolname; - char *fdwlibrary; + char *fdwvalidator; char *fdwoptions; char *fdwacl; } FdwInfo; diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index beab9ca528..0cc52c8b71 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -8,7 +8,7 @@ * * Copyright (c) 2000-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.200 2009/02/23 15:59:55 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.201 2009/02/24 10:06:34 petere Exp $ */ #include "postgres_fe.h" @@ -2894,10 +2894,10 @@ listForeignDataWrappers(const char *pattern, bool verbose) printfPQExpBuffer(&buf, "SELECT fdwname AS \"%s\",\n" " pg_catalog.pg_get_userbyid(fdwowner) AS \"%s\",\n" - " fdwlibrary AS \"%s\"", + " fdwvalidator::pg_catalog.regproc AS \"%s\"", gettext_noop("Name"), gettext_noop("Owner"), - gettext_noop("Library")); + gettext_noop("Validator")); if (verbose) { diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index d4b977bd6d..363857542e 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.179 2009/01/01 17:23:55 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.180 2009/02/24 10:06:34 petere Exp $ */ /*---------------------------------------------------------------------- @@ -749,7 +749,7 @@ psql_completion(char *text, int start, int end) pg_strcasecmp(prev2_wd, "WRAPPER") == 0) { static const char *const list_ALTER_FDW[] = - {"LIBRARY", "OPTIONS", "OWNER TO", NULL}; + {"VALIDATOR", "OPTIONS", "OWNER TO", NULL}; COMPLETE_WITH_LIST(list_ALTER_FDW); } @@ -1258,12 +1258,7 @@ psql_completion(char *text, int start, int end) pg_strcasecmp(prev4_wd, "FOREIGN") == 0 && pg_strcasecmp(prev3_wd, "DATA") == 0 && pg_strcasecmp(prev2_wd, "WRAPPER") == 0) - COMPLETE_WITH_CONST("LIBRARY"); - - else if (pg_strcasecmp(prev5_wd, "DATA") == 0 && - pg_strcasecmp(prev4_wd, "WRAPPER") == 0 && - pg_strcasecmp(prev2_wd, "LIBRARY") == 0) - COMPLETE_WITH_CONST("LANGUAGE C"); + COMPLETE_WITH_CONST("VALIDATOR"); /* CREATE INDEX */ /* First off we complete CREATE UNIQUE with "INDEX" */ |
