From: | Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-patches(at)postgresql(dot)org |
Subject: | Re: Patch for units in postgresql.conf |
Date: | 2006-07-26 11:24:19 |
Message-ID: | 44C750E3.5090205@sun.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Peter Eisentraut wrote:
> Here is a preliminary patch for units in postgresql.conf (and SET and so on,
> of course). It currently supports memory units only. Time units would be
> similar. Let me know if you have comments.
The concept is good. However, parse should generate overflow. You
multiply first time and convert value to bytes and after you divide it.
By my opinion, better solution is compute number and
direction(multiply/divide) of shift bits and do it in one step.
There is small concept:
------------
int shift_tab[][] = { { 0 , -10, -20, -30 },
{ 10, 0 , -10, -20 },
{ 20, 10, 0 , -10 },
{ 30, 20, 10, 0 },
{ shift for block } };
if (strcmp(endptr, "kB") == 0)
{
shift = shift_tab[1][ flags & ..... ];
used = true;
endptr += 2;
}
if( shift < 0 )
val >> = shift;
else
{
int mask = ~0;
mask << = shift;
if( val & mask == 0 )
val << = shift;
else
....!!! Overflow
}
--------------------
I am not sure but I expect that values are stored in native format
(native unit). I think, there is not reason to divide/multiply it?
> @@ -5082,8 +5124,34 @@
> val = (*conf->show_hook) ();
> else
> {
> - snprintf(buffer, sizeof(buffer), "%d",
> - *conf->variable);
> + char unit[3];
> + int result = *conf->variable;
> +
> + if (record->flags & (GUC_UNIT_KB|GUC_UNIT_BLOCKS))
> + {
> + if (record->flags & GUC_UNIT_BLOCKS)
> + result *= BLCKSZ/1024;
> +
Zdenek
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-07-26 13:58:19 | Re: Resurrecting per-page cleaner for btree |
Previous Message | Stefan Kaltenbrunner | 2006-07-26 08:34:52 | Re: [COMMITTERS] pgsql: /contrib/cube improvements: Update |