Commit 327e0250 authored by Tom Lane's avatar Tom Lane

Create the catalog infrastructure for foreign-data-wrapper handlers.

Add a fdwhandler column to pg_foreign_data_wrapper, plus HANDLER options
in the CREATE FOREIGN DATA WRAPPER and ALTER FOREIGN DATA WRAPPER commands,
plus pg_dump support for same.  Also invent a new pseudotype fdw_handler
with properties similar to language_handler.

This is split out of the "FDW API" patch for ease of review; it's all stuff
we will certainly need, regardless of any other details of the FDW API.
FDW handler functions will not actually get called yet.

In passing, fix some omissions and infelicities in foreigncmds.c.

Shigeru Hanada, Jan Urbanski, Heikki Linnakangas
parent 4077980d
......@@ -3031,16 +3031,27 @@
<entry>Owner of the foreign-data wrapper</entry>
</row>
<row>
<entry><structfield>fdwhandler</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
<entry>
References a handler function that is responsible for
supplying execution routines for the foreign-data wrapper.
Zero if no handler is provided
</entry>
</row>
<row>
<entry><structfield>fdwvalidator</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
<entry>
References a validator function that is responsible for
checking the validity of the generic options given to the
foreign-data wrapper, as well as to foreign servers and user
checking the validity of the options given to the
foreign-data wrapper, as well as options for foreign servers and user
mappings using the foreign-data wrapper. Zero if no validator
is provided.
is provided
</entry>
</row>
......@@ -3079,8 +3090,8 @@
<para>
The catalog <structname>pg_foreign_server</structname> stores
foreign server definitions. A foreign server describes the
connection to a remote server, managing external data. Foreign
foreign server definitions. A foreign server describes a source
of external data, such as a remote server. Foreign
servers are accessed via foreign-data wrappers.
</para>
......@@ -3116,7 +3127,7 @@
<entry><structfield>srvfdw</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-foreign-data-wrapper"><structname>pg_foreign_data_wrapper</structname></link>.oid</literal></entry>
<entry>The OID of the foreign-data wrapper of this foreign server</entry>
<entry>OID of the foreign-data wrapper of this foreign server</entry>
</row>
<row>
......@@ -3167,9 +3178,12 @@
</indexterm>
<para>
The catalog <structname>pg_foreign_table</structname> contains part
of the information about foreign tables.
The rest is mostly in <structname>pg_class</structname>.
The catalog <structname>pg_foreign_table</structname> contains
auxiliary information about foreign tables. A foreign table is
primarily represented by a <structname>pg_class</structname> entry,
just like a regular table. Its <structname>pg_foreign_table</structname>
entry contains the information that is pertinent only to foreign tables
and not any other kind of relation.
</para>
<table>
......@@ -3190,14 +3204,14 @@
<entry><structfield>ftrelid</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
<entry>The OID of the <structname>pg_class</> entry for this foreign table</entry>
<entry>OID of the <structname>pg_class</> entry for this foreign table</entry>
</row>
<row>
<entry><structfield>ftserver</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-foreign-server"><structname>pg_foreign_server</structname></link>.oid</literal></entry>
<entry>The OID of the foreign server for this foreign table</entry>
<entry>OID of the foreign server for this foreign table</entry>
</row>
<row>
......@@ -3205,7 +3219,7 @@
<entry><type>text[]</type></entry>
<entry></entry>
<entry>
Foreign table options, as <quote>keyword=value</> strings.
Foreign table options, as <quote>keyword=value</> strings
</entry>
</row>
</tbody>
......
......@@ -4431,6 +4431,10 @@ SELECT * FROM pg_attribute
<primary>language_handler</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>fdw_handler</primary>
</indexterm>
<indexterm zone="datatype-pseudo">
<primary>cstring</primary>
</indexterm>
......@@ -4513,6 +4517,11 @@ SELECT * FROM pg_attribute
<entry>A procedural language call handler is declared to return <type>language_handler</>.</entry>
</row>
<row>
<entry><type>fdw_handler</></entry>
<entry>A foreign-data wrapper handler is declared to return <type>fdw_handler</>.</entry>
</row>
<row>
<entry><type>record</></entry>
<entry>Identifies a function returning an unspecified row type.</entry>
......
......@@ -22,7 +22,8 @@ PostgreSQL documentation
<refsynopsisdiv>
<synopsis>
ALTER FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
[ VALIDATOR <replaceable class="parameter">valfunction</replaceable> | NO VALIDATOR ]
[ HANDLER <replaceable class="parameter">handler_function</replaceable> | NO HANDLER ]
[ VALIDATOR <replaceable class="parameter">validator_function</replaceable> | NO VALIDATOR ]
[ OPTIONS ( [ ADD | SET | DROP ] <replaceable class="PARAMETER">option</replaceable> ['<replaceable class="PARAMETER">value</replaceable>'] [, ... ]) ]
ALTER FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable> OWNER TO <replaceable>new_owner</replaceable>
</synopsis>
......@@ -34,7 +35,7 @@ ALTER FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable> OWN
<para>
<command>ALTER FOREIGN DATA WRAPPER</command> changes the
definition of a foreign-data wrapper. The first form of the
command changes the library or the generic options of the
command changes the support functions or the generic options of the
foreign-data wrapper (at least one clause is required). The second
form changes the owner of the foreign-data wrapper.
</para>
......@@ -59,10 +60,33 @@ ALTER FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable> OWN
</varlistentry>
<varlistentry>
<term><literal>VALIDATOR <replaceable class="parameter">valfunction</replaceable></literal></term>
<term><literal>HANDLER <replaceable class="parameter">handler_function</replaceable></literal></term>
<listitem>
<para>
Specifies a new foreign-data wrapper validator function.
Specifies a new handler function for the foreign-data wrapper.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>NO HANDLER</literal></term>
<listitem>
<para>
This is used to specify that the foreign-data wrapper should no
longer have a handler function.
</para>
<para>
Note that foreign tables that use a foreign-data wrapper with no
handler cannot be accessed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>VALIDATOR <replaceable class="parameter">validator_function</replaceable></literal></term>
<listitem>
<para>
Specifies a new validator function for the foreign-data wrapper.
</para>
<para>
......@@ -94,7 +118,7 @@ ALTER FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable> OWN
specify the action to be performed. <literal>ADD</> is assumed
if no operation is explicitly specified. Option names must be
unique; names and values are also validated using the foreign
data wrapper library.
data wrapper's validator function, if any.
</para>
</listitem>
</varlistentry>
......@@ -126,9 +150,8 @@ ALTER FOREIGN DATA WRAPPER dbi VALIDATOR bob.myvalidator;
<para>
<command>ALTER FOREIGN DATA WRAPPER</command> conforms to ISO/IEC
9075-9 (SQL/MED). The standard does not specify the <literal>
VALIDATOR</literal> and <literal>OWNER TO</> variants of the
command.
9075-9 (SQL/MED), except that the <literal>HANDLER</literal>,
<literal>VALIDATOR</> and <literal>OWNER TO</> clauses are extensions.
</para>
</refsect1>
......
......@@ -22,7 +22,8 @@ PostgreSQL documentation
<refsynopsisdiv>
<synopsis>
CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
[ VALIDATOR <replaceable class="parameter">valfunction</replaceable> | NO VALIDATOR ]
[ HANDLER <replaceable class="parameter">handler_function</replaceable> | NO HANDLER ]
[ VALIDATOR <replaceable class="parameter">validator_function</replaceable> | NO VALIDATOR ]
[ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] ) ]
</synopsis>
</refsynopsisdiv>
......@@ -59,13 +60,32 @@ CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
</varlistentry>
<varlistentry>
<term><literal>VALIDATOR <replaceable class="parameter">valfunction</replaceable></literal></term>
<term><literal>HANDLER <replaceable class="parameter">handler_function</replaceable></literal></term>
<listitem>
<para>
<replaceable class="parameter">valfunction</replaceable> is the
<replaceable class="parameter">handler_function</replaceable> is the
name of a previously registered function that will be called to
retrieve the execution functions for foreign tables.
The handler function must take no arguments, and
its return type must be <type>fdw_handler</type>.
</para>
<para>
It is possible to create a foreign-data wrapper with no handler
function, but foreign tables using such a wrapper can only be declared,
not accessed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>VALIDATOR <replaceable class="parameter">validator_function</replaceable></literal></term>
<listitem>
<para>
<replaceable class="parameter">validator_function</replaceable> is the
name of a previously registered function that will be called to
check the generic options given to the foreign-data wrapper, as
well as to foreign servers and user mappings using the
well as options for foreign servers and user mappings using the
foreign-data wrapper. If no validator function or <literal>NO
VALIDATOR</literal> is specified, then options will not be
checked at creation time. (Foreign-data wrappers will possibly
......@@ -75,8 +95,8 @@ CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
contain the array of options as stored in the system catalogs,
and one of type <type>oid</type>, which will be the OID of the
system catalog containing the options. The return type is ignored;
the function should indicate invalid options using the
<function>ereport()</function> function.
the function should report invalid options using the
<function>ereport(ERROR)</function> function.
</para>
</listitem>
</varlistentry>
......@@ -87,8 +107,8 @@ CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
<para>
This clause specifies options for the new foreign-data wrapper.
The allowed option names and values are specific to each foreign
data wrapper and are validated using the foreign-data wrapper
library. Option names must be unique.
data wrapper and are validated using the foreign-data wrapper's
validator function. Option names must be unique.
</para>
</listitem>
</varlistentry>
......@@ -122,17 +142,17 @@ CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
<title>Examples</title>
<para>
Create a foreign-data wrapper <literal>dummy</>:
Create a useless foreign-data wrapper <literal>dummy</>:
<programlisting>
CREATE FOREIGN DATA WRAPPER dummy;
</programlisting>
</para>
<para>
Create a foreign-data wrapper <literal>postgresql</> with
validator function <literal>postgresql_fdw_validator</>:
Create a foreign-data wrapper <literal>file</> with
handler function <literal>file_fdw_handler</>:
<programlisting>
CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator;
CREATE FOREIGN DATA WRAPPER file HANDLER file_fdw_handler;
</programlisting>
</para>
......@@ -151,10 +171,10 @@ CREATE FOREIGN DATA WRAPPER mywrapper
<para>
<command>CREATE FOREIGN DATA WRAPPER</command> conforms to ISO/IEC
9075-9 (SQL/MED), with the exception that
the <literal>VALIDATOR</literal> clause is an extension and the
9075-9 (SQL/MED), with the exception that the <literal>HANDLER</literal>
and <literal>VALIDATOR</literal> clauses are extensions and the standard
clauses <literal>LIBRARY</literal> and <literal>LANGUAGE</literal>
are not yet implemented in PostgreSQL.
are not implemented in PostgreSQL.
</para>
<para>
......
This diff is collapsed.
......@@ -58,6 +58,7 @@ GetForeignDataWrapper(Oid fdwid)
fdw->fdwid = fdwid;
fdw->owner = fdwform->fdwowner;
fdw->fdwname = pstrdup(NameStr(fdwform->fdwname));
fdw->fdwhandler = fdwform->fdwhandler;
fdw->fdwvalidator = fdwform->fdwvalidator;
/* Extract the options */
......
......@@ -3282,7 +3282,7 @@ _copyCreateFdwStmt(CreateFdwStmt *from)
CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
COPY_STRING_FIELD(fdwname);
COPY_NODE_FIELD(validator);
COPY_NODE_FIELD(func_options);
COPY_NODE_FIELD(options);
return newnode;
......@@ -3294,8 +3294,7 @@ _copyAlterFdwStmt(AlterFdwStmt *from)
AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
COPY_STRING_FIELD(fdwname);
COPY_NODE_FIELD(validator);
COPY_SCALAR_FIELD(change_validator);
COPY_NODE_FIELD(func_options);
COPY_NODE_FIELD(options);
return newnode;
......
......@@ -1679,7 +1679,7 @@ static bool
_equalCreateFdwStmt(CreateFdwStmt *a, CreateFdwStmt *b)
{
COMPARE_STRING_FIELD(fdwname);
COMPARE_NODE_FIELD(validator);
COMPARE_NODE_FIELD(func_options);
COMPARE_NODE_FIELD(options);
return true;
......@@ -1689,8 +1689,7 @@ static bool
_equalAlterFdwStmt(AlterFdwStmt *a, AlterFdwStmt *b)
{
COMPARE_STRING_FIELD(fdwname);
COMPARE_NODE_FIELD(validator);
COMPARE_SCALAR_FIELD(change_validator);
COMPARE_NODE_FIELD(func_options);
COMPARE_NODE_FIELD(options);
return true;
......
......@@ -309,6 +309,9 @@ static RangeVar *makeRangeVarFromAnyName(List *names, int position, core_yyscan_
create_generic_options alter_generic_options
relation_expr_list dostmt_opt_list
%type <list> opt_fdw_options fdw_options
%type <defelt> fdw_option
%type <range> OptTempTableName
%type <into> into_clause create_as_target
......@@ -3505,20 +3508,37 @@ AlterExtensionContentsStmt:
/*****************************************************************************
*
* QUERY:
* CREATE FOREIGN DATA WRAPPER name [ VALIDATOR name ]
* CREATE FOREIGN DATA WRAPPER name options
*
*****************************************************************************/
CreateFdwStmt: CREATE FOREIGN DATA_P WRAPPER name opt_validator create_generic_options
CreateFdwStmt: CREATE FOREIGN DATA_P WRAPPER name opt_fdw_options create_generic_options
{
CreateFdwStmt *n = makeNode(CreateFdwStmt);
n->fdwname = $5;
n->validator = $6;
n->func_options = $6;
n->options = $7;
$$ = (Node *) n;
}
;
fdw_option:
HANDLER handler_name { $$ = makeDefElem("handler", (Node *)$2); }
| NO HANDLER { $$ = makeDefElem("handler", NULL); }
| VALIDATOR handler_name { $$ = makeDefElem("validator", (Node *)$2); }
| NO VALIDATOR { $$ = makeDefElem("validator", NULL); }
;
fdw_options:
fdw_option { $$ = list_make1($1); }
| fdw_options fdw_option { $$ = lappend($1, $2); }
;
opt_fdw_options:
fdw_options { $$ = $1; }
| /*EMPTY*/ { $$ = NIL; }
;
/*****************************************************************************
*
* QUERY :
......@@ -3547,32 +3567,24 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
/*****************************************************************************
*
* QUERY :
* ALTER FOREIGN DATA WRAPPER name
* ALTER FOREIGN DATA WRAPPER name options
*
****************************************************************************/
AlterFdwStmt: ALTER FOREIGN DATA_P WRAPPER name validator_clause alter_generic_options
AlterFdwStmt: ALTER FOREIGN DATA_P WRAPPER name opt_fdw_options alter_generic_options
{
AlterFdwStmt *n = makeNode(AlterFdwStmt);
n->fdwname = $5;
n->validator = $6;
n->change_validator = true;
n->func_options = $6;
n->options = $7;
$$ = (Node *) n;
}
| ALTER FOREIGN DATA_P WRAPPER name validator_clause
| ALTER FOREIGN DATA_P WRAPPER name fdw_options
{
AlterFdwStmt *n = makeNode(AlterFdwStmt);
n->fdwname = $5;
n->validator = $6;
n->change_validator = true;
$$ = (Node *) n;
}
| ALTER FOREIGN DATA_P WRAPPER name alter_generic_options
{
AlterFdwStmt *n = makeNode(AlterFdwStmt);
n->fdwname = $5;
n->options = $6;
n->func_options = $6;
n->options = NIL;
$$ = (Node *) n;
}
;
......
......@@ -267,6 +267,33 @@ language_handler_out(PG_FUNCTION_ARGS)
}
/*
* fdw_handler_in - input routine for pseudo-type FDW_HANDLER.
*/
Datum
fdw_handler_in(PG_FUNCTION_ARGS)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot accept a value of type fdw_handler")));
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* fdw_handler_out - output routine for pseudo-type FDW_HANDLER.
*/
Datum
fdw_handler_out(PG_FUNCTION_ARGS)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot display a value of type fdw_handler")));
PG_RETURN_VOID(); /* keep compiler quiet */
}
/*
* internal_in - input routine for pseudo-type INTERNAL.
*/
......
......@@ -6260,6 +6260,7 @@ getForeignDataWrappers(int *numForeignDataWrappers)
int i_oid;
int i_fdwname;
int i_rolname;
int i_fdwhandler;
int i_fdwvalidator;
int i_fdwacl;
int i_fdwoptions;
......@@ -6274,13 +6275,30 @@ getForeignDataWrappers(int *numForeignDataWrappers)
/* Make sure we are in proper schema */
selectSourceSchema("pg_catalog");
appendPQExpBuffer(query, "SELECT tableoid, oid, fdwname, "
"(%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 "
"FROM pg_foreign_data_wrapper",
username_subquery);
if (g_fout->remoteVersion >= 90100)
{
appendPQExpBuffer(query, "SELECT tableoid, oid, fdwname, "
"(%s fdwowner) AS rolname, "
"fdwhandler::pg_catalog.regproc, "
"fdwvalidator::pg_catalog.regproc, fdwacl, "
"array_to_string(ARRAY("
" SELECT option_name || ' ' || quote_literal(option_value) "
" FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions "
"FROM pg_foreign_data_wrapper",
username_subquery);
}
else
{
appendPQExpBuffer(query, "SELECT tableoid, oid, fdwname, "
"(%s fdwowner) AS rolname, "
"'-' AS fdwhandler, "
"fdwvalidator::pg_catalog.regproc, fdwacl, "
"array_to_string(ARRAY("
" SELECT option_name || ' ' || quote_literal(option_value) "
" FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions "
"FROM pg_foreign_data_wrapper",
username_subquery);
}
res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
......@@ -6294,6 +6312,7 @@ getForeignDataWrappers(int *numForeignDataWrappers)
i_oid = PQfnumber(res, "oid");
i_fdwname = PQfnumber(res, "fdwname");
i_rolname = PQfnumber(res, "rolname");
i_fdwhandler = PQfnumber(res, "fdwhandler");
i_fdwvalidator = PQfnumber(res, "fdwvalidator");
i_fdwacl = PQfnumber(res, "fdwacl");
i_fdwoptions = PQfnumber(res, "fdwoptions");
......@@ -6307,11 +6326,11 @@ 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].fdwhandler = strdup(PQgetvalue(res, i, i_fdwhandler));
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));
/* Decide whether we want to dump it */
selectDumpableObject(&(fdwinfo[i].dobj));
}
......@@ -10929,11 +10948,13 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
appendPQExpBuffer(q, "CREATE FOREIGN DATA WRAPPER %s",
qfdwname);
if (fdwinfo->fdwvalidator && strcmp(fdwinfo->fdwvalidator, "-") != 0)
appendPQExpBuffer(q, " VALIDATOR %s",
fdwinfo->fdwvalidator);
if (strcmp(fdwinfo->fdwhandler, "-") != 0)
appendPQExpBuffer(q, " HANDLER %s", fdwinfo->fdwhandler);
if (strcmp(fdwinfo->fdwvalidator, "-") != 0)
appendPQExpBuffer(q, " VALIDATOR %s", fdwinfo->fdwvalidator);
if (fdwinfo->fdwoptions && strlen(fdwinfo->fdwoptions) > 0)
if (strlen(fdwinfo->fdwoptions) > 0)
appendPQExpBuffer(q, " OPTIONS (%s)", fdwinfo->fdwoptions);
appendPQExpBuffer(q, ";\n");
......
......@@ -440,6 +440,7 @@ typedef struct _fdwInfo
{
DumpableObject dobj;
char *rolname;
char *fdwhandler;
char *fdwvalidator;
char *fdwoptions;
char *fdwacl;
......
......@@ -3562,10 +3562,15 @@ listForeignDataWrappers(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT fdwname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(fdwowner) AS \"%s\",\n"
" fdwvalidator::pg_catalog.regproc AS \"%s\"",
" pg_catalog.pg_get_userbyid(fdwowner) AS \"%s\",\n",
gettext_noop("Name"),
gettext_noop("Owner"),
gettext_noop("Owner"));
if (pset.sversion >= 90100)
appendPQExpBuffer(&buf,
" fdwhandler::pg_catalog.regproc AS \"%s\",\n",
gettext_noop("Handler"));
appendPQExpBuffer(&buf,
" fdwvalidator::pg_catalog.regproc AS \"%s\"",
gettext_noop("Validator"));
if (verbose)
......
......@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 201102181
#define CATALOG_VERSION_NO 201102191
#endif
......@@ -32,7 +32,8 @@ CATALOG(pg_foreign_data_wrapper,2328)
{
NameData fdwname; /* foreign-data wrapper name */
Oid fdwowner; /* FDW owner */
Oid fdwvalidator; /* optional validation function */
Oid fdwhandler; /* handler function, or 0 if none */
Oid fdwvalidator; /* option validation function, or 0 if none */
/* VARIABLE LENGTH FIELDS start here. */
......@@ -52,11 +53,12 @@ typedef FormData_pg_foreign_data_wrapper *Form_pg_foreign_data_wrapper;
* ----------------
*/
#define Natts_pg_foreign_data_wrapper 5
#define Natts_pg_foreign_data_wrapper 6
#define Anum_pg_foreign_data_wrapper_fdwname 1
#define Anum_pg_foreign_data_wrapper_fdwowner 2
#define Anum_pg_foreign_data_wrapper_fdwvalidator 3
#define Anum_pg_foreign_data_wrapper_fdwacl 4
#define Anum_pg_foreign_data_wrapper_fdwoptions 5
#define Anum_pg_foreign_data_wrapper_fdwhandler 3
#define Anum_pg_foreign_data_wrapper_fdwvalidator 4
#define Anum_pg_foreign_data_wrapper_fdwacl 5
#define Anum_pg_foreign_data_wrapper_fdwoptions 6
#endif /* PG_FOREIGN_DATA_WRAPPER_H */
......@@ -3913,6 +3913,10 @@ DATA(insert OID = 2777 ( anynonarray_in PGNSP PGUID 12 1 0 0 f f f t f i 1 0 27
DESCR("I/O");
DATA(insert OID = 2778 ( anynonarray_out PGNSP PGUID 12 1 0 0 f f f t f i 1 0 2275 "2776" _null_ _null_ _null_ _null_ anynonarray_out _null_ _null_ _null_ ));
DESCR("I/O");
DATA(insert OID = 3116 ( fdw_handler_in PGNSP PGUID 12 1 0 0 f f f f f i 1 0 3115 "2275" _null_ _null_ _null_ _null_ fdw_handler_in _null_ _null_ _null_ ));
DESCR("I/O");
DATA(insert OID = 3117 ( fdw_handler_out PGNSP PGUID 12 1 0 0 f f f t f i 1 0 2275 "3115" _null_ _null_ _null_ _null_ fdw_handler_out _null_ _null_ _null_ ));
DESCR("I/O");
/* cryptographic */
DATA(insert OID = 2311 ( md5 PGNSP PGUID 12 1 0 0 f f f t f i 1 0 25 "25" _null_ _null_ _null_ _null_ md5_text _null_ _null_ _null_ ));
......
......@@ -631,6 +631,8 @@ DATA(insert OID = 2776 ( anynonarray PGNSP PGUID 4 t p P f t \054 0 0 0 anynona
#define ANYNONARRAYOID 2776
DATA(insert OID = 3500 ( anyenum PGNSP PGUID 4 t p P f t \054 0 0 0 anyenum_in anyenum_out - - - - - i p f 0 -1 0 0 _null_ _null_ ));
#define ANYENUMOID 3500
DATA(insert OID = 3115 ( fdw_handler PGNSP PGUID 4 t p P f t \054 0 0 0 fdw_handler_in fdw_handler_out - - - - - i p f 0 -1 0 0 _null_ _null_ ));
#define FDW_HANDLEROID 3115
/*
......
......@@ -37,7 +37,8 @@ typedef struct ForeignDataWrapper
Oid fdwid; /* FDW Oid */
Oid owner; /* FDW owner user Oid */
char *fdwname; /* Name of the FDW */
Oid fdwvalidator;
Oid fdwhandler; /* Oid of handler function, or 0 */
Oid fdwvalidator; /* Oid of validator function, or 0 */
List *options; /* fdwoptions as DefElem list */
} ForeignDataWrapper;
......
......@@ -1574,7 +1574,7 @@ typedef struct CreateFdwStmt
{
NodeTag type;
char *fdwname; /* foreign-data wrapper name */
List *validator; /* optional validator function (qual. name) */
List *func_options; /* HANDLER/VALIDATOR options */
List *options; /* generic options to FDW */
} CreateFdwStmt;
......@@ -1582,8 +1582,7 @@ typedef struct AlterFdwStmt
{
NodeTag type;
char *fdwname; /* foreign-data wrapper name */
List *validator; /* optional validator function (qual. name) */
bool change_validator;
List *func_options; /* HANDLER/VALIDATOR options */
List *options; /* generic options to FDW */
} AlterFdwStmt;
......
......@@ -508,6 +508,8 @@ extern Datum trigger_in(PG_FUNCTION_ARGS);
extern Datum trigger_out(PG_FUNCTION_ARGS);
extern Datum language_handler_in(PG_FUNCTION_ARGS);
extern Datum language_handler_out(PG_FUNCTION_ARGS);
extern Datum fdw_handler_in(PG_FUNCTION_ARGS);
extern Datum fdw_handler_out(PG_FUNCTION_ARGS);
extern Datum internal_in(PG_FUNCTION_ARGS);
extern Datum internal_out(PG_FUNCTION_ARGS);
extern Datum opaque_in(PG_FUNCTION_ARGS);
......
This diff is collapsed.
......@@ -24,7 +24,7 @@ CREATE FOREIGN DATA WRAPPER dummy;
CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator;
-- At this point we should have 2 built-in wrappers and no servers.
SELECT fdwname, fdwvalidator::regproc, fdwoptions FROM pg_foreign_data_wrapper ORDER BY 1, 2, 3;
SELECT fdwname, fdwhandler::regproc, fdwvalidator::regproc, fdwoptions FROM pg_foreign_data_wrapper ORDER BY 1, 2, 3;
SELECT srvname, srvoptions FROM pg_foreign_server;
SELECT * FROM pg_user_mapping;
......@@ -271,6 +271,8 @@ COMMENT ON COLUMN ft1.c1 IS 'ft1.c1';
\d+ ft1
\det+
CREATE INDEX id_ft1_c2 ON ft1 (c2); -- ERROR
SELECT * FROM ft1; -- ERROR
EXPLAIN SELECT * FROM ft1; -- ERROR
-- ALTER FOREIGN TABLE
COMMENT ON FOREIGN TABLE ft1 IS 'foreign table';
......@@ -453,6 +455,6 @@ DROP FOREIGN DATA WRAPPER dummy CASCADE;
DROP ROLE foreign_data_user;
-- At this point we should have no wrappers, no servers, and no mappings.
SELECT fdwname, fdwvalidator, fdwoptions FROM pg_foreign_data_wrapper;
SELECT fdwname, fdwhandler, fdwvalidator, fdwoptions FROM pg_foreign_data_wrapper;
SELECT srvname, srvoptions FROM pg_foreign_server;
SELECT * FROM pg_user_mapping;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment