Skip to content

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

@Laubeee

Description

@Laubeee

this throws an "ERROR: must be superuser to create a job for another role"

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:

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.

if (usernameText != NULL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions