Header And Logo

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

smgrdesc.c

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * smgrdesc.c
00004  *    rmgr descriptor routines for catalog/storage.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/smgrdesc.c
00012  *
00013  *-------------------------------------------------------------------------
00014  */
00015 #include "postgres.h"
00016 
00017 #include "catalog/catalog.h"
00018 #include "catalog/storage_xlog.h"
00019 #include "common/relpath.h"
00020 
00021 
00022 void
00023 smgr_desc(StringInfo buf, uint8 xl_info, char *rec)
00024 {
00025     uint8       info = xl_info & ~XLR_INFO_MASK;
00026 
00027     if (info == XLOG_SMGR_CREATE)
00028     {
00029         xl_smgr_create *xlrec = (xl_smgr_create *) rec;
00030         char       *path = relpathperm(xlrec->rnode, xlrec->forkNum);
00031 
00032         appendStringInfo(buf, "file create: %s", path);
00033         pfree(path);
00034     }
00035     else if (info == XLOG_SMGR_TRUNCATE)
00036     {
00037         xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
00038         char       *path = relpathperm(xlrec->rnode, MAIN_FORKNUM);
00039 
00040         appendStringInfo(buf, "file truncate: %s to %u blocks", path,
00041                          xlrec->blkno);
00042         pfree(path);
00043     }
00044     else
00045         appendStringInfo(buf, "UNKNOWN");
00046 }