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,
12161216SET_VARSIZE (& chunk_data ,chunk_size + VARHDRSZ );
12171217memcpy (VARDATA (& chunk_data ),data_p ,chunk_size );
12181218toasttup = heap_form_tuple (toasttupDesc ,t_values ,t_isnull );
1219- if (!HeapTupleIsValid (toasttup ))
1220- elog (ERROR ,"failed to build TOAST tuple" );
12211219
12221220heap_insert (toastrel ,toasttup ,mycid ,use_wal ,use_fsm );
12231221
@@ -1412,7 +1410,9 @@ toast_fetch_datum(struct varlena * attr)
14121410else
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 ));
14161416chunksize = 0 ;/* keep compiler quiet */
14171417chunkdata = NULL ;
14181418}
@@ -1421,31 +1421,35 @@ toast_fetch_datum(struct varlena * attr)
14211421 * Some checks on the data we've found
14221422 */
14231423if (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 " ,
14251425residx ,nextidx ,
1426- toast_pointer .va_valueid );
1426+ toast_pointer .va_valueid ,
1427+ RelationGetRelationName (toastrel ));
14271428if (residx < numchunks - 1 )
14281429{
14291430if (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 " ,
14311432chunksize , (int )TOAST_MAX_CHUNK_SIZE ,
14321433residx ,numchunks ,
1433- toast_pointer .va_valueid );
1434+ toast_pointer .va_valueid ,
1435+ RelationGetRelationName (toastrel ));
14341436}
14351437else if (residx == numchunks - 1 )
14361438{
14371439if ((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 " ,
14391441chunksize ,
14401442 (int ) (ressize - residx * TOAST_MAX_CHUNK_SIZE ),
14411443residx ,
1442- toast_pointer .va_valueid );
1444+ toast_pointer .va_valueid ,
1445+ RelationGetRelationName (toastrel ));
14431446}
14441447else
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 " ,
14461449residx ,
1450+ 0 ,numchunks - 1 ,
14471451toast_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 */
14631467if (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 " ,
14651469nextidx ,
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)
16211626else
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 ));
16251632chunksize = 0 ;/* keep compiler quiet */
16261633chunkdata = 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 */
16321639if ((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 " ,
16341641residx ,nextidx ,
1635- toast_pointer .va_valueid );
1642+ toast_pointer .va_valueid ,
1643+ RelationGetRelationName (toastrel ));
16361644if (residx < totalchunks - 1 )
16371645{
16381646if (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 %s when fetching slice" ,
16401648chunksize , (int )TOAST_MAX_CHUNK_SIZE ,
16411649residx ,totalchunks ,
1642- toast_pointer .va_valueid );
1650+ toast_pointer .va_valueid ,
1651+ RelationGetRelationName (toastrel ));
16431652}
16441653else if (residx == totalchunks - 1 )
16451654{
16461655if ((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 %s when fetching slice" ,
16481657chunksize ,
16491658 (int ) (attrsize - residx * TOAST_MAX_CHUNK_SIZE ),
16501659residx ,
1651- toast_pointer .va_valueid );
1660+ toast_pointer .va_valueid ,
1661+ RelationGetRelationName (toastrel ));
16521662}
16531663else
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 " ,
16551665residx ,
1666+ 0 ,totalchunks - 1 ,
16561667toast_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 */
16801691if (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 " ,
16821693nextidx ,
1683- toast_pointer .va_valueid );
1694+ toast_pointer .va_valueid ,
1695+ RelationGetRelationName (toastrel ));
16841696
16851697/*
16861698 * End scan and close relations