You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add some helper function to decouple OSM from direct catalog access:
_timescaledb_functions.get_hypertable_id(hypertable REGCLASS)
_timescaledb_functions.get_hypertable_id(schema_name name, table_name name)
_timescaledb_functions.get_hypertable_name(IN hypertable_id INTEGER, OUT schema_name name, OUT table_name name)
_timescaledb_functions.get_chunk_id(hypertable REGCLASS)
_timescaledb_functions.get_chunk_id(schema_name name, table_name name)
_timescaledb_functions.get_chunk_name(IN chunk_id INTEGER, OUT schema_name name, OUT table_name name)
_timescaledb_functions.get_hypertable_info
_timescaledb_functions.get_primary_dimension
_timescaledb_functions.get_chunk_info
_timescaledb_functions.get_chunk_info_by_id
_timescaledb_functions.get_chunk_primary_range
_timescaledb_functions.get_chunk_primary_range_by_id
_timescaledb_functions.lock_osm_dimension_slice
_timescaledb_functions.lock_osm_dimension_slice_by_id
$$ LANGUAGE SQL STABLE SET search_path = pg_catalog, pg_temp;
47
+
48
+
CREATE OR REPLACEFUNCTION_timescaledb_functions.get_hypertable_info(IN relation REGCLASS, OUT hypertable_id INTEGER, OUT schema_name name, OUT table_name name, OUT is_cagg BOOLEAN) AS $$
49
+
SELECTht.id, ht.schema_name, ht.table_name, false AS is_cagg
50
+
FROM_timescaledb_catalog.hypertable ht
51
+
JOIN pg_class c ONht.table_name=c.relnameANDht.schema_name=c.relnamespace::regnamespace::name ANDc.oid= relation
52
+
UNION ALL
53
+
SELECTht.id, ht.schema_name, ht.table_name, true AS is_cagg
54
+
FROM_timescaledb_catalog.continuous_agg cagg
55
+
JOIN pg_class c ONcagg.user_view_name=c.relnameANDcagg.user_view_schema=c.relnamespace::regnamespace::name ANDc.oid= relation
$$ LANGUAGE SQL STABLE SET search_path = pg_catalog, pg_temp;
58
+
59
+
CREATE OR REPLACEFUNCTION_timescaledb_functions.get_primary_dimension(IN hypertable_id INTEGER, OUT column_name NAME, OUT column_type REGTYPE, OUT integer_now_func regproc) AS $$
60
+
SELECT
61
+
d.column_name,
62
+
d.column_type,
63
+
CASE WHEN integer_now_func_schema IS NOT NULLAND integer_now_func IS NOT NULL THEN to_regproc(format('%I.%I',integer_now_func_schema,integer_now_func)) END AS integer_now
64
+
FROM_timescaledb_catalog.dimension d
65
+
LEFT JOIN_timescaledb_catalog.continuous_agg cagg ONcagg.mat_hypertable_id= $1
66
+
WHEREd.hypertable_id= COALESCE(cagg.raw_hypertable_id, $1) ORDER BYd.idLIMIT1;
67
+
$$ LANGUAGE SQL STABLE SET search_path = pg_catalog, pg_temp;
68
+
69
+
CREATE OR REPLACEFUNCTION_timescaledb_functions.get_chunk_info(IN chunk REGCLASS, OUT chunk_id INTEGER, OUT hypertable_id INTEGER, OUT ht_schema_name NAME, OUT ht_table_name NAME, OUT chunk_schema NAME, OUT chunk_name NAME, OUT is_osm_chunk BOOLEAN, OUT is_frozen BOOLEAN) AS $$
$$ LANGUAGE SQL STABLE SET search_path = pg_catalog, pg_temp;
80
+
81
+
CREATE OR REPLACEFUNCTION_timescaledb_functions.get_chunk_info_by_id(IN chunk_id INTEGER, OUT chunk_id INTEGER, OUT hypertable_id INTEGER, OUT ht_schema_name NAME, OUT ht_table_name NAME, OUT chunk_schema NAME, OUT chunk_name NAME, OUT is_osm_chunk BOOLEAN, OUT is_frozen BOOLEAN) AS $$
0 commit comments