Inconsistent use of relpages = -1

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Inconsistent use of relpages = -1
Date: 2024-10-18 18:56:08
Message-ID: 463b50cec98ba58d0622f9cbd3ab3103ea9426e6.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-10-18 19:14:01 Re: Inconsistent use of relpages = -1
Previous Message Tom Lane 2024-10-18 17:43:45 Re: ECPG Refactor: move sqlca variable in ecpg_log()