Header And Logo

PostgreSQL
| The world's most advanced open source database.

gistdesc.c

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * gistdesc.c
00004  *    rmgr descriptor routines for access/gist/gistxlog.c
00005  *
00006  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00007  * Portions Copyright (c) 1994, Regents of the University of California
00008  *
00009  *
00010  * IDENTIFICATION
00011  *    src/backend/access/rmgrdesc/gistdesc.c
00012  *
00013  *-------------------------------------------------------------------------
00014  */
00015 #include "postgres.h"
00016 
00017 #include "access/gist_private.h"
00018 #include "lib/stringinfo.h"
00019 #include "storage/relfilenode.h"
00020 
00021 static void
00022 out_target(StringInfo buf, RelFileNode node)
00023 {
00024     appendStringInfo(buf, "rel %u/%u/%u",
00025                      node.spcNode, node.dbNode, node.relNode);
00026 }
00027 
00028 static void
00029 out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
00030 {
00031     out_target(buf, xlrec->node);
00032     appendStringInfo(buf, "; block number %u", xlrec->blkno);
00033 }
00034 
00035 static void
00036 out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
00037 {
00038     appendStringInfo(buf, "page_split: ");
00039     out_target(buf, xlrec->node);
00040     appendStringInfo(buf, "; block number %u splits to %d pages",
00041                      xlrec->origblkno, xlrec->npage);
00042 }
00043 
00044 void
00045 gist_desc(StringInfo buf, uint8 xl_info, char *rec)
00046 {
00047     uint8       info = xl_info & ~XLR_INFO_MASK;
00048 
00049     switch (info)
00050     {
00051         case XLOG_GIST_PAGE_UPDATE:
00052             appendStringInfo(buf, "page_update: ");
00053             out_gistxlogPageUpdate(buf, (gistxlogPageUpdate *) rec);
00054             break;
00055         case XLOG_GIST_PAGE_SPLIT:
00056             out_gistxlogPageSplit(buf, (gistxlogPageSplit *) rec);
00057             break;
00058         case XLOG_GIST_CREATE_INDEX:
00059             appendStringInfo(buf, "create_index: rel %u/%u/%u",
00060                              ((RelFileNode *) rec)->spcNode,
00061                              ((RelFileNode *) rec)->dbNode,
00062                              ((RelFileNode *) rec)->relNode);
00063             break;
00064         default:
00065             appendStringInfo(buf, "unknown gist op code %u", info);
00066             break;
00067     }
00068 }