/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2010, 2013 Oracle and/or its affiliates.  All rights reserved.
 *
 * $Id$
 */

DBPRIVATE
PREFIX	__heap

INCLUDE #include "db_int.h"
INCLUDE #include "dbinc/crypto.h"
INCLUDE #include "dbinc/db_page.h"
INCLUDE #include "dbinc/db_am.h"
INCLUDE #include "dbinc/heap.h"
INCLUDE #include "dbinc/txn.h"
INCLUDE

/*
 * addrem -- Add or remove an entry from a heap db.
 *
 * opcode:	identifies if this is an add or delete.
 * fileid:	file identifier of the file being modified.
 * pgno:	page number.
 * indx:	location at which to insert or delete.
 * nbytes:	number of bytes added/removed to/from the page.
 * hdr:		header for the data item.
 * dbt:		data that is to be added or deleted.
 * pagelsn:	former lsn of the page.
 */
BEGIN addrem		49	151
ARG	opcode		u_int32_t	lu
DB	fileid		int32_t		ld
ARG	pgno		db_pgno_t	lu
ARG	indx		u_int32_t	lu
ARG	nbytes		u_int32_t	lu
DBT	hdr		DBT		s
DBT	dbt		DBT		s
POINTER	pagelsn		DB_LSN *	lu
END

/*
 * pg_alloc: used to record allocating a new page in a heap database.
 *
 * meta_lsn:	the lsn of the metadata page
 * meta_pgno	the metadata page
 * page_lsn:	the allocated page's original lsn.
 * pgno:	the page allocated.
 * ptype:	the type of the page allocated.
 * last_pgno:	the last page in the file after this op (4.3+).
 */
BEGIN pg_alloc	49	152
DB	fileid		int32_t		ld
POINTER	meta_lsn	DB_LSN *	lu
ARG	meta_pgno	db_pgno_t	lu
ARG	pgno		db_pgno_t	lu
ARG	ptype		u_int32_t	lu
ARG	last_pgno	db_pgno_t	lu
END

/*
 * trunc_meta -- Used to record truncation of a heap database's meta page
 *
 * fileid:	file identifier of the file being modified.
 * pgno:	page number.
 * last_pgno:	value of last_pgno on meta page
 * key_count:	value of key_count on meta page
 * record_count: value of record_count on meta page
 * curregion:	value of curregion on meta page
 * nregions:	value of nregions on meta page
 * pagelsn:	former lsn of the page.
 */
BEGIN trunc_meta	49	153
DB	fileid		int32_t		ld
ARG	pgno		db_pgno_t	lu
ARG	last_pgno	u_int32_t	lu
ARG	key_count	u_int32_t	lu
ARG	record_count	u_int32_t	lu
ARG	curregion	u_int32_t	lu
ARG	nregions	u_int32_t	lu
POINTER	pagelsn		DB_LSN *	lu
END

/*
 * trunc_page -- Used to record truncation of a heap database's region page
 *
 * fileid:	file identifier of the file being modified.
 * pgno:	page number.
 * old_data:	the contents of the page before truncation
 * pagelsn:	former lsn of the page.
 */
BEGIN trunc_page	49	154
DB	fileid		int32_t		ld
ARG	pgno		db_pgno_t	lu
DBT	old_data	DBT		s
ARG	is_region	u_int32_t	lu
POINTER	pagelsn		DB_LSN *	lu
END


