Re: pg_autovacuum patch for 7.4.2 and HEAD

Lists: pgsql-patches
From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: "'pgsql-patches(at)postgresql(dot)org'" <pgsql-patches(at)postgresql(dot)org>
Subject: pg_autovacuum patch for 7.4.2 and HEAD
Date: 2004-03-04 07:22:29
Message-ID: 200403040222.29013.matthew@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

As reported by Cott Lang on 1/17
( http://archives.postgresql.org/pgsql-bugs/2004-01/msg00111.php )
pg_autovacuum.c has some problems with int overflow and not using appropriate
datatypes to track certain table values. This patch attempts to fix all
these issues. Someone should take a look and make sure its valid.

Matthew T. O'Connor

Attachment Content-Type Size
pg_autovacuum.diff text/x-diff 10.9 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
Cc: "'pgsql-patches(at)postgresql(dot)org'" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: pg_autovacuum patch for 7.4.2 and HEAD
Date: 2004-03-05 05:04:31
Message-ID: 3086.1078463071@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

"Matthew T. O'Connor" <matthew(at)zeut(dot)net> writes:
> pg_autovacuum.c has some problems with int overflow and not using appropriate
> datatypes to track certain table values. This patch attempts to fix all
> these issues. Someone should take a look and make sure its valid.

> ! new_tbl->relid = atol(PQgetvalue(res, row, PQfnumber(res, "oid")));
> ! new_tbl->reltuples = atof(PQgetvalue(res, row, PQfnumber(res, "reltuples")));
> ! new_tbl->relpages = atol(PQgetvalue(res, row, PQfnumber(res, "relpages")));

This ignores the fact that relid and relpages are unsigned. I would
suggest adopting the same convention for OID as is used in pg_dump and
other places:

#define atooid(x) ((Oid) strtoul((x), NULL, 10))

You could actually use this same macro for reading relpages, but that's
probably abusing the notation. I'd use strtoul directly for relpages,
I think.

> ! init_dbinfo(char *dbname, int oid, int age)
> ...
> ! init_dbinfo(char *dbname, uint oid, uint age)

This (and other declarations) should be "Oid oid".

regards, tom lane


From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'pgsql-patches(at)postgresql(dot)org'" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: pg_autovacuum patch for 7.4.2 and HEAD
Date: 2004-03-13 16:50:02
Message-ID: 40533BBA.1050509@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:

>"Matthew T. O'Connor" <matthew(at)zeut(dot)net> writes:
>
>
>>! new_tbl->relid = atol(PQgetvalue(res, row, PQfnumber(res, "oid")));
>>! new_tbl->reltuples = atof(PQgetvalue(res, row, PQfnumber(res, "reltuples")));
>>! new_tbl->relpages = atol(PQgetvalue(res, row, PQfnumber(res, "relpages")));
>>
>>
>
>This ignores the fact that relid and relpages are unsigned. I would
>suggest adopting the same convention for OID as is used in pg_dump and
>other places:
>
>#define atooid(x) ((Oid) strtoul((x), NULL, 10))
>
>You could actually use this same macro for reading relpages, but that's
>probably abusing the notation. I'd use strtoul directly for relpages,
>I think.
>
>
>
>>! init_dbinfo(char *dbname, int oid, int age)
>>...
>>! init_dbinfo(char *dbname, uint oid, uint age)
>>
>>
>
>This (and other declarations) should be "Oid oid".
>
>
>

Thanks for the help / review. Here is my 2nd cut at fixing this. I
believe I have addressed the above concernes. Please review again and
(hopefully) apply.

Matthew


From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "'pgsql-patches(at)postgresql(dot)org'" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: pg_autovacuum patch for 7.4.2 and HEAD
Date: 2004-03-13 17:01:51
Message-ID: 40533E7F.7060601@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:

>> "Matthew T. O'Connor" <matthew(at)zeut(dot)net> writes:
>>
>>> ! new_tbl->relid = atol(PQgetvalue(res, row, PQfnumber(res,
>>> "oid")));
>>> ! new_tbl->reltuples = atof(PQgetvalue(res, row, PQfnumber(res,
>>> "reltuples")));
>>> ! new_tbl->relpages = atol(PQgetvalue(res, row, PQfnumber(res,
>>> "relpages")));
>>
>>
>> This ignores the fact that relid and relpages are unsigned. I would
>> suggest adopting the same convention for OID as is used in pg_dump and
>> other places:
>>
>> #define atooid(x) ((Oid) strtoul((x), NULL, 10))
>>
>> You could actually use this same macro for reading relpages, but that's
>> probably abusing the notation. I'd use strtoul directly for relpages,
>> I think.
>>
>>> ! init_dbinfo(char *dbname, int oid, int age)
>>> ...
>>> ! init_dbinfo(char *dbname, uint oid, uint age)
>>>
>>
>>
>> This (and other declarations) should be "Oid oid".
>
>
> Thanks for the help / review. Here is my 2nd cut at fixing this. I
> believe I have addressed the above concernes. Please review again and
> (hopefully) apply.

Ack... sorry. This time with the attachment....

Attachment Content-Type Size
pg_autovacuum.diff text/plain 11.1 KB

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "'pgsql-patches(at)postgresql(dot)org'" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: pg_autovacuum patch for 7.4.2 and HEAD
Date: 2004-03-15 16:17:34
Message-ID: 200403151617.i2FGHYt10308@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Patch applied. Thanks.

---------------------------------------------------------------------------

Matthew T. O'Connor wrote:
> Tom Lane wrote:
>
> >"Matthew T. O'Connor" <matthew(at)zeut(dot)net> writes:
> >
> >
> >>! new_tbl->relid = atol(PQgetvalue(res, row, PQfnumber(res, "oid")));
> >>! new_tbl->reltuples = atof(PQgetvalue(res, row, PQfnumber(res, "reltuples")));
> >>! new_tbl->relpages = atol(PQgetvalue(res, row, PQfnumber(res, "relpages")));
> >>
> >>
> >
> >This ignores the fact that relid and relpages are unsigned. I would
> >suggest adopting the same convention for OID as is used in pg_dump and
> >other places:
> >
> >#define atooid(x) ((Oid) strtoul((x), NULL, 10))
> >
> >You could actually use this same macro for reading relpages, but that's
> >probably abusing the notation. I'd use strtoul directly for relpages,
> >I think.
> >
> >
> >
> >>! init_dbinfo(char *dbname, int oid, int age)
> >>...
> >>! init_dbinfo(char *dbname, uint oid, uint age)
> >>
> >>
> >
> >This (and other declarations) should be "Oid oid".
> >
> >
> >
>
> Thanks for the help / review. Here is my 2nd cut at fixing this. I
> believe I have addressed the above concernes. Please review again and
> (hopefully) apply.
>
>
> Matthew
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073