As Corey discovered, and I re-discovered later, partitioned tables can
have relpages=-1:

https://www.postgresql.org/message-id/f4a0cf7975f1ad42a20fcc91be9e938a4f71259d.ca...@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



Reply via email to