1996-08-27 23:50:29 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* sdir.h
|
1996-08-27 23:50:29 +02:00
|
|
|
* POSTGRES scan direction definitions.
|
|
|
|
*
|
|
|
|
*
|
2024-01-04 02:49:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/access/sdir.h
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef SDIR_H
|
|
|
|
#define SDIR_H
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2023-01-31 22:52:41 +01:00
|
|
|
* Defines the direction for scanning a table or an index. Scans are never
|
|
|
|
* invoked using NoMovementScanDirectionScans. For convenience, we use the
|
|
|
|
* values -1 and 1 for backward and forward scans. This allows us to perform
|
|
|
|
* a few mathematical tricks such as what is done in ScanDirectionCombine.
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
|
|
|
typedef enum ScanDirection
|
|
|
|
{
|
|
|
|
BackwardScanDirection = -1,
|
|
|
|
NoMovementScanDirection = 0,
|
|
|
|
ForwardScanDirection = 1
|
|
|
|
} ScanDirection;
|
|
|
|
|
2023-01-31 22:52:41 +01:00
|
|
|
/*
|
|
|
|
* Determine the net effect of two direction specifications.
|
|
|
|
* This relies on having ForwardScanDirection = +1, BackwardScanDirection = -1,
|
|
|
|
* and will probably not do what you want if applied to any other values.
|
|
|
|
*/
|
|
|
|
#define ScanDirectionCombine(a, b) ((a) * (b))
|
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/*
|
1999-02-14 00:22:53 +01:00
|
|
|
* ScanDirectionIsValid
|
1996-08-27 23:50:29 +02:00
|
|
|
* True iff scan direction is valid.
|
|
|
|
*/
|
|
|
|
#define ScanDirectionIsValid(direction) \
|
2000-11-03 00:11:03 +01:00
|
|
|
((bool) (BackwardScanDirection <= (direction) && \
|
|
|
|
(direction) <= ForwardScanDirection))
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
1999-02-14 00:22:53 +01:00
|
|
|
* ScanDirectionIsBackward
|
1996-08-27 23:50:29 +02:00
|
|
|
* True iff scan direction is backward.
|
|
|
|
*/
|
|
|
|
#define ScanDirectionIsBackward(direction) \
|
2000-11-03 00:11:03 +01:00
|
|
|
((bool) ((direction) == BackwardScanDirection))
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
1999-02-14 00:22:53 +01:00
|
|
|
* ScanDirectionIsNoMovement
|
1996-08-27 23:50:29 +02:00
|
|
|
* True iff scan direction indicates no movement.
|
|
|
|
*/
|
|
|
|
#define ScanDirectionIsNoMovement(direction) \
|
2000-11-03 00:11:03 +01:00
|
|
|
((bool) ((direction) == NoMovementScanDirection))
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
/*
|
1999-02-14 00:22:53 +01:00
|
|
|
* ScanDirectionIsForward
|
1996-08-27 23:50:29 +02:00
|
|
|
* True iff scan direction is forward.
|
|
|
|
*/
|
|
|
|
#define ScanDirectionIsForward(direction) \
|
2000-11-03 00:11:03 +01:00
|
|
|
((bool) ((direction) == ForwardScanDirection))
|
2001-10-28 07:26:15 +01:00
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
#endif /* SDIR_H */
|