Обсуждение: Is the a "magic number" for WAL files

Поиск
Список
Период
Сортировка

Is the a "magic number" for WAL files

От
Rob Sargent
Дата:
I would like the "file" command to tell me something other than "data",
yes even though I can tell by the name (and the directory of course).
Hoping someone has something I can slip into /usr/share/misc/magic.mgc
or that directory.

Along the same lines, what info is embedded in the file name? I see that
the second non-zero recently went from 2 to 3.  Significance?


0000000100000030000000CF
              ^
--------------|

Re: Is the a "magic number" for WAL files

От
Thom Brown
Дата:
On 9 December 2011 18:46, Rob Sargent <robjsargent@gmail.com> wrote:
> Along the same lines, what info is embedded in the file name? I see that
> the second non-zero recently went from 2 to 3.  Significance?
>
>
> 0000000100000030000000CF
>              ^
> --------------|

The WAL file name consists of timeline, segment set/segment block and
segment,  Once the segment (the last 8 characters of the file name)
reaches 000000FE, the next file will have a segment 00000000 but
characters 9-16 will increment their value to reflect this wraparound.
 So it's not any more significant that 1 added to 99 results in it
becoming 00 with a 1 before it.

--
Thom

Re: Is the a "magic number" for WAL files

От
Peter Geoghegan
Дата:
On 9 December 2011 18:46, Rob Sargent <robjsargent@gmail.com> wrote:
> I would like the "file" command to tell me something other than "data",
> yes even though I can tell by the name (and the directory of course).
> Hoping someone has something I can slip into /usr/share/misc/magic.mgc
> or that directory.

You mean something like this?:

/*
 * Each page of XLOG file has a header like this:
 */
#define XLOG_PAGE_MAGIC 0xD068    /* can be used as WAL version indicator */

Obviously that isn't stable.

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services