diff options
| author | Robert Haas <rhaas@postgresql.org> | 2010-12-29 06:48:53 -0500 |
|---|---|---|
| committer | Robert Haas <rhaas@postgresql.org> | 2010-12-29 06:48:53 -0500 |
| commit | 53dbc27c62d8e1b6c5253feba04a5094cb8fe046 (patch) | |
| tree | b27563b69fa73dc4b7dc873bfc653bedc6ba1e05 /src/backend/access/nbtree/nbtree.c | |
| parent | 9b8aff8c192e2f313f90395d114c58a9ef84f97f (diff) | |
| download | postgresql-53dbc27c62d8e1b6c5253feba04a5094cb8fe046.tar.gz | |
Support unlogged tables.
The contents of an unlogged table are WAL-logged; thus, they are not
available on standby servers and are truncated whenever the database
system enters recovery. Indexes on unlogged tables are also unlogged.
Unlogged GiST indexes are not currently supported.
Diffstat (limited to 'src/backend/access/nbtree/nbtree.c')
| -rw-r--r-- | src/backend/access/nbtree/nbtree.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index 655a40090e..a13d629b0e 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -29,6 +29,7 @@ #include "storage/indexfsm.h" #include "storage/ipc.h" #include "storage/lmgr.h" +#include "storage/smgr.h" #include "utils/memutils.h" @@ -205,6 +206,36 @@ btbuildCallback(Relation index, } /* + * btbuildempty() -- build an empty btree index in the initialization fork + */ +Datum +btbuildempty(PG_FUNCTION_ARGS) +{ + Relation index = (Relation) PG_GETARG_POINTER(0); + Page metapage; + + /* Construct metapage. */ + metapage = (Page) palloc(BLCKSZ); + _bt_initmetapage(metapage, P_NONE, 0); + + /* Write the page. If archiving/streaming, XLOG it. */ + smgrwrite(index->rd_smgr, INIT_FORKNUM, BTREE_METAPAGE, + (char *) metapage, true); + if (XLogIsNeeded()) + log_newpage(&index->rd_smgr->smgr_rnode.node, INIT_FORKNUM, + BTREE_METAPAGE, metapage); + + /* + * An immediate sync is require even if we xlog'd the page, because the + * write did not go through shared_buffers and therefore a concurrent + * checkpoint may have move the redo pointer past our xlog record. + */ + smgrimmedsync(index->rd_smgr, INIT_FORKNUM); + + PG_RETURN_VOID(); +} + +/* * btinsert() -- insert an index tuple into a btree. * * Descend the tree recursively, find the appropriate location for our |
