mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-18 18:44:06 +08:00
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:
parent
2093f66305
commit
25794e841e
@ -1169,10 +1169,10 @@ find_update_path(List *evi_list,
|
|||||||
/*
|
/*
|
||||||
* CREATE EXTENSION worker
|
* CREATE EXTENSION worker
|
||||||
*
|
*
|
||||||
* When CASCADE is specified CreateExtensionInternal() recurses if required
|
* When CASCADE is specified, CreateExtensionInternal() recurses if required
|
||||||
* extensions need to be installed. To sanely handle cyclic dependencies
|
* extensions need to be installed. To sanely handle cyclic dependencies,
|
||||||
* cascade_parent contains the dependency chain leading to the current
|
* the "parents" list contains a list of names of extensions already being
|
||||||
* invocation; thus allowing to error out if there's a cyclic dependency.
|
* installed, allowing us to error out if we recurse to one of those.
|
||||||
*/
|
*/
|
||||||
static ObjectAddress
|
static ObjectAddress
|
||||||
CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
|
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
|
* Look up the prerequisite extensions, install them if necessary, and
|
||||||
* the OIDs of their target schemas.
|
* build lists of their OIDs and the OIDs of their target schemas.
|
||||||
*/
|
*/
|
||||||
requiredExtensions = NIL;
|
requiredExtensions = NIL;
|
||||||
requiredSchemas = NIL;
|
requiredSchemas = NIL;
|
||||||
@ -1416,18 +1416,19 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
|
|||||||
{
|
{
|
||||||
if (cascade)
|
if (cascade)
|
||||||
{
|
{
|
||||||
|
/* Must install it. */
|
||||||
CreateExtensionStmt *ces;
|
CreateExtensionStmt *ces;
|
||||||
ListCell *lc;
|
ListCell *lc2;
|
||||||
ObjectAddress addr;
|
ObjectAddress addr;
|
||||||
List *cascade_parents;
|
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_valid_extension_name(curreq);
|
||||||
|
|
||||||
/* Check for cyclic dependency between extensions. */
|
/* 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)
|
if (strcmp(pname, curreq) == 0)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -1440,26 +1441,26 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
|
|||||||
(errmsg("installing required extension \"%s\"",
|
(errmsg("installing required extension \"%s\"",
|
||||||
curreq)));
|
curreq)));
|
||||||
|
|
||||||
/* Create and execute new CREATE EXTENSION statement. */
|
/* Build a CREATE EXTENSION statement to pass down. */
|
||||||
ces = makeNode(CreateExtensionStmt);
|
ces = makeNode(CreateExtensionStmt);
|
||||||
ces->extname = curreq;
|
ces->extname = curreq;
|
||||||
|
ces->if_not_exists = false;
|
||||||
|
|
||||||
/* Propagate the CASCADE option */
|
/* Propagate the CASCADE option. */
|
||||||
ces->options = list_make1(d_cascade);
|
ces->options = list_make1(d_cascade);
|
||||||
|
|
||||||
/* Propagate the SCHEMA option if given. */
|
/* Propagate the SCHEMA option if given. */
|
||||||
if (d_schema && d_schema->arg)
|
if (d_schema && d_schema->arg)
|
||||||
ces->options = lappend(ces->options, d_schema);
|
ces->options = lappend(ces->options, d_schema);
|
||||||
|
|
||||||
/*
|
/* Add current extension to list of parents to pass down. */
|
||||||
* Pass the current list of parents + the current extension to
|
|
||||||
* the "child" CreateExtensionInternal().
|
|
||||||
*/
|
|
||||||
cascade_parents =
|
cascade_parents =
|
||||||
lappend(list_copy(parents), stmt->extname);
|
lappend(list_copy(parents), stmt->extname);
|
||||||
|
|
||||||
/* Create the required extension. */
|
/* Create the required extension. */
|
||||||
addr = CreateExtensionInternal(ces, cascade_parents);
|
addr = CreateExtensionInternal(ces, cascade_parents);
|
||||||
|
|
||||||
|
/* Get its newly-assigned OID. */
|
||||||
reqext = addr.objectId;
|
reqext = addr.objectId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1551,7 +1552,6 @@ CreateExtension(CreateExtensionStmt *stmt)
|
|||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
errmsg("nested CREATE EXTENSION is not supported")));
|
errmsg("nested CREATE EXTENSION is not supported")));
|
||||||
|
|
||||||
|
|
||||||
/* Finally create the extension. */
|
/* Finally create the extension. */
|
||||||
return CreateExtensionInternal(stmt, NIL);
|
return CreateExtensionInternal(stmt, NIL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user