Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit36ad1a8

Browse files
committed
Implement mxid_age() to compute multi-xid age
Report by Josh Berkus
1 parent84aa8ba commit36ad1a8

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

‎doc/src/sgml/maintenance.sgml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,12 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
640640
possible multixact ID still appearing in any tuple of that table.
641641
If this value is older than
642642
<xref linkend="guc-vacuum-multixact-freeze-table-age">, a whole-table
643-
scan is forced. Whole-table <command>VACUUM</> scans, regardless of
643+
scan is forced. <function>mxid_age()</> can be used on
644+
<structname>pg_class</>.<structfield>relminmxid</> to find its age.
645+
</para>
646+
647+
<para>
648+
Whole-table <command>VACUUM</> scans, regardless of
644649
what causes them, enable advancing the value for that table.
645650
Eventually, as all tables in all databases are scanned and their
646651
oldest multixact values are advanced, on-disk storage for older

‎src/backend/utils/adt/xid.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include<limits.h>
1818

19+
#include"access/multixact.h"
1920
#include"access/transam.h"
2021
#include"access/xact.h"
2122
#include"libpq/pqformat.h"
@@ -102,6 +103,21 @@ xid_age(PG_FUNCTION_ARGS)
102103
PG_RETURN_INT32((int32) (now-xid));
103104
}
104105

106+
/*
107+
*mxid_age- compute age of a multi XID (relative to latest stable mxid)
108+
*/
109+
Datum
110+
mxid_age(PG_FUNCTION_ARGS)
111+
{
112+
TransactionIdxid=PG_GETARG_TRANSACTIONID(0);
113+
MultiXactIdnow=ReadNextMultiXactId();
114+
115+
if (!MultiXactIdIsValid(xid))
116+
PG_RETURN_INT32(INT_MAX);
117+
118+
PG_RETURN_INT32((int32) (now-xid));
119+
}
120+
105121
/*
106122
* xidComparator
107123
*qsort comparison function for XIDs

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201409091
56+
#defineCATALOG_VERSION_NO201409101
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,8 @@ DATA(insert OID = 1180 ( abstime PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 7
12791279
DESCR("convert timestamp with time zone to abstime");
12801280
DATA(insertOID=1181 (agePGNSPPGUID121000fffftfs1023"28"_null__null__null__null_xid_age_null__null__null_ ));
12811281
DESCR("age of a transaction ID, in transactions before current transaction");
1282+
DATA(insertOID=3939 (mxid_agePGNSPPGUID121000fffftfs1023"28"_null__null__null__null_mxid_age_null__null__null_ ));
1283+
DESCR("age of a multi-transaction ID, in multi-transactions before current multi-transaction");
12821284

12831285
DATA(insertOID=1188 (timestamptz_miPGNSPPGUID121000fffftfi201186"1184 1184"_null__null__null__null_timestamp_mi_null__null__null_ ));
12841286
DATA(insertOID=1189 (timestamptz_pl_intervalPGNSPPGUID121000fffftfs201184"1184 1186"_null__null__null__null_timestamptz_pl_interval_null__null__null_ ));

‎src/include/utils/builtins.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ extern Datum xidrecv(PG_FUNCTION_ARGS);
845845
externDatumxidsend(PG_FUNCTION_ARGS);
846846
externDatumxideq(PG_FUNCTION_ARGS);
847847
externDatumxid_age(PG_FUNCTION_ARGS);
848+
externDatummxid_age(PG_FUNCTION_ARGS);
848849
externintxidComparator(constvoid*arg1,constvoid*arg2);
849850
externDatumcidin(PG_FUNCTION_ARGS);
850851
externDatumcidout(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp