mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-06 15:37:29 +08:00
This introduces the concept of table access methods, i.e. CREATE
ACCESS METHOD ... TYPE TABLE and
CREATE TABLE ... USING (storage-engine).
No table access functionality is delegated to table AMs as of this
commit, that'll be done in following commits.
Subsequent commits will incrementally abstract table access
functionality to be routed through table access methods. That change
is too large to be reviewed & committed at once, so it'll be done
incrementally.
Docs will be updated at the end, as adding them incrementally would
likely make them less coherent, and definitely is a lot more work,
without a lot of benefit.
Table access methods are specified similar to index access methods,
i.e. pg_am.amhandler returns, as INTERNAL, a pointer to a struct with
callbacks. In contrast to index AMs that struct needs to live as long
as a backend, typically that's achieved by just returning a pointer to
a constant struct.
Psql's \d+ now displays a table's access method. That can be disabled
with HIDE_TABLEAM=true, which is mainly useful so regression tests can
be run against different AMs. It's quite possible that this behaviour
still needs to be fine tuned.
For now it's not allowed to set a table AM for a partitioned table, as
we've not resolved how partitions would inherit that. Disallowing
allows us to introduce, if we decide that's the way forward, such a
behaviour without a compatibility break.
Catversion bumped, to add the heap table AM and references to it.
Author: Haribabu Kommi, Andres Freund, Alvaro Herrera, Dimitri Golgov and others
Discussion:
https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
https://postgr.es/m/20160812231527.GA690404@alvherre.pgsql
https://postgr.es/m/20190107235616.6lur25ph22u5u5av@alap3.anarazel.de
https://postgr.es/m/20190304234700.w5tmhducs5wxgzls@alap3.anarazel.de
146 lines
4.2 KiB
C
146 lines
4.2 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* relcache.h
|
|
* Relation descriptor cache definitions.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/utils/relcache.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef RELCACHE_H
|
|
#define RELCACHE_H
|
|
|
|
#include "access/tupdesc.h"
|
|
#include "nodes/bitmapset.h"
|
|
|
|
|
|
/*
|
|
* Name of relcache init file(s), used to speed up backend startup
|
|
*/
|
|
#define RELCACHE_INIT_FILENAME "pg_internal.init"
|
|
|
|
typedef struct RelationData *Relation;
|
|
|
|
/* ----------------
|
|
* RelationPtr is used in the executor to support index scans
|
|
* where we have to keep track of several index relations in an
|
|
* array. -cim 9/10/89
|
|
* ----------------
|
|
*/
|
|
typedef Relation *RelationPtr;
|
|
|
|
/*
|
|
* Routines to open (lookup) and close a relcache entry
|
|
*/
|
|
extern Relation RelationIdGetRelation(Oid relationId);
|
|
extern void RelationClose(Relation relation);
|
|
|
|
/*
|
|
* Routines to compute/retrieve additional cached information
|
|
*/
|
|
extern List *RelationGetFKeyList(Relation relation);
|
|
extern List *RelationGetIndexList(Relation relation);
|
|
extern List *RelationGetStatExtList(Relation relation);
|
|
extern Oid RelationGetPrimaryKeyIndex(Relation relation);
|
|
extern Oid RelationGetReplicaIndex(Relation relation);
|
|
extern List *RelationGetIndexExpressions(Relation relation);
|
|
extern List *RelationGetIndexPredicate(Relation relation);
|
|
|
|
typedef enum IndexAttrBitmapKind
|
|
{
|
|
INDEX_ATTR_BITMAP_ALL,
|
|
INDEX_ATTR_BITMAP_KEY,
|
|
INDEX_ATTR_BITMAP_PRIMARY_KEY,
|
|
INDEX_ATTR_BITMAP_IDENTITY_KEY
|
|
} IndexAttrBitmapKind;
|
|
|
|
extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation,
|
|
IndexAttrBitmapKind keyAttrs);
|
|
|
|
extern void RelationGetExclusionInfo(Relation indexRelation,
|
|
Oid **operators,
|
|
Oid **procs,
|
|
uint16 **strategies);
|
|
|
|
extern void RelationSetIndexList(Relation relation,
|
|
List *indexIds);
|
|
|
|
extern void RelationInitIndexAccessInfo(Relation relation);
|
|
|
|
/* caller must include pg_publication.h */
|
|
struct PublicationActions;
|
|
extern struct PublicationActions *GetRelationPublicationActions(Relation relation);
|
|
|
|
extern void RelationInitTableAccessMethod(Relation relation);
|
|
|
|
/*
|
|
* Routines to support ereport() reports of relation-related errors
|
|
*/
|
|
extern int errtable(Relation rel);
|
|
extern int errtablecol(Relation rel, int attnum);
|
|
extern int errtablecolname(Relation rel, const char *colname);
|
|
extern int errtableconstraint(Relation rel, const char *conname);
|
|
|
|
/*
|
|
* Routines for backend startup
|
|
*/
|
|
extern void RelationCacheInitialize(void);
|
|
extern void RelationCacheInitializePhase2(void);
|
|
extern void RelationCacheInitializePhase3(void);
|
|
|
|
/*
|
|
* Routine to create a relcache entry for an about-to-be-created relation
|
|
*/
|
|
extern Relation RelationBuildLocalRelation(const char *relname,
|
|
Oid relnamespace,
|
|
TupleDesc tupDesc,
|
|
Oid relid,
|
|
Oid accessmtd,
|
|
Oid relfilenode,
|
|
Oid reltablespace,
|
|
bool shared_relation,
|
|
bool mapped_relation,
|
|
char relpersistence,
|
|
char relkind);
|
|
|
|
/*
|
|
* Routine to manage assignment of new relfilenode to a relation
|
|
*/
|
|
extern void RelationSetNewRelfilenode(Relation relation, char persistence,
|
|
TransactionId freezeXid, MultiXactId minmulti);
|
|
|
|
/*
|
|
* Routines for flushing/rebuilding relcache entries in various scenarios
|
|
*/
|
|
extern void RelationForgetRelation(Oid rid);
|
|
|
|
extern void RelationCacheInvalidateEntry(Oid relationId);
|
|
|
|
extern void RelationCacheInvalidate(void);
|
|
|
|
extern void RelationCloseSmgrByOid(Oid relationId);
|
|
|
|
extern void AtEOXact_RelationCache(bool isCommit);
|
|
extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid,
|
|
SubTransactionId parentSubid);
|
|
|
|
/*
|
|
* Routines to help manage rebuilding of relcache init files
|
|
*/
|
|
extern bool RelationIdIsInInitFile(Oid relationId);
|
|
extern void RelationCacheInitFilePreInvalidate(void);
|
|
extern void RelationCacheInitFilePostInvalidate(void);
|
|
extern void RelationCacheInitFileRemove(void);
|
|
|
|
/* should be used only by relcache.c and catcache.c */
|
|
extern bool criticalRelcachesBuilt;
|
|
|
|
/* should be used only by relcache.c and postinit.c */
|
|
extern bool criticalSharedRelcachesBuilt;
|
|
|
|
#endif /* RELCACHE_H */
|