1) Overview

This proposal is part of inplace upgrade project. PostgreSQL should be able to read any page in old version. This is basic for all possible upgrade method.


2) Background

We have several macros for manipulating of the page structures but this list is not complete and many parts of code access into this structures directly and severals part does not use existing macros. The idea is to use only specified API for manipulation/access of data structure on page. This API will recognize page layout version and it process data correctly.


3) API

Proposed API is extended version of current macros which does not satisfy all Page Header manipulation. I plan to use function in first implementation, because it offers better type control and debugging capability, but some functions could be converted into macros (or into inline functions) in final solution (performance improving). All changes are related to bufpage.h and page.c.


4) Implementation

The main point of implementation is to have several version of PageHeader structure (e.g. PageHeader_04, PageHeader_03 ...) and correct structure will be handled in special branch (see examples).

Possible improvement is to use union which combine different PageHeader version and because most PageHeader items are same for all Page Layout version, it will reduce number of switches. But I'm afraid if union have same data layout as separate structure on all supported platforms.

There are examples:

void PageSetFull(Page page)
{
        switch ( PageGetPageLayoutVersion(page) )
        {
                case 4 : ((PageHeader_04) (page))->pd_flags |= PD_PAGE_FULL;
                                  break;
                default elog(PANIC, "PageSetFull is not supported on page layout 
version %i",
                                PageGetPageLayoutVersion(page));
        }
}

LocationIndex PageGetLower(Page page)
{
        switch ( PageGetPageLayoutVersion(page) )
        {
                case 4 : return ((PageHeader_04) (page))->pd_lower);
        }
        elog(PANIC, "Unsupported page layout in function PageGetLower.");
}


5) Issues

a) hash index has hardcoded PageHeader into meta page structure -> need rewrite hash index implementation to be multiheader version friendly b) All *ItemSize macros (+toast chunk size) depends on sizeof(PageHeader) -> separate proposal will follow soon.


        All comments are welcome.

                Zdenek


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to