Chore
Validate custom pg_net.ttl configs
Describe the chore
The pg_net.ttl config is an interval type, but it doesn't perform any validation checks in the code:
DefineCustomStringVariable("pg_net.database_name", "Database where the worker will connect to",
NULL, &guc_database_name, "postgres", PGC_SU_BACKEND, 0, NULL, NULL,
NULL);
Based on the DefineCustomStringVariable definition:
extern void DefineCustomStringVariable(const char *name,
const char *short_desc,
const char *long_desc,
char **valueAddr,
const char *bootValue,
GucContext context,
int flags,
GucStringCheckHook check_hook,
GucStringAssignHook assign_hook,
GucShowHook show_hook) pg_attribute_nonnull(1, 4);
validation likely would have to be added to the GucStringCheckHook parameter. cybrosys has an article on the topic. Clickhouse also has a good article that may be worth referencing.
The function interval_in can be called against the input string to validate that it is in interval format.
Additional context
Tried to update the MGMT-API/CLI to expose the ttl and batch_size settings:
Came across an issue related to type interval validation. It can be circumvented with API level checks, but I think it would be better if the extension also prevented invalid entries. During testing, I found it to be trivial to break the background worker by running something like:
ALTER SYSTEM SET pg_net.ttl = '1 mins';
SELECT net.worker_restart();
Chore
Validate custom
pg_net.ttlconfigsDescribe the chore
The
pg_net.ttlconfig is an interval type, but it doesn't perform any validation checks in the code:Based on the
DefineCustomStringVariabledefinition:validation likely would have to be added to the
GucStringCheckHookparameter. cybrosys has an article on the topic. Clickhouse also has a good article that may be worth referencing.The function interval_in can be called against the input string to validate that it is in interval format.
Additional context
Tried to update the MGMT-API/CLI to expose the
ttlandbatch_sizesettings:Came across an issue related to type interval validation. It can be circumvented with API level checks, but I think it would be better if the extension also prevented invalid entries. During testing, I found it to be trivial to break the background worker by running something like: