mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
R-tree is dead ... long live GiST.
This commit is contained in:
@@ -9,18 +9,18 @@
|
||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/gist.h,v 1.50 2005/10/15 02:49:42 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/gist.h,v 1.51 2005/11/07 17:36:46 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef GIST_H
|
||||
#define GIST_H
|
||||
|
||||
#include "access/xlog.h"
|
||||
#include "access/xlogdefs.h"
|
||||
#include "storage/bufpage.h"
|
||||
#include "storage/off.h"
|
||||
#include "utils/rel.h"
|
||||
#include "access/xlog.h"
|
||||
#include "access/xlogdefs.h"
|
||||
|
||||
/*
|
||||
* amproc indexes for GiST indexes.
|
||||
@@ -34,6 +34,23 @@
|
||||
#define GIST_EQUAL_PROC 7
|
||||
#define GISTNProcs 7
|
||||
|
||||
/*
|
||||
* strategy numbers for GiST opclasses that want to implement the old
|
||||
* RTREE behavior.
|
||||
*/
|
||||
#define RTLeftStrategyNumber 1
|
||||
#define RTOverLeftStrategyNumber 2
|
||||
#define RTOverlapStrategyNumber 3
|
||||
#define RTOverRightStrategyNumber 4
|
||||
#define RTRightStrategyNumber 5
|
||||
#define RTSameStrategyNumber 6
|
||||
#define RTContainsStrategyNumber 7
|
||||
#define RTContainedByStrategyNumber 8
|
||||
#define RTOverBelowStrategyNumber 9
|
||||
#define RTBelowStrategyNumber 10
|
||||
#define RTAboveStrategyNumber 11
|
||||
#define RTOverAboveStrategyNumber 12
|
||||
|
||||
/*
|
||||
* Page opaque data in a GiST index page.
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Resource managers definition
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.14 2005/06/06 17:01:24 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.15 2005/11/07 17:36:46 tgl Exp $
|
||||
*/
|
||||
#ifndef RMGR_H
|
||||
#define RMGR_H
|
||||
@@ -23,7 +23,6 @@ typedef uint8 RmgrId;
|
||||
#define RM_HEAP_ID 10
|
||||
#define RM_BTREE_ID 11
|
||||
#define RM_HASH_ID 12
|
||||
#define RM_RTREE_ID 13
|
||||
#define RM_GIST_ID 14
|
||||
#define RM_SEQ_ID 15
|
||||
#define RM_MAX_ID RM_SEQ_ID
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* rtree.h
|
||||
* common declarations for the rtree access method code.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/rtree.h,v 1.41 2005/06/24 20:53:31 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef RTREE_H
|
||||
#define RTREE_H
|
||||
|
||||
#include "access/itup.h"
|
||||
#include "access/sdir.h"
|
||||
#include "access/skey.h"
|
||||
#include "access/xlog.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
/* see rtstrat.c for what all this is about */
|
||||
#define RTNStrategies 12
|
||||
#define RTLeftStrategyNumber 1
|
||||
#define RTOverLeftStrategyNumber 2
|
||||
#define RTOverlapStrategyNumber 3
|
||||
#define RTOverRightStrategyNumber 4
|
||||
#define RTRightStrategyNumber 5
|
||||
#define RTSameStrategyNumber 6
|
||||
#define RTContainsStrategyNumber 7
|
||||
#define RTContainedByStrategyNumber 8
|
||||
#define RTOverBelowStrategyNumber 9
|
||||
#define RTBelowStrategyNumber 10
|
||||
#define RTAboveStrategyNumber 11
|
||||
#define RTOverAboveStrategyNumber 12
|
||||
|
||||
#define RTNProcs 3
|
||||
#define RT_UNION_PROC 1
|
||||
#define RT_INTER_PROC 2
|
||||
#define RT_SIZE_PROC 3
|
||||
|
||||
#define F_LEAF (1 << 0)
|
||||
|
||||
typedef struct RTreePageOpaqueData
|
||||
{
|
||||
uint32 flags;
|
||||
} RTreePageOpaqueData;
|
||||
|
||||
typedef RTreePageOpaqueData *RTreePageOpaque;
|
||||
|
||||
/*
|
||||
* When we descend a tree, we keep a stack of parent pointers.
|
||||
*/
|
||||
|
||||
typedef struct RTSTACK
|
||||
{
|
||||
struct RTSTACK *rts_parent;
|
||||
OffsetNumber rts_child;
|
||||
BlockNumber rts_blk;
|
||||
} RTSTACK;
|
||||
|
||||
/*
|
||||
* When we're doing a scan, we need to keep track of the parent stack
|
||||
* for the marked and current items. Also, rtrees have the following
|
||||
* property: if you're looking for the box (1,1,2,2), on the internal
|
||||
* nodes you have to search for all boxes that *contain* (1,1,2,2),
|
||||
* and not the ones that match it. We have a private scan key for
|
||||
* internal nodes in the opaque structure for rtrees for this reason.
|
||||
* See access/index-rtree/rtscan.c and rtstrat.c for how it gets
|
||||
* initialized. We also keep pins on the scan's current buffer and
|
||||
* marked buffer, if any: this avoids the need to invoke ReadBuffer()
|
||||
* for each tuple produced by the index scan.
|
||||
*/
|
||||
|
||||
typedef struct RTreeScanOpaqueData
|
||||
{
|
||||
struct RTSTACK *s_stack;
|
||||
struct RTSTACK *s_markstk;
|
||||
uint16 s_flags;
|
||||
int s_internalNKey;
|
||||
ScanKey s_internalKey;
|
||||
Buffer curbuf;
|
||||
Buffer markbuf;
|
||||
} RTreeScanOpaqueData;
|
||||
|
||||
typedef RTreeScanOpaqueData *RTreeScanOpaque;
|
||||
|
||||
/*
|
||||
* When we're doing a scan and updating a tree at the same time, the
|
||||
* updates may affect the scan. We use the flags entry of the scan's
|
||||
* opaque space to record our actual position in response to updates
|
||||
* that we can't handle simply by adjusting pointers.
|
||||
*/
|
||||
|
||||
#define RTS_CURBEFORE ((uint16) (1 << 0))
|
||||
#define RTS_MRKBEFORE ((uint16) (1 << 1))
|
||||
|
||||
/* root page of an rtree */
|
||||
#define P_ROOT 0
|
||||
|
||||
/*
|
||||
* When we update a relation on which we're doing a scan, we need to
|
||||
* check the scan and fix it if the update affected any of the pages it
|
||||
* touches. Otherwise, we can miss records that we should see. The only
|
||||
* times we need to do this are for deletions and splits. See the code in
|
||||
* rtscan.c for how the scan is fixed. These two contants tell us what sort
|
||||
* of operation changed the index.
|
||||
*/
|
||||
|
||||
#define RTOP_DEL 0
|
||||
#define RTOP_SPLIT 1
|
||||
|
||||
/* defined in rtree.c */
|
||||
extern void freestack(RTSTACK *s);
|
||||
|
||||
/*
|
||||
* RTree code.
|
||||
* Defined in access/rtree/
|
||||
*/
|
||||
extern Datum rtinsert(PG_FUNCTION_ARGS);
|
||||
extern Datum rtbulkdelete(PG_FUNCTION_ARGS);
|
||||
extern Datum rtbeginscan(PG_FUNCTION_ARGS);
|
||||
extern Datum rtgettuple(PG_FUNCTION_ARGS);
|
||||
extern Datum rtgetmulti(PG_FUNCTION_ARGS);
|
||||
extern Datum rtendscan(PG_FUNCTION_ARGS);
|
||||
extern Datum rtmarkpos(PG_FUNCTION_ARGS);
|
||||
extern Datum rtrestrpos(PG_FUNCTION_ARGS);
|
||||
extern Datum rtrescan(PG_FUNCTION_ARGS);
|
||||
extern Datum rtbuild(PG_FUNCTION_ARGS);
|
||||
extern void _rtdump(Relation r);
|
||||
|
||||
extern void rtree_redo(XLogRecPtr lsn, XLogRecord *record);
|
||||
extern void rtree_desc(char *buf, uint8 xl_info, char *rec);
|
||||
|
||||
/* rtscan.c */
|
||||
extern void rtadjscans(Relation r, int op, BlockNumber blkno,
|
||||
OffsetNumber offnum);
|
||||
extern void ReleaseResources_rtree(void);
|
||||
|
||||
/* rtstrat.c */
|
||||
extern StrategyNumber RTMapToInternalOperator(StrategyNumber strat);
|
||||
extern bool RTMapToInternalNegate(StrategyNumber strat);
|
||||
|
||||
#endif /* RTREE_H */
|
||||
@@ -1,23 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* rtscan.h
|
||||
* routines defined in access/rtree/rtscan.c
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/rtscan.h,v 1.18 2004/12/31 22:03:21 pgsql Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef RTSCAN_H
|
||||
#define RTSCAN_H
|
||||
|
||||
#include "storage/block.h"
|
||||
#include "storage/off.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
void rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum);
|
||||
|
||||
#endif /* RTSCAN_H */
|
||||
Reference in New Issue
Block a user