From: Shigeru Hanada Date: Fri, 8 Oct 2010 02:17:52 +0000 (+0900) Subject: Pull flatten_deflist() up to foreign.c with renaming to X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=9c824d6eb9a5a7a6835fc0f199cf2fd05d36c5c8;p=users%2Fhanada%2Fpostgres.git Pull flatten_deflist() up to foreign.c with renaming to flaten_generic_options(). --- diff --git a/contrib/postgresql_fdw/postgresql_fdw.c b/contrib/postgresql_fdw/postgresql_fdw.c index 7193e756f7..8a097613a2 100644 --- a/contrib/postgresql_fdw/postgresql_fdw.c +++ b/contrib/postgresql_fdw/postgresql_fdw.c @@ -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; /* diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c index 6c31b9ec7a..edf94cdb44 100644 --- a/src/backend/foreign/foreign.c +++ b/src/backend/foreign/foreign.c @@ -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; +} diff --git a/src/include/foreign/foreign.h b/src/include/foreign/foreign.h index 343d316840..ec111ad2f5 100644 --- a/src/include/foreign/foreign.h +++ b/src/include/foreign/foreign.h @@ -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);