* @exception StandardException Standard exception policy.
**/
private RecordHandle doInsert(DataValueDescriptor[] row)
throws StandardException
{
Page page = null;
byte insert_mode;
RecordHandle rh;
if (SanityManager.DEBUG)
{
Heap heap = (Heap) open_conglom.getConglomerate();
// Make sure valid columns are in the list. The RowUtil
// call is too expensive to make in a released system for
// every insert.
int invalidColumn =
RowUtil.columnOutOfRange(
row, null, heap.format_ids.length);
if (invalidColumn >= 0)
{
throw(StandardException.newException(
SQLState.HEAP_TEMPLATE_MISMATCH,
new Long(invalidColumn),
new Long(heap.format_ids.length)));
}
}
// Get the last page that was returned for insert or the last page
// that was allocated.
page = open_conglom.getContainer().getPageForInsert(0);
if (page != null) {
// if there are 0 rows on the page allow the insert to overflow.
insert_mode =
(page.recordCount() == 0) ?
Page.INSERT_OVERFLOW : Page.INSERT_DEFAULT;
// Check to see if there is enough space on the page
// for the row.
rh = page.insert(row, null, insert_mode,
AccessFactoryGlobals.HEAP_OVERFLOW_THRESHOLD);
page.unlatch();
page = null;
// If we have found a page with enough space for the row,
// insert it and release exclusive access to the page.
if (rh != null)
{
return rh;
}
}
// If the last inserted page is now full, or RawStore have
// forgotten what it was, or the row cannot fit on the last
// inserted page, try to have rawStore get a relatively unfilled
// page.
page =
open_conglom.getContainer().getPageForInsert(
ContainerHandle.GET_PAGE_UNFILLED);
if (page != null)
{
// Do the insert all over again hoping that it will fit into
// this page, and if not, allocate a new page.
// if there are 0 rows on the page allow the insert to overflow.
insert_mode =
(page.recordCount() == 0) ?
Page.INSERT_OVERFLOW : Page.INSERT_DEFAULT;
rh = page.insert(row, null, insert_mode,
AccessFactoryGlobals.HEAP_OVERFLOW_THRESHOLD);
page.unlatch();
page = null;
// If we have found a page with enough space for the row,
// insert it and release exclusive access to the page.
if (rh != null)
{
return rh;
}
}
page = open_conglom.getContainer().addPage();
// At this point with long rows the raw store will guarantee
// that any size row will fit on an empty page.
rh = page.insert(row, null, Page.INSERT_OVERFLOW,
AccessFactoryGlobals.HEAP_OVERFLOW_THRESHOLD);
page.unlatch();
page = null;
if (SanityManager.DEBUG)
{
// a null will only be returned if this page is not empty