Fix off-by-one error on range-end

A hash function can have the value 2147483647, so range_end has to be
2147483648.
This commit is contained in:
Matvey Arye 2017-10-23 09:27:47 -04:00 committed by Matvey Arye
parent 5be7521a0b
commit 2dfbc829b0
10 changed files with 53 additions and 51 deletions

View File

@ -25,6 +25,8 @@ INNER JOIN pg_class pg_hypertable_index_class ON (
pg_hypertable_con.conindid = pg_hypertable_index_class.oid
);
UPDATE _timescaledb_catalog.dimension_slice SET range_end = 2147483648 WHERE range_end = 2147483647;
-- Upgrade support for setting partitioning function
DROP FUNCTION create_hypertable(regclass,name,name,integer,name,name,anyelement,boolean,boolean);
DROP FUNCTION add_dimension(regclass,name,integer,bigint);

View File

@ -108,7 +108,7 @@ BEGIN
return format(
$$
%1$I.%2$s(%3$I%4$s) >= %5$L AND %1$I.%2$s(%3$I%4$s) < %6$L
%1$I.%2$s(%3$I%4$s) >= %5$L::bigint AND %1$I.%2$s(%3$I%4$s) < %6$L::bigint
$$,
dimension_row.partitioning_func_schema,
dimension_row.partitioning_func,

View File

@ -143,7 +143,7 @@ create_range_datum(FunctionCallInfo fcinfo, DimensionSlice *slice)
return HeapTupleGetDatum(tuple);
}
#define RANGE_VALUE_MAX PG_INT32_MAX
#define RANGE_VALUE_MAX ((int64)PG_INT32_MAX + 1)
static DimensionSlice *
calculate_open_range_default(Dimension *dim, int64 value)
@ -192,7 +192,7 @@ calculate_closed_range_default(Dimension *dim, int64 value)
range_end;
/* The interval that divides the dimension into N equal sized slices */
int64 interval = RANGE_VALUE_MAX / dim->fd.num_slices;
int64 interval = RANGE_VALUE_MAX / ((int64)dim->fd.num_slices);
int64 last_start = interval * (dim->fd.num_slices - 1);
if (value < 0)

View File

@ -35,7 +35,7 @@ SELECT * FROM _timescaledb_catalog.dimension_slice;
id | dimension_id | range_start | range_end
----+--------------+-------------+------------
1 | 1 | 3 | 6
2 | 2 | 0 | 1073741823
2 | 2 | 0 | 1073741824
(2 rows)
INSERT INTO chunk_test VALUES (4, 24.3, 2, 1);
@ -50,11 +50,11 @@ ORDER BY c.id, d.id;
chunk_name | dimension_id | slice_id | range_start | range_end
------------------+--------------+----------+-------------+------------
_hyper_1_1_chunk | 1 | 1 | 3 | 6
_hyper_1_1_chunk | 2 | 2 | 0 | 1073741823
_hyper_1_1_chunk | 2 | 2 | 0 | 1073741824
_hyper_1_2_chunk | 1 | 1 | 3 | 6
_hyper_1_2_chunk | 2 | 3 | 1073741823 | 2147483647
_hyper_1_2_chunk | 2 | 3 | 1073741824 | 2147483648
_hyper_1_3_chunk | 1 | 4 | 9 | 12
_hyper_1_3_chunk | 2 | 3 | 1073741823 | 2147483647
_hyper_1_3_chunk | 2 | 3 | 1073741824 | 2147483648
(6 rows)
\c single :ROLE_SUPERUSER
@ -94,11 +94,11 @@ ORDER BY c.id, d.id;
chunk_name | dimension_id | slice_id | range_start | range_end
------------------+--------------+----------+-------------+------------
_hyper_1_1_chunk | 1 | 1 | 3 | 6
_hyper_1_1_chunk | 2 | 2 | 0 | 1073741823
_hyper_1_1_chunk | 2 | 2 | 0 | 1073741824
_hyper_1_2_chunk | 1 | 1 | 3 | 6
_hyper_1_2_chunk | 2 | 3 | 1073741823 | 2147483647
_hyper_1_2_chunk | 2 | 3 | 1073741824 | 2147483648
_hyper_1_3_chunk | 1 | 4 | 9 | 12
_hyper_1_3_chunk | 2 | 3 | 1073741823 | 2147483647
_hyper_1_3_chunk | 2 | 3 | 1073741824 | 2147483648
_hyper_1_4_chunk | 1 | 5 | 8 | 9
_hyper_1_4_chunk | 2 | 6 | 0 | 715827882
_hyper_1_5_chunk | 1 | 7 | 6 | 8

View File

@ -178,10 +178,10 @@ SELECT *,
) sub2;
chunk_id | chunk_table | partitioning_columns | partitioning_column_types | partitioning_hash_functions | ranges | table_bytes | index_bytes | toast_bytes | total_bytes
----------+--------------------------------------------+------------------------+---------------------------+-------------------------------------------------+-----------------------------------------------------------------------------+-------------+-------------+-------------+-------------
1 | "_timescaledb_internal"."_hyper_1_1_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[1073741823,2147483647)"} | 8192 | 114688 | 8192 | 131072
2 | "_timescaledb_internal"."_hyper_1_2_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257897600000000000','1257900192000000000')","[1073741823,2147483647)"} | 8192 | 106496 | 8192 | 122880
3 | "_timescaledb_internal"."_hyper_1_3_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257985728000000000','1257988320000000000')","[1073741823,2147483647)"} | 8192 | 98304 | 8192 | 114688
4 | "_timescaledb_internal"."_hyper_1_4_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[0,1073741823)"} | 8192 | 98304 | 8192 | 114688
1 | "_timescaledb_internal"."_hyper_1_1_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[1073741824,2147483648)"} | 8192 | 114688 | 8192 | 131072
2 | "_timescaledb_internal"."_hyper_1_2_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257897600000000000','1257900192000000000')","[1073741824,2147483648)"} | 8192 | 106496 | 8192 | 122880
3 | "_timescaledb_internal"."_hyper_1_3_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257985728000000000','1257988320000000000')","[1073741824,2147483648)"} | 8192 | 98304 | 8192 | 114688
4 | "_timescaledb_internal"."_hyper_1_4_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[0,1073741824)"} | 8192 | 98304 | 8192 | 114688
(4 rows)
\echo 'Hypertable index sizes'

View File

@ -288,11 +288,11 @@ INSERT INTO "3dim" VALUES('2017-01-20T09:00:21', 21.2, 'brown', 'sthlm');
INSERT INTO "3dim" VALUES('2017-01-20T09:00:47', 25.1, 'yellow', 'la');
--show the constraints on the three-dimensional chunk
SELECT * FROM test.show_constraints('_timescaledb_internal._hyper_7_15_chunk');
Constraint | Type | Columns | Index | Expr
---------------+------+------------+-------+----------------------------------------------------------------------------------------------------------------------------------------------
Constraint | Type | Columns | Index | Expr
---------------+------+------------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------
constraint_15 | c | {time} | - | (("time" >= 'Sat Dec 24 16:00:00 2016'::timestamp without time zone) AND ("time" < 'Mon Jan 23 16:00:00 2017'::timestamp without time zone))
constraint_16 | c | {device} | - | ((_timescaledb_internal.get_partition_hash(device) >= 0) AND (_timescaledb_internal.get_partition_hash(device) < 1073741823))
constraint_17 | c | {location} | - | ((_timescaledb_internal.get_partition_hash(location) >= 1073741823) AND (_timescaledb_internal.get_partition_hash(location) < 2147483647))
constraint_16 | c | {device} | - | ((_timescaledb_internal.get_partition_hash(device) >= '0'::bigint) AND (_timescaledb_internal.get_partition_hash(device) < '1073741824'::bigint))
constraint_17 | c | {location} | - | ((_timescaledb_internal.get_partition_hash(location) >= '1073741824'::bigint) AND (_timescaledb_internal.get_partition_hash(location) < '2147483648'::bigint))
(3 rows)
--queries should work in three dimensions

View File

@ -19,12 +19,12 @@ INSERT INTO part_legacy VALUES ('2017-03-22T09:18:23', 23.4, 76);
VACUUM part_legacy;
-- Show two chunks and CHECK constraint with cast
SELECT * FROM test.show_constraintsp('_timescaledb_internal._hyper_1_%_chunk');
Table | Constraint | Type | Columns | Index | Expr
----------------------------------------+--------------+------+----------+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------
Table | Constraint | Type | Columns | Index | Expr
----------------------------------------+--------------+------+----------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
_timescaledb_internal._hyper_1_1_chunk | constraint_1 | c | {time} | - | (("time" >= 'Wed Feb 22 16:00:00 2017 PST'::timestamp with time zone) AND ("time" < 'Fri Mar 24 17:00:00 2017 PDT'::timestamp with time zone))
_timescaledb_internal._hyper_1_1_chunk | constraint_2 | c | {device} | - | ((_timescaledb_internal.get_partition_for_key((device)::text) >= 1073741823) AND (_timescaledb_internal.get_partition_for_key((device)::text) < 2147483647))
_timescaledb_internal._hyper_1_1_chunk | constraint_2 | c | {device} | - | ((_timescaledb_internal.get_partition_for_key((device)::text) >= '1073741824'::bigint) AND (_timescaledb_internal.get_partition_for_key((device)::text) < '2147483648'::bigint))
_timescaledb_internal._hyper_1_2_chunk | constraint_1 | c | {time} | - | (("time" >= 'Wed Feb 22 16:00:00 2017 PST'::timestamp with time zone) AND ("time" < 'Fri Mar 24 17:00:00 2017 PDT'::timestamp with time zone))
_timescaledb_internal._hyper_1_2_chunk | constraint_3 | c | {device} | - | ((_timescaledb_internal.get_partition_for_key((device)::text) >= 0) AND (_timescaledb_internal.get_partition_for_key((device)::text) < 1073741823))
_timescaledb_internal._hyper_1_2_chunk | constraint_3 | c | {device} | - | ((_timescaledb_internal.get_partition_for_key((device)::text) >= '0'::bigint) AND (_timescaledb_internal.get_partition_for_key((device)::text) < '1073741824'::bigint))
(4 rows)
-- Make sure constraint exclusion works on device column
@ -63,12 +63,12 @@ INSERT INTO part_new VALUES ('2017-03-22T09:18:23', 23.4, 2);
VACUUM part_new;
-- Show two chunks and CHECK constraint without cast
SELECT * FROM test.show_constraintsp('_timescaledb_internal._hyper_2_%_chunk');
Table | Constraint | Type | Columns | Index | Expr
----------------------------------------+--------------+------+----------+-------+------------------------------------------------------------------------------------------------------------------------------------------------
Table | Constraint | Type | Columns | Index | Expr
----------------------------------------+--------------+------+----------+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------
_timescaledb_internal._hyper_2_3_chunk | constraint_4 | c | {time} | - | (("time" >= 'Wed Feb 22 16:00:00 2017 PST'::timestamp with time zone) AND ("time" < 'Fri Mar 24 17:00:00 2017 PDT'::timestamp with time zone))
_timescaledb_internal._hyper_2_3_chunk | constraint_5 | c | {device} | - | ((_timescaledb_internal.get_partition_hash(device) >= 0) AND (_timescaledb_internal.get_partition_hash(device) < 1073741823))
_timescaledb_internal._hyper_2_3_chunk | constraint_5 | c | {device} | - | ((_timescaledb_internal.get_partition_hash(device) >= '0'::bigint) AND (_timescaledb_internal.get_partition_hash(device) < '1073741824'::bigint))
_timescaledb_internal._hyper_2_4_chunk | constraint_4 | c | {time} | - | (("time" >= 'Wed Feb 22 16:00:00 2017 PST'::timestamp with time zone) AND ("time" < 'Fri Mar 24 17:00:00 2017 PDT'::timestamp with time zone))
_timescaledb_internal._hyper_2_4_chunk | constraint_6 | c | {device} | - | ((_timescaledb_internal.get_partition_hash(device) >= 1073741823) AND (_timescaledb_internal.get_partition_hash(device) < 2147483647))
_timescaledb_internal._hyper_2_4_chunk | constraint_6 | c | {device} | - | ((_timescaledb_internal.get_partition_hash(device) >= '1073741824'::bigint) AND (_timescaledb_internal.get_partition_hash(device) < '2147483648'::bigint))
(4 rows)
-- Make sure constraint exclusion works on device column

View File

@ -107,11 +107,11 @@ SELECT * FROM test.show_constraints('public."two_Partitions"');
(1 row)
SELECT * FROM test.show_constraints('_timescaledb_internal._hyper_1_1_chunk');
Constraint | Type | Columns | Index | Expr
---------------------------------------+------+---------------------------------+---------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------
Constraint | Type | Columns | Index | Expr
---------------------------------------+------+---------------------------------+---------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------
1_1_timecustom_device_id_series_2_key | u | {timeCustom,device_id,series_2} | _timescaledb_internal."1_1_timecustom_device_id_series_2_key" |
constraint_1 | c | {timeCustom} | - | (("timeCustom" >= '1257892416000000000'::bigint) AND ("timeCustom" < '1257895008000000000'::bigint))
constraint_2 | c | {device_id} | - | ((_timescaledb_internal.get_partition_hash(device_id) >= 1073741823) AND (_timescaledb_internal.get_partition_hash(device_id) < 2147483647))
constraint_2 | c | {device_id} | - | ((_timescaledb_internal.get_partition_hash(device_id) >= '1073741824'::bigint) AND (_timescaledb_internal.get_partition_hash(device_id) < '2147483648'::bigint))
(3 rows)
SELECT * FROM test.show_triggers('public."two_Partitions"');
@ -294,11 +294,11 @@ SELECT * FROM test.show_constraints('public."two_Partitions"');
(1 row)
SELECT * FROM test.show_constraints('_timescaledb_internal._hyper_1_1_chunk');
Constraint | Type | Columns | Index | Expr
---------------------------------------+------+---------------------------------+---------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------
Constraint | Type | Columns | Index | Expr
---------------------------------------+------+---------------------------------+---------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------
1_1_timecustom_device_id_series_2_key | u | {timeCustom,device_id,series_2} | _timescaledb_internal."1_1_timecustom_device_id_series_2_key" |
constraint_1 | c | {timeCustom} | - | (("timeCustom" >= '1257892416000000000'::bigint) AND ("timeCustom" < '1257895008000000000'::bigint))
constraint_2 | c | {device_id} | - | ((_timescaledb_internal.get_partition_hash(device_id) >= 1073741823) AND (_timescaledb_internal.get_partition_hash(device_id) < 2147483647))
constraint_2 | c | {device_id} | - | ((_timescaledb_internal.get_partition_hash(device_id) >= '1073741824'::bigint) AND (_timescaledb_internal.get_partition_hash(device_id) < '2147483648'::bigint))
(3 rows)
SELECT * FROM test.show_triggers('public."two_Partitions"');

View File

@ -52,19 +52,19 @@ SELECT * FROM hypertable_relation_size_pretty('"public"."two_Partitions"');
SELECT * FROM chunk_relation_size('"public"."two_Partitions"');
chunk_id | chunk_table | partitioning_columns | partitioning_column_types | partitioning_hash_functions | ranges | table_bytes | index_bytes | toast_bytes | total_bytes
----------+--------------------------------------------+------------------------+---------------------------+-------------------------------------------------+-------------------------------------------------------------------------+-------------+-------------+-------------+-------------
1 | "_timescaledb_internal"."_hyper_1_1_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1257892416000000000,1257895008000000000)","[1073741823,2147483647)"} | 8192 | 114688 | 8192 | 131072
2 | "_timescaledb_internal"."_hyper_1_2_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1257897600000000000,1257900192000000000)","[1073741823,2147483647)"} | 8192 | 106496 | 8192 | 122880
3 | "_timescaledb_internal"."_hyper_1_3_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1257985728000000000,1257988320000000000)","[1073741823,2147483647)"} | 8192 | 98304 | 8192 | 114688
4 | "_timescaledb_internal"."_hyper_1_4_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1257892416000000000,1257895008000000000)","[0,1073741823)"} | 8192 | 98304 | 8192 | 114688
1 | "_timescaledb_internal"."_hyper_1_1_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1257892416000000000,1257895008000000000)","[1073741824,2147483648)"} | 8192 | 114688 | 8192 | 131072
2 | "_timescaledb_internal"."_hyper_1_2_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1257897600000000000,1257900192000000000)","[1073741824,2147483648)"} | 8192 | 106496 | 8192 | 122880
3 | "_timescaledb_internal"."_hyper_1_3_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1257985728000000000,1257988320000000000)","[1073741824,2147483648)"} | 8192 | 98304 | 8192 | 114688
4 | "_timescaledb_internal"."_hyper_1_4_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1257892416000000000,1257895008000000000)","[0,1073741824)"} | 8192 | 98304 | 8192 | 114688
(4 rows)
SELECT * FROM chunk_relation_size_pretty('"public"."two_Partitions"');
chunk_id | chunk_table | partitioning_columns | partitioning_column_types | partitioning_hash_functions | ranges | table_size | index_size | toast_size | total_size
----------+--------------------------------------------+------------------------+---------------------------+-------------------------------------------------+-----------------------------------------------------------------------------+------------+------------+------------+------------
1 | "_timescaledb_internal"."_hyper_1_1_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[1073741823,2147483647)"} | 8192 bytes | 112 kB | 8192 bytes | 128 kB
2 | "_timescaledb_internal"."_hyper_1_2_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257897600000000000','1257900192000000000')","[1073741823,2147483647)"} | 8192 bytes | 104 kB | 8192 bytes | 120 kB
3 | "_timescaledb_internal"."_hyper_1_3_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257985728000000000','1257988320000000000')","[1073741823,2147483647)"} | 8192 bytes | 96 kB | 8192 bytes | 112 kB
4 | "_timescaledb_internal"."_hyper_1_4_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[0,1073741823)"} | 8192 bytes | 96 kB | 8192 bytes | 112 kB
1 | "_timescaledb_internal"."_hyper_1_1_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[1073741824,2147483648)"} | 8192 bytes | 112 kB | 8192 bytes | 128 kB
2 | "_timescaledb_internal"."_hyper_1_2_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257897600000000000','1257900192000000000')","[1073741824,2147483648)"} | 8192 bytes | 104 kB | 8192 bytes | 120 kB
3 | "_timescaledb_internal"."_hyper_1_3_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257985728000000000','1257988320000000000')","[1073741824,2147483648)"} | 8192 bytes | 96 kB | 8192 bytes | 112 kB
4 | "_timescaledb_internal"."_hyper_1_4_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[0,1073741824)"} | 8192 bytes | 96 kB | 8192 bytes | 112 kB
(4 rows)
SELECT * FROM indexes_relation_size('"public"."two_Partitions"');
@ -104,15 +104,15 @@ INSERT INTO timestamp_partitioned VALUES('2004-12-19 10:23:54', '30');
SELECT * FROM chunk_relation_size('timestamp_partitioned');
chunk_id | chunk_table | partitioning_columns | partitioning_column_types | partitioning_hash_functions | ranges | table_bytes | index_bytes | toast_bytes | total_bytes
----------+--------------------------------------------+----------------------+--------------------------------------+-------------------------------------------------+-------------------------------------------------------------------+-------------+-------------+-------------+-------------
5 | "_timescaledb_internal"."_hyper_2_5_chunk" | {time,value} | {"timestamp without time zone",text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1096416000000000,1099008000000000)","[1073741823,2147483647)"} | 8192 | 32768 | 8192 | 49152
6 | "_timescaledb_internal"."_hyper_2_6_chunk" | {time,value} | {"timestamp without time zone",text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1101600000000000,1104192000000000)","[1073741823,2147483647)"} | 8192 | 32768 | 8192 | 49152
5 | "_timescaledb_internal"."_hyper_2_5_chunk" | {time,value} | {"timestamp without time zone",text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1096416000000000,1099008000000000)","[1073741824,2147483648)"} | 8192 | 32768 | 8192 | 49152
6 | "_timescaledb_internal"."_hyper_2_6_chunk" | {time,value} | {"timestamp without time zone",text} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1101600000000000,1104192000000000)","[1073741824,2147483648)"} | 8192 | 32768 | 8192 | 49152
(2 rows)
SELECT * FROM chunk_relation_size_pretty('timestamp_partitioned');
chunk_id | chunk_table | partitioning_columns | partitioning_column_types | partitioning_hash_functions | ranges | table_size | index_size | toast_size | total_size
----------+--------------------------------------------+----------------------+--------------------------------------+-------------------------------------------------+-----------------------------------------------------------------------------------------------+------------+------------+------------+------------
5 | "_timescaledb_internal"."_hyper_2_5_chunk" | {time,value} | {"timestamp without time zone",text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['Tue Sep 28 17:00:00 2004 PDT','Thu Oct 28 17:00:00 2004 PDT')","[1073741823,2147483647)"} | 8192 bytes | 32 kB | 8192 bytes | 48 kB
6 | "_timescaledb_internal"."_hyper_2_6_chunk" | {time,value} | {"timestamp without time zone",text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['Sat Nov 27 16:00:00 2004 PST','Mon Dec 27 16:00:00 2004 PST')","[1073741823,2147483647)"} | 8192 bytes | 32 kB | 8192 bytes | 48 kB
5 | "_timescaledb_internal"."_hyper_2_5_chunk" | {time,value} | {"timestamp without time zone",text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['Tue Sep 28 17:00:00 2004 PDT','Thu Oct 28 17:00:00 2004 PDT')","[1073741824,2147483648)"} | 8192 bytes | 32 kB | 8192 bytes | 48 kB
6 | "_timescaledb_internal"."_hyper_2_6_chunk" | {time,value} | {"timestamp without time zone",text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['Sat Nov 27 16:00:00 2004 PST','Mon Dec 27 16:00:00 2004 PST')","[1073741824,2147483648)"} | 8192 bytes | 32 kB | 8192 bytes | 48 kB
(2 rows)
CREATE TABLE timestamp_partitioned_2(time TIMESTAMP, value CHAR(9));
@ -128,14 +128,14 @@ INSERT INTO timestamp_partitioned_2 VALUES('2004-12-19 10:23:54', '30');
SELECT * FROM chunk_relation_size('timestamp_partitioned_2');
chunk_id | chunk_table | partitioning_columns | partitioning_column_types | partitioning_hash_functions | ranges | table_bytes | index_bytes | toast_bytes | total_bytes
----------+--------------------------------------------+----------------------+-------------------------------------------+-------------------------------------------------+-------------------------------------------------------------------+-------------+-------------+-------------+-------------
7 | "_timescaledb_internal"."_hyper_3_7_chunk" | {time,value} | {"timestamp without time zone",character} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1096416000000000,1099008000000000)","[1073741823,2147483647)"} | 8192 | 32768 | | 40960
8 | "_timescaledb_internal"."_hyper_3_8_chunk" | {time,value} | {"timestamp without time zone",character} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1101600000000000,1104192000000000)","[1073741823,2147483647)"} | 8192 | 32768 | | 40960
7 | "_timescaledb_internal"."_hyper_3_7_chunk" | {time,value} | {"timestamp without time zone",character} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1096416000000000,1099008000000000)","[1073741824,2147483648)"} | 8192 | 32768 | | 40960
8 | "_timescaledb_internal"."_hyper_3_8_chunk" | {time,value} | {"timestamp without time zone",character} | {NULL,_timescaledb_internal.get_partition_hash} | {"[1101600000000000,1104192000000000)","[1073741824,2147483648)"} | 8192 | 32768 | | 40960
(2 rows)
SELECT * FROM chunk_relation_size_pretty('timestamp_partitioned_2');
chunk_id | chunk_table | partitioning_columns | partitioning_column_types | partitioning_hash_functions | ranges | table_size | index_size | toast_size | total_size
----------+--------------------------------------------+----------------------+-------------------------------------------+-------------------------------------------------+-----------------------------------------------------------------------------------------------+------------+------------+------------+------------
7 | "_timescaledb_internal"."_hyper_3_7_chunk" | {time,value} | {"timestamp without time zone",character} | {NULL,_timescaledb_internal.get_partition_hash} | {"['Tue Sep 28 17:00:00 2004 PDT','Thu Oct 28 17:00:00 2004 PDT')","[1073741823,2147483647)"} | 8192 bytes | 32 kB | | 40 kB
8 | "_timescaledb_internal"."_hyper_3_8_chunk" | {time,value} | {"timestamp without time zone",character} | {NULL,_timescaledb_internal.get_partition_hash} | {"['Sat Nov 27 16:00:00 2004 PST','Mon Dec 27 16:00:00 2004 PST')","[1073741823,2147483647)"} | 8192 bytes | 32 kB | | 40 kB
7 | "_timescaledb_internal"."_hyper_3_7_chunk" | {time,value} | {"timestamp without time zone",character} | {NULL,_timescaledb_internal.get_partition_hash} | {"['Tue Sep 28 17:00:00 2004 PDT','Thu Oct 28 17:00:00 2004 PDT')","[1073741824,2147483648)"} | 8192 bytes | 32 kB | | 40 kB
8 | "_timescaledb_internal"."_hyper_3_8_chunk" | {time,value} | {"timestamp without time zone",character} | {NULL,_timescaledb_internal.get_partition_hash} | {"['Sat Nov 27 16:00:00 2004 PST','Mon Dec 27 16:00:00 2004 PST')","[1073741824,2147483648)"} | 8192 bytes | 32 kB | | 40 kB
(2 rows)

View File

@ -27,8 +27,8 @@ SELECT assert_equal(-20::bigint, actual_range_start), assert_equal(-10::bigint,
FROM _timescaledb_internal.dimension_calculate_default_range_open(-11,10) AS res(actual_range_start, actual_range_end);
--closed
SELECT assert_equal(0::bigint, actual_range_start), assert_equal(1073741823::bigint, actual_range_end)
SELECT assert_equal(0::bigint, actual_range_start), assert_equal(1073741824::bigint, actual_range_end)
FROM _timescaledb_internal.dimension_calculate_default_range_closed(0,2::smallint) AS res(actual_range_start, actual_range_end);
SELECT assert_equal(1073741823::bigint, actual_range_start), assert_equal(2147483647::bigint, actual_range_end)
FROM _timescaledb_internal.dimension_calculate_default_range_closed(1073741823,2::smallint) AS res(actual_range_start, actual_range_end);
SELECT assert_equal(1073741824::bigint, actual_range_start), assert_equal(2147483648::bigint, actual_range_end)
FROM _timescaledb_internal.dimension_calculate_default_range_closed(1073741824,2::smallint) AS res(actual_range_start, actual_range_end);