citusdata / citusdata/pg_cron

cron.schedule_in_database confusing ERROR: must be superuser to create a job for another role

Open
#390 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3.9k
Forks
260
Avg merge
5d 5h
Merged PRs (30d)
1

Description

this throws an "ERROR: must be superuser to create a job for another role"
```SQL
SELECT cron.schedule_in_database(
'refresh_mv',
'30 5 * * *',
'REFRESH MATERIALIZED VIEW schema.my_view;',
'my-db',
current_user, -- or specified as 'my_user'
true
);
```
but this will work, and schedule the job as current_user:
```SQL
SELECT cron.schedule_in_database(
'refresh_mv',
'30 5 * * *',
'REFRESH MATERIALIZED VIEW schema.my_view;',
'my-db'
);
```
seems unintended and extremely confusing.

The error is thrown here, and only checks if the userstring is not empty. It should also check whether it is different from the current user before throwing the error.
https://github.com/citusdata/pg_cron/blob/d33586c61457863010cb9f07a0063be57340bea2/src/job_metadata.c#L280

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.