Lists: | pgsql-hackers |
---|
From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | age(xid) function bug |
Date: | 2008-08-20 03:14:02 |
Message-ID: | 200808200314.m7K3E2I00516@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
I see we recommend using the age(xid) function to check for XID
wraparound:
http://www.postgresql.org/docs/8.3/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
However, the function only does a subtraction with no adjustment for
overflow, and considering it returns a signed int, it can't even display
the full range of valid values:
test=> \df age
List of functions
Schema | Name | Result data type | Argument data types
------------+------+------------------+----------------------------------------------------------
...
pg_catalog | age | integer | xid
For example:
test=> select txid_current();
txid_current
--------------
397
(1 row)
test=> select age('10000'::xid);
age
-------
-9602
(1 row)
Seems this is a bug. I think the fix is to do the arithmetic in int8
and return an int8.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Bruce Momjian <bruce(at)momjian(dot)us> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: age(xid) function bug |
Date: | 2008-08-20 03:58:46 |
Message-ID: | 19803.1219204726@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Bruce Momjian <bruce(at)momjian(dot)us> writes:
> However, the function only does a subtraction with no adjustment for
> overflow, and considering it returns a signed int, it can't even display
> the full range of valid values:
Say again? The possible range of ages is only 2 billion.
regards, tom lane
From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: age(xid) function bug |
Date: | 2008-08-20 04:06:40 |
Message-ID: | 200808200406.m7K46eb01937@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > However, the function only does a subtraction with no adjustment for
> > overflow, and considering it returns a signed int, it can't even display
> > the full range of valid values:
>
> Say again? The possible range of ages is only 2 billion.
If we assume that only xid stored in actual tables are used, yes:
test=> select txid_current();
txid_current
--------------
402
(1 row)
test=> select age('4294967290'::xid);
age
-----
409
(1 row)
OK, so it does work based on the limitations we place on stored xids.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +