/*
**  Definitions for the range table.
**
**	Version:
**		@(#)range.h	8.2	1/15/85
*/

# ifndef MAXRANGE

# define	MAXRANGE	(MAXVAR + 1)


/*
**	DESCRIPTOR struct
**
**	The DESCRIPTOR struct is initialized by OPENR to describe any
**	open relation.  The first part of the descriptor is the tuple
**	from the RELATION relation.  The remainder contains some magic
**	numbers and a template initialized from the ATTRIBUTE relation.
**
**	This structure also defines the range table.
*/

struct descriptor
{
	struct relation	reldum;
		/*the above part of the descriptor struct is identical
		  to the relation struct and the inormation in this
		  part of the struct is read directly from the
		  relation tuple by openr.  the rest of the descriptor
		  struct is calculated by openr.  */
	char	relvname[MAXNAME];	/* range variable name */
	i_2	relfp;		/*filep for relation , if open	*/
	i_2	relopn;		/*indicates if relation is really open*/
	tid_type reltid;	/*when relation is open, this indicates
				  the tid in the relation relation for
				  this relation */
	i_4	reladds;	/*no. of additions of tuples during this open*/
	i_2	reloff[MAXDOM];	/*reloff[i] is offset to domain i 	*/
	c_1	relfrmt[MAXDOM]; /* format of domain i
				 ** INT, FLOAT, or CHAR  */
	c_1	relfrml[MAXDOM]; /* relfrml[i] is an unsigned integer
				  which indicates length
				  in bytes of domain */
	c_1	relxtra[MAXDOM]; /*relxtra[i] is non-zero if domain i is
				 ** a key domain for the relation */
	c_1	relgiven[MAXDOM]; /*cleared by openr and set before
				  call to find to indicate value of this
				  domain has been supplied in the key*/
	struct descriptor *relbtree;	/* used to store info about
					secondary btree stucture */
	int	btree_fd;	/* contains pointer to btree file */
};

typedef struct descriptor	DESC;

/*
** Various modes to openr.
*/
# define	OR_READ		0	/* Open relation for reading */
# define	OR_WRITE	2	/* Open relation for writing */
# define	OR_RELTID	-1	/* Only get relation relation 
					** tuple and tid only */
# define	OR_AREAD	-2	/* Open for reading after OR_RELTID */
# define	OR_AWRITE	-3	/* Open for writing after OR_RELTID */
# define	OR_REREAD	-4	/* Open for reading after openr()/closer() */
# define	OR_REWRITE	-5	/* Open for writing after openr()/closer() */


typedef struct
{
	DESC	*rngvdesc;	/* pointer to descriptor for this var */
	bool	rngvmark;	/* send if marked */
}  RANGEV;


# endif MAXRANGE
