aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-09-05 18:53:25 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-09-05 18:53:33 -0400
commit25794e841e5b86a0f90fac7f7f851e5d950e51e2 (patch)
tree342c1f5fd870f90f5692a4ef8b6538b9541bb3b6 /src
parent2093f6630500c9d5e122748ac7d3719855d71174 (diff)
downloadpostgresql-25794e841e5b86a0f90fac7f7f851e5d950e51e2.tar.gz
postgresql-25794e841e5b86a0f90fac7f7f851e5d950e51e2.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/extension.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 518fefcf09b..fa861e670b7 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -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);
}