Re: HOT - whats next ?

From: "Simon Riggs" <simon(at)2ndquadrant(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Pavan Deolasee" <pavan(dot)deolasee(at)enterprisedb(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: HOT - whats next ?
Date: 2007-03-05 16:03:15
Message-ID: 1173110596.3760.1939.camel@silverbirch.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2007-03-02 at 21:53 -0500, Bruce Momjian wrote:
> Simon Riggs wrote:
>
> > It would also be very useful to have a version of pgstattuple that
> > worked with heaps, so test cases can be written that examine the header
> > fields, info flags etc. It would be useful to be able to specify the
> > basic behaviour in terms of explicit test cases.
> >
> > Would those two approaches to test execution be desirable in the
> > regression tests?
>
> Sure.

I've written some utility functions that will help us look inside heap
blocks to examine headers and the like. I'd like to add these to core
(not contrib) so we can write regression tests directly using them.

I'll post what I have now to -patches, under the title: Heap page
diagnostic/test functions (WIP). (I have extended the pgstattuple
contrib module, but thats not the eventual destination, I hope).

The first function reads a single block from a file, returning the
complete page as a bytea of length BLCKSZ.

CREATE OR REPLACE FUNCTION bufpage_get_raw_page(text, int4)
RETURNS bytea ...

We do this to ensure that we get a time consistent view of all data on
the page, rather than returning to it repeatedly to read items from it.
This is a similar idea to heapgetpage() for page-at-a-time scans, but we
may want to inspect all aspects of the page, not just visible tuples.

Returning a bytea means we can also dump that out as text easily, so
this is also a useful tool for retrieving the contents of damaged blocks
and emailing them to people. We can also save the page data in a table.

Other functions then work from the bytea version of the page.

-- A simple function for checking page header validity
CREATE OR REPLACE FUNCTION heap_raw_page_header_is_valid(bytea)
RETURNS boolean ...

-- An SRF for showing the details of tuple headers on a page
CREATE OR REPLACE FUNCTION heap_raw_page_tuple_headers(bytea)
RETURNS SETOF heap_page_tuple_header_type ...

example output: select * from
heap_raw_page_tuple_headers(bufpage_get_raw_page('foo',6));

itemid | ok | len | tctid | xmn | cn | xmx | cx | cid | natts |
toid | info_flag_text
--------+----+-----+---------+-------+----+-------+----+-----+-------+------+----------------
1 | t | 33 | (6,1) | 51800 | | 0 | i | 0 | 2 |
0 | HEAP_UPDATED
2 | t | 33 | (6,2) | 602 | c | 0 | i | 0 | 2 |
0 |
3 | t | 33 | (6,1) | 602 | c | 51800 | | 0 | 2 |
0 |

cn = xmin hint bits, cx = xmax hint bits

Can I have some additional requests for features on this, so I can
submit as a patch to core? What else do we want?

Thanks,

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2007-03-05 16:09:39 Re: Latest plans for Utilities with HOT
Previous Message Tom Lane 2007-03-05 16:02:31 Re: Aggressive freezing in lazy-vacuum