Re: pg_rewarm status - Mailing list pgsql-hackers

From Robert Haas
Subject Re: pg_rewarm status
Date
Msg-id CA+TgmoZZPhyA_-W85uSi08PSpd_J2BSNB1f-sGei68Puu_XegQ@mail.gmail.com
Whole thread Raw
In response to Re: pg_rewarm status  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: pg_rewarm status
List pgsql-hackers
On Thu, Dec 19, 2013 at 8:37 AM, Amit Kapila <amit.kapila16@gmail.com> wrote:
> Few observations:
> 1.
> pg_prewarm.control
> +# pg_buffercache extension
> Wrong name.

Oops.

> 2.
> +pg_prewarm(regclass, mode text default 'buffer', fork text default 'main',
> +           first_block int8 default null,
> +           last_block int8 default null) RETURNS int8
> {
> ..
> int64 first_block;
> int64 last_block;
> int64 nblocks;
> int64 blocks_done = 0;
> ..
> }
> is there specific reason to keep parameters type as int8, shouldn't it
> be uint32 (BlockNumber)?

There's no uint32 type at the SQL level, and int32 is no good because
it can't represent sufficiently large positive values to cover the
largest possible block number.  So we have to use int64 at the SQL
level; there is precedent elsewhere.  So first_block and last_block
have to be int64, because those are the raw values we got from the
user; they haven't initially been bounds-checked yet.  And blocks_done
is the value we're going to return to the user, so it should match the
SQL return type of the function, which again has to be int64 because
int32 doesn't have enough range.  nblocks could possibly be changed to
be BlockNumber, but I think the code is easier to understand using one
type predominantly throughout rather than worry about exactly which
type is going to be used for comparisons after promoting.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: pg_rewarm status
Next
From: Andres Freund
Date:
Subject: Re: preserving forensic information when we freeze