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

Commit55a5684

Browse files
committed
Improve the various elog messages in tuptoaster.c to report which TOAST table
the problem happened in. These are all supposedly can't-happen cases, butwhen they do happen it's useful to know where.Back-patch to 8.3, but not further because the patch doesn't apply cleanlyfurther back. Given the lack of response to my proposal of this, theredoesn't seem to be enough interest to justify much back-porting effort.
1 parent2319ddf commit55a5684

File tree

1 file changed

+37
-25
lines changed

1 file changed

+37
-25
lines changed

‎src/backend/access/heap/tuptoaster.c

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.87 2008/04/17 21:37:28 alvherre Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.88 2008/06/13 02:59:47 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1216,8 +1216,6 @@ toast_save_datum(Relation rel, Datum value,
12161216
SET_VARSIZE(&chunk_data,chunk_size+VARHDRSZ);
12171217
memcpy(VARDATA(&chunk_data),data_p,chunk_size);
12181218
toasttup=heap_form_tuple(toasttupDesc,t_values,t_isnull);
1219-
if (!HeapTupleIsValid(toasttup))
1220-
elog(ERROR,"failed to build TOAST tuple");
12211219

12221220
heap_insert(toastrel,toasttup,mycid,use_wal,use_fsm);
12231221

@@ -1412,7 +1410,9 @@ toast_fetch_datum(struct varlena * attr)
14121410
else
14131411
{
14141412
/* should never happen */
1415-
elog(ERROR,"found toasted toast chunk");
1413+
elog(ERROR,"found toasted toast chunk for toast value %u in %s",
1414+
toast_pointer.va_valueid,
1415+
RelationGetRelationName(toastrel));
14161416
chunksize=0;/* keep compiler quiet */
14171417
chunkdata=NULL;
14181418
}
@@ -1421,31 +1421,35 @@ toast_fetch_datum(struct varlena * attr)
14211421
* Some checks on the data we've found
14221422
*/
14231423
if (residx!=nextidx)
1424-
elog(ERROR,"unexpected chunk number %d (expected %d) for toast value %u",
1424+
elog(ERROR,"unexpected chunk number %d (expected %d) for toast value %u in %s",
14251425
residx,nextidx,
1426-
toast_pointer.va_valueid);
1426+
toast_pointer.va_valueid,
1427+
RelationGetRelationName(toastrel));
14271428
if (residx<numchunks-1)
14281429
{
14291430
if (chunksize!=TOAST_MAX_CHUNK_SIZE)
1430-
elog(ERROR,"unexpected chunk size %d (expected %d) in chunk %d of %d for toast value %u",
1431+
elog(ERROR,"unexpected chunk size %d (expected %d) in chunk %d of %d for toast value %u in %s",
14311432
chunksize, (int)TOAST_MAX_CHUNK_SIZE,
14321433
residx,numchunks,
1433-
toast_pointer.va_valueid);
1434+
toast_pointer.va_valueid,
1435+
RelationGetRelationName(toastrel));
14341436
}
14351437
elseif (residx==numchunks-1)
14361438
{
14371439
if ((residx*TOAST_MAX_CHUNK_SIZE+chunksize)!=ressize)
1438-
elog(ERROR,"unexpected chunk size %d (expected %d) in final chunk %d for toast value %u",
1440+
elog(ERROR,"unexpected chunk size %d (expected %d) in final chunk %d for toast value %u in %s",
14391441
chunksize,
14401442
(int) (ressize-residx*TOAST_MAX_CHUNK_SIZE),
14411443
residx,
1442-
toast_pointer.va_valueid);
1444+
toast_pointer.va_valueid,
1445+
RelationGetRelationName(toastrel));
14431446
}
14441447
else
1445-
elog(ERROR,"unexpected chunk number %dfor toast value %u(out of range %d..%d)",
1448+
elog(ERROR,"unexpected chunk number %d (out of range %d..%d) for toast value %u in %s",
14461449
residx,
1450+
0,numchunks-1,
14471451
toast_pointer.va_valueid,
1448-
0,numchunks-1);
1452+
RelationGetRelationName(toastrel));
14491453

14501454
/*
14511455
* Copy the data into proper place in our result
@@ -1461,9 +1465,10 @@ toast_fetch_datum(struct varlena * attr)
14611465
* Final checks that we successfully fetched the datum
14621466
*/
14631467
if (nextidx!=numchunks)
1464-
elog(ERROR,"missing chunk number %d for toast value %u",
1468+
elog(ERROR,"missing chunk number %d for toast value %u in %s",
14651469
nextidx,
1466-
toast_pointer.va_valueid);
1470+
toast_pointer.va_valueid,
1471+
RelationGetRelationName(toastrel));
14671472

14681473
/*
14691474
* End scan and close relations
@@ -1621,7 +1626,9 @@ toast_fetch_datum_slice(struct varlena * attr, int32 sliceoffset, int32 length)
16211626
else
16221627
{
16231628
/* should never happen */
1624-
elog(ERROR,"found toasted toast chunk");
1629+
elog(ERROR,"found toasted toast chunk for toast value %u in %s",
1630+
toast_pointer.va_valueid,
1631+
RelationGetRelationName(toastrel));
16251632
chunksize=0;/* keep compiler quiet */
16261633
chunkdata=NULL;
16271634
}
@@ -1630,31 +1637,35 @@ toast_fetch_datum_slice(struct varlena * attr, int32 sliceoffset, int32 length)
16301637
* Some checks on the data we've found
16311638
*/
16321639
if ((residx!=nextidx)|| (residx>endchunk)|| (residx<startchunk))
1633-
elog(ERROR,"unexpected chunk number %d (expected %d) for toast value %u",
1640+
elog(ERROR,"unexpected chunk number %d (expected %d) for toast value %u in %s",
16341641
residx,nextidx,
1635-
toast_pointer.va_valueid);
1642+
toast_pointer.va_valueid,
1643+
RelationGetRelationName(toastrel));
16361644
if (residx<totalchunks-1)
16371645
{
16381646
if (chunksize!=TOAST_MAX_CHUNK_SIZE)
1639-
elog(ERROR,"unexpected chunk size %d (expected %d) in chunk %d of %d for toast value %u when fetching slice",
1647+
elog(ERROR,"unexpected chunk size %d (expected %d) in chunk %d of %d for toast value %uin %swhen fetching slice",
16401648
chunksize, (int)TOAST_MAX_CHUNK_SIZE,
16411649
residx,totalchunks,
1642-
toast_pointer.va_valueid);
1650+
toast_pointer.va_valueid,
1651+
RelationGetRelationName(toastrel));
16431652
}
16441653
elseif (residx==totalchunks-1)
16451654
{
16461655
if ((residx*TOAST_MAX_CHUNK_SIZE+chunksize)!=attrsize)
1647-
elog(ERROR,"unexpected chunk size %d (expected %d) in final chunk %d for toast value %u when fetching slice",
1656+
elog(ERROR,"unexpected chunk size %d (expected %d) in final chunk %d for toast value %uin %swhen fetching slice",
16481657
chunksize,
16491658
(int) (attrsize-residx*TOAST_MAX_CHUNK_SIZE),
16501659
residx,
1651-
toast_pointer.va_valueid);
1660+
toast_pointer.va_valueid,
1661+
RelationGetRelationName(toastrel));
16521662
}
16531663
else
1654-
elog(ERROR,"unexpected chunk number %dfor toast value %u(out of range %d..%d)",
1664+
elog(ERROR,"unexpected chunk number %d (out of range %d..%d) for toast value %u in %s",
16551665
residx,
1666+
0,totalchunks-1,
16561667
toast_pointer.va_valueid,
1657-
0,totalchunks-1);
1668+
RelationGetRelationName(toastrel));
16581669

16591670
/*
16601671
* Copy the data into proper place in our result
@@ -1678,9 +1689,10 @@ toast_fetch_datum_slice(struct varlena * attr, int32 sliceoffset, int32 length)
16781689
* Final checks that we successfully fetched the datum
16791690
*/
16801691
if (nextidx!= (endchunk+1))
1681-
elog(ERROR,"missing chunk number %d for toast value %u",
1692+
elog(ERROR,"missing chunk number %d for toast value %u in %s",
16821693
nextidx,
1683-
toast_pointer.va_valueid);
1694+
toast_pointer.va_valueid,
1695+
RelationGetRelationName(toastrel));
16841696

16851697
/*
16861698
* End scan and close relations

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp