|
27 | 27 | * Copyright (c) 1994, Regents of the University of California
|
28 | 28 | *
|
29 | 29 | * IDENTIFICATION
|
30 |
| - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.47 1999/10/17 22:15:04 tgl Exp $ |
| 30 | + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.48 2000/01/08 21:24:49 tgl Exp $ |
31 | 31 | *
|
32 | 32 | *-------------------------------------------------------------------------
|
33 | 33 | */
|
@@ -301,6 +301,23 @@ _bt_buildadd(Relation index, BTPageState *state, BTItem bti, int flags)
|
301 | 301 | pgspc=PageGetFreeSpace(npage);
|
302 | 302 | btisz=BTITEMSZ(bti);
|
303 | 303 | btisz=MAXALIGN(btisz);
|
| 304 | + |
| 305 | +/* |
| 306 | + * Check whether the item can fit on a btree page at all. |
| 307 | + * (Eventually, we ought to try to apply TOAST methods if not.) |
| 308 | + * We actually need to be able to fit three items on every page, |
| 309 | + * so restrict any one item to 1/3 the per-page available space. |
| 310 | + * Note that at this point, btisz doesn't include the ItemId. |
| 311 | + * |
| 312 | + * NOTE: similar code appears in _bt_insertonpg() to defend against |
| 313 | + * oversize items being inserted into an already-existing index. |
| 314 | + * But during creation of an index, we don't go through there. |
| 315 | + */ |
| 316 | +if (btisz> (PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3-sizeof(ItemIdData)) |
| 317 | +elog(ERROR,"btree: index item size %d exceeds maximum %d", |
| 318 | +btisz, |
| 319 | + (PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3-sizeof(ItemIdData)); |
| 320 | + |
304 | 321 | if (pgspc<btisz)
|
305 | 322 | {
|
306 | 323 | Bufferobuf=nbuf;
|
|