Unmark gen_random_uuid() function leakproof.
[pgsql.git] / src / include / storage / fsm_internals.h
bloba922e691fe067b936a6e3d74d67f267245c14a0b
1 /*-------------------------------------------------------------------------
3 * fsm_internals.h
4 * internal functions for free space map
7 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/storage/fsm_internals.h
12 *-------------------------------------------------------------------------
14 #ifndef FSM_INTERNALS_H
15 #define FSM_INTERNALS_H
17 #include "storage/buf.h"
18 #include "storage/bufpage.h"
21 * Structure of a FSM page. See src/backend/storage/freespace/README for
22 * details.
24 typedef struct
27 * fsm_search_avail() tries to spread the load of multiple backends by
28 * returning different pages to different backends in a round-robin
29 * fashion. fp_next_slot points to the next slot to be returned (assuming
30 * there's enough space on it for the request). It's defined as an int,
31 * because it's updated without an exclusive lock. uint16 would be more
32 * appropriate, but int is more likely to be atomically
33 * fetchable/storable.
35 int fp_next_slot;
38 * fp_nodes contains the binary tree, stored in array. The first
39 * NonLeafNodesPerPage elements are upper nodes, and the following
40 * LeafNodesPerPage elements are leaf nodes. Unused nodes are zero.
42 uint8 fp_nodes[FLEXIBLE_ARRAY_MEMBER];
43 } FSMPageData;
45 typedef FSMPageData *FSMPage;
48 * Number of non-leaf and leaf nodes, and nodes in total, on an FSM page.
49 * These definitions are internal to fsmpage.c.
51 #define NodesPerPage (BLCKSZ - MAXALIGN(SizeOfPageHeaderData) - \
52 offsetof(FSMPageData, fp_nodes))
54 #define NonLeafNodesPerPage (BLCKSZ / 2 - 1)
55 #define LeafNodesPerPage (NodesPerPage - NonLeafNodesPerPage)
58 * Number of FSM "slots" on a FSM page. This is what should be used
59 * outside fsmpage.c.
61 #define SlotsPerFSMPage LeafNodesPerPage
63 /* Prototypes for functions in fsmpage.c */
64 extern int fsm_search_avail(Buffer buf, uint8 minvalue, bool advancenext,
65 bool exclusive_lock_held);
66 extern uint8 fsm_get_avail(Page page, int slot);
67 extern uint8 fsm_get_max_avail(Page page);
68 extern bool fsm_set_avail(Page page, int slot, uint8 value);
69 extern bool fsm_truncate_avail(Page page, int nslots);
70 extern bool fsm_rebuild_page(Page page);
72 #endif /* FSM_INTERNALS_H */