Fix segfaults in policy check functions

This commit is contained in:
Sven Klemm 2022-08-28 19:18:16 +02:00 committed by Sven Klemm
parent c697700add
commit 1fa8373931
6 changed files with 42 additions and 0 deletions

View File

@ -159,6 +159,12 @@ Datum
policy_compression_check(PG_FUNCTION_ARGS)
{
PolicyCompressionData policy_data;
if (PG_ARGISNULL(0))
{
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("config must not be NULL")));
}
policy_compression_read_and_validate_config(PG_GETARG_JSONB_P(0), &policy_data);
ts_cache_release(policy_data.hcache);

View File

@ -220,6 +220,11 @@ policy_refresh_cagg_proc(PG_FUNCTION_ARGS)
Datum
policy_refresh_cagg_check(PG_FUNCTION_ARGS)
{
if (PG_ARGISNULL(0))
{
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("config must not be NULL")));
}
policy_refresh_cagg_read_and_validate_config(PG_GETARG_JSONB_P(0), NULL);
PG_RETURN_VOID();

View File

@ -111,6 +111,11 @@ policy_reorder_check(PG_FUNCTION_ARGS)
{
TS_PREVENT_FUNC_IF_READ_ONLY();
if (PG_ARGISNULL(0))
{
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("config must not be NULL")));
}
policy_reorder_read_and_validate_config(PG_GETARG_JSONB_P(0), NULL);
PG_RETURN_VOID();

View File

@ -45,6 +45,11 @@ policy_retention_check(PG_FUNCTION_ARGS)
{
TS_PREVENT_FUNC_IF_READ_ONLY();
if (PG_ARGISNULL(0))
{
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("config must not be NULL")));
}
policy_retention_read_and_validate_config(PG_GETARG_JSONB_P(0), NULL);
PG_RETURN_VOID();

View File

@ -719,3 +719,14 @@ select * from _timescaledb_config.bgw_job where id in (:retenion_id_missing_sche
1010 | Compression Policy [1010] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user_2 | t | 10 | {"hypertable_id": 10, "compress_after": 600000} | _timescaledb_internal | policy_compression_check
(3 rows)
-- test policy check functions with NULL args
\set ON_ERROR_STOP 0
SELECT _timescaledb_internal.policy_compression_check(NULL);
ERROR: config must not be NULL
SELECT _timescaledb_internal.policy_refresh_continuous_aggregate_check(NULL);
ERROR: config must not be NULL
SELECT _timescaledb_internal.policy_reorder_check(NULL);
ERROR: config must not be NULL
SELECT _timescaledb_internal.policy_retention_check(NULL);
ERROR: config must not be NULL
\set ON_ERROR_STOP 1

View File

@ -363,3 +363,13 @@ alter table test_missing_schedint_integer set (timescaledb.compress);
select add_compression_policy('test_missing_schedint_integer', BIGINT '600000') as compression_id_integer \gset
select * from _timescaledb_config.bgw_job where id in (:retenion_id_missing_schedint, :compression_id_missing_schedint, :compression_id_integer);
-- test policy check functions with NULL args
\set ON_ERROR_STOP 0
SELECT _timescaledb_internal.policy_compression_check(NULL);
SELECT _timescaledb_internal.policy_refresh_continuous_aggregate_check(NULL);
SELECT _timescaledb_internal.policy_reorder_check(NULL);
SELECT _timescaledb_internal.policy_retention_check(NULL);
\set ON_ERROR_STOP 1