@@ -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 contains the dependency chain leading to the current
1175- * invocation; thus allowing to error out if there'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 contains a list of names of extensions already being
1175+ * installed, allowing us to error out if we 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 */
14061406 requiredExtensions = NIL ;
14071407 requiredSchemas = NIL ;
@@ -1416,18 +1416,19 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
14161416 {
14171417 if (cascade )
14181418 {
1419+ /* Must install it. */
14191420 CreateExtensionStmt * ces ;
1420- ListCell * lc ;
1421+ ListCell * lc2 ;
14211422 ObjectAddress addr ;
14221423 List * cascade_parents ;
14231424
1424- /* Check extension name validity before trying to cascade */
1425+ /* Check extension name validity before trying to cascade. */
14251426 check_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
14321433 if (strcmp (pname , curreq ) == 0 )
14331434 ereport (ERROR ,
@@ -1440,26 +1441,26 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
14401441 (errmsg ("installing required extension \"%s\"" ,
14411442 curreq )));
14421443
1443- /* Create and execute new CREATE EXTENSION statement. */
1444+ /* Build a CREATE EXTENSION statement to pass down . */
14441445 ces = makeNode (CreateExtensionStmt );
14451446 ces -> extname = curreq ;
1447+ ces -> if_not_exists = false;
14461448
1447- /* Propagate the CASCADE option */
1449+ /* Propagate the CASCADE option. */
14481450 ces -> options = list_make1 (d_cascade );
14491451
14501452 /* Propagate the SCHEMA option if given. */
14511453 if (d_schema && d_schema -> arg )
14521454 ces -> 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. */
14581457 cascade_parents =
14591458 lappend (list_copy (parents ), stmt -> extname );
14601459
14611460 /* Create the required extension. */
14621461 addr = CreateExtensionInternal (ces , cascade_parents );
1462+
1463+ /* Get its newly-assigned OID. */
14631464 reqext = addr .objectId ;
14641465 }
14651466 else
@@ -1551,7 +1552,6 @@ CreateExtension(CreateExtensionStmt *stmt)
15511552 (errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
15521553 errmsg ("nested CREATE EXTENSION is not supported" )));
15531554
1554-
15551555 /* Finally create the extension. */
15561556 return CreateExtensionInternal (stmt , NIL );
15571557}
0 commit comments