Skip to content

Commit

Permalink
feat: support non-superuser event trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Jan 14, 2025
1 parent e861d3e commit 262251b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/supautils.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,32 @@ static void supautils_hook(PROCESS_UTILITY_PARAMS) {
}
}

case T_CreateEventTrigStmt: {
if (!IsTransactionState()) {
break;
}
if (superuser()) {
break;
}

if (!is_current_role_privileged()) {
break;
}

{
bool already_switched_to_superuser = false;
switch_to_superuser(supautils_superuser, &already_switched_to_superuser);

run_process_utility_hook(prev_hook);

if (!already_switched_to_superuser) {
switch_to_original_role();
}

return;
}
}

default:
break;
}
Expand Down

0 comments on commit 262251b

Please sign in to comment.