1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-23 14:01:44 +03:00

Improve code around the recently added rm_identify rmgr callback.

There are four weaknesses in728f152e07f998d2cb4fe5f24ec8da2c3bda98f2:

* append_init() in heapdesc.c was ugly and required that rm_identify
  return values are only valid till the next call. Instead just add a
  couple more switch() cases for the INIT_PAGE cases. Now the returned
  value will always be valid.
* a couple rm_identify() callbacks missed masking xl_info with
  ~XLR_INFO_MASK.
* pg_xlogdump didn't map a NULL rm_identify to UNKNOWN or a similar
  string.
* append_init() was called when id=NULL - which should never actually
  happen. But it's better to be careful.
This commit is contained in:
Andres Freund
2014-09-22 16:48:14 +02:00
parent 898f8a96ef
commit 604f7956b9
18 changed files with 36 additions and 38 deletions

View File

@ -166,36 +166,34 @@ heap2_desc(StringInfo buf, XLogRecord *record)
}
}
static const char *
append_init(const char *str)
{
static char x[32];
strcpy(x, str);
strcat(x, "+INIT");
return x;
}
const char *
heap_identify(uint8 info)
{
const char *id = NULL;
switch (info & XLOG_HEAP_OPMASK)
switch (info & ~XLR_INFO_MASK)
{
case XLOG_HEAP_INSERT:
id = "INSERT";
break;
case XLOG_HEAP_INSERT | XLOG_HEAP_INIT_PAGE:
id = "INSERT+INIT";
break;
case XLOG_HEAP_DELETE:
id = "DELETE";
break;
case XLOG_HEAP_UPDATE:
id = "UPDATE";
break;
case XLOG_HEAP_UPDATE | XLOG_HEAP_INIT_PAGE:
id = "UPDATE+INIT";
break;
case XLOG_HEAP_HOT_UPDATE:
id = "HOT_UPDATE";
break;
case XLOG_HEAP_HOT_UPDATE | XLOG_HEAP_INIT_PAGE:
id = "HOT_UPDATE+INIT";
break;
case XLOG_HEAP_LOCK:
id = "LOCK";
break;
@ -204,9 +202,6 @@ heap_identify(uint8 info)
break;
}
if (info & XLOG_HEAP_INIT_PAGE)
id = append_init(id);
return id;
}
@ -215,7 +210,7 @@ heap2_identify(uint8 info)
{
const char *id = NULL;
switch (info & XLOG_HEAP_OPMASK)
switch (info & ~XLR_INFO_MASK)
{
case XLOG_HEAP2_CLEAN:
id = "CLEAN";
@ -232,6 +227,9 @@ heap2_identify(uint8 info)
case XLOG_HEAP2_MULTI_INSERT:
id = "MULTI_INSERT";
break;
case XLOG_HEAP2_MULTI_INSERT | XLOG_HEAP_INIT_PAGE:
id = "MULTI_INSERT+INIT";
break;
case XLOG_HEAP2_LOCK_UPDATED:
id = "LOCK_UPDATED";
break;
@ -243,8 +241,5 @@ heap2_identify(uint8 info)
break;
}
if (info & XLOG_HEAP_INIT_PAGE)
id = append_init(id);
return id;
}