Skip to content

Commit f757431

Browse files
Fix add_dimension assertion on NULL hypertable (#10327)
ts_dimension_add_general read the hypertable argument with a bare PG_GETARG_OID(0), so a NULL argument left table_relid as InvalidOid and tripped an assertion in ts_dimension_add_internal. Guard it with GETARG_NOTNULL_OID to reject NULL with a clear error, matching the dimension argument guard on the line above. --------- Signed-off-by: Sven Klemm <31455525+svenklemm@users.noreply.github.com> Co-authored-by: Sven Klemm <31455525+svenklemm@users.noreply.github.com>
1 parent 1ffc7a7 commit f757431

4 files changed

Lines changed: 6 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixes: #10327 Assertion failure in add_dimension when the hypertable argument is NULL
2+
Thanks: @JoongHyuk-Shin for reporting and fixing NULL handling in add_dimension

src/dimension.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ ts_dimension_add_general(PG_FUNCTION_ARGS)
19481948
{
19491949
DimensionInfo *info = NULL;
19501950
GETARG_NOTNULL_POINTER(info, 1, "dimension", DimensionInfo);
1951-
info->table_relid = PG_GETARG_OID(0);
1951+
GETARG_NOTNULL_OID(info->table_relid, 0, "hypertable");
19521952
if (PG_GETARG_BOOL(2))
19531953
{
19541954
info->if_not_exists = true;

tsl/test/expected/hypertable_generalization.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ SELECT create_hypertable('n',NULL::_timescaledb_internal.dimension_info);
1818
ERROR: dimension cannot be NULL
1919
SELECT add_dimension('n',NULL::_timescaledb_internal.dimension_info);
2020
ERROR: dimension cannot be NULL
21+
SELECT add_dimension(NULL, by_range('id'));
22+
ERROR: hypertable cannot be NULL
2123
\set ON_ERROR_STOP 1
2224
-- test int types
2325
SELECT by_range('id',2::int2);

tsl/test/sql/hypertable_generalization.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ $BODY$;
1818
CREATE TABLE n();
1919
SELECT create_hypertable('n',NULL::_timescaledb_internal.dimension_info);
2020
SELECT add_dimension('n',NULL::_timescaledb_internal.dimension_info);
21+
SELECT add_dimension(NULL, by_range('id'));
2122
\set ON_ERROR_STOP 1
2223

2324
-- test int types

0 commit comments

Comments
 (0)