head     1.4;
branch   ;
access   ;
symbols  Version_2_1:1.2;
locks    ; strict;
comment  @ * @;


1.4
date     91.05.22.07.48.42;  author mao;  state Exp;
branches ;
next     1.3;

1.3
date     91.04.28.15.21.59;  author mao;  state Exp;
branches ;
next     1.2;

1.2
date     91.02.24.09.05.20;  author mao;  state Exp;
branches ;
next     1.1;

1.1
date     91.02.19.15.52.12;  author mao;  state Exp;
branches ;
next     ;


desc
@defines for new rtree code
@


1.4
log
@if the index changes while a scan is active on it, need to fix the scan.
support for this install.ed
@
text
@/*
 *  rtree.h -- common declarations for the rtree access method code.
 *
 *	$Header: RCS/rtree.h,v 1.3 91/04/28 15:21:59 mao Exp Locker: mao $
 */

#ifndef RTreeHIncluded
#define RTreeHIncluded

/* see rtstrat.c for what all this is about */
#define RTNStrategies			8
#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 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;
	OffsetIndex	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.
 */

typedef struct RTreeScanOpaqueData {
	struct RTSTACK	*s_stack;
	struct RTSTACK	*s_markstk;
	uint16		s_flags;
	uint16		s_internalNKey;
	ScanKeyData	s_internalKey;
} 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

#endif /* RTreeHIncluded */
@


1.3
log
@add code to manage deletion of tuples and handle updates to pages on which
we have active scans.
@
text
@d4 1
a4 1
 *	$Header: RCS/rtree.h,v 1.2 91/02/24 09:05:20 mao Exp Locker: mao $
d57 1
d63 10
@


1.2
log
@working version of rtree access method for postgres 2.1
@
text
@d4 1
a4 1
 *	$Header: RCS/rtree.h,v 1.1 91/02/19 15:52:12 mao Exp Locker: mao $
d39 3
a41 3
	struct RTSTACK *rts_parent;
	OffsetNumber   rts_child;
	BlockNumber    rts_blk;
d65 12
@


1.1
log
@Initial revision
@
text
@d4 1
a4 1
 *	$Header$
d11 9
a19 8
#define RTNStrategies			7
#define RTContainedByStrategyNumber	1
#define RTIntersectsStrategyNumber	2
#define RTDisjointStrategyNumber	3
#define RTContainsStrategyNumber	4
#define RTNotCBStrategyNumber		5
#define RTNotCStrategyNumber		6
#define RTEqualStrategyNumber		7
d23 2
a24 2
#define RT_SIZE_PROC			2
#define RT_INTER_PROC			3
d34 30
@
