@@ -1169,10 +1169,10 @@ find_update_path(List *evi_list,
1169
1169
/*
1170
1170
* CREATE EXTENSION worker
1171
1171
*
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 .
1176
1176
*/
1177
1177
static ObjectAddress
1178
1178
CreateExtensionInternal (CreateExtensionStmt * stmt , List * parents )
@@ -1400,8 +1400,8 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
1400
1400
*/
1401
1401
1402
1402
/*
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.
1405
1405
*/
1406
1406
requiredExtensions = NIL ;
1407
1407
requiredSchemas = NIL ;
@@ -1416,18 +1416,19 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
1416
1416
{
1417
1417
if (cascade )
1418
1418
{
1419
+ /* Must install it. */
1419
1420
CreateExtensionStmt * ces ;
1420
- ListCell * lc ;
1421
+ ListCell * lc2 ;
1421
1422
ObjectAddress addr ;
1422
1423
List * cascade_parents ;
1423
1424
1424
- /* Check extension name validity before trying to cascade */
1425
+ /* Check extension name validity before trying to cascade. */
1425
1426
check_valid_extension_name (curreq );
1426
1427
1427
1428
/* Check for cyclic dependency between extensions. */
1428
- foreach (lc , parents )
1429
+ foreach (lc2 , parents )
1429
1430
{
1430
- char * pname = (char * ) lfirst (lc );
1431
+ char * pname = (char * ) lfirst (lc2 );
1431
1432
1432
1433
if (strcmp (pname , curreq ) == 0 )
1433
1434
ereport (ERROR ,
@@ -1440,26 +1441,26 @@ CreateExtensionInternal(CreateExtensionStmt *stmt, List *parents)
1440
1441
(errmsg ("installing required extension \"%s\"" ,
1441
1442
curreq )));
1442
1443
1443
- /* Create and execute new CREATE EXTENSION statement. */
1444
+ /* Build a CREATE EXTENSION statement to pass down . */
1444
1445
ces = makeNode (CreateExtensionStmt );
1445
1446
ces -> extname = curreq ;
1447
+ ces -> if_not_exists = false;
1446
1448
1447
- /* Propagate the CASCADE option */
1449
+ /* Propagate the CASCADE option. */
1448
1450
ces -> options = list_make1 (d_cascade );
1449
1451
1450
1452
/* Propagate the SCHEMA option if given. */
1451
1453
if (d_schema && d_schema -> arg )
1452
1454
ces -> options = lappend (ces -> options , d_schema );
1453
1455
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. */
1458
1457
cascade_parents =
1459
1458
lappend (list_copy (parents ), stmt -> extname );
1460
1459
1461
1460
/* Create the required extension. */
1462
1461
addr = CreateExtensionInternal (ces , cascade_parents );
1462
+
1463
+ /* Get its newly-assigned OID. */
1463
1464
reqext = addr .objectId ;
1464
1465
}
1465
1466
else
@@ -1551,7 +1552,6 @@ CreateExtension(CreateExtensionStmt *stmt)
1551
1552
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
1552
1553
errmsg ("nested CREATE EXTENSION is not supported" )));
1553
1554
1554
-
1555
1555
/* Finally create the extension. */
1556
1556
return CreateExtensionInternal (stmt , NIL );
1557
1557
}
0 commit comments