Add manvolnum, so that man pages are generated.
[PostgreSQL.git] / contrib / pageinspect / fsmfuncs.c
blobccf67214e20899441fc9163114cbca28a67c3de3
1 /*-------------------------------------------------------------------------
3 * fsmfuncs.c
4 * Functions to investigate FSM pages
6 * These functions are restricted to superusers for the fear of introducing
7 * security holes if the input checking isn't as water-tight as it should.
8 * You'd need to be superuser to obtain a raw page image anyway, so
9 * there's hardly any use case for using these without superuser-rights
10 * anyway.
12 * Copyright (c) 2007-2009, PostgreSQL Global Development Group
14 * IDENTIFICATION
15 * $PostgreSQL$
17 *-------------------------------------------------------------------------
20 #include "postgres.h"
21 #include "lib/stringinfo.h"
22 #include "storage/fsm_internals.h"
23 #include "utils/builtins.h"
24 #include "miscadmin.h"
25 #include "funcapi.h"
27 Datum fsm_page_contents(PG_FUNCTION_ARGS);
30 * Dumps the contents of a FSM page.
32 PG_FUNCTION_INFO_V1(fsm_page_contents);
34 Datum
35 fsm_page_contents(PG_FUNCTION_ARGS)
37 bytea *raw_page = PG_GETARG_BYTEA_P(0);
38 int raw_page_size;
39 StringInfoData sinfo;
40 FSMPage fsmpage;
41 int i;
43 if (!superuser())
44 ereport(ERROR,
45 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
46 (errmsg("must be superuser to use raw page functions"))));
48 raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
49 fsmpage = (FSMPage) PageGetContents(VARDATA(raw_page));
51 initStringInfo(&sinfo);
53 for (i = 0; i < NodesPerPage; i++)
55 if (fsmpage->fp_nodes[i] != 0)
56 appendStringInfo(&sinfo, "%d: %d\n", i, fsmpage->fp_nodes[i]);
58 appendStringInfo(&sinfo, "fp_next_slot: %d\n", fsmpage->fp_next_slot);
60 PG_RETURN_TEXT_P(cstring_to_text(sinfo.data));