mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user