aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/tableam.h48
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/catalog/heap.h2
-rw-r--r--src/include/catalog/pg_am.dat3
-rw-r--r--src/include/catalog/pg_am.h1
-rw-r--r--src/include/catalog/pg_class.dat8
-rw-r--r--src/include/catalog/pg_class.h2
-rw-r--r--src/include/catalog/pg_proc.dat13
-rw-r--r--src/include/catalog/pg_type.dat5
-rw-r--r--src/include/nodes/nodes.h1
-rw-r--r--src/include/nodes/parsenodes.h1
-rw-r--r--src/include/nodes/primnodes.h1
-rw-r--r--src/include/utils/rel.h15
-rw-r--r--src/include/utils/relcache.h3
14 files changed, 98 insertions, 7 deletions
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
new file mode 100644
index 00000000000..caeb5887d5d
--- /dev/null
+++ b/src/include/access/tableam.h
@@ -0,0 +1,48 @@
+/*-------------------------------------------------------------------------
+ *
+ * tableam.h
+ * POSTGRES table access method definitions.
+ *
+ *
+ * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/access/tableam.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef TABLEAM_H
+#define TABLEAM_H
+
+#include "utils/guc.h"
+
+
+#define DEFAULT_TABLE_ACCESS_METHOD "heap"
+
+extern char *default_table_access_method;
+
+
+
+/*
+ * API struct for a table AM. Note this must be allocated in a
+ * server-lifetime manner, typically as a static const struct, which then gets
+ * returned by FormData_pg_am.amhandler.
+ */
+typedef struct TableAmRoutine
+{
+ /* this must be set to T_TableAmRoutine */
+ NodeTag type;
+} TableAmRoutine;
+
+
+
+/*
+ * Functions in tableamapi.c
+ */
+extern const TableAmRoutine *GetTableAmRoutine(Oid amhandler);
+extern const TableAmRoutine *GetTableAmRoutineByAmId(Oid amoid);
+extern const TableAmRoutine *GetHeapamTableAmRoutine(void);
+extern bool check_default_table_access_method(char **newval, void **extra,
+ GucSource source);
+
+#endif /* TABLEAM_H */
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 0c4c2e11d59..f596ea53511 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201903041
+#define CATALOG_VERSION_NO 201903061
#endif
diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h
index 50fb62be9d5..85076d07437 100644
--- a/src/include/catalog/heap.h
+++ b/src/include/catalog/heap.h
@@ -49,6 +49,7 @@ extern Relation heap_create(const char *relname,
Oid reltablespace,
Oid relid,
Oid relfilenode,
+ Oid accessmtd,
TupleDesc tupDesc,
char relkind,
char relpersistence,
@@ -63,6 +64,7 @@ extern Oid heap_create_with_catalog(const char *relname,
Oid reltypeid,
Oid reloftypeid,
Oid ownerid,
+ Oid accessmtd,
TupleDesc tupdesc,
List *cooked_constraints,
char relkind,
diff --git a/src/include/catalog/pg_am.dat b/src/include/catalog/pg_am.dat
index 08f331d4e10..393b41dd684 100644
--- a/src/include/catalog/pg_am.dat
+++ b/src/include/catalog/pg_am.dat
@@ -12,6 +12,9 @@
[
+{ oid => '2', oid_symbol => 'HEAP_TABLE_AM_OID',
+ descr => 'heap table access method',
+ amname => 'heap', amhandler => 'heap_tableam_handler', amtype => 't' },
{ oid => '403', oid_symbol => 'BTREE_AM_OID',
descr => 'b-tree index access method',
amname => 'btree', amhandler => 'bthandler', amtype => 'i' },
diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h
index eb3495c36a1..706b5e81cba 100644
--- a/src/include/catalog/pg_am.h
+++ b/src/include/catalog/pg_am.h
@@ -53,6 +53,7 @@ typedef FormData_pg_am *Form_pg_am;
* Allowed values for amtype
*/
#define AMTYPE_INDEX 'i' /* index access method */
+#define AMTYPE_TABLE 't' /* table access method */
#endif /* EXPOSE_TO_CLIENT_CODE */
diff --git a/src/include/catalog/pg_class.dat b/src/include/catalog/pg_class.dat
index cccad25c148..ef0cf97ab73 100644
--- a/src/include/catalog/pg_class.dat
+++ b/src/include/catalog/pg_class.dat
@@ -22,7 +22,7 @@
{ oid => '1247',
relname => 'pg_type', relnamespace => 'PGNSP', reltype => '71',
- reloftype => '0', relowner => 'PGUID', relam => '0', relfilenode => '0',
+ reloftype => '0', relowner => 'PGUID', relam => 'PGHEAPAM', relfilenode => '0',
reltablespace => '0', relpages => '0', reltuples => '0', relallvisible => '0',
reltoastrelid => '0', relhasindex => 'f', relisshared => 'f',
relpersistence => 'p', relkind => 'r', relnatts => '31', relchecks => '0',
@@ -33,7 +33,7 @@
reloptions => '_null_', relpartbound => '_null_' },
{ oid => '1249',
relname => 'pg_attribute', relnamespace => 'PGNSP', reltype => '75',
- reloftype => '0', relowner => 'PGUID', relam => '0', relfilenode => '0',
+ reloftype => '0', relowner => 'PGUID', relam => 'PGHEAPAM', relfilenode => '0',
reltablespace => '0', relpages => '0', reltuples => '0', relallvisible => '0',
reltoastrelid => '0', relhasindex => 'f', relisshared => 'f',
relpersistence => 'p', relkind => 'r', relnatts => '24', relchecks => '0',
@@ -44,7 +44,7 @@
reloptions => '_null_', relpartbound => '_null_' },
{ oid => '1255',
relname => 'pg_proc', relnamespace => 'PGNSP', reltype => '81',
- reloftype => '0', relowner => 'PGUID', relam => '0', relfilenode => '0',
+ reloftype => '0', relowner => 'PGUID', relam => 'PGHEAPAM', relfilenode => '0',
reltablespace => '0', relpages => '0', reltuples => '0', relallvisible => '0',
reltoastrelid => '0', relhasindex => 'f', relisshared => 'f',
relpersistence => 'p', relkind => 'r', relnatts => '29', relchecks => '0',
@@ -55,7 +55,7 @@
reloptions => '_null_', relpartbound => '_null_' },
{ oid => '1259',
relname => 'pg_class', relnamespace => 'PGNSP', reltype => '83',
- reloftype => '0', relowner => 'PGUID', relam => '0', relfilenode => '0',
+ reloftype => '0', relowner => 'PGUID', relam => 'PGHEAPAM', relfilenode => '0',
reltablespace => '0', relpages => '0', reltuples => '0', relallvisible => '0',
reltoastrelid => '0', relhasindex => 'f', relisshared => 'f',
relpersistence => 'p', relkind => 'r', relnatts => '33', relchecks => '0',
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index 5d82ce09a6c..ad698c9e84c 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -36,7 +36,7 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat
Oid reloftype; /* OID of entry in pg_type for underlying
* composite type */
Oid relowner; /* class owner */
- Oid relam; /* index access method; 0 if not an index */
+ Oid relam; /* access method; 0 if not a table / index */
Oid relfilenode; /* identifier of physical storage file */
/* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5bb56b2c639..bce909b05ac 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -867,6 +867,12 @@
proname => 'int4', prorettype => 'int4', proargtypes => 'float4',
prosrc => 'ftoi4' },
+# Table access method handlers
+{ oid => '3', oid_symbol => 'HEAP_TABLE_AM_HANDLER_OID',
+ descr => 'row-oriented heap table access method handler',
+ proname => 'heap_tableam_handler', provolatile => 'v', prorettype => 'table_am_handler',
+ proargtypes => 'internal', prosrc => 'heap_tableam_handler' },
+
# Index access method handlers
{ oid => '330', descr => 'btree index access method handler',
proname => 'bthandler', provolatile => 'v', prorettype => 'index_am_handler',
@@ -6981,6 +6987,13 @@
{ oid => '3312', descr => 'I/O',
proname => 'tsm_handler_out', prorettype => 'cstring',
proargtypes => 'tsm_handler', prosrc => 'tsm_handler_out' },
+{ oid => '267', descr => 'I/O',
+ proname => 'table_am_handler_in', proisstrict => 'f',
+ prorettype => 'table_am_handler', proargtypes => 'cstring',
+ prosrc => 'table_am_handler_in' },
+{ oid => '268', descr => 'I/O',
+ proname => 'table_am_handler_out', prorettype => 'cstring',
+ proargtypes => 'table_am_handler', prosrc => 'table_am_handler_out' },
# tablesample method handlers
{ oid => '3313', descr => 'BERNOULLI tablesample method handler',
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index 4b7750d4398..4497ff6a2c5 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -580,6 +580,11 @@
typcategory => 'P', typinput => 'tsm_handler_in',
typoutput => 'tsm_handler_out', typreceive => '-', typsend => '-',
typalign => 'i' },
+{ oid => '269',
+ typname => 'table_am_handler', typlen => '4', typbyval => 't', typtype => 'p',
+ typcategory => 'P', typinput => 'table_am_handler_in',
+ typoutput => 'table_am_handler_out', typreceive => '-', typsend => '-',
+ typalign => 'i' },
{ oid => '3831',
descr => 'pseudo-type representing a polymorphic base type that is a range',
typname => 'anyrange', typlen => '-1', typbyval => 'f', typtype => 'p',
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index f9389257c60..ffb4cd4bcc4 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -504,6 +504,7 @@ typedef enum NodeTag
T_InlineCodeBlock, /* in nodes/parsenodes.h */
T_FdwRoutine, /* in foreign/fdwapi.h */
T_IndexAmRoutine, /* in access/amapi.h */
+ T_TableAmRoutine, /* in access/tableam.h */
T_TsmRoutine, /* in access/tsmapi.h */
T_ForeignKeyCacheInfo, /* in utils/rel.h */
T_CallContext, /* in nodes/parsenodes.h */
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index a7e859dc90e..fe35783359e 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2044,6 +2044,7 @@ typedef struct CreateStmt
List *options; /* options from WITH clause */
OnCommitAction oncommit; /* what do we do at COMMIT? */
char *tablespacename; /* table space to use, or NULL */
+ char *accessMethod; /* table access method */
bool if_not_exists; /* just do nothing if it already exists? */
} CreateStmt;
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index a7efae70381..f9b1cf2df72 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -111,6 +111,7 @@ typedef struct IntoClause
RangeVar *rel; /* target relation name */
List *colNames; /* column names to assign, or NIL */
+ char *accessMethod; /* table access method */
List *options; /* options from WITH clause */
OnCommitAction onCommit; /* what do we do at COMMIT? */
char *tableSpaceName; /* table space to use, or NULL */
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 1d054653039..9d805ca23d2 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -124,6 +124,20 @@ typedef struct RelationData
*/
bytea *rd_options; /* parsed pg_class.reloptions */
+ /*
+ * Oid of the handler for this relation. For an index this is a function
+ * returning IndexAmRoutine, for table like relations a function returning
+ * TableAmRoutine. This is stored separately from rd_indam, rd_tableam as
+ * its lookup requires syscache access, but during relcache bootstrap we
+ * need to be able to initialize rd_tableam without syscache lookups.
+ */
+ Oid rd_amhandler; /* OID of index AM's handler function */
+
+ /*
+ * Table access method.
+ */
+ const struct TableAmRoutine *rd_tableam;
+
/* These are non-NULL only for an index relation: */
Form_pg_index rd_index; /* pg_index tuple describing this index */
/* use "struct" here to avoid needing to include htup.h: */
@@ -144,7 +158,6 @@ typedef struct RelationData
* rd_indexcxt. A relcache reset will include freeing that chunk and
* setting rd_amcache = NULL.
*/
- Oid rd_amhandler; /* OID of index AM's handler function */
MemoryContext rd_indexcxt; /* private memory cxt for this stuff */
/* use "struct" here to avoid needing to include amapi.h: */
struct IndexAmRoutine *rd_indam; /* index AM's API struct */
diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h
index a80e335374d..8f5bd676498 100644
--- a/src/include/utils/relcache.h
+++ b/src/include/utils/relcache.h
@@ -75,6 +75,8 @@ extern void RelationInitIndexAccessInfo(Relation relation);
struct PublicationActions;
extern struct PublicationActions *GetRelationPublicationActions(Relation relation);
+extern void RelationInitTableAccessMethod(Relation relation);
+
/*
* Routines to support ereport() reports of relation-related errors
*/
@@ -97,6 +99,7 @@ extern Relation RelationBuildLocalRelation(const char *relname,
Oid relnamespace,
TupleDesc tupDesc,
Oid relid,
+ Oid accessmtd,
Oid relfilenode,
Oid reltablespace,
bool shared_relation,