codekingpro/portable-devtools
116k
1/*-------------------------------------------------------------------------2 *3 * sdir.h4 * POSTGRES scan direction definitions.5 *6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/access/sdir.h11 *12 *-------------------------------------------------------------------------13 */14#ifndef SDIR_H15#define SDIR_H16 17 18/*19 * Defines the direction for scanning a table or an index. Scans are never20 * invoked using NoMovementScanDirectionScans. For convenience, we use the21 * values -1 and 1 for backward and forward scans. This allows us to perform22 * a few mathematical tricks such as what is done in ScanDirectionCombine.23 */24typedef enum ScanDirection25{26 BackwardScanDirection = -1,27 NoMovementScanDirection = 0,28 ForwardScanDirection = 129} ScanDirection;30 31/*32 * Determine the net effect of two direction specifications.33 * This relies on having ForwardScanDirection = +1, BackwardScanDirection = -1,34 * and will probably not do what you want if applied to any other values.35 */36#define ScanDirectionCombine(a, b) ((a) * (b))37 38/*39 * ScanDirectionIsValid40 * True iff scan direction is valid.41 */42#define ScanDirectionIsValid(direction) \43 ((bool) (BackwardScanDirection <= (direction) && \44 (direction) <= ForwardScanDirection))45 46/*47 * ScanDirectionIsBackward48 * True iff scan direction is backward.49 */50#define ScanDirectionIsBackward(direction) \51 ((bool) ((direction) == BackwardScanDirection))52 53/*54 * ScanDirectionIsNoMovement55 * True iff scan direction indicates no movement.56 */57#define ScanDirectionIsNoMovement(direction) \58 ((bool) ((direction) == NoMovementScanDirection))59 60/*61 * ScanDirectionIsForward62 * True iff scan direction is forward.63 */64#define ScanDirectionIsForward(direction) \65 ((bool) ((direction) == ForwardScanDirection))66 67#endif /* SDIR_H */68 