Inconsistent use of relpages = -1 - Mailing list pgsql-hackers

From Jeff Davis
Subject Inconsistent use of relpages = -1
Date
Msg-id 463b50cec98ba58d0622f9cbd3ab3103ea9426e6.camel@j-davis.com
Whole thread Raw
Responses Re: Inconsistent use of relpages = -1
List pgsql-hackers
As Corey discovered, and I re-discovered later, partitioned tables can
have relpages=-1:

https://www.postgresql.org/message-id/f4a0cf7975f1ad42a20fcc91be9e938a4f71259d.camel@j-davis.com

One problem is that the code (analyze.c:680) is a bit unclear because
it implicitly casts back and forth between signed and unsigned. If we
really mean InvalidBlockNumber, then we should use that instead of -1,
and then explicitly cast to an integer for storage in the catalog.

Another problem is that it's inconsistent: sometimes it's 0 (before
analyze) and sometimes -1. Views also don't have any storage, but
relpages are always 0.

And lastly, it's undocumented: if -1 is allowable, it should be in the
public docs for pg_class.

I don't see any obvious reason that -1 is better than 0, or any code
that checks for it, so I'm inclined to just use zero instead.

Thoughts?

Regards,
    Jeff Davis




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: ECPG Refactor: move sqlca variable in ecpg_log()
Next
From: Tom Lane
Date:
Subject: Re: Inconsistent use of relpages = -1