nus-yam/ex-repair huggingface dataset:
Program: 16115
Project: 16115
Buggy source:
/** 
 * Get the size of a row (only the part that is stored in the index).
 * @param dummy a dummy data page to calculate the size
 * @param row the row
 * @param onlyPosition whether only the position of the row is stored
 * @return the number of bytes
 */
int getRowSize(Data dummy,SearchRow row,boolean onlyPosition) throws SQLException {
  int rowsize=DataPage.LENGTH_INT;
  if (!onlyPosition) {
    for (    Column col : columns) {
      Value v=row.getValue(col.getColumnId());
      rowsize+=dummy.getValueLen(v);
    }
  }
  return rowsize;
}

Fixed version (ground truth):
/** 
 * Get the size of a row (only the part that is stored in the index).
 * @param dummy a dummy data page to calculate the size
 * @param row the row
 * @param onlyPosition whether only the position of the row is stored
 * @return the number of bytes
 */
int getRowSize(Data dummy,SearchRow row,boolean onlyPosition) throws SQLException {
  int rowsize=dummy.getVarLongLen(row.getKey());
  if (!onlyPosition) {
    for (    Column col : columns) {
      Value v=row.getValue(col.getColumnId());
      rowsize+=dummy.getValueLen(v);
    }
  }
  return rowsize;
}
Program: 16116
Project: 16116
Buggy source:
SearchRow remove(SearchRow row) throws SQLException {
  int at=find(row,false,false,true);
  SearchRow delete=getRow(at);
  if (index.compareRows(row,delete) != 0 || delete.getKey() != row.getKey()) {
    throw Message.getSQLException(ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1,index.getSQL() + "String_Node_Str" + row);
  }
  if (entryCount == 1) {
    return row;
  }
  removeRow(at);
  index.getPageStore().updateRecord(this,true,data);
  if (at == entryCount) {
    return getRow(at - 1);
  }
  return null;
}

Fixed version (ground truth):
SearchRow remove(SearchRow row) throws SQLException {
  int at=find(row,false,false,true);
  SearchRow delete=getRow(at);
  if (index.compareRows(row,delete) != 0 || delete.getKey() != row.getKey()) {
    throw Message.getSQLException(ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1,index.getSQL() + "String_Node_Str" + row);
  }
  if (entryCount == 1) {
    return row;
  }
  index.getPageStore().logUndo(this,data);
  removeRow(at);
  index.getPageStore().updateRecord(this);
  if (at == entryCount) {
    return getRow(at - 1);
  }
  return null;
}
Program: 16118
Project: 16118
Buggy source:
PageBtree split(int splitPoint) throws SQLException {
  int newPageId=index.getPageStore().allocatePage();
  PageBtreeLeaf p2=new PageBtreeLeaf(index,newPageId,index.getPageStore().createData());
  p2.parentPageId=parentPageId;
  for (int i=splitPoint; i < entryCount; ) {
    p2.addRowTry(getRow(splitPoint));
    removeRow(splitPoint);
  }
  return p2;
}

Fixed version (ground truth):
PageBtree split(int splitPoint) throws SQLException {
  int newPageId=index.getPageStore().allocatePage();
  PageBtreeLeaf p2=PageBtreeLeaf.create(index,newPageId,parentPageId);
  for (int i=splitPoint; i < entryCount; ) {
    p2.addRowTry(getRow(splitPoint));
    removeRow(splitPoint);
  }
  return p2;
}
Program: 16119
Project: 16119
Buggy source:
/** 
 * Create a new page.
 * @param index the index
 * @param pageId the page id
 * @param parentPageId the parent
 * @return the page
 */
static PageBtreeLeaf create(PageBtreeIndex index,int pageId,int parentPageId){
  PageBtreeLeaf p=new PageBtreeLeaf(index,pageId,index.getPageStore().createData());
  p.parentPageId=parentPageId;
  p.writeHead();
  p.start=p.data.length();
  return p;
}

Fixed version (ground truth):
/** 
 * Create a new page.
 * @param index the index
 * @param pageId the page id
 * @param parentPageId the parent
 * @return the page
 */
static PageBtreeLeaf create(PageBtreeIndex index,int pageId,int parentPageId) throws SQLException {
  PageBtreeLeaf p=new PageBtreeLeaf(index,pageId,index.getPageStore().createData());
  index.getPageStore().logUndo(p,p.data);
  p.parentPageId=parentPageId;
  p.writeHead();
  p.start=p.data.length();
  return p;
}
Program: 16120
Project: 16120
Buggy source:
private void removeRow(int i) throws SQLException {
  readAllRows();
  entryCount--;
  written=false;
  if (entryCount <= 0) {
    Message.throwInternalError();
  }
  int[] newOffsets=new int[entryCount];
  SearchRow[] newRows=new SearchRow[entryCount];
  System.arraycopy(offsets,0,newOffsets,0,i);
  System.arraycopy(rows,0,newRows,0,i);
  int startNext=i > 0 ? offsets[i - 1] : index.getPageStore().getPageSize();
  int rowLength=startNext - offsets[i];
  for (int j=i; j < entryCount; j++) {
    newOffsets[j]=offsets[j + 1] + rowLength;
  }
  System.arraycopy(rows,i + 1,newRows,i,entryCount - i);
  start-=OFFSET_LENGTH;
  offsets=newOffsets;
  rows=newRows;
}

Fixed version (ground truth):
private void removeRow(int i) throws SQLException {
  readAllRows();
  index.getPageStore().logUndo(this,data);
  entryCount--;
  written=false;
  if (entryCount <= 0) {
    Message.throwInternalError();
  }
  int[] newOffsets=new int[entryCount];
  SearchRow[] newRows=new SearchRow[entryCount];
  System.arraycopy(offsets,0,newOffsets,0,i);
  System.arraycopy(rows,0,newRows,0,i);
  int startNext=i > 0 ? offsets[i - 1] : index.getPageStore().getPageSize();
  int rowLength=startNext - offsets[i];
  for (int j=i; j < entryCount; j++) {
    newOffsets[j]=offsets[j + 1] + rowLength;
  }
  System.arraycopy(rows,i + 1,newRows,i,entryCount - i);
  start-=OFFSET_LENGTH;
  offsets=newOffsets;
  rows=newRows;
}
Program: 16121
Project: 16121
Buggy source:
public void moveTo(Session session,int newPos) throws SQLException {
  PageStore store=index.getPageStore();
  PageBtreeLeaf p2=new PageBtreeLeaf(index,newPos,store.createData());
  readAllRows();
  p2.rows=rows;
  p2.entryCount=entryCount;
  p2.offsets=offsets;
  p2.onlyPosition=onlyPosition;
  p2.parentPageId=parentPageId;
  p2.start=start;
  store.updateRecord(p2,false,null);
  if (parentPageId == ROOT) {
    index.setRootPageId(session,newPos);
  }
 else {
    PageBtreeNode p=(PageBtreeNode)store.getPage(parentPageId);
    p.moveChild(getPos(),newPos);
  }
  store.freePage(getPos(),true,data);
}

Fixed version (ground truth):
public void moveTo(Session session,int newPos) throws SQLException {
  PageStore store=index.getPageStore();
  readAllRows();
  PageBtreeLeaf p2=PageBtreeLeaf.create(index,newPos,parentPageId);
  store.logUndo(this,data);
  store.logUndo(p2,null);
  p2.rows=rows;
  p2.entryCount=entryCount;
  p2.offsets=offsets;
  p2.onlyPosition=onlyPosition;
  p2.parentPageId=parentPageId;
  p2.start=start;
  store.updateRecord(p2);
  if (parentPageId == ROOT) {
    index.setRootPageId(session,newPos);
  }
 else {
    PageBtreeNode p=(PageBtreeNode)store.getPage(parentPageId);
    p.moveChild(getPos(),newPos);
  }
  store.freePage(getPos(),true,data);
}
Program: 16122
Project: 16122
Buggy source:
SearchRow remove(SearchRow row) throws SQLException {
  int at=find(row,false,false,true);
  PageBtree page=index.getPage(childPageIds[at]);
  SearchRow last=page.remove(row);
  updateRowCount(-1);
  written=false;
  if (last == null) {
    return null;
  }
 else   if (last == row) {
    index.getPageStore().freePage(page.getPos(),true,page.data);
    if (entryCount < 1) {
      return row;
    }
    if (at == entryCount) {
      last=getRow(at - 1);
    }
 else {
      last=null;
    }
    removeChild(at);
    index.getPageStore().updateRecord(this,true,data);
    return last;
  }
  if (at == entryCount) {
    return last;
  }
  int child=childPageIds[at];
  removeChild(at);
  addChild(at,child,last);
  int temp=childPageIds[at];
  childPageIds[at]=childPageIds[at + 1];
  childPageIds[at + 1]=temp;
  index.getPageStore().updateRecord(this,true,data);
  return null;
}

Fixed version (ground truth):
SearchRow remove(SearchRow row) throws SQLException {
  int at=find(row,false,false,true);
  PageBtree page=index.getPage(childPageIds[at]);
  SearchRow last=page.remove(row);
  index.getPageStore().logUndo(this,data);
  updateRowCount(-1);
  written=false;
  if (last == null) {
    return null;
  }
 else   if (last == row) {
    index.getPageStore().freePage(page.getPos(),true,page.data);
    if (entryCount < 1) {
      return row;
    }
    if (at == entryCount) {
      last=getRow(at - 1);
    }
 else {
      last=null;
    }
    removeChild(at);
    index.getPageStore().updateRecord(this);
    return last;
  }
  if (at == entryCount) {
    return last;
  }
  int child=childPageIds[at];
  removeChild(at);
  addChild(at,child,last);
  int temp=childPageIds[at];
  childPageIds[at]=childPageIds[at + 1];
  childPageIds[at + 1]=temp;
  index.getPageStore().updateRecord(this);
  return null;
}
Program: 16123
Project: 16123
Buggy source:
int addRowTry(SearchRow row) throws SQLException {
  while (true) {
    int x=find(row,false,true,true);
    PageBtree page=index.getPage(childPageIds[x]);
    int splitPoint=page.addRowTry(row);
    if (splitPoint == -1) {
      break;
    }
    SearchRow pivot=page.getRow(splitPoint - 1);
    int splitPoint2=addChildTry(pivot);
    if (splitPoint2 != -1) {
      return splitPoint2;
    }
    PageBtree page2=page.split(splitPoint);
    readAllRows();
    addChild(x,page2.getPos(),pivot);
    index.getPageStore().updateRecord(page,true,page.data);
    index.getPageStore().updateRecord(page2,true,page2.data);
    index.getPageStore().updateRecord(this,true,data);
  }
  updateRowCount(1);
  written=false;
  return -1;
}

Fixed version (ground truth):
int addRowTry(SearchRow row) throws SQLException {
  while (true) {
    int x=find(row,false,true,true);
    PageBtree page=index.getPage(childPageIds[x]);
    int splitPoint=page.addRowTry(row);
    if (splitPoint == -1) {
      break;
    }
    SearchRow pivot=page.getRow(splitPoint - 1);
    index.getPageStore().logUndo(this,data);
    int splitPoint2=addChildTry(pivot);
    if (splitPoint2 != -1) {
      return splitPoint2;
    }
    PageBtree page2=page.split(splitPoint);
    readAllRows();
    addChild(x,page2.getPos(),pivot);
    index.getPageStore().updateRecord(page);
    index.getPageStore().updateRecord(page2);
    index.getPageStore().updateRecord(this);
  }
  updateRowCount(1);
  written=false;
  return -1;
}
Program: 16124
Project: 16124
Buggy source:
PageBtree split(int splitPoint) throws SQLException {
  int newPageId=index.getPageStore().allocatePage();
  PageBtreeNode p2=new PageBtreeNode(index,newPageId,index.getPageStore().createData());
  p2.parentPageId=parentPageId;
  if (onlyPosition) {
    p2.onlyPosition=true;
  }
  int firstChild=childPageIds[splitPoint];
  readAllRows();
  for (int i=splitPoint; i < entryCount; ) {
    p2.addChild(p2.entryCount,childPageIds[splitPoint + 1],rows[splitPoint]);
    removeChild(splitPoint);
  }
  int lastChild=childPageIds[splitPoint - 1];
  removeChild(splitPoint - 1);
  childPageIds[splitPoint - 1]=lastChild;
  if (p2.childPageIds == null) {
    p2.childPageIds=new int[1];
  }
  p2.childPageIds[0]=firstChild;
  p2.remapChildren();
  return p2;
}

Fixed version (ground truth):
PageBtree split(int splitPoint) throws SQLException {
  int newPageId=index.getPageStore().allocatePage();
  PageBtreeNode p2=PageBtreeNode.create(index,newPageId,parentPageId);
  index.getPageStore().logUndo(this,data);
  if (onlyPosition) {
    p2.onlyPosition=true;
  }
  int firstChild=childPageIds[splitPoint];
  readAllRows();
  for (int i=splitPoint; i < entryCount; ) {
    p2.addChild(p2.entryCount,childPageIds[splitPoint + 1],rows[splitPoint]);
    removeChild(splitPoint);
  }
  int lastChild=childPageIds[splitPoint - 1];
  removeChild(splitPoint - 1);
  childPageIds[splitPoint - 1]=lastChild;
  if (p2.childPageIds == null) {
    p2.childPageIds=new int[1];
  }
  p2.childPageIds[0]=firstChild;
  p2.remapChildren();
  return p2;
}
Program: 16125
Project: 16125
Buggy source:
/** 
 * One of the children has moved to a new page.
 * @param oldPos the old position
 * @param newPos the new position
 */
void moveChild(int oldPos,int newPos) throws SQLException {
  for (int i=0; i < childPageIds.length; i++) {
    if (childPageIds[i] == oldPos) {
      written=false;
      childPageIds[i]=newPos;
      index.getPageStore().updateRecord(this,true,data);
      return;
    }
  }
  throw Message.throwInternalError();
}

Fixed version (ground truth):
/** 
 * One of the children has moved to a new page.
 * @param oldPos the old position
 * @param newPos the new position
 */
void moveChild(int oldPos,int newPos) throws SQLException {
  for (int i=0; i < childPageIds.length; i++) {
    if (childPageIds[i] == oldPos) {
      index.getPageStore().logUndo(this,data);
      written=false;
      childPageIds[i]=newPos;
      index.getPageStore().updateRecord(this);
      return;
    }
  }
  throw Message.throwInternalError();
}
Program: 16126
Project: 16126
Buggy source:
/** 
 * Create a new b-tree node page.
 * @param index the index
 * @param pageId the page id
 * @param parentPageId the parent page id
 * @return the page
 */
static PageBtreeNode create(PageBtreeIndex index,int pageId,int parentPageId){
  PageBtreeNode p=new PageBtreeNode(index,pageId,index.getPageStore().createData());
  p.parentPageId=parentPageId;
  p.writeHead();
  p.start=p.data.length() + 4;
  return p;
}

Fixed version (ground truth):
/** 
 * Create a new b-tree node page.
 * @param index the index
 * @param pageId the page id
 * @param parentPageId the parent page id
 * @return the page
 */
static PageBtreeNode create(PageBtreeIndex index,int pageId,int parentPageId) throws SQLException {
  PageBtreeNode p=new PageBtreeNode(index,pageId,index.getPageStore().createData());
  index.getPageStore().logUndo(p,p.data);
  p.parentPageId=parentPageId;
  p.writeHead();
  p.start=p.data.length() + 4;
  return p;
}
Program: 16127
Project: 16127
Buggy source:
protected void remapChildren() throws SQLException {
  for (  int child : childPageIds) {
    PageBtree p=index.getPage(child);
    p.setParentPageId(getPos());
    index.getPageStore().updateRecord(p,true,p.data);
  }
}

Fixed version (ground truth):
protected void remapChildren() throws SQLException {
  for (  int child : childPageIds) {
    PageBtree p=index.getPage(child);
    p.setParentPageId(getPos());
    index.getPageStore().updateRecord(p);
  }
}
Program: 16128
Project: 16128
Buggy source:
public void moveTo(Session session,int newPos) throws SQLException {
  PageStore store=index.getPageStore();
  PageBtreeNode p2=new PageBtreeNode(index,newPos,store.createData());
  readAllRows();
  p2.childPageIds=childPageIds;
  p2.rows=rows;
  p2.entryCount=entryCount;
  p2.offsets=offsets;
  p2.onlyPosition=onlyPosition;
  p2.parentPageId=parentPageId;
  p2.start=start;
  store.updateRecord(p2,false,null);
  if (parentPageId == ROOT) {
    index.setRootPageId(session,newPos);
  }
 else {
    PageBtreeNode p=(PageBtreeNode)store.getPage(parentPageId);
    p.moveChild(getPos(),newPos);
  }
  for (int i=0; i < childPageIds.length; i++) {
    PageBtree p=(PageBtree)store.getPage(childPageIds[i]);
    p.setParentPageId(newPos);
    store.updateRecord(p,true,p.data);
  }
  store.freePage(getPos(),true,data);
}

Fixed version (ground truth):
public void moveTo(Session session,int newPos) throws SQLException {
  PageStore store=index.getPageStore();
  store.logUndo(this,data);
  PageBtreeNode p2=PageBtreeNode.create(index,newPos,parentPageId);
  readAllRows();
  p2.childPageIds=childPageIds;
  p2.rows=rows;
  p2.entryCount=entryCount;
  p2.offsets=offsets;
  p2.onlyPosition=onlyPosition;
  p2.parentPageId=parentPageId;
  p2.start=start;
  store.updateRecord(p2);
  if (parentPageId == ROOT) {
    index.setRootPageId(session,newPos);
  }
 else {
    PageBtreeNode p=(PageBtreeNode)store.getPage(parentPageId);
    p.moveChild(getPos(),newPos);
  }
  for (int i=0; i < childPageIds.length; i++) {
    PageBtree p=(PageBtree)store.getPage(childPageIds[i]);
    p.setParentPageId(newPos);
    store.updateRecord(p);
  }
  store.freePage(getPos(),true,data);
}
Program: 16129
Project: 16129
Buggy source:
/** 
 * Change the parent page id.
 * @param id the new parent page id
 */
void setParentPageId(int id){
  parentPageId=id;
  if (written) {
    data.setInt(START_PARENT,parentPageId);
  }
}

Fixed version (ground truth):
/** 
 * Change the parent page id.
 * @param id the new parent page id
 */
void setParentPageId(int id) throws SQLException {
  index.getPageStore().logUndo(this,data);
  parentPageId=id;
  if (written) {
    data.setInt(START_PARENT,parentPageId);
  }
}
Program: 16130
Project: 16130
Buggy source:
/** 
 * Read the given page.
 * @param id the page id
 * @param parent the parent, or -1 if unknown
 * @return the page
 */
PageData getPage(int id,int parent) throws SQLException {
  PageData p=(PageData)store.getPage(id);
  if (p == null) {
    PageDataLeaf empty=PageDataLeaf.create(this,id,parent);
    return empty;
  }
  if (p.index.rootPageId != rootPageId) {
    throw Message.throwInternalError("String_Node_Str" + p.index.getName() + "String_Node_Str"+ p.index.rootPageId+ "String_Node_Str"+ getName()+ "String_Node_Str"+ rootPageId);
  }
  if (parent != -1) {
    if (p.getParentPageId() != parent) {
      throw Message.throwInternalError(p + "String_Node_Str" + p.getParentPageId()+ "String_Node_Str"+ parent);
    }
  }
  return p;
}

Fixed version (ground truth):
/** 
 * Read the given page.
 * @param id the page id
 * @param parent the parent, or -1 if unknown
 * @return the page
 */
PageData getPage(int id,int parent) throws SQLException {
  PageData p=(PageData)store.getPage(id);
  if (p == null) {
    PageDataLeaf empty=PageDataLeaf.create(this,id,parent);
    store.logUndo(empty,null);
    store.updateRecord(empty);
    return empty;
  }
  if (p.index.rootPageId != rootPageId) {
    throw Message.throwInternalError("String_Node_Str" + p.index.getName() + "String_Node_Str"+ p.index.rootPageId+ "String_Node_Str"+ getName()+ "String_Node_Str"+ rootPageId);
  }
  if (parent != -1) {
    if (p.getParentPageId() != parent) {
      throw Message.throwInternalError(p + "String_Node_Str" + p.getParentPageId()+ "String_Node_Str"+ parent);
    }
  }
  return p;
}
Program: 16131
Project: 16131
Buggy source:
private void removeAllRows() throws SQLException {
  PageData root=getPage(rootPageId,0);
  root.freeChildren();
  root=PageDataLeaf.create(this,rootPageId,PageData.ROOT);
  store.removeRecord(rootPageId);
  store.updateRecord(root,true,null);
  rowCount=0;
  lastKey=0;
}

Fixed version (ground truth):
private void removeAllRows() throws SQLException {
  PageData root=getPage(rootPageId,0);
  root.freeChildren();
  root=PageDataLeaf.create(this,rootPageId,PageData.ROOT);
  store.removeRecord(rootPageId);
  store.updateRecord(root);
  rowCount=0;
  lastKey=0;
}
Program: 16132
Project: 16132
Buggy source:
public PageDataIndex(TableData table,int id,IndexColumn[] columns,IndexType indexType,int headPos,Session session) throws SQLException {
  initBaseIndex(table,id,table.getName() + "String_Node_Str",columns,indexType);
  if (database.isMultiVersion()) {
    sessionRowCount=New.hashMap();
    isMultiVersion=true;
  }
  tableData=table;
  this.store=database.getPageStore();
  store.addIndex(this);
  if (!database.isPersistent()) {
    throw Message.throwInternalError(table.getName());
  }
  if (headPos == Index.EMPTY_HEAD) {
    rootPageId=store.allocatePage();
    store.addMeta(this,session);
    PageDataLeaf root=PageDataLeaf.create(this,rootPageId,PageData.ROOT);
    store.updateRecord(root,true,root.data);
  }
 else {
    rootPageId=store.getRootPageId(id);
    PageData root=getPage(rootPageId,0);
    lastKey=root.getLastKey();
    rowCount=root.getRowCount();
    if (!database.isReadOnly()) {
      store.updateRecord(root,false,null);
    }
  }
  if (trace.isDebugEnabled()) {
    trace.debug("String_Node_Str" + getName() + "String_Node_Str"+ rowCount);
  }
  table.setRowCount(rowCount);
  fastDuplicateKeyException=super.getDuplicateKeyException();
  memorySizePerPage=store.getPageSize();
  int estimatedRowsPerPage=store.getPageSize() / ((1 + columns.length) * 8);
  memorySizePerPage+=estimatedRowsPerPage * 64;
}

Fixed version (ground truth):
public PageDataIndex(TableData table,int id,IndexColumn[] columns,IndexType indexType,int headPos,Session session) throws SQLException {
  initBaseIndex(table,id,table.getName() + "String_Node_Str",columns,indexType);
  if (database.isMultiVersion()) {
    sessionRowCount=New.hashMap();
    isMultiVersion=true;
  }
  tableData=table;
  this.store=database.getPageStore();
  store.addIndex(this);
  if (!database.isPersistent()) {
    throw Message.throwInternalError(table.getName());
  }
  if (headPos == Index.EMPTY_HEAD) {
    rootPageId=store.allocatePage();
    store.addMeta(this,session);
    PageDataLeaf root=PageDataLeaf.create(this,rootPageId,PageData.ROOT);
    store.updateRecord(root);
  }
 else {
    rootPageId=store.getRootPageId(id);
    PageData root=getPage(rootPageId,0);
    lastKey=root.getLastKey();
    rowCount=root.getRowCount();
  }
  if (trace.isDebugEnabled()) {
    trace.debug("String_Node_Str" + getName() + "String_Node_Str"+ rowCount);
  }
  table.setRowCount(rowCount);
  fastDuplicateKeyException=super.getDuplicateKeyException();
  memorySizePerPage=store.getPageSize();
  int estimatedRowsPerPage=store.getPageSize() / ((1 + columns.length) * 8);
  memorySizePerPage+=estimatedRowsPerPage * 64;
}
Program: 16133
Project: 16133
Buggy source:
private void addTry(Session session,Row row) throws SQLException {
  while (true) {
    PageData root=getPage(rootPageId,0);
    int splitPoint=root.addRowTry(row);
    if (splitPoint == -1) {
      break;
    }
    if (trace.isDebugEnabled()) {
      trace.debug("String_Node_Str" + splitPoint);
    }
    long pivot=splitPoint == 0 ? row.getKey() : root.getKey(splitPoint - 1);
    PageData page1=root;
    PageData page2=root.split(splitPoint);
    int rootPageId=root.getPos();
    int id=store.allocatePage();
    page1.setPageId(id);
    page1.setParentPageId(rootPageId);
    page2.setParentPageId(rootPageId);
    PageDataNode newRoot=PageDataNode.create(this,rootPageId,PageData.ROOT);
    newRoot.init(page1,pivot,page2);
    store.updateRecord(page1,true,page1.data);
    store.updateRecord(page2,true,page2.data);
    store.updateRecord(newRoot,true,null);
    root=newRoot;
  }
  row.setDeleted(false);
  if (database.isMultiVersion()) {
    if (delta == null) {
      delta=New.hashSet();
    }
    boolean wasDeleted=delta.remove(row);
    if (!wasDeleted) {
      delta.add(row);
    }
    incrementRowCount(session.getId(),1);
  }
  invalidateRowCount();
  rowCount++;
  store.logAddOrRemoveRow(session,tableData.getId(),row,true);
}

Fixed version (ground truth):
private void addTry(Session session,Row row) throws SQLException {
  while (true) {
    PageData root=getPage(rootPageId,0);
    int splitPoint=root.addRowTry(row);
    if (splitPoint == -1) {
      break;
    }
    if (trace.isDebugEnabled()) {
      trace.debug("String_Node_Str" + splitPoint);
    }
    long pivot=splitPoint == 0 ? row.getKey() : root.getKey(splitPoint - 1);
    PageData page1=root;
    PageData page2=root.split(splitPoint);
    int rootPageId=root.getPos();
    int id=store.allocatePage();
    page1.setPageId(id);
    page1.setParentPageId(rootPageId);
    page2.setParentPageId(rootPageId);
    PageDataNode newRoot=PageDataNode.create(this,rootPageId,PageData.ROOT);
    newRoot.init(page1,pivot,page2);
    store.updateRecord(page1);
    store.updateRecord(page2);
    store.updateRecord(newRoot);
    root=newRoot;
  }
  row.setDeleted(false);
  if (database.isMultiVersion()) {
    if (delta == null) {
      delta=New.hashSet();
    }
    boolean wasDeleted=delta.remove(row);
    if (!wasDeleted) {
      delta.add(row);
    }
    incrementRowCount(session.getId(),1);
  }
  invalidateRowCount();
  rowCount++;
  store.logAddOrRemoveRow(session,tableData.getId(),row,true);
}
Program: 16135
Project: 16135
Buggy source:
/** 
 * Get all sessions that are currently connected to the database.
 * @param includingSystemSession if the system session should also beincluded
 * @return the list of sessions
 */
public Session[] getSessions(boolean includingSystemSession){
  ArrayList<Session> list=New.arrayList(userSessions);
  Session sys=systemSession;
  if (includingSystemSession && sys != null) {
    list.add(sys);
  }
  Session[] array=new Session[list.size()];
  list.toArray(array);
  return array;
}

Fixed version (ground truth):
/** 
 * Get all sessions that are currently connected to the database.
 * @param includingSystemSession if the system session should also beincluded
 * @return the list of sessions
 */
public Session[] getSessions(boolean includingSystemSession){
  ArrayList<Session> list;
synchronized (userSessions) {
    list=New.arrayList(userSessions);
  }
  Session sys=systemSession;
  if (includingSystemSession && sys != null) {
    list.add(sys);
  }
  Session[] array=new Session[list.size()];
  list.toArray(array);
  return array;
}
Program: 16138
Project: 16138
Buggy source:
/** 
 * Create a new overflow page.
 * @param store the page store
 * @param page the page id
 * @param type the page type
 * @param parentPageId the parent page id
 * @param next the next page or 0
 * @param all the data
 * @param offset the offset within the data
 * @param size the number of bytes
 * @return the page
 */
static PageDataOverflow create(PageStore store,int page,int type,int parentPageId,int next,Data all,int offset,int size){
  Data data=store.createData();
  PageDataOverflow p=new PageDataOverflow(store,page,data);
  data.writeByte((byte)type);
  data.writeInt(parentPageId);
  if (type == Page.TYPE_DATA_OVERFLOW) {
    data.writeInt(next);
  }
 else {
    data.writeShortInt(size);
  }
  p.start=data.length();
  data.write(all.getBytes(),offset,size);
  p.type=type;
  p.parentPageId=parentPageId;
  p.nextPage=next;
  p.size=size;
  return p;
}

Fixed version (ground truth):
/** 
 * Create a new overflow page.
 * @param store the page store
 * @param page the page id
 * @param type the page type
 * @param parentPageId the parent page id
 * @param next the next page or 0
 * @param all the data
 * @param offset the offset within the data
 * @param size the number of bytes
 * @return the page
 */
static PageDataOverflow create(PageStore store,int page,int type,int parentPageId,int next,Data all,int offset,int size){
  Data data=store.createData();
  PageDataOverflow p=new PageDataOverflow(store,page,data);
  data.writeByte((byte)type);
  data.writeShortInt(0);
  data.writeInt(parentPageId);
  if (type == Page.TYPE_DATA_OVERFLOW) {
    data.writeInt(next);
  }
 else {
    data.writeShortInt(size);
  }
  p.start=data.length();
  data.write(all.getBytes(),offset,size);
  p.type=type;
  p.parentPageId=parentPageId;
  p.nextPage=next;
  p.size=size;
  return p;
}
Program: 16139
Project: 16139
Buggy source:
private void removeOld() throws SQLException {
  int i=0;
  ObjectArray<CacheObject> changed=ObjectArray.newInstance();
  while (sizeMemory * 4 > maxSize * 3 && recordCount > Constants.CACHE_MIN_RECORDS) {
    i++;
    if (i == recordCount) {
      writer.flushLog();
    }
    if (i >= recordCount * 2) {
      writer.getTrace().info("String_Node_Str");
      break;
    }
    CacheObject last=head.next;
    if (SysProperties.CHECK && last == head) {
      Message.throwInternalError("String_Node_Str");
    }
    if (!last.canRemove()) {
      removeFromLinkedList(last);
      addToFront(last);
      continue;
    }
    remove(last.getPos());
    if (last.isChanged()) {
      changed.add(last);
    }
  }
  if (changed.size() > 0) {
    CacheObject.sort(changed);
    for (i=0; i < changed.size(); i++) {
      CacheObject rec=changed.get(i);
      writer.writeBack(rec);
    }
  }
}

Fixed version (ground truth):
private void removeOld() throws SQLException {
  int i=0;
  int todoImplementInOtherCachesAsWell;
  ObjectArray<CacheObject> changed=ObjectArray.newInstance();
  int mem=sizeMemory;
  int rc=recordCount;
  while (mem * 4 > maxSize * 3 && rc > Constants.CACHE_MIN_RECORDS) {
    i++;
    if (i == recordCount) {
      writer.flushLog();
    }
    if (i >= recordCount * 2) {
      writer.getTrace().info("String_Node_Str");
      break;
    }
    CacheObject last=head.next;
    if (SysProperties.CHECK && last == head) {
      Message.throwInternalError("String_Node_Str");
    }
    if (!last.canRemove()) {
      removeFromLinkedList(last);
      addToFront(last);
      continue;
    }
    if (last.isChanged()) {
      changed.add(last);
    }
 else {
      remove(last.getPos());
    }
    rc--;
    mem-=last.getMemorySize();
  }
  if (changed.size() > 0) {
    CacheObject.sort(changed);
    for (i=0; i < changed.size(); i++) {
      CacheObject rec=changed.get(i);
      writer.writeBack(rec);
    }
    for (i=0; i < changed.size(); i++) {
      CacheObject rec=changed.get(i);
      remove(rec.getPos());
    }
  }
}
Program: 16140
Project: 16140
Buggy source:
private String getDeadlockDetails(ObjectArray<Session> sessions){
  StatementBuilder buff=new StatementBuilder();
  for (  Session s : sessions) {
    Table lock=s.getWaitForLock();
    buff.append("String_Node_Str").append(s.toString()).append("String_Node_Str").append(lock.toString()).append("String_Node_Str");
    for (    Table t : s.getLocks()) {
      buff.appendExceptFirst("String_Node_Str");
      buff.append(t.toString());
      if (t instanceof TableData) {
        if (((TableData)t).lockExclusive == s) {
          buff.append("String_Node_Str");
        }
 else {
          buff.append("String_Node_Str");
        }
      }
    }
    buff.append('.');
  }
  return buff.toString();
}

Fixed version (ground truth):
private String getDeadlockDetails(ObjectArray<Session> sessions){
  StringBuilder buff=new StringBuilder();
  for (  Session s : sessions) {
    Table lock=s.getWaitForLock();
    buff.append("String_Node_Str").append(s.toString()).append("String_Node_Str").append(lock.toString()).append("String_Node_Str");
    int i=0;
    for (    Table t : s.getLocks()) {
      if (i++ > 0) {
        buff.append("String_Node_Str");
      }
      buff.append(t.toString());
      if (t instanceof TableData) {
        if (((TableData)t).lockExclusive == s) {
          buff.append("String_Node_Str");
        }
 else {
          buff.append("String_Node_Str");
        }
      }
    }
    buff.append('.');
  }
  return buff.toString();
}
Program: 16142
Project: 16142
Buggy source:
private void removeRow(int i) throws SQLException {
  written=false;
  readAllRows();
  entryCount--;
  if (entryCount <= 0) {
    Message.throwInternalError();
  }
  int[] newOffsets=new int[entryCount];
  int[] newKeys=new int[entryCount];
  Row[] newRows=new Row[entryCount];
  System.arraycopy(offsets,0,newOffsets,0,i);
  System.arraycopy(keys,0,newKeys,0,i);
  System.arraycopy(rows,0,newRows,0,i);
  int startNext=i > 0 ? offsets[i - 1] : index.getPageStore().getPageSize();
  int rowLength=startNext - offsets[i];
  for (int j=i; j < entryCount; j++) {
    newOffsets[j]=offsets[j + 1] + rowLength;
  }
  System.arraycopy(keys,i + 1,newKeys,i,entryCount - i);
  System.arraycopy(rows,i + 1,newRows,i,entryCount - i);
  start-=KEY_OFFSET_PAIR_LENGTH;
  offsets=newOffsets;
  keys=newKeys;
  rows=newRows;
}

Fixed version (ground truth):
private void removeRow(int i) throws SQLException {
  written=false;
  readAllRows();
  entryCount--;
  if (entryCount < 0) {
    Message.throwInternalError();
  }
  int[] newOffsets=new int[entryCount];
  int[] newKeys=new int[entryCount];
  Row[] newRows=new Row[entryCount];
  System.arraycopy(offsets,0,newOffsets,0,i);
  System.arraycopy(keys,0,newKeys,0,i);
  System.arraycopy(rows,0,newRows,0,i);
  int startNext=i > 0 ? offsets[i - 1] : index.getPageStore().getPageSize();
  int rowLength=startNext - offsets[i];
  for (int j=i; j < entryCount; j++) {
    newOffsets[j]=offsets[j + 1] + rowLength;
  }
  System.arraycopy(keys,i + 1,newKeys,i,entryCount - i);
  System.arraycopy(rows,i + 1,newRows,i,entryCount - i);
  start-=KEY_OFFSET_PAIR_LENGTH;
  offsets=newOffsets;
  keys=newKeys;
  rows=newRows;
}
Program: 16143
Project: 16143
Buggy source:
/** 
 * Set all pages as 'allocated' in the page store.
 */
void allocateAllPages() throws SQLException {
  int trunkPage=trunkNext;
  while (trunkPage != 0) {
    store.allocatePage(trunkPage);
    PageStreamTrunk t=new PageStreamTrunk(store,trunkPage);
    t.read();
    while (true) {
      int n=t.getNextPageData();
      if (n == -1) {
        break;
      }
      store.allocatePage(n);
    }
    trunkPage=t.getNextTrunk();
  }
}

Fixed version (ground truth):
/** 
 * Set all pages as 'allocated' in the page store.
 * @return the bit set
 */
BitField allocateAllPages() throws SQLException {
  BitField pages=new BitField();
  int trunkPage=trunkNext;
  while (trunkPage != 0) {
    pages.set(trunkPage);
    store.allocatePage(trunkPage);
    PageStreamTrunk t=new PageStreamTrunk(store,trunkPage);
    t.read();
    while (true) {
      int n=t.getNextPageData();
      if (n == -1) {
        break;
      }
      pages.set(n);
      store.allocatePage(n);
    }
    trunkPage=t.getNextTrunk();
  }
  return pages;
}
Program: 16144
Project: 16144
Buggy source:
/** 
 * Switch to a new log id.
 */
void checkpoint() throws SQLException {
  try {
    out.write(CHECKPOINT);
    flushOut();
  }
 catch (  IOException e) {
    throw Message.convertIOException(e,null);
  }
  undo=new BitField();
  logId++;
  pageOut.fillPage();
  int currentDataPage=pageOut.getCurrentDataPageId();
  logIdPageMap.put(logId,currentDataPage);
}

Fixed version (ground truth):
/** 
 * Switch to a new log id.
 */
void checkpoint() throws SQLException {
  try {
    out.write(CHECKPOINT);
    flushOut();
  }
 catch (  IOException e) {
    throw Message.convertIOException(e,null);
  }
  undo=new BitField();
  logSectionId++;
  pageOut.fillPage();
  int currentDataPage=pageOut.getCurrentDataPageId();
  logSectionPageMap.put(logSectionId,currentDataPage);
}
Program: 16145
Project: 16145
Buggy source:
/** 
 * Open the log for writing. For an existing database, the recovery must be run first.
 * @param firstTrunkPage the first trunk page
 */
void openForWriting(int firstTrunkPage) throws SQLException {
  trace.debug("String_Node_Str" + firstTrunkPage);
  this.firstTrunkPage=firstTrunkPage;
  pageOut=new PageOutputStream(store,firstTrunkPage);
  pageOut.reserve(1);
  store.setLogFirstPage(firstTrunkPage,pageOut.getCurrentDataPageId());
  buffer=new ByteArrayOutputStream();
  out=new DataOutputStream(buffer);
}

Fixed version (ground truth):
/** 
 * Open the log for writing. For an existing database, the recovery must be run first.
 * @param firstTrunkPage the first trunk page
 */
void openForWriting(int firstTrunkPage) throws SQLException {
  trace.debug("String_Node_Str" + firstTrunkPage);
  this.firstTrunkPage=firstTrunkPage;
  pageOut=new PageOutputStream(store,firstTrunkPage,undoAll);
  pageOut.reserve(1);
  store.setLogFirstPage(firstTrunkPage,pageOut.getCurrentDataPageId());
  buffer=new ByteArrayOutputStream();
  out=new DataOutputStream(buffer);
}
Program: 16146
Project: 16146
Buggy source:
/** 
 * A table is truncated.
 * @param session the session
 * @param tableId the table id
 */
void logTruncate(Session session,int tableId) throws SQLException {
  try {
    if (trace.isDebugEnabled()) {
      trace.debug("String_Node_Str" + session.getId() + "String_Node_Str"+ tableId);
    }
    session.addLogPos(logId,logPos);
    data.reset();
    out.write(TRUNCATE);
    out.writeInt(session.getId());
    out.writeInt(tableId);
    flushOut();
  }
 catch (  IOException e) {
    throw Message.convertIOException(e,null);
  }
}

Fixed version (ground truth):
/** 
 * A table is truncated.
 * @param session the session
 * @param tableId the table id
 */
void logTruncate(Session session,int tableId) throws SQLException {
  try {
    if (trace.isDebugEnabled()) {
      trace.debug("String_Node_Str" + session.getId() + "String_Node_Str"+ tableId);
    }
    session.addLogPos(logSectionId,logPos);
    data.reset();
    out.write(TRUNCATE);
    out.writeInt(session.getId());
    out.writeInt(tableId);
    flushOut();
  }
 catch (  IOException e) {
    throw Message.convertIOException(e,null);
  }
}
Program: 16148
Project: 16148
Buggy source:
/** 
 * A record is added to a table, or removed from a table.
 * @param session the session
 * @param tableId the table id
 * @param row the row to add
 * @param add true if the row is added, false if it is removed
 */
void logAddOrRemoveRow(Session session,int tableId,Row row,boolean add) throws SQLException {
  try {
    if (trace.isDebugEnabled()) {
      trace.debug("String_Node_Str" + (add ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ session.getId()+ "String_Node_Str"+ tableId+ "String_Node_Str"+ row);
    }
    session.addLogPos(logId,logPos);
    row.setLastLog(logId,logPos);
    data.reset();
    data.checkCapacity(row.getByteCount(data));
    row.write(data);
    out.write(add ? ADD : REMOVE);
    out.writeInt(session.getId());
    out.writeInt(tableId);
    out.writeInt(row.getPos());
    out.writeInt(data.length());
    out.write(data.getBytes(),0,data.length());
    flushOut();
  }
 catch (  IOException e) {
    throw Message.convertIOException(e,null);
  }
}

Fixed version (ground truth):
/** 
 * A record is added to a table, or removed from a table.
 * @param session the session
 * @param tableId the table id
 * @param row the row to add
 * @param add true if the row is added, false if it is removed
 */
void logAddOrRemoveRow(Session session,int tableId,Row row,boolean add) throws SQLException {
  try {
    if (trace.isDebugEnabled()) {
      trace.debug("String_Node_Str" + (add ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ session.getId()+ "String_Node_Str"+ tableId+ "String_Node_Str"+ row);
    }
    session.addLogPos(logSectionId,logPos);
    row.setLastLog(logSectionId,logPos);
    data.reset();
    data.checkCapacity(row.getByteCount(data));
    row.write(data);
    out.write(add ? ADD : REMOVE);
    out.writeInt(session.getId());
    out.writeInt(tableId);
    out.writeInt(row.getPos());
    out.writeInt(data.length());
    out.write(data.getBytes(),0,data.length());
    flushOut();
  }
 catch (  IOException e) {
    throw Message.convertIOException(e,null);
  }
}
Program: 16149
Project: 16149
Buggy source:
/** 
 * Add an undo entry to the log. The page data is only written once until the next checkpoint.
 * @param pageId the page id
 * @param page the old page data
 */
void addUndo(int pageId,Data page) throws SQLException {
  try {
    if (undo.get(pageId)) {
      return;
    }
    if (trace.isDebugEnabled()) {
      trace.debug("String_Node_Str" + pageId);
    }
    undo.set(pageId);
    out.write(UNDO);
    out.writeInt(pageId);
    out.write(page.getBytes(),0,store.getPageSize());
    flushOut();
  }
 catch (  IOException e) {
    throw Message.convertIOException(e,null);
  }
}

Fixed version (ground truth):
/** 
 * Add an undo entry to the log. The page data is only written once until the next checkpoint.
 * @param pageId the page id
 * @param page the old page data
 */
void addUndo(int pageId,Data page) throws SQLException {
  try {
    if (undo.get(pageId)) {
      return;
    }
    if (trace.isDebugEnabled()) {
      trace.debug("String_Node_Str" + pageId);
    }
    undo.set(pageId);
    undoAll.set(pageId);
    out.write(UNDO);
    out.writeInt(pageId);
    out.write(page.getBytes(),0,store.getPageSize());
    flushOut();
  }
 catch (  IOException e) {
    throw Message.convertIOException(e,null);
  }
}
Program: 16150
Project: 16150
Buggy source:
/** 
 * Allocate the required pages so that no pages need to be allocated while writing.
 * @param minBuffer the number of bytes to allocate
 */
void reserve(int minBuffer) throws SQLException {
  if (reserved < minBuffer) {
    int pageSize=store.getPageSize();
    int capacityPerPage=PageStreamData.getCapacity(pageSize);
    int pages=PageStreamTrunk.getPagesAddressed(pageSize);
    int pagesToAllocate=pages;
    int totalCapacity=pages * capacityPerPage;
    while (totalCapacity < minBuffer) {
      pagesToAllocate+=pagesToAllocate;
      totalCapacity+=totalCapacity;
    }
    pagesToAllocate++;
    for (int i=0; i < pagesToAllocate; i++) {
      int page=store.allocatePage();
      reservedPages.add(page);
    }
    reserved+=totalCapacity;
    if (data == null) {
      initNextData();
    }
  }
}

Fixed version (ground truth):
/** 
 * Allocate the required pages so that no pages need to be allocated while writing.
 * @param minBuffer the number of bytes to allocate
 */
void reserve(int minBuffer) throws SQLException {
  if (reserved < minBuffer) {
    int pageSize=store.getPageSize();
    int capacityPerPage=PageStreamData.getCapacity(pageSize);
    int pages=PageStreamTrunk.getPagesAddressed(pageSize);
    int pagesToAllocate=pages;
    int totalCapacity=pages * capacityPerPage;
    while (totalCapacity < minBuffer) {
      pagesToAllocate+=pagesToAllocate;
      totalCapacity+=totalCapacity;
    }
    pagesToAllocate++;
    store.allocatePages(reservedPages,pagesToAllocate,exclude);
    reserved+=totalCapacity;
    if (data == null) {
      initNextData();
    }
  }
}
Program: 16151
Project: 16151
Buggy source:
/** 
 * Create a new page output stream.
 * @param store the page store
 * @param trunkPage the first trunk page (already allocated)
 */
public PageOutputStream(PageStore store,int trunkPage){
  this.trace=store.getTrace();
  this.store=store;
  this.trunkPageId=trunkPage;
}

Fixed version (ground truth):
/** 
 * Create a new page output stream.
 * @param store the page store
 * @param trunkPage the first trunk page (already allocated)
 */
public PageOutputStream(PageStore store,int trunkPage,BitField exclude){
  this.trace=store.getTrace();
  this.store=store;
  this.trunkPageId=trunkPage;
  this.exclude=exclude;
}
Program: 16152
Project: 16152
Buggy source:
private void process(File file) throws IOException {
  String name=file.getCanonicalPath();
  if (name.endsWith("String_Node_Str")) {
    return;
  }
  if (name.indexOf("String_Node_Str") > 0 && name.indexOf("String_Node_Str") < 0) {
    return;
  }
  if (file.isDirectory()) {
    for (    File f : file.listFiles()) {
      process(f);
    }
  }
 else {
    String fileName=file.getAbsolutePath();
    int idx=fileName.lastIndexOf('.');
    String suffix;
    if (idx < 0) {
      suffix="String_Node_Str";
    }
 else {
      suffix=fileName.substring(idx + 1);
    }
    boolean ignore=false;
    for (    String s : IGNORE) {
      if (s.equals(suffix)) {
        ignore=true;
        break;
      }
    }
    if (fileName.endsWith(IGNORE_FILE)) {
      ignore=true;
    }
    if (ignore) {
      return;
    }
    boolean ok=false;
    for (    String s : SUFFIX) {
      if (s.equals(suffix)) {
        ok=true;
        break;
      }
    }
    if (!ok) {
      throw new IOException("String_Node_Str" + suffix + "String_Node_Str"+ fileName);
    }
    String text=new String(BuildBase.readFile(file));
    if (fileName.endsWith("String_Node_Str")) {
      addToDictionary=true;
    }
 else {
      addToDictionary=false;
    }
    scan(fileName,text);
  }
}

Fixed version (ground truth):
/** 
 * Searches for spelling errors in the source and documentation 
 */
private void process(File file) throws IOException {
  String name=file.getCanonicalPath();
  if (name.endsWith("String_Node_Str")) {
    return;
  }
  if (file.getCanonicalFile().getName().startsWith("String_Node_Str") && name.indexOf("String_Node_Str") < 0) {
    return;
  }
  if (file.isDirectory()) {
    for (    File f : file.listFiles()) {
      process(f);
    }
  }
 else {
    String fileName=file.getAbsolutePath();
    int idx=fileName.lastIndexOf('.');
    String suffix;
    if (idx < 0) {
      suffix="String_Node_Str";
    }
 else {
      suffix=fileName.substring(idx + 1);
    }
    boolean ignore=false;
    for (    String s : IGNORE) {
      if (s.equals(suffix)) {
        ignore=true;
        break;
      }
    }
    for (int i=0; i < IGNORE_FILES.length; i++) {
      if (fileName.endsWith(IGNORE_FILES[i])) {
        ignore=true;
        break;
      }
    }
    if (ignore) {
      return;
    }
    boolean ok=false;
    for (    String s : SUFFIX) {
      if (s.equals(suffix)) {
        ok=true;
        break;
      }
    }
    if (!ok) {
      throw new IOException("String_Node_Str" + suffix + "String_Node_Str"+ fileName);
    }
    String text=new String(BuildBase.readFile(file));
    if (fileName.endsWith("String_Node_Str")) {
      addToDictionary=true;
    }
 else {
      addToDictionary=false;
    }
    scan(fileName,text);
  }
}
Program: 16153
Project: 16153
Buggy source:
int addRowTry(SearchRow row) throws SQLException {
  while (true) {
    int x=find(row,false,false);
    PageBtree page=index.getPage(childPageIds[x]);
    int splitPoint=page.addRowTry(row);
    if (splitPoint == 0) {
      break;
    }
    SearchRow pivot=page.getRow(splitPoint - 1);
    int splitPoint2=addChildTry(pivot);
    if (splitPoint2 != 0) {
      return splitPoint2;
    }
    PageBtree page2=page.split(splitPoint);
    addChild(x,page2.getPos(),pivot);
    index.getPageStore().updateRecord(page,true,page.data);
    index.getPageStore().updateRecord(page2,true,page2.data);
    index.getPageStore().updateRecord(this,true,data);
  }
  updateRowCount(1);
  written=false;
  return 0;
}

Fixed version (ground truth):
int addRowTry(SearchRow row) throws SQLException {
  while (true) {
    int x=find(row,false,false);
    PageBtree page=index.getPage(childPageIds[x]);
    int splitPoint=page.addRowTry(row);
    if (splitPoint == 0) {
      break;
    }
    SearchRow pivot=page.getRow(splitPoint - 1);
    int splitPoint2=addChildTry(pivot);
    if (splitPoint2 != 0) {
      return splitPoint2;
    }
    PageBtree page2=page.split(splitPoint);
    readAllRows();
    addChild(x,page2.getPos(),pivot);
    index.getPageStore().updateRecord(page,true,page.data);
    index.getPageStore().updateRecord(page2,true,page2.data);
    index.getPageStore().updateRecord(this,true,data);
  }
  updateRowCount(1);
  written=false;
  return 0;
}
Program: 16154
Project: 16154
Buggy source:
private void fillBuffer() throws SQLException {
  if (remaining > 0 || endOfFile) {
    return;
  }
  if (trunkNext == 0) {
    endOfFile=true;
    return;
  }
  if (trunk == null) {
    trunk=new PageStreamTrunk(store,trunkNext);
    trunk.read();
    trunkNext=trunk.getNextTrunk();
  }
  int next;
  while (true) {
    next=trunk.getNextPageData();
    if (dataPage == -1 || dataPage == next) {
      if (next != -1) {
        break;
      }
      trunk=new PageStreamTrunk(store,trunkNext);
      trunk.read();
      trunkNext=trunk.getNextTrunk();
    }
  }
  if (trace.isDebugEnabled()) {
    trace.debug("String_Node_Str" + next);
  }
  dataPage=-1;
  data=new PageStreamData(store,next,0);
  data.read();
  remaining=data.getLength();
}

Fixed version (ground truth):
private void fillBuffer() throws SQLException {
  if (remaining > 0 || endOfFile) {
    return;
  }
  if (trunkNext == 0) {
    endOfFile=true;
    return;
  }
  int next;
  while (true) {
    if (trunk == null) {
      trunk=new PageStreamTrunk(store,trunkNext);
      trunk.read();
      trunkNext=trunk.getNextTrunk();
    }
    if (trunk != null) {
      next=trunk.getNextPageData();
      if (next == -1) {
        trunk=null;
      }
 else       if (dataPage == -1 || dataPage == next) {
        break;
      }
    }
  }
  if (trace.isDebugEnabled()) {
    trace.debug("String_Node_Str" + next);
  }
  dataPage=-1;
  data=new PageStreamData(store,next,0);
  data.read();
  remaining=data.getLength();
}
Program: 16155
Project: 16155
Buggy source:
public void test() throws Exception {
  testUniqueIndex();
  testCreateIndexLater();
  testFuzzOperations();
}

Fixed version (ground truth):
public void test() throws Exception {
  testLargeIndex();
  testUniqueIndex();
  testCreateIndexLater();
  testFuzzOperations();
}
Program: 16156
Project: 16156
Buggy source:
boolean remove(SearchRow row) throws SQLException {
  int at=find(row,false,false);
  PageBtree page=index.getPage(childPageIds[at]);
  boolean empty=page.remove(row);
  updateRowCount(-1);
  if (!empty) {
    return false;
  }
  index.getPageStore().freePage(page.getPos(),true,page.data);
  if (entryCount < 1) {
    return true;
  }
  written=false;
  removeChild(at);
  index.getPageStore().updateRecord(this,true,data);
  return false;
}

Fixed version (ground truth):
boolean remove(SearchRow row) throws SQLException {
  int at=find(row,false,false);
  PageBtree page=index.getPage(childPageIds[at]);
  boolean empty=page.remove(row);
  updateRowCount(-1);
  if (!empty) {
    return false;
  }
  index.getPageStore().freePage(page.getPos(),true,page.data);
  if (entryCount < 1) {
    return true;
  }
  removeChild(at);
  index.getPageStore().updateRecord(this,true,data);
  return false;
}