Skip to content

Commit 6580668

Browse files
committed
Back-patch fix for problems with oversize pg_statistic tuples when both
the min and max values of a column are long.
1 parent 621e372 commit 6580668

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/backend/commands/vacuum.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.110.2.3 1999/08/25 12:01:45 ishii Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.110.2.4 2000/01/04 17:27:26 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2405,10 +2405,21 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
24052405
stup = heap_formtuple(sd->rd_att, values, nulls);
24062406

24072407
/* ----------------
2408-
* insert the tuple in the relation and get the tuple's oid.
2408+
* Watch out for oversize tuple, which can happen if
2409+
* both of the saved data values are long.
2410+
* Our fallback strategy is just to not store the
2411+
* pg_statistic tuple at all in that case. (We could
2412+
* replace the values by NULLs and still store the
2413+
* numeric stats, but presently selfuncs.c couldn't
2414+
* do anything useful with that case anyway.)
24092415
* ----------------
24102416
*/
2411-
heap_insert(sd, stup);
2417+
if (MAXALIGN(stup->t_len) <= MaxTupleSize)
2418+
{
2419+
/* OK to store tuple */
2420+
heap_insert(sd, stup);
2421+
}
2422+
24122423
pfree(DatumGetPointer(values[3]));
24132424
pfree(DatumGetPointer(values[4]));
24142425
pfree(stup);

0 commit comments

Comments
 (0)