pgsql: tableam: introduce table AM infrastructure.
tableam: introduce table AM infrastructure.
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:
/messages/by-id/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
/messages/by-id/20160812231527.GA690404@alvherre.pgsql
/messages/by-id/20190107235616.6lur25ph22u5u5av@alap3.anarazel.de
/messages/by-id/20190304234700.w5tmhducs5wxgzls@alap3.anarazel.de
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/8586bf7ed8889f39a59dd99b292014b73be85342
Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml | 11 ++
src/backend/access/heap/Makefile | 2 +-
src/backend/access/heap/heapam_handler.c | 44 ++++++++
src/backend/access/table/Makefile | 2 +-
src/backend/access/table/tableam.c | 18 +++
src/backend/access/table/tableamapi.c | 173 +++++++++++++++++++++++++++++
src/backend/bootstrap/bootparse.y | 2 +
src/backend/catalog/genbki.pl | 4 +
src/backend/catalog/heap.c | 21 ++++
src/backend/catalog/index.c | 1 +
src/backend/catalog/toasting.c | 1 +
src/backend/commands/amcmds.c | 28 +++--
src/backend/commands/cluster.c | 1 +
src/backend/commands/createas.c | 1 +
src/backend/commands/tablecmds.c | 40 +++++++
src/backend/nodes/copyfuncs.c | 1 +
src/backend/parser/gram.y | 100 ++++++++++-------
src/backend/rewrite/rewriteDefine.c | 1 +
src/backend/utils/adt/pseudotypes.c | 1 +
src/backend/utils/cache/relcache.c | 123 +++++++++++++++++++-
src/backend/utils/misc/guc.c | 12 ++
src/bin/psql/describe.c | 16 ++-
src/bin/psql/help.c | 2 +
src/bin/psql/settings.h | 1 +
src/bin/psql/startup.c | 8 ++
src/include/access/tableam.h | 48 ++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/heap.h | 2 +
src/include/catalog/pg_am.dat | 3 +
src/include/catalog/pg_am.h | 1 +
src/include/catalog/pg_class.dat | 8 +-
src/include/catalog/pg_class.h | 2 +-
src/include/catalog/pg_proc.dat | 13 +++
src/include/catalog/pg_type.dat | 5 +
src/include/nodes/nodes.h | 1 +
src/include/nodes/parsenodes.h | 1 +
src/include/nodes/primnodes.h | 1 +
src/include/utils/rel.h | 15 ++-
src/include/utils/relcache.h | 3 +
src/test/regress/expected/create_am.out | 164 +++++++++++++++++++++++++++
src/test/regress/expected/opr_sanity.out | 19 +++-
src/test/regress/expected/psql.out | 39 +++++++
src/test/regress/expected/sanity_check.out | 7 ++
src/test/regress/expected/type_sanity.out | 15 ++-
src/test/regress/pg_regress_main.c | 7 +-
src/test/regress/sql/create_am.sql | 116 +++++++++++++++++++
src/test/regress/sql/opr_sanity.sql | 16 ++-
src/test/regress/sql/psql.sql | 15 +++
src/test/regress/sql/type_sanity.sql | 11 +-
src/tools/pgindent/typedefs.list | 1 +
50 files changed, 1055 insertions(+), 74 deletions(-)
On 2019-Mar-06, Andres Freund wrote:
tableam: introduce table AM infrastructure.
Thanks for doing this!!
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On Wed, Mar 06, 2019 at 03:03:44PM -0300, Alvaro Herrera wrote:
On 2019-Mar-06, Andres Freund wrote:
tableam: introduce table AM infrastructure.
Thanks for doing this!!
+1.
--
Michael
On Wed, Mar 6, 2019 at 11:31 PM Andres Freund <andres@anarazel.de> wrote:
tableam: introduce table AM infrastructure.
Thanks for this work. I noticed a few typos in this commit. The
patch for the same is attached.
--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
Attachments:
0001-Fix-typos-in-commit-8586bf7ed8.patchapplication/octet-stream; name=0001-Fix-typos-in-commit-8586bf7ed8.patchDownload
From 8dd1a142ec3c4c87ff2a92ede67adcb48fb4b005 Mon Sep 17 00:00:00 2001
From: Amit Kapila <akapila@postgresql.org>
Date: Mon, 11 Mar 2019 08:16:14 +0530
Subject: [PATCH] Fix typos in commit 8586bf7ed8.
---
src/backend/access/table/tableamapi.c | 6 +++---
src/backend/utils/cache/relcache.c | 2 +-
src/include/access/tableam.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/table/tableamapi.c b/src/backend/access/table/tableamapi.c
index d49607e..54a078d 100644
--- a/src/backend/access/table/tableamapi.c
+++ b/src/backend/access/table/tableamapi.c
@@ -103,9 +103,9 @@ get_table_am_oid(const char *tableamname, bool missing_ok)
ScanKeyData entry[1];
/*
- * Search pg_tablespace. We use a heapscan here even though there is an
- * index on name, on the theory that pg_tablespace will usually have just
- * a few entries and so an indexed lookup is a waste of effort.
+ * Search pg_am. We use a heapscan here even though there is an index on
+ * name, on the theory that pg_am will usually have just a few entries and
+ * so an indexed lookup is a waste of effort.
*/
rel = heap_open(AccessMethodRelationId, AccessShareLock);
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index d9ffb78..fb21301 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -1681,7 +1681,7 @@ InitTableAmRoutine(Relation relation)
}
/*
- * Initialize table access method support for a table like relation relation
+ * Initialize table access method support for a table like relation
*/
void
RelationInitTableAccessMethod(Relation relation)
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index caeb588..ccdc6de 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -4,7 +4,7 @@
* POSTGRES table access method definitions.
*
*
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/access/tableam.h
--
1.8.3.1
On 2019-03-11 08:21:21 +0530, Amit Kapila wrote:
I noticed a few typos in this commit. The patch for the same is
attached.
Merged, thanks!
Hi,
For the archive's sake:
On 2019-03-06 18:01:15 +0000, Andres Freund wrote:
tableam: introduce table AM infrastructure.
Author: Haribabu Kommi, Andres Freund, Alvaro Herrera, Dimitri Golgov and others
Please note that I completely butchered a name here. It's not Dimitri
Golgov, it's Dmitry Dolgov.
I'll take care of fixing the name in the release notes.
- Andres