PostgreSQL Source Code: src/backend/storage/freespace/fsmpage.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

24

27

28

29#define leftchild(x) (2 * (x) + 1)

30#define rightchild(x) (2 * (x) + 2)

31#define parentof(x) (((x) - 1) / 2)

32

33

34

35

36static int

38{

39

40

41

42

43 x++;

44

45

46

47

48

49

50

51 if (((x + 1) & x) == 0)

53

54 return x;

55}

56

57

58

59

60

61

62bool

64{

68

70

72

73

75 return false;

76

78

79

80

81

82

83 do

84 {

88

92

97

100 break;

101

103 } while (nodeno > 0);

104

105

106

107

108

111

112 return true;

113}

114

115

116

117

118

119

120

130

131

132

133

134

135

136

144

145

146

147

148

149

150

151

152

153

154

155

156

157int

160{

164 int target;

166

167restart:

168

169

170

171

172

174 return -1;

175

176

177

178

179

180

183 target = 0;

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

229 {

231 break;

232

233

234

235

236

238 }

239

240

241

242

243

244

246 {

248

251 {

253 continue;

254 }

255 childnodeno++;

258 {

260 }

261 else

262 {

263

264

265

266

267

268

269

270

274

276 elog(DEBUG1, "fixing corrupt FSM block %u, relation %u/%u/%u",

278

279

281 {

285 }

288 goto restart;

289 }

290 }

291

292

294

295

296

297

298

299

300

301

302

304

305 return slot;

306}

307

308

309

310

311

312bool

314{

318

320

321

324 {

325 if (*ptr != 0)

327 *ptr = 0;

328 }

329

330

333

335}

336

337

338

339

340

341bool

343{

347

348

349

350

351

353 {

357

358

361

365

367 {

370 }

371 }

372

374}

void BufferGetTag(Buffer buffer, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *blknum)

void MarkBufferDirtyHint(Buffer buffer, bool buffer_std)

static Page BufferGetPage(Buffer buffer)

static void LockBuffer(Buffer buffer, BufferLockMode mode)

static char * PageGetContents(Page page)

#define Assert(condition)

#define NonLeafNodesPerPage

static int rightneighbor(int x)

uint8 fsm_get_avail(Page page, int slot)

bool fsm_rebuild_page(Page page)

uint8 fsm_get_max_avail(Page page)

bool fsm_set_avail(Page page, int slot, uint8 value)

bool fsm_truncate_avail(Page page, int nslots)

int fsm_search_avail(Buffer buf, uint8 minvalue, bool advancenext, bool exclusive_lock_held)

static char buf[DEFAULT_XLOG_SEG_SIZE]

uint8 fp_nodes[FLEXIBLE_ARRAY_MEMBER]