|
5 | 5 | *
|
6 | 6 | *
|
7 | 7 | * IDENTIFICATION
|
8 |
| - * $Id: nbtsort.c,v 1.40.2.1 1999/08/02 05:24:41 scrappy Exp $ |
| 8 | + * $Id: nbtsort.c,v 1.40.2.2 2000/01/08 21:47:31 tgl Exp $ |
9 | 9 | *
|
10 | 10 | * NOTES
|
11 | 11 | *
|
@@ -904,6 +904,23 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags)
|
904 | 904 | pgspc=PageGetFreeSpace(npage);
|
905 | 905 | btisz=BTITEMSZ(bti);
|
906 | 906 | btisz=MAXALIGN(btisz);
|
| 907 | + |
| 908 | +/* |
| 909 | + * Check whether the item can fit on a btree page at all. |
| 910 | + * (Eventually, we ought to try to apply TOAST methods if not.) |
| 911 | + * We actually need to be able to fit three items on every page, |
| 912 | + * so restrict any one item to 1/3 the per-page available space. |
| 913 | + * Note that at this point, btisz doesn't include the ItemId. |
| 914 | + * |
| 915 | + * NOTE: similar code appears in _bt_insertonpg() to defend against |
| 916 | + * oversize items being inserted into an already-existing index. |
| 917 | + * But during creation of an index, we don't go through there. |
| 918 | + */ |
| 919 | +if (btisz> (PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3-sizeof(ItemIdData)) |
| 920 | +elog(ERROR,"btree: index item size %d exceeds maximum %d", |
| 921 | +btisz, |
| 922 | + (PageGetPageSize(npage)-sizeof(PageHeaderData)-MAXALIGN(sizeof(BTPageOpaqueData)))/3-sizeof(ItemIdData)); |
| 923 | + |
907 | 924 | if (pgspc<btisz)
|
908 | 925 | {
|
909 | 926 | Bufferobuf=nbuf;
|
|