Current content of control file is insufficient to check if database is
compatible with postgres server. I think we should create footprint file which
will contains all page data structures and their member offset and length (and
maybe more).
As a first step which is useful at least for in-place-upgrade is footprint
switch which prints page layout structures. I attach WIP patch.
I'm thinking also to create pg_footprint view with (version, structure name,
attribute, offset, size) columns. But I'm not sure about usefulness of this
catalog (?maybe for regression tests?).
Comments, ideas?
Thanks Zdenek
--
Zdenek Kotala Sun Microsystems
Prague, Czech Republic http://sun.com/postgresql
*** pgsql_footprint.76863ce445f3/src/backend/main/main.c po srp 11 06:48:20 2008
--- pgsql_footprint/src/backend/main/main.c ne srp 10 19:15:03 2008
***************
*** 34,39 ****
--- 34,40 ----
#include <sys/param.h>
#endif
+ #include "access/itup.h"
#include "bootstrap/bootstrap.h"
#include "postmaster/postmaster.h"
#include "tcop/tcopprot.h"
***************
*** 44,50 ****
#include "libpq/pqsignal.h"
#endif
-
const char *progname;
--- 45,50 ----
***************
*** 52,60 ****
static void help(const char *progname);
static void check_root(const char *progname);
static char *get_current_username(const char *progname);
-
int
main(int argc, char *argv[])
{
--- 52,60 ----
static void help(const char *progname);
static void check_root(const char *progname);
static char *get_current_username(const char *progname);
+ static void footprint(void);
int
main(int argc, char *argv[])
{
***************
*** 149,154 ****
--- 149,159 ----
puts("postgres (PostgreSQL) " PG_VERSION);
exit(0);
}
+ if ( strcmp(argv[1], "--footprint") == 0 )
+ {
+ footprint();
+ exit(0);
+ }
}
/*
***************
*** 301,306 ****
--- 306,312 ----
printf(_(" -t pa|pl|ex show timings after each query\n"));
printf(_(" -T send SIGSTOP to all backend servers if one dies\n"));
printf(_(" -W NUM wait NUM seconds to allow attach from a debugger\n"));
+ printf(_(" --footprint output page structure layout, then exit\n"));
printf(_("\nOptions for single-user mode:\n"));
printf(_(" --single selects single-user mode (must be first argument)\n"));
***************
*** 396,398 ****
--- 402,439 ----
return name;
#endif
}
+
+ #define PRT_STRUCT(str) \
+ printf("%s (%i/%i)\n", CppAsString(str), sizeof(str), MAXALIGN(sizeof(str)));
+ #define PRT_ATTR(str, attr) \
+ printf("\t%s - %i,%i\n", CppAsString(attr), offsetof(str,attr), sizeof(((str *)0)->attr));
+
+ static void
+ footprint(void)
+ {
+ PRT_STRUCT(PageHeaderData);
+ PRT_ATTR(PageHeaderData, pd_lsn);
+ PRT_ATTR(PageHeaderData, pd_tli);
+ PRT_ATTR(PageHeaderData, pd_flags);
+ PRT_ATTR(PageHeaderData, pd_lower);
+ PRT_ATTR(PageHeaderData, pd_upper);
+ PRT_ATTR(PageHeaderData, pd_special);
+ PRT_ATTR(PageHeaderData, pd_pagesize_version);
+ PRT_ATTR(PageHeaderData, pd_prune_xid);
+ PRT_ATTR(PageHeaderData, pd_linp);
+
+ PRT_STRUCT(HeapTupleHeaderData);
+ PRT_ATTR(HeapTupleHeaderData, t_choice.t_heap.t_xmin);
+ PRT_ATTR(HeapTupleHeaderData, t_choice.t_heap.t_xmax);
+ PRT_ATTR(HeapTupleHeaderData, t_choice.t_heap.t_field3.t_cid);
+ PRT_ATTR(HeapTupleHeaderData, t_ctid);
+ PRT_ATTR(HeapTupleHeaderData, t_infomask2);
+ PRT_ATTR(HeapTupleHeaderData, t_infomask);
+ PRT_ATTR(HeapTupleHeaderData, t_hoff);
+ PRT_ATTR(HeapTupleHeaderData, t_bits);
+
+ PRT_STRUCT(IndexTupleData);
+ PRT_ATTR(IndexTupleData, t_tid);
+ PRT_ATTR(IndexTupleData, t_info);
+ }
+
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers