Subject: pageinspect forks

From: Vik Fearing <[email-masked]>
Date: Wed, 30 Jul 2014 14:11:05 +0200

I noticed that the documentation for pageinspect lists the different
forks but omits the initialization fork.

Here is a trivial patch to fix that.

-- 
Vik

*** a/doc/src/sgml/pageinspect.sgml
--- b/doc/src/sgml/pageinspect.sgml
***************
*** 31,38 ****
        table and returns a copy as a <type>bytea</> value.  This allows a
        single time-consistent copy of the block to be obtained.
        <replaceable>fork</replaceable> should be <literal>'main'</literal> for
!       the main data fork, or <literal>'fsm'</literal> for the free space map,
!       or <literal>'vm'</literal> for the visibility map.
       </para>
      </listitem>
     </varlistentry>
--- 31,39 ----
        table and returns a copy as a <type>bytea</> value.  This allows a
        single time-consistent copy of the block to be obtained.
        <replaceable>fork</replaceable> should be <literal>'main'</literal> for
!       the main data fork, <literal>'fsm'</literal> for the free space map,
!       <literal>'vm'</literal> for the visibility map, or <literal>'init'</literal>
!       for the initialization fork.
       </para>
      </listitem>
     </varlistentry>

-- 
Sent via pgsql-docs mailing list ([email-masked])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs

---

From: "MauMau" <[email-masked]>
Date: Sun, 10 Aug 2014 22:24:03 +0900

From: "Vik Fearing" <[email-masked]>
> Here is a trivial patch to fix that.

Could you also improve the doc by changing "table" to "relation" in the 
description of get_raw_page()?  Having a quick look at the code, it seems 
that the function can also handle indexes.

Regards
MauMau

---

From: Fujii Masao <[email-masked]>
Date: Mon, 11 Aug 2014 00:48:46 +0900

> Here is a trivial patch to fix that.

ISTM that this fix needs to back-patched to 9.1 where
the initialization fork was introduced.

I found that the document of pg_relation_size() had
the same problem and it has been fixed recently by
2d00190495b22e0d0ba351b2cda9c95fb2e3d083,
but it has not been back-patched to 9.1, 9.2 and 9.3.
I think that we should back-patch that to those versions.

That commit also fixed the HINT message
"HINT:  Valid fork names are "main", "fsm", and "vm".",
so that the initialization fork is included in that message.
This also needs to be back-patched to those versions.

Regards,

-- 
Fujii Masao

---

From: Vik Fearing <[email-masked]>
Date: Sun, 10 Aug 2014 20:59:59 +0200

On 08/10/2014 03:24 PM, MauMau wrote:
> description of get_raw_page()?  Having a quick look at the code, it
> seems that the function can also handle indexes.
> 

Good catch.  I wasn't sure whether using "relation" or "table or index"
was better, but after a quick test it seems it works for sequences, too,
so I've gone with "relation".

It doesn't work with views, of course, but it does work with
materialized views.

Modified patch attached.
-- 
Vik
*** a/doc/src/sgml/pageinspect.sgml
--- b/doc/src/sgml/pageinspect.sgml
***************
*** 28,38 ****
      <listitem>
       <para>
        <function>get_raw_page</function> reads the specified block of the named
!       table and returns a copy as a <type>bytea</> value.  This allows a
        single time-consistent copy of the block to be obtained.
        <replaceable>fork</replaceable> should be <literal>'main'</literal> for
!       the main data fork, or <literal>'fsm'</literal> for the free space map,
!       or <literal>'vm'</literal> for the visibility map.
       </para>
      </listitem>
     </varlistentry>
--- 28,39 ----
      <listitem>
       <para>
        <function>get_raw_page</function> reads the specified block of the named
!       relation and returns a copy as a <type>bytea</> value.  This allows a
        single time-consistent copy of the block to be obtained.
        <replaceable>fork</replaceable> should be <literal>'main'</literal> for
!       the main data fork, <literal>'fsm'</literal> for the free space map,
!       <literal>'vm'</literal> for the visibility map, or <literal>'init'</literal>
!       for the initialization fork.
       </para>
      </listitem>
     </varlistentry>

---

From: "MauMau" <[email-masked]>
Date: Mon, 11 Aug 2014 07:22:09 +0900

> It doesn't work with views, of course, but it does work with

Thanks, I marked this as ready for committer.

I think I'll leave it up to you to decide whether you improve the HINT 
message Fujii-san pointed out, which is in src/backend/catalog/catalog.c.

Regards
MauMau

---

From: Vik Fearing <[email-masked]>
Date: Mon, 11 Aug 2014 14:34:46 +0200

> message Fujii-san pointed out, which is in src/backend/catalog/catalog.c.

I think you're looking at an old version of the code.  My understanding
of his message was that that patch had already been applied but not
backpatched and he wants it backpatched.  To wit, that hint message does
include "init" on master and it's located in src/common/relpath.c.

However, I did find another occurence in the documentation, so third
patch attached.
-- 
Vik
*** a/doc/src/sgml/pageinspect.sgml
--- b/doc/src/sgml/pageinspect.sgml
***************
*** 28,38 ****
      <listitem>
       <para>
        <function>get_raw_page</function> reads the specified block of the named
!       table and returns a copy as a <type>bytea</> value.  This allows a
        single time-consistent copy of the block to be obtained.
        <replaceable>fork</replaceable> should be <literal>'main'</literal> for
!       the main data fork, or <literal>'fsm'</literal> for the free space map,
!       or <literal>'vm'</literal> for the visibility map.
       </para>
      </listitem>
     </varlistentry>
--- 28,39 ----
      <listitem>
       <para>
        <function>get_raw_page</function> reads the specified block of the named
!       relation and returns a copy as a <type>bytea</> value.  This allows a
        single time-consistent copy of the block to be obtained.
        <replaceable>fork</replaceable> should be <literal>'main'</literal> for
!       the main data fork, <literal>'fsm'</literal> for the free space map,
!       <literal>'vm'</literal> for the visibility map, or <literal>'init'</literal>
!       for the initialization fork.
       </para>
      </listitem>
     </varlistentry>
*** a/doc/src/sgml/storage.sgml
--- b/doc/src/sgml/storage.sgml
***************
*** 265,272 **** The <function>pg_relation_filepath()</> function shows the entire path
  as a substitute for remembering many of the above rules.  But keep in
  mind that this function just gives the name of the first segment of the
  main fork of the relation &mdash; you may need to append a segment number
! and/or <literal>_fsm</> or <literal>_vm</> to find all the files associated
! with the relation.
  </para>
  
  <para>
--- 265,272 ----
  as a substitute for remembering many of the above rules.  But keep in
  mind that this function just gives the name of the first segment of the
  main fork of the relation &mdash; you may need to append a segment number
! and/or <literal>_fsm</>, <literal>_vm</>, or <literal>_init</> to find all
! the files associated with the relation.
  </para>
  
  <para>

---

From: "MauMau" <[email-masked]>
Date: Mon, 11 Aug 2014 22:42:48 +0900

> However, I did find another occurence in the documentation, so third

You are right, I was looking at the code of 9.3.4 at hand.  The latest code 
certainly has the accurate HINT message.

Your v3 patch looks reasonable.

Regards
MauMau

---

From: Fujii Masao <[email-masked]>
Date: Mon, 11 Aug 2014 23:38:57 +0900

> Your v3 patch looks reasonable.

Thanks for the patch! Applied.

Regards,

-- 
Fujii Masao