@@ -448,29 +448,36 @@ static void supautils_hook(PROCESS_UTILITY_PARAMS) {
448
448
449
449
constrain_extension (stmt -> extname , cexts , total_cexts );
450
450
451
- if (is_extension_privileged (stmt -> extname , privileged_extensions )) {
452
- bool already_switched_to_superuser = false;
451
+ bool already_switched_to_superuser = false;
453
452
454
- switch_to_superuser (supautils_superuser , & already_switched_to_superuser );
453
+ switch_to_superuser (supautils_superuser , & already_switched_to_superuser );
455
454
456
- run_global_before_create_script (stmt -> extname , stmt -> options , privileged_extensions_custom_scripts_path );
455
+ run_global_before_create_script (stmt -> extname , stmt -> options , privileged_extensions_custom_scripts_path );
457
456
458
- run_ext_before_create_script (stmt -> extname , stmt -> options , privileged_extensions_custom_scripts_path );
457
+ run_ext_before_create_script (stmt -> extname , stmt -> options , privileged_extensions_custom_scripts_path );
459
458
460
- override_create_ext_statement (stmt , total_epos , epos );
459
+ override_create_ext_statement (stmt , total_epos , epos );
461
460
462
- run_process_utility_hook (prev_hook );
461
+ if (is_extension_privileged (stmt -> extname , privileged_extensions )) {
462
+ if (!already_switched_to_superuser ) {
463
+ switch_to_original_role ();
464
+ already_switched_to_superuser = false;
465
+ }
463
466
464
- run_ext_after_create_script ( stmt -> extname , stmt -> options , privileged_extensions_custom_scripts_path );
467
+ run_process_utility_hook ( prev_hook );
465
468
466
- if (!already_switched_to_superuser ) {
467
- switch_to_original_role ();
468
- }
469
+ switch_to_superuser (supautils_superuser , & already_switched_to_superuser );
470
+ } else {
471
+ run_process_utility_hook (prev_hook );
472
+ }
469
473
470
- return ;
474
+ run_ext_after_create_script (stmt -> extname , stmt -> options , privileged_extensions_custom_scripts_path );
475
+
476
+ if (!already_switched_to_superuser ) {
477
+ switch_to_original_role ();
471
478
}
472
479
473
- break ;
480
+ return ;
474
481
}
475
482
476
483
/*
0 commit comments