1/* contrib/pageinspect/pageinspect--1.3--1.4.sql */
2
3-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4\echo Use "ALTER EXTENSION pageinspect UPDATE TO '1.4'" to load this file. \quit
5
6--
7-- heap_page_items()
8--
9DROP FUNCTION heap_page_items(bytea);
10CREATE FUNCTION heap_page_items(IN page bytea,
11    OUT lp smallint,
12    OUT lp_off smallint,
13    OUT lp_flags smallint,
14    OUT lp_len smallint,
15    OUT t_xmin xid,
16    OUT t_xmax xid,
17    OUT t_field3 int4,
18    OUT t_ctid tid,
19    OUT t_infomask2 integer,
20    OUT t_infomask integer,
21    OUT t_hoff smallint,
22    OUT t_bits text,
23    OUT t_oid oid,
24    OUT t_data bytea)
25RETURNS SETOF record
26AS 'MODULE_PATHNAME', 'heap_page_items'
27LANGUAGE C STRICT;
28
29--
30-- tuple_data_split()
31--
32CREATE FUNCTION tuple_data_split(rel_oid oid,
33    t_data bytea,
34    t_infomask integer,
35    t_infomask2 integer,
36    t_bits text)
37RETURNS bytea[]
38AS 'MODULE_PATHNAME','tuple_data_split'
39LANGUAGE C;
40
41CREATE FUNCTION tuple_data_split(rel_oid oid,
42    t_data bytea,
43    t_infomask integer,
44    t_infomask2 integer,
45    t_bits text,
46    do_detoast bool)
47RETURNS bytea[]
48AS 'MODULE_PATHNAME','tuple_data_split'
49LANGUAGE C;
50
51--
52-- heap_page_item_attrs()
53--
54CREATE FUNCTION heap_page_item_attrs(
55    IN page bytea,
56    IN rel_oid regclass,
57    IN do_detoast bool,
58    OUT lp smallint,
59    OUT lp_off smallint,
60    OUT lp_flags smallint,
61    OUT lp_len smallint,
62    OUT t_xmin xid,
63    OUT t_xmax xid,
64    OUT t_field3 int4,
65    OUT t_ctid tid,
66    OUT t_infomask2 integer,
67    OUT t_infomask integer,
68    OUT t_hoff smallint,
69    OUT t_bits text,
70    OUT t_oid oid,
71    OUT t_attrs bytea[]
72    )
73RETURNS SETOF record AS $$
74SELECT lp,
75       lp_off,
76       lp_flags,
77       lp_len,
78       t_xmin,
79       t_xmax,
80       t_field3,
81       t_ctid,
82       t_infomask2,
83       t_infomask,
84       t_hoff,
85       t_bits,
86       t_oid,
87       tuple_data_split(
88         rel_oid,
89         t_data,
90	 t_infomask,
91	 t_infomask2,
92	 t_bits,
93	 do_detoast)
94	 AS t_attrs
95  FROM heap_page_items(page);
96$$ LANGUAGE SQL;
97
98CREATE FUNCTION heap_page_item_attrs(
99    IN page bytea,
100    IN rel_oid regclass,
101    OUT lp smallint,
102    OUT lp_off smallint,
103    OUT lp_flags smallint,
104    OUT lp_len smallint,
105    OUT t_xmin xid,
106    OUT t_xmax xid,
107    OUT t_field3 int4,
108    OUT t_ctid tid,
109    OUT t_infomask2 integer,
110    OUT t_infomask integer,
111    OUT t_hoff smallint,
112    OUT t_bits text,
113    OUT t_oid oid,
114    OUT t_attrs bytea[]
115    )
116RETURNS SETOF record AS $$
117SELECT * from heap_page_item_attrs(page, rel_oid, false);
118$$ LANGUAGE SQL;
119