Cosmetic code cleanup in commands/extension.c.

Some of the comments added by the CREATE EXTENSION CASCADE patch were
a bit sloppy, and I didn't care for redeclaring the same local variable
inside a nested block either.  No functional changes.
This commit is contained in:
Tom Lane 2016-09-05 18:53:25 -04:00
parent 2093f66305
commit 25794e841e

View File

@ -1169,10 +1169,10 @@ find_update_path(List *evi_list,
/*
* CREATE EXTENSION worker
*
* When CASCADE is specified CreateExtensionInternal() recurses if required
* extensions need to be installed. To sanely handle cyclic dependencies
* cascade_parent contains the dependency chain leading to the current
* invocation; thus allowing to error out if there's a cyclic dependency.
* When CASCADE is specified, CreateExtensionInternal() recurses if required
* extensions need to be installed. To sanely handle cyclic dependencies,
* the "parents" list contains a list of names of extensions already being
* installed, allowing us to error out if we recurse to one of those.
*/
static ObjectAddress
CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
@ -1400,8 +1400,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
*/
/*
* Look up the prerequisite extensions, and build lists of their OIDs and
* the OIDs of their target schemas.
* Look up the prerequisite extensions, install them if necessary, and
* build lists of their OIDs and the OIDs of their target schemas.
*/
requiredExtensions = NIL;
requiredSchemas = NIL;
@ -1416,18 +1416,19 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
{
if (cascade)
{
/* Must install it. */
CreateExtensionStmt *ces;
ListCell *lc;
ListCell *lc2;
ObjectAddress addr;
List *cascade_parents;
/* Check extension name validity before trying to cascade */
/* Check extension name validity before trying to cascade. */
check_valid_extension_name(curreq);
/* Check for cyclic dependency between extensions. */
foreach(lc, parents)
foreach(lc2, parents)
{
char *pname = (char *) lfirst(lc);
char *pname = (char *) lfirst(lc2);
if (strcmp(pname, curreq) == 0)
ereport(ERROR,
@ -1440,26 +1441,26 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
(errmsg("installing required extension \"%s\"",
curreq)));
/* Create and execute new CREATE EXTENSION statement. */
/* Build a CREATE EXTENSION statement to pass down. */
ces = makeNode(CreateExtensionStmt);
ces->extname = curreq;
ces->if_not_exists = false;
/* Propagate the CASCADE option */
/* Propagate the CASCADE option. */
ces->options = list_make1(d_cascade);
/* Propagate the SCHEMA option if given. */
if (d_schema && d_schema->arg)
ces->options = lappend(ces->options, d_schema);
/*
* Pass the current list of parents + the current extension to
* the "child" CreateExtensionInternal().
*/
/* Add current extension to list of parents to pass down. */
cascade_parents =
lappend(list_copy(parents), stmt->extname);
/* Create the required extension. */
addr = CreateExtensionInternal(ces, cascade_parents);
/* Get its newly-assigned OID. */
reqext = addr.objectId;
}
else
@ -1551,7 +1552,6 @@ CreateExtension(CreateExtensionStmt *stmt)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nested CREATE EXTENSION is not supported")));
/* Finally create the extension. */
return CreateExtensionInternal(stmt, NIL);
}