mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 02:23:49 +08:00
Refactor and fix cache invalidation
TimescaleDB cache invalidation happens as a side effect of doing a full SQL statement (INSERT/UPDATE/DELETE) on a catalog table (via table triggers). However, triggers aren't invoked when using PostgreSQL's internal catalog API for updates, since PostgreSQL's catalog tables don't have triggers that require full statement parsing, planning, and execution. Since we are now using the regular PostgreSQL catalog update API for some TimescaleDB catalog operations, we need to do cache invalidation also on such operations. This change adds cache invalidation when updating catalogs using the internal (C) API and also makes the cache invalidation more fine grained. For instance, caches are no longer invalidated on some INSERTS that do not affect the validity of objects already in the cache, such as adding a new chunk.
This commit is contained in:
parent
7b299fa05f
commit
e1a0e819cf
@ -17,20 +17,20 @@ SELECT pg_catalog.pg_extension_config_dump('_timescaledb_cache.cache_inval_exten
|
||||
|
||||
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.hypertable;
|
||||
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.hypertable
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger();
|
||||
|
||||
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.chunk;
|
||||
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.chunk
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger();
|
||||
|
||||
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.chunk_constraint;
|
||||
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.chunk_constraint
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger();
|
||||
|
||||
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.dimension_slice;
|
||||
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.dimension_slice
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger();
|
||||
|
||||
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.dimension;
|
||||
CREATE TRIGGER "0_cache_inval" AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON _timescaledb_catalog.dimension
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger('cache_inval_hypertable');
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE _timescaledb_cache.invalidate_relcache_trigger();
|
||||
|
@ -1,10 +1,8 @@
|
||||
-- this trigger function causes an invalidation event on the table whose name is
|
||||
-- passed in as the first element.
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_cache.invalidate_relcache_trigger()
|
||||
RETURNS TRIGGER AS '$libdir/timescaledb', 'invalidate_relcache_trigger' LANGUAGE C;
|
||||
RETURNS TRIGGER AS '$libdir/timescaledb', 'invalidate_relcache_trigger' LANGUAGE C STRICT;
|
||||
|
||||
-- This function is only used for debugging
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_cache.invalidate_relcache(proxy_oid OID)
|
||||
RETURNS BOOLEAN AS '$libdir/timescaledb', 'invalidate_relcache' LANGUAGE C;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_cache.invalidate_relcache(catalog_table REGCLASS)
|
||||
RETURNS BOOLEAN AS '$libdir/timescaledb', 'invalidate_relcache' LANGUAGE C STRICT;
|
||||
|
@ -1,2 +1,3 @@
|
||||
DROP FUNCTION _timescaledb_internal.create_hypertable_row(REGCLASS, NAME, NAME, NAME, NAME, INTEGER, NAME, NAME, BIGINT, NAME, REGPROC);
|
||||
DROP FUNCTION _timescaledb_internal.rename_hypertable(NAME, NAME, NAME, NAME);
|
||||
DROP FUNCTION _timescaledb_cache.invalidate_relcache(oid);
|
||||
|
@ -1,37 +1,44 @@
|
||||
/*
|
||||
* Notes on the way caching works: Since out caches are stored in per-process
|
||||
* (per-backend memory), we have to have a way to propagate invalidation
|
||||
* messages to all backends, for that we use the Postgres relcache
|
||||
* mechanism. Relcache is a cache that keeps internal info about
|
||||
* relations(tables). Postgres has a mechanism for registering for relcache
|
||||
* invalidation events that are propagated to all backends:
|
||||
* CacheRegisterRelcacheCallback(). We register inval_cache_callback() with
|
||||
* this mechanism and route all invalidation messages through it to the correct
|
||||
* cache invalidation functions.
|
||||
*
|
||||
* The plan for our caches is to use (abuse) this mechanism to serve as a
|
||||
* notify to invalidate our caches. Thus, we create proxy tables for each
|
||||
* cache we use and attach the invalidate_relcache_trigger trigger to all
|
||||
* tables whose changes should invalidate the cache. This trigger will
|
||||
* invalidate the relcache for the proxy table specified as the first argument
|
||||
* to the trigger (see cache.sql).
|
||||
*/
|
||||
|
||||
#include <postgres.h>
|
||||
#include <access/xact.h>
|
||||
#include <utils/lsyscache.h>
|
||||
#include <catalog/namespace.h>
|
||||
#include <miscadmin.h>
|
||||
#include <commands/trigger.h>
|
||||
#include <commands/event_trigger.h>
|
||||
#include <nodes/nodes.h>
|
||||
#include <utils/inval.h>
|
||||
#include <unistd.h>
|
||||
#include <catalog/namespace.h>
|
||||
#include <commands/trigger.h>
|
||||
#include <nodes/nodes.h>
|
||||
#include <miscadmin.h>
|
||||
|
||||
#include "hypertable_cache.h"
|
||||
#include "catalog.h"
|
||||
#include "extension.h"
|
||||
|
||||
/*
|
||||
* Notes on the way cache invalidation works.
|
||||
*
|
||||
* Since our caches are stored in per-process (per-backend memory), we need a
|
||||
* way to signal all backends that they should invalidate their caches. For this
|
||||
* we use the PostgreSQL relcache mechanism that propagates relation cache
|
||||
* invalidation events to all backends. We register a callback with this
|
||||
* mechanism to recieve events on all backends whenever a relation cache entry
|
||||
* is invalidated.
|
||||
*
|
||||
* To know which events should trigger invalidation of our caches, we use dummy
|
||||
* (empty) tables. We can trigger relcache invalidation events for these tables
|
||||
* to signal other backends. If the received table OID is a dummy table, we know
|
||||
* that this is an event that we care about.
|
||||
*
|
||||
* Caches for catalog tables should be invalidated on:
|
||||
*
|
||||
* 1. INSERT/UPDATE/DELETE on a catalog table
|
||||
* 2. Aborted transactions that taint the caches
|
||||
*
|
||||
* Generally, INSERTS do not warrant cache invalidation, unless it is an insert
|
||||
* of a subobject that belongs to an object that might already be in the cache
|
||||
* (e.g., a new dimension of a hypertable), or when replacing an existing entry
|
||||
* (e.g., when replacing a negative hypertable entry with a positive one). Note,
|
||||
* also, that INSERTS can taint the cache if the transaction that did the INSERT
|
||||
* fails. This is why we also need to invalidate caches on transaction failure.
|
||||
*/
|
||||
|
||||
void _cache_invalidate_init(void);
|
||||
void _cache_invalidate_fini(void);
|
||||
void _cache_invalidate_extload(void);
|
||||
@ -41,7 +48,7 @@ void _cache_invalidate_extload(void);
|
||||
* Should route the invalidation to the correct cache.
|
||||
*/
|
||||
static void
|
||||
inval_cache_callback(Datum arg, Oid relid)
|
||||
cache_invalidate_callback(Datum arg, Oid relid)
|
||||
{
|
||||
Catalog *catalog;
|
||||
|
||||
@ -60,41 +67,38 @@ inval_cache_callback(Datum arg, Oid relid)
|
||||
hypertable_cache_invalidate_callback();
|
||||
}
|
||||
|
||||
static inline CmdType
|
||||
trigger_event_to_cmdtype(TriggerEvent event)
|
||||
{
|
||||
if (TRIGGER_FIRED_BY_INSERT(event))
|
||||
return CMD_INSERT;
|
||||
|
||||
if (TRIGGER_FIRED_BY_UPDATE(event))
|
||||
return CMD_UPDATE;
|
||||
|
||||
return CMD_DELETE;
|
||||
}
|
||||
|
||||
PGDLLEXPORT Datum invalidate_relcache_trigger(PG_FUNCTION_ARGS);
|
||||
|
||||
PG_FUNCTION_INFO_V1(invalidate_relcache_trigger);
|
||||
|
||||
/*
|
||||
* This trigger causes the relcache for the cache_inval_proxy table (passed in
|
||||
* as arg 0) to be invalidated. It should be called to invalidate the caches
|
||||
* associated with a proxy table (usually each cache has it's own proxy table)
|
||||
* This function is attached to the right tables in common/cache.sql
|
||||
* Trigger for catalog tables that invalidates caches.
|
||||
*
|
||||
* This trigger generates a cache invalidation event on changes to the catalog
|
||||
* table that the trigger is defined for.
|
||||
*/
|
||||
Datum
|
||||
invalidate_relcache_trigger(PG_FUNCTION_ARGS)
|
||||
{
|
||||
TriggerData *trigdata = (TriggerData *) fcinfo->context;
|
||||
Oid proxy_oid;
|
||||
Catalog *catalog = catalog_get();
|
||||
|
||||
if (!CALLED_AS_TRIGGER(fcinfo))
|
||||
elog(ERROR, "not called by trigger manager");
|
||||
|
||||
/* arg 0 = name of the proxy table */
|
||||
proxy_oid = catalog_get_cache_proxy_id_by_name(catalog, trigdata->tg_trigger->tgargs[0]);
|
||||
if (proxy_oid != 0)
|
||||
{
|
||||
CacheInvalidateRelcacheByRelid(proxy_oid);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* This can happen during upgrade scripts when the catalog is
|
||||
* unavailable
|
||||
*/
|
||||
CacheInvalidateRelcacheByRelid(get_relname_relid(trigdata->tg_trigger->tgargs[0], get_namespace_oid(CACHE_SCHEMA_NAME, false)));
|
||||
}
|
||||
catalog_invalidate_cache(RelationGetRelid(trigdata->tg_relation),
|
||||
trigger_event_to_cmdtype(trigdata->tg_event));
|
||||
|
||||
/* tuple to return to executor */
|
||||
if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
|
||||
@ -108,30 +112,52 @@ PGDLLEXPORT Datum invalidate_relcache(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(invalidate_relcache);
|
||||
|
||||
/*
|
||||
* This is similar to invalidate_relcache_trigger but not a trigger.
|
||||
* Not used regularly but useful for debugging.
|
||||
* Force a cache invalidation for a catalog table.
|
||||
*
|
||||
* This function is used for debugging purposes and triggers
|
||||
* a cache invalidation.
|
||||
*
|
||||
* The first argument should be the catalog table that has changed, warranting a
|
||||
* cache invalidation.
|
||||
*/
|
||||
Datum
|
||||
invalidate_relcache(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid proxy_oid = PG_GETARG_OID(0);
|
||||
catalog_invalidate_cache(PG_GETARG_OID(0), CMD_UPDATE);
|
||||
PG_RETURN_BOOL(true);
|
||||
}
|
||||
|
||||
/* arg 0 = relid of the cache_inval_proxy table */
|
||||
CacheInvalidateRelcacheByRelid(proxy_oid);
|
||||
static void
|
||||
cache_invalidate_xact_end(XactEvent event, void *arg)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case XACT_EVENT_ABORT:
|
||||
case XACT_EVENT_PARALLEL_ABORT:
|
||||
|
||||
/* tuple to return to executor */
|
||||
return BoolGetDatum(true);
|
||||
/*
|
||||
* Invalidate caches on aborted transactions to purge entries that
|
||||
* have been added during the transaction and are now no longer
|
||||
* valid. Note that we need not signal other backends of this
|
||||
* change since the transaction hasn't been committed and other
|
||||
* backends cannot have the invalid state.
|
||||
*/
|
||||
hypertable_cache_invalidate_callback();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_cache_invalidate_init(void)
|
||||
{
|
||||
CacheRegisterRelcacheCallback(inval_cache_callback, PointerGetDatum(NULL));
|
||||
RegisterXactCallback(cache_invalidate_xact_end, NULL);
|
||||
CacheRegisterRelcacheCallback(cache_invalidate_callback, PointerGetDatum(NULL));
|
||||
}
|
||||
|
||||
void
|
||||
_cache_invalidate_fini(void)
|
||||
{
|
||||
UnregisterXactCallback(cache_invalidate_xact_end, NULL);
|
||||
/* No way to unregister relcache callback */
|
||||
}
|
||||
|
143
src/catalog.c
143
src/catalog.c
@ -5,6 +5,7 @@
|
||||
#include <utils/lsyscache.h>
|
||||
#include <utils/builtins.h>
|
||||
#include <utils/syscache.h>
|
||||
#include <utils/inval.h>
|
||||
#include <access/xact.h>
|
||||
#include <access/htup_details.h>
|
||||
#include <miscadmin.h>
|
||||
@ -20,13 +21,14 @@
|
||||
#include <utils/regproc.h>
|
||||
#endif
|
||||
|
||||
static const char *catalog_table_names[_MAX_CATALOG_TABLES] = {
|
||||
static const char *catalog_table_names[_MAX_CATALOG_TABLES + 1] = {
|
||||
[HYPERTABLE] = HYPERTABLE_TABLE_NAME,
|
||||
[DIMENSION] = DIMENSION_TABLE_NAME,
|
||||
[DIMENSION_SLICE] = DIMENSION_SLICE_TABLE_NAME,
|
||||
[CHUNK] = CHUNK_TABLE_NAME,
|
||||
[CHUNK_CONSTRAINT] = CHUNK_CONSTRAINT_TABLE_NAME,
|
||||
[CHUNK_INDEX] = CHUNK_INDEX_TABLE_NAME,
|
||||
[_MAX_CATALOG_TABLES] = "invalid table",
|
||||
};
|
||||
|
||||
typedef struct TableIndexDef
|
||||
@ -273,15 +275,29 @@ catalog_reset(void)
|
||||
catalog.database_id = InvalidOid;
|
||||
}
|
||||
|
||||
const char *
|
||||
catalog_get_cache_proxy_name(CacheType type)
|
||||
{
|
||||
return cache_proxy_table_names[type];
|
||||
}
|
||||
|
||||
Oid
|
||||
catalog_get_cache_proxy_id(Catalog *catalog, CacheType type)
|
||||
{
|
||||
if (!catalog_is_valid(catalog))
|
||||
{
|
||||
Oid schema;
|
||||
|
||||
/*
|
||||
* The catalog can be invalid during upgrade scripts. Try a non-cached
|
||||
* relation lookup, but we need to be in a transaction for
|
||||
* get_namespace_oid() to work.
|
||||
*/
|
||||
if (!IsTransactionState())
|
||||
return InvalidOid;
|
||||
|
||||
schema = get_namespace_oid(CACHE_SCHEMA_NAME, true);
|
||||
|
||||
if (!OidIsValid(schema))
|
||||
return InvalidOid;
|
||||
|
||||
return get_relname_relid(cache_proxy_table_names[type], schema);
|
||||
}
|
||||
|
||||
return catalog->caches[type].inval_proxy_id;
|
||||
}
|
||||
|
||||
@ -291,26 +307,6 @@ catalog_get_internal_function_id(Catalog *catalog, InternalFunction func)
|
||||
return catalog->functions[func].function_id;
|
||||
}
|
||||
|
||||
Oid
|
||||
catalog_get_cache_proxy_id_by_name(Catalog *catalog, const char *relname)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!catalog_is_valid(catalog))
|
||||
return InvalidOid;
|
||||
|
||||
for (i = 0; i < _MAX_CACHE_TYPES; i++)
|
||||
{
|
||||
if (strcmp(relname, cache_proxy_table_names[i]) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (_MAX_CACHE_TYPES == i)
|
||||
return InvalidOid;
|
||||
|
||||
return catalog->caches[i].inval_proxy_id;
|
||||
}
|
||||
|
||||
/*
|
||||
* Become the user that owns the catalog schema.
|
||||
*
|
||||
@ -347,11 +343,46 @@ catalog_restore_user(CatalogSecurityContext *sec_ctx)
|
||||
SetUserIdAndSecContext(sec_ctx->saved_uid, sec_ctx->saved_security_context);
|
||||
}
|
||||
|
||||
Oid
|
||||
catalog_table_get_id(Catalog *catalog, CatalogTable table)
|
||||
{
|
||||
return catalog->tables[table].id;
|
||||
}
|
||||
|
||||
CatalogTable
|
||||
catalog_table_get(Catalog *catalog, Oid relid)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!catalog_is_valid(catalog))
|
||||
{
|
||||
const char *relname = get_rel_name(relid);
|
||||
|
||||
for (i = 0; i < _MAX_CATALOG_TABLES; i++)
|
||||
if (strcmp(catalog_table_names[i], relname) == 0)
|
||||
return (CatalogTable) i;
|
||||
|
||||
return INVALID_CATALOG_TABLE;
|
||||
}
|
||||
|
||||
for (i = 0; i < _MAX_CATALOG_TABLES; i++)
|
||||
if (catalog->tables[i].id == relid)
|
||||
return (CatalogTable) i;
|
||||
|
||||
return INVALID_CATALOG_TABLE;
|
||||
}
|
||||
|
||||
const char *
|
||||
catalog_table_name(CatalogTable table)
|
||||
{
|
||||
return catalog_table_names[table];
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the next serial ID for a catalog table, if one exists for the given table.
|
||||
*/
|
||||
int64
|
||||
catalog_table_next_seq_id(Catalog *catalog, enum CatalogTable table)
|
||||
catalog_table_next_seq_id(Catalog *catalog, CatalogTable table)
|
||||
{
|
||||
Oid relid = catalog->tables[table].serial_relid;
|
||||
|
||||
@ -386,7 +417,7 @@ void
|
||||
catalog_insert(Relation rel, HeapTuple tuple)
|
||||
{
|
||||
CatalogTupleInsert(rel, tuple);
|
||||
|
||||
catalog_invalidate_cache(RelationGetRelid(rel), CMD_INSERT);
|
||||
/* Make changes visible */
|
||||
CommandCounterIncrement();
|
||||
}
|
||||
@ -407,6 +438,7 @@ void
|
||||
catalog_update(Relation rel, HeapTuple tuple)
|
||||
{
|
||||
CatalogTupleUpdate(rel, &tuple->t_self, tuple);
|
||||
catalog_invalidate_cache(RelationGetRelid(rel), CMD_UPDATE);
|
||||
/* Make changes visible */
|
||||
CommandCounterIncrement();
|
||||
}
|
||||
@ -415,6 +447,7 @@ void
|
||||
catalog_delete_tid(Relation rel, ItemPointer tid)
|
||||
{
|
||||
CatalogTupleDelete(rel, tid);
|
||||
catalog_invalidate_cache(RelationGetRelid(rel), CMD_DELETE);
|
||||
CommandCounterIncrement();
|
||||
}
|
||||
|
||||
@ -423,3 +456,55 @@ catalog_delete(Relation rel, HeapTuple tuple)
|
||||
{
|
||||
catalog_delete_tid(rel, &tuple->t_self);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Invalidate TimescaleDB catalog caches.
|
||||
*
|
||||
* This function should be called whenever a TimescaleDB catalog table changes
|
||||
* in a way that might invalidate associated caches. It is currently called in
|
||||
* two distinct ways:
|
||||
*
|
||||
* 1. If a catalog table changes via the catalog API in catalog.c
|
||||
* 2. Via a trigger if a SQL INSERT/UPDATE/DELETE occurs on a catalog table
|
||||
*
|
||||
* Since triggers (2) require full parsing, planning and execution of SQL
|
||||
* statements, they aren't supported for simple catalog updates via (1) in
|
||||
* native code and are therefore discouraged. Ideally, catalog updates should
|
||||
* happen consistently via method (1) in the future, obviating the need for
|
||||
* triggers on catalog tables that cause side effects.
|
||||
*
|
||||
* The invalidation event is signaled to other backends (processes) via the
|
||||
* relcache invalidation mechanism on a dummy relation (table).
|
||||
*
|
||||
* Parameters: The OID of the catalog table that changed, and the operation
|
||||
* involved (e.g., INSERT, UPDATE, DELETE).
|
||||
*/
|
||||
void
|
||||
catalog_invalidate_cache(Oid catalog_relid, CmdType operation)
|
||||
{
|
||||
Catalog *catalog = catalog_get();
|
||||
CatalogTable table = catalog_table_get(catalog, catalog_relid);
|
||||
Oid relid;
|
||||
|
||||
switch (table)
|
||||
{
|
||||
case CHUNK:
|
||||
case CHUNK_CONSTRAINT:
|
||||
case DIMENSION_SLICE:
|
||||
if (operation == CMD_UPDATE || operation == CMD_DELETE)
|
||||
{
|
||||
relid = catalog_get_cache_proxy_id(catalog, CACHE_TYPE_HYPERTABLE);
|
||||
CacheInvalidateRelcacheByRelid(relid);
|
||||
}
|
||||
break;
|
||||
case HYPERTABLE:
|
||||
case DIMENSION:
|
||||
relid = catalog_get_cache_proxy_id(catalog, CACHE_TYPE_HYPERTABLE);
|
||||
CacheInvalidateRelcacheByRelid(relid);
|
||||
break;
|
||||
case CHUNK_INDEX:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <postgres.h>
|
||||
|
||||
#include <utils/rel.h>
|
||||
#include <nodes/nodes.h>
|
||||
#include <access/heapam.h>
|
||||
/*
|
||||
* TimescaleDB catalog.
|
||||
@ -20,7 +21,7 @@
|
||||
* Generally, definitions and naming should roughly follow how things are done
|
||||
* in Postgres internally.
|
||||
*/
|
||||
enum CatalogTable
|
||||
typedef enum CatalogTable
|
||||
{
|
||||
HYPERTABLE = 0,
|
||||
DIMENSION,
|
||||
@ -29,7 +30,9 @@ enum CatalogTable
|
||||
CHUNK_CONSTRAINT,
|
||||
CHUNK_INDEX,
|
||||
_MAX_CATALOG_TABLES,
|
||||
};
|
||||
} CatalogTable;
|
||||
|
||||
#define INVALID_CATALOG_TABLE _MAX_CATALOG_TABLES
|
||||
|
||||
#define CatalogInternalCall1(func, datum1) \
|
||||
OidFunctionCall1(catalog_get_internal_function_id(catalog_get(), func), datum1)
|
||||
@ -416,6 +419,7 @@ typedef struct Catalog
|
||||
{
|
||||
Oid inval_proxy_id;
|
||||
} caches[_MAX_CACHE_TYPES];
|
||||
|
||||
Oid owner_uid;
|
||||
Oid internal_schema_id;
|
||||
struct
|
||||
@ -436,21 +440,22 @@ Catalog *catalog_get(void);
|
||||
void catalog_reset(void);
|
||||
|
||||
Oid catalog_get_cache_proxy_id(Catalog *catalog, CacheType type);
|
||||
Oid catalog_get_cache_proxy_id_by_name(Catalog *catalog, const char *relname);
|
||||
|
||||
Oid catalog_get_internal_function_id(Catalog *catalog, InternalFunction func);
|
||||
|
||||
const char *catalog_get_cache_proxy_name(CacheType type);
|
||||
|
||||
bool catalog_become_owner(Catalog *catalog, CatalogSecurityContext *sec_ctx);
|
||||
void catalog_restore_user(CatalogSecurityContext *sec_ctx);
|
||||
|
||||
int64 catalog_table_next_seq_id(Catalog *catalog, enum CatalogTable table);
|
||||
int64 catalog_table_next_seq_id(Catalog *catalog, CatalogTable table);
|
||||
Oid catalog_table_get_id(Catalog *catalog, CatalogTable table);
|
||||
CatalogTable catalog_table_get(Catalog *catalog, Oid relid);
|
||||
const char *catalog_table_name(CatalogTable table);
|
||||
|
||||
void catalog_insert(Relation rel, HeapTuple tuple);
|
||||
void catalog_insert_values(Relation rel, TupleDesc tupdesc, Datum *values, bool *nulls);
|
||||
void catalog_update(Relation rel, HeapTuple tuple);
|
||||
void catalog_delete_tid(Relation rel, ItemPointer tid);
|
||||
void catalog_delete(Relation rel, HeapTuple tuple);
|
||||
void catalog_invalidate_cache(Oid catalog_relid, CmdType operation);
|
||||
|
||||
#endif /* TIMESCALEDB_CATALOG_H */
|
||||
|
@ -39,7 +39,7 @@ static Cache *
|
||||
hypertable_cache_create()
|
||||
{
|
||||
MemoryContext ctx = AllocSetContextCreate(CacheMemoryContext,
|
||||
catalog_get_cache_proxy_name(CACHE_TYPE_HYPERTABLE),
|
||||
"Hypertable cache",
|
||||
ALLOCSET_DEFAULT_SIZES);
|
||||
|
||||
Cache *cache = MemoryContextAlloc(ctx, sizeof(Cache));
|
||||
|
Loading…
x
Reference in New Issue
Block a user