@@ -1169,10 +1169,10 @@ find_update_path(List *evi_list,
11691169/*
11701170 * CREATE EXTENSION worker
11711171 *
1172- * When CASCADE is specified CreateExtensionInternal() recurses if required
1173- * extensions need to be installed. To sanely handle cyclic dependencies
1174- *cascade_parent containsthe dependency chain leading to the current
1175- *invocation; thus allowing to error out ifthere's a cyclic dependency .
1172+ * When CASCADE is specified, CreateExtensionInternal() recurses if required
1173+ * extensions need to be installed. To sanely handle cyclic dependencies,
1174+ *the "parents" list containsa list of names of extensions already being
1175+ *installed, allowingus to error out ifwe recurse to one of those .
11761176 */
11771177static ObjectAddress
11781178CreateExtensionInternal (CreateExtensionStmt * stmt ,List * parents )
@@ -1400,8 +1400,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
14001400 */
14011401
14021402/*
1403- * Look up the prerequisite extensions,and build lists of their OIDs and
1404- * the OIDs of their target schemas.
1403+ * Look up the prerequisite extensions,install them if necessary, and
1404+ *build lists of their OIDs and the OIDs of their target schemas.
14051405 */
14061406requiredExtensions = NIL ;
14071407requiredSchemas = NIL ;
@@ -1416,18 +1416,19 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
14161416{
14171417if (cascade )
14181418{
1419+ /* Must install it. */
14191420CreateExtensionStmt * ces ;
1420- ListCell * lc ;
1421+ ListCell * lc2 ;
14211422ObjectAddress addr ;
14221423List * cascade_parents ;
14231424
1424- /* Check extension name validity before trying to cascade */
1425+ /* Check extension name validity before trying to cascade. */
14251426check_valid_extension_name (curreq );
14261427
14271428/* Check for cyclic dependency between extensions. */
1428- foreach (lc ,parents )
1429+ foreach (lc2 ,parents )
14291430{
1430- char * pname = (char * )lfirst (lc );
1431+ char * pname = (char * )lfirst (lc2 );
14311432
14321433if (strcmp (pname ,curreq )== 0 )
14331434ereport (ERROR ,
@@ -1440,26 +1441,26 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
14401441(errmsg ("installing required extension \"%s\"" ,
14411442curreq )));
14421443
1443- /*Create and execute new CREATE EXTENSION statement. */
1444+ /*Build a CREATE EXTENSION statement to pass down . */
14441445ces = makeNode (CreateExtensionStmt );
14451446ces -> extname = curreq ;
1447+ ces -> if_not_exists = false;
14461448
1447- /* Propagate the CASCADE option */
1449+ /* Propagate the CASCADE option. */
14481450ces -> options = list_make1 (d_cascade );
14491451
14501452/* Propagate the SCHEMA option if given. */
14511453if (d_schema && d_schema -> arg )
14521454ces -> options = lappend (ces -> options ,d_schema );
14531455
1454- /*
1455- * Pass the current list of parents + the current extension to
1456- * the "child" CreateExtensionInternal().
1457- */
1456+ /* Add current extension to list of parents to pass down. */
14581457cascade_parents =
14591458lappend (list_copy (parents ),stmt -> extname );
14601459
14611460/* Create the required extension. */
14621461addr = CreateExtensionInternal (ces ,cascade_parents );
1462+
1463+ /* Get its newly-assigned OID. */
14631464reqext = addr .objectId ;
14641465}
14651466else
@@ -1551,7 +1552,6 @@ CreateExtension(CreateExtensionStmt *stmt)
15511552(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
15521553errmsg ("nested CREATE EXTENSION is not supported" )));
15531554
1554-
15551555/* Finally create the extension. */
15561556return CreateExtensionInternal (stmt ,NIL );
15571557}