summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/rmgrlist.h1
-rw-r--r--src/include/access/robert_page.h22
-rw-r--r--src/include/access/robert_scan.h79
-rw-r--r--src/include/access/robert_slot.h31
-rw-r--r--src/include/access/robert_tuple.h60
-rw-r--r--src/include/access/robert_xlog.h29
-rw-r--r--src/include/access/robertam.h103
-rw-r--r--src/include/catalog/pg_am.dat3
-rw-r--r--src/include/catalog/pg_proc.dat5
9 files changed, 333 insertions, 0 deletions
diff --git a/src/include/access/rmgrlist.h b/src/include/access/rmgrlist.h
index 6da5930e0b..b6e6754447 100644
--- a/src/include/access/rmgrlist.h
+++ b/src/include/access/rmgrlist.h
@@ -49,3 +49,4 @@ PG_RMGR(RM_GENERIC_ID, "Generic", generic_redo, generic_desc, generic_identify,
PG_RMGR(RM_LOGICALMSG_ID, "LogicalMessage", logicalmsg_redo, logicalmsg_desc, logicalmsg_identify, NULL, NULL, NULL, NULL, NULL, NULL)
PG_RMGR(RM_UNDOLOG_ID, "UndoLog", undolog_redo, undolog_desc, undolog_identify, NULL, NULL, NULL, NULL, NULL, NULL)
PG_RMGR(RM_UNDOACTION_ID, "UndoAction", undoaction_redo, undoaction_desc, undoaction_identify, NULL, NULL, NULL, NULL, NULL, NULL)
+PG_RMGR(RM_ROBERT_ID, "Robert", robert_redo, robert_desc, robert_identify, NULL, NULL, NULL, robert_undo, NULL, robert_undo_desc)
diff --git a/src/include/access/robert_page.h b/src/include/access/robert_page.h
new file mode 100644
index 0000000000..cf94de9691
--- /dev/null
+++ b/src/include/access/robert_page.h
@@ -0,0 +1,22 @@
+/*-------------------------------------------------------------------------
+ *
+ * robert_page.h
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef ROBERT_PAGE_H
+#define ROBERT_PAGE_H
+
+#include "access/robert_tuple.h"
+#include "access/undolog.h"
+#include "storage/block.h"
+#include "storage/itemptr.h"
+#include "storage/off.h"
+
+/* External function prototypes. */
+extern OffsetNumber robert_page_free_offset(Page page, Size size);
+extern void robert_page_add_item(Page page, OffsetNumber offnum,
+ RobertTuple tuple);
+
+#endif
diff --git a/src/include/access/robert_scan.h b/src/include/access/robert_scan.h
new file mode 100644
index 0000000000..d47d2b51ad
--- /dev/null
+++ b/src/include/access/robert_scan.h
@@ -0,0 +1,79 @@
+/*
+ * robert_scan.h
+ */
+
+#ifndef ROBERT_SCAN_H
+#define ROBERT_SCAN_H
+
+#include "access/relscan.h"
+#include "access/sdir.h"
+#include "access/skey.h"
+#include "executor/tuptable.h"
+#include "nodes/execnodes.h"
+#include "nodes/tidbitmap.h"
+#include "utils/snapshot.h"
+
+typedef enum RobertScanState
+{
+ ROBERT_SCAN_NOT_STARTED,
+ ROBERT_SCAN_BLOCK_DONE,
+ ROBERT_SCAN_TUPLE_DONE,
+ ROBERT_SCAN_READY
+} RobertScanState;
+
+typedef struct RobertScanDescData
+{
+ TableScanDescData rrs_base; /* AM independent part of the descriptor */
+ BlockNumber rrs_nblocks;
+ BlockNumber rrs_startblock;
+ BlockNumber rrs_numblocks;
+ RobertScanState rrs_state;
+ BlockNumber rrs_cblock;
+ OffsetNumber rrs_coffset;
+ OffsetNumber rrs_lastoffset;
+ int rrs_tupindex;
+ BufferAccessStrategy rrs_strategy;
+ Page rrs_cpage;
+} RobertScanDescData;
+
+typedef RobertScanDescData *RobertScanDesc;
+
+/* Table scans. */
+extern TableScanDesc robert_scan_begin(Relation rel, Snapshot snapshot,
+ int nkeys, ScanKeyData *key,
+ ParallelTableScanDesc pscan, uint32 flags);
+extern void robert_scan_end(TableScanDesc sscan);
+extern void robert_scan_rescan(TableScanDesc sscan, ScanKeyData *key,
+ bool set_params, bool allow_strat,
+ bool allow_sync, bool allow_pagemode);
+extern bool robert_scan_getnextslot(TableScanDesc sscan,
+ ScanDirection direction,
+ TupleTableSlot *slot);
+
+/* Index scans. */
+extern IndexFetchTableData *robert_index_fetch_begin(Relation rel);
+extern void robert_index_fetch_reset(IndexFetchTableData *data);
+extern void robert_index_fetch_end(IndexFetchTableData *data);
+extern bool robert_index_fetch_tuple(IndexFetchTableData *data,
+ ItemPointer tid, Snapshot snapshot,
+ TupleTableSlot *slot,
+ bool *call_again, bool *all_dead);
+
+/* Bitmap scans. */
+extern bool robert_scan_bitmap_next_block(TableScanDesc sscan,
+ TBMIterateResult *tbmres);
+extern bool robert_scan_bitmap_next_tuple(TableScanDesc sscan,
+ TBMIterateResult *tbmres,
+ TupleTableSlot *slot);
+
+/* Sample scans. */
+extern bool robert_scan_sample_next_block(TableScanDesc scan,
+ SampleScanState *scanstate);
+extern bool robert_scan_sample_next_tuple(TableScanDesc scan,
+ SampleScanState *scanstate,
+ TupleTableSlot *slot);
+
+/* Internal functions */
+extern BlockNumber robert_scan_get_blocks_done(RobertScanDesc scan);
+
+#endif
diff --git a/src/include/access/robert_slot.h b/src/include/access/robert_slot.h
new file mode 100644
index 0000000000..8e7585b21d
--- /dev/null
+++ b/src/include/access/robert_slot.h
@@ -0,0 +1,31 @@
+/*
+ * robert_slot.h
+ */
+
+#ifndef ROBERT_SLOT_H
+#define ROBERT_SLOT_H
+
+#include "access/robert_tuple.h"
+#include "executor/tuptable.h"
+#include "utils/rel.h"
+
+typedef struct RobertTupleTableSlot
+{
+ TupleTableSlot base;
+ RobertTuple tuple;
+ uint32 off;
+} RobertTupleTableSlot;
+
+extern PGDLLIMPORT const TupleTableSlotOps TTSOpsRobert;
+
+extern const TupleTableSlotOps *robert_slot_callbacks(Relation relation);
+extern void robert_slot_store(TupleTableSlot *slot, RobertTupleHeader td,
+ Size len, Oid tableOid, BlockNumber blkno,
+ OffsetNumber offset);
+extern bool robert_slot_store_visible(TupleTableSlot *slot,
+ RobertTupleHeader td, Size len,
+ Oid tableOid, BlockNumber blkno,
+ OffsetNumber offset, Snapshot snapshot,
+ bool item_is_dead);
+
+#endif
diff --git a/src/include/access/robert_tuple.h b/src/include/access/robert_tuple.h
new file mode 100644
index 0000000000..28bbc90885
--- /dev/null
+++ b/src/include/access/robert_tuple.h
@@ -0,0 +1,60 @@
+/*
+ * robert_tuple.h
+ */
+
+#ifndef ROBERT_TUPLE_H
+#define ROBERT_TUPLE_H
+
+#include "access/transam.h"
+#include "access/tupdesc.h"
+#include "access/undolog.h"
+#include "storage/itemptr.h"
+#include "utils/relcache.h"
+
+struct TupleTableSlot;
+
+typedef struct RobertTupleHeaderData
+{
+ UndoRecPtr r_undoptr;
+ uint16 r_flags;
+ uint8 r_hoff;
+ bits8 r_bits[FLEXIBLE_ARRAY_MEMBER];
+} RobertTupleHeaderData;
+
+#define SizeofRobertTupleHeader offsetof(RobertTupleHeaderData, r_bits)
+
+/* Flags for use in r_flags. */
+#define ROBERT_NATTS_MASK 0x07FF /* 11 bits */
+#define ROBERT_HASEXTERNAL 0x0800
+
+typedef RobertTupleHeaderData *RobertTupleHeader;
+
+typedef struct RobertTupleData
+{
+ uint32 r_len;
+ RobertTupleHeader r_data;
+ Oid r_tableOid;
+ ItemPointerData r_self;
+} RobertTupleData;
+
+typedef RobertTupleData *RobertTuple;
+
+#define ROBERTTUPLESIZE MAXALIGN(sizeof(RobertTupleData))
+
+extern Size robert_compute_data_size(TupleDesc tupleDesc, Datum *values,
+ bool *isnull, uint8 hoff);
+extern void robert_fill_null_bitmap(bits8 *bits, int entries_needed,
+ bool *isnull);
+extern void robert_fill_tuple(TupleDesc tupleDesc, Datum *values, bool *isnull,
+ RobertTupleHeader td, Size len);
+extern RobertTuple robert_form_tuple(TupleDesc tupleDesc, Datum *values,
+ bool *isnull);
+extern void robert_deform_tuple(TupleDesc tupleDesc, RobertTuple tuple,
+ Datum *values, bool *isnull, int natts, int oldnatts,
+ uint32 *offp);
+extern RobertTuple robert_toast_tuple(Relation rel,
+ struct TupleTableSlot *slot,
+ int options);
+extern char *robert_print_tuple(RobertTuple tuple, TupleDesc tupleDesc);
+
+#endif
diff --git a/src/include/access/robert_xlog.h b/src/include/access/robert_xlog.h
new file mode 100644
index 0000000000..67496ff0b0
--- /dev/null
+++ b/src/include/access/robert_xlog.h
@@ -0,0 +1,29 @@
+/*-------------------------------------------------------------------------
+ *
+ * robert_xlog.h
+ *
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/access/robert_xlog.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef ROBERT_XLOG_H
+#define ROBERT_XLOG_H
+
+#include "access/undoaccess.h"
+#include "access/xlogreader.h"
+#include "lib/stringinfo.h"
+
+#define ROBERT_UNDO_INSERT 1
+#define ROBERT_UNDO_DELETE 2
+
+extern void robert_redo(XLogReaderState *record);
+extern void robert_desc(StringInfo buf, XLogReaderState *record);
+extern const char *robert_identify(uint8 info);
+
+extern void robert_undo(int nrecords, UndoRecInfo *records);
+extern void robert_undo_desc(StringInfo buf, UnpackedUndoRecord *record);
+
+#endif /* ROBERT_XLOG_H */
diff --git a/src/include/access/robertam.h b/src/include/access/robertam.h
new file mode 100644
index 0000000000..b6c3bc42d9
--- /dev/null
+++ b/src/include/access/robertam.h
@@ -0,0 +1,103 @@
+/*
+ * robertam.h
+ */
+
+#ifndef ROBERTAM_H
+#define ROBERTAM_H
+
+#include "access/hio.h"
+#include "access/skey.h"
+#include "access/tableam.h"
+#include "catalog/index.h"
+#include "commands/vacuum.h"
+#include "nodes/execnodes.h"
+
+/* MVCC. */
+extern bool robert_tuple_fetch_row_version(Relation rel, ItemPointer tid,
+ Snapshot snapshot, TupleTableSlot *slot);
+extern bool robert_tuple_tid_valid(TableScanDesc sscan, ItemPointer tid);
+extern void robert_tuple_get_latest_tid(TableScanDesc scan, ItemPointer tid);
+extern bool robert_tuple_satisfies_snapshot(Relation rel,
+ TupleTableSlot *slot,
+ Snapshot snapshot);
+extern TransactionId robert_compute_xid_horizon_for_tuples(Relation rel,
+ ItemPointerData *items,
+ int nitems);
+
+/* DML */
+extern void robert_tuple_insert(Relation rel, TupleTableSlot *slot,
+ CommandId cid, int options,
+ BulkInsertStateData *bistate);
+extern void robert_tuple_insert_speculative(Relation rel, TupleTableSlot *slot,
+ CommandId cid, int options,
+ BulkInsertStateData *bistate,
+ uint32 specToken);
+extern void robert_tuple_complete_speculative(Relation rel,
+ TupleTableSlot *slot, uint32 specToken,
+ bool succeeded);
+extern void robert_multi_insert(Relation rel,
+ TupleTableSlot **slots, int nslots,
+ CommandId cid, int options,
+ BulkInsertStateData *bistate);
+extern TM_Result robert_tuple_delete(Relation rel, ItemPointer tid,
+ CommandId cid, Snapshot snapshot, Snapshot crosscheck,
+ bool wait, TM_FailureData *tmfd, bool changingPart);
+extern TM_Result robert_tuple_update(Relation rel, ItemPointer otid,
+ TupleTableSlot *slot, CommandId cid, Snapshot snapshot,
+ Snapshot crosscheck, bool wait, TM_FailureData *tmfd,
+ LockTupleMode *lockmode, bool *update_indexes);
+extern TM_Result robert_tuple_lock(Relation rel, ItemPointer tid,
+ Snapshot snapshot, TupleTableSlot *slot, CommandId cid,
+ LockTupleMode mode, LockWaitPolicy wait_policy, uint8 flags,
+ TM_FailureData *tmfd);
+extern void robert_finish_bulk_insert(Relation rel, int options);
+
+
+/* DDL. */
+extern void robert_relation_set_new_filenode(Relation rel,
+ const RelFileNode *newrnode,
+ char persistence,
+ TransactionId *freezeXid,
+ MultiXactId *minmulti);
+extern void robert_relation_nontransactional_truncate(Relation rel);
+extern void robert_relation_copy_data(Relation rel,
+ const RelFileNode *newrnode);
+extern void robert_relation_copy_for_cluster(Relation NewHeap,
+ Relation OldHeap, Relation OldIndex,
+ bool use_sort, TransactionId OldestXmin,
+ TransactionId *xid_cutoff,
+ MultiXactId *multi_cutoff,
+ double *num_tuples, double *tups_vacuumed,
+ double *tups_recently_dead);
+extern void robert_relation_vacuum(Relation onerel, VacuumParams *params,
+ BufferAccessStrategy bstrategy);
+extern bool robert_scan_analyze_next_block(TableScanDesc scan,
+ BlockNumber blockno,
+ BufferAccessStrategy bstrategy);
+extern bool robert_scan_analyze_next_tuple(TableScanDesc scan,
+ TransactionId OldestXmin,
+ double *liverows, double *deadrows,
+ TupleTableSlot *slot);
+extern double robert_index_build_range_scan(Relation heap_rel,
+ Relation index_rel, IndexInfo *index_nfo,
+ bool allow_sync, bool anyvisible, bool progress,
+ BlockNumber start_blockno,
+ BlockNumber end_blockno,
+ IndexBuildCallback callback,
+ void *callback_state,
+ TableScanDesc scan);
+extern void robert_index_validate_scan(Relation heap_rel, Relation index_rel,
+ IndexInfo *index_info, Snapshot snapshot,
+ ValidateIndexState *state);
+
+/* Miscellaneous. */
+extern uint64 robert_relation_size(Relation rel, ForkNumber forkNumber);
+extern bool robert_relation_needs_toast_table(Relation rel);
+extern Oid robert_relation_toast_am(Relation rel);
+
+/* Planner. */
+extern void robert_relation_estimate_size(Relation rel, int32 *attr_widths,
+ BlockNumber *pages, double *tuples,
+ double *allvisfrac);
+
+#endif
diff --git a/src/include/catalog/pg_am.dat b/src/include/catalog/pg_am.dat
index 393b41dd68..d855db86d4 100644
--- a/src/include/catalog/pg_am.dat
+++ b/src/include/catalog/pg_am.dat
@@ -33,5 +33,8 @@
{ oid => '3580', oid_symbol => 'BRIN_AM_OID',
descr => 'block range index (BRIN) access method',
amname => 'brin', amhandler => 'brinhandler', amtype => 'i' },
+{ oid => '8192', oid_symbol => 'ROBERT_HEAP_TABLE_AM_OID',
+ descr => 'robert table access method',
+ amname => 'robert', amhandler => 'robert_tableam_handler', amtype => 't' },
]
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index de475cb2d4..3417efc7aa 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -873,6 +873,11 @@
proname => 'heap_tableam_handler', provolatile => 'v',
prorettype => 'table_am_handler', proargtypes => 'internal',
prosrc => 'heap_tableam_handler' },
+{ oid => '8193', oid_symbol => 'ROBERT_TABLE_AM_HANDLER_OID',
+ descr => 'robert table access method handler',
+ proname => 'robert_tableam_handler', provolatile => 'v',
+ prorettype => 'table_am_handler', proargtypes => 'internal',
+ prosrc => 'robert_tableam_handler' },
# Index access method handlers
{ oid => '330', descr => 'btree index access method handler',