Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault in ts_chunk_attach_osm_table_chunk on old pg versions #6073

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4781,13 +4781,22 @@
bool ret = false;

Cache *hcache;
Hypertable *par_ht =
Hypertable *ht =
ts_hypertable_cache_get_cache_and_entry(hypertable_relid, CACHE_FLAG_MISSING_OK, &hcache);
if (par_ht == NULL)
elog(ERROR, "\"%s\" is not a hypertable", get_rel_name(hypertable_relid));

if (!ht)
{
char *name = get_rel_name(hypertable_relid);

if (!name)
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("invalid Oid")));
else
elog(ERROR, "\"%s\" is not a hypertable", name);
}

Check warning on line 4795 in src/chunk.c

View check run for this annotation

Codecov / codecov/patch

src/chunk.c#L4795

Added line #L4795 was not covered by tests

if (get_rel_relkind(ftable_relid) == RELKIND_FOREIGN_TABLE)
{
add_foreign_table_as_chunk(ftable_relid, par_ht);
add_foreign_table_as_chunk(ftable_relid, ht);
ret = true;
}
ts_cache_release(hcache);
Expand Down
2 changes: 1 addition & 1 deletion tsl/test/shared/expected/compat.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WARNING: function _timescaledb_internal.alter_job_set_hypertable_id(integer,reg
ERROR: job 0 not found
SELECT _timescaledb_internal.attach_osm_table_chunk(0,0);
WARNING: function _timescaledb_internal.attach_osm_table_chunk(regclass,regclass) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
ERROR: "(null)" is not a hypertable
ERROR: invalid Oid
SELECT _timescaledb_internal.cagg_migrate_plan_exists(0);
WARNING: function _timescaledb_internal.cagg_migrate_plan_exists(integer) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
cagg_migrate_plan_exists
Expand Down