Pull flatten_deflist() up to foreign.c with renaming to
authorShigeru Hanada <hanada@metrosystems.co.jp>
Fri, 8 Oct 2010 02:17:52 +0000 (11:17 +0900)
committerShigeru Hanada <hanada@metrosystems.co.jp>
Fri, 8 Oct 2010 02:17:52 +0000 (11:17 +0900)
flaten_generic_options().

contrib/postgresql_fdw/postgresql_fdw.c
src/backend/foreign/foreign.c
src/include/foreign/foreign.h

index 7193e756f7b71a7c3b782a97a2f979f4c82840cc..8a097613a2d5eb7c5420bd099fff15047f97bd2d 100644 (file)
@@ -63,8 +63,6 @@ static bool is_immutable_func(Oid funcid);
 static bool is_foreign_qual(Expr *expr);
 static bool foreign_qual_walker(Node *node, void *context);
 static char *deparseSql(ForeignScanState *scanstate);
-static int flatten_deflist(List *options,
-                          const char **keywords, const char **values);
 static void check_conn_params(const char **keywords, const char **values);
 
 /* tuple handling */
@@ -127,8 +125,10 @@ pgConnectServer(ForeignServer *server, UserMapping *user)
    keywords = (const char **) palloc(sizeof(char *) * n);
    values = (const char **) palloc(sizeof(char *) * n);
    n = 0;
-   n += flatten_deflist(server->options, all_keywords + n, all_values + n);
-   n += flatten_deflist(user->options, all_keywords + n, all_values + n);
+   n += flatten_generic_options(server->options,
+                                all_keywords + n, all_values + n);
+   n += flatten_generic_options(user->options,
+                                all_keywords + n, all_values + n);
    all_keywords[n] = all_values[n] = NULL;
 
    for (i = 0, j = 0; all_keywords[i]; i++)
@@ -633,26 +633,6 @@ pgReOpen(ForeignScanState *scanstate)
    }
 }
 
-/*
- * Flattern options into keywords and values buffers.
- */
-static int
-flatten_deflist(List *options, const char **keywords, const char **values)
-{
-   ListCell   *cell;
-   int         n = 0;
-
-   foreach(cell, options)
-   {
-       DefElem    *def = lfirst(cell);
-
-       keywords[n] = def->defname;
-       values[n] = strVal(def->arg);
-       n++;
-   }
-   return n;
-}
-
 /*
  * For non-superusers, insist that the connstr specify a password. This
  * prevents a password from being picked up from .pgpass, a service file,
@@ -800,8 +780,8 @@ pgEstimateCost(Path *path, PlannerInfo *root, RelOptInfo *baserel)
    keywords = (const char **) palloc(sizeof(char *) * n);
    values = (const char **) palloc(sizeof(char *) * n);
    n = 0;
-   n += flatten_deflist(server->options, keywords + n, values + n);
-   n += flatten_deflist(table->options, keywords + n, values + n);
+   n += flatten_generic_options(server->options, keywords + n, values + n);
+   n += flatten_generic_options(table->options, keywords + n, values + n);
    keywords[n] = values[n] = NULL;
 
    /*
index 6c31b9ec7a840422394370eae6ea1a3e6febf247..edf94cdb44704f364f26beef830f703479a225b5 100644 (file)
@@ -527,3 +527,24 @@ IsForeignTable(Oid relid)
 
    return (relkind == RELKIND_FOREIGN_TABLE);
 }
+
+/*
+ * Flattern generic options into keywords and values buffers.
+ */
+int
+flatten_generic_options(List *options, const char **keywords,
+                       const char **values)
+{
+   ListCell   *cell;
+   int         n = 0;
+
+   foreach(cell, options)
+   {
+       DefElem    *def = lfirst(cell);
+
+       keywords[n] = def->defname;
+       values[n] = strVal(def->arg);
+       n++;
+   }
+   return n;
+}
index 343d31684098a46120105b6a57c07700373b5742..ec111ad2f5b0fbf86ab1732cf5c562238555ddf3 100644 (file)
@@ -85,6 +85,8 @@ extern Oid    GetForeignDataWrapperOidByName(const char *name, bool missing_ok);
 extern ForeignTable *GetForeignTable(Oid relid);
 extern FdwRoutine *GetFdwRoutine(Oid fdwhandler);
 extern bool IsForeignTable(Oid relid);
+extern int flatten_generic_options(List *options,
+                          const char **keywords, const char **values);
 
 /* ALTER FOREIGN TABLE ... OPTIONS (...) handlers */
 extern void ATExecGenericOptions(Relation rel, List *options);